Exemplo n.º 1
0
/* 更新当前文本框的样式 */
static void
TextBox_ExecUpdateStyle( LCUI_Widget *widget )
{
	LCUI_Border border;
	
	Widget_SetBackgroundColor( widget, RGB(255,255,255) );
	Widget_SetBackgroundTransparent( widget, FALSE );
	/* 如果该部件已经获得全局焦点 */
	if( Widget_GetGlobalFocus( widget ) ) {
		border = Border( 1, BORDER_STYLE_SOLID, RGB(55,123,203) );
		Widget_SetBorder( widget, border );
		return;
	}
	Border_Radius( &border, 0 );
	/* 根据不同的状态,设定不同的边框样式 */
	switch( widget->state ) {
	case WIDGET_STATE_NORMAL:
		border.left_width = 1;
		border.left_style = BORDER_STYLE_SOLID;
		border.left_color = RGB(204,204,204);
		border.top_width = 1;
		border.top_style = BORDER_STYLE_SOLID;
		border.top_color = RGB(204,204,204);
		border.right_width = 1;
		border.right_style = BORDER_STYLE_SOLID;
		border.right_color = RGB(221,221,221);
		border.bottom_width = 1;
		border.bottom_style = BORDER_STYLE_SOLID;
		border.bottom_color = RGB(221,221,221);
		break;
	case WIDGET_STATE_OVERLAY :
		border.left_width = 1;
		border.left_style = BORDER_STYLE_SOLID;
		border.left_color = RGB(171,171,171);
		border.top_width = 1;
		border.top_style = BORDER_STYLE_SOLID;
		border.top_color = RGB(171,171,171);
		border.right_width = 1;
		border.right_style = BORDER_STYLE_SOLID;
		border.right_color = RGB(204,204,204);
		border.bottom_width = 1;
		border.bottom_style = BORDER_STYLE_SOLID;
		border.bottom_color = RGB(204,204,204);
		break;
	case WIDGET_STATE_ACTIVE :
		border = Border( 1, BORDER_STYLE_SOLID, RGB(55,123,203) );
		break;
	case WIDGET_STATE_DISABLE :
		break;
		default : break;
	}
	Widget_SetBorder( widget, border );
}
Exemplo n.º 2
0
/*
 * 创建一个部件,作为滚动条的容器
 * 再创建一个部件,作为滚动条
 * 限制滚动条的移动范围
 * */
static void 
ScrollBar_Init( LCUI_Widget *widget )
{
	LCUI_ScrollBar *scrollbar;
	
	scrollbar = WidgetPrivData_New(widget, sizeof(LCUI_ScrollBar));
	scrollbar->data.max_num = 100;
	scrollbar->data.current_num = 100;
	scrollbar->data.max_size = 100;
	scrollbar->data.current_size = 100;
	scrollbar->direction = 0;
	scrollbar->callback_func = NULL;
	
	scrollbar->widget = Widget_New("button");
	/* 禁用部件的自动尺寸调整 */
	Widget_SetAutoSize( scrollbar->widget, FALSE, 0 );
	
	Widget_Container_Add( widget, scrollbar->widget );
	Widget_SetSize( scrollbar->widget, "100%", "100%" );
	Widget_LimitPos( scrollbar->widget, Pos(0,0), Pos(0,0) );
	Widget_SetBorder( widget,
	 Border(1, BORDER_STYLE_SOLID, RGB(100,100,100)) );
	Widget_SetPadding( widget, Padding(1,1,1,1) );
	Widget_SetBackgroundColor( widget, RGB(200,200,200) );
	Widget_SetBackgroundTransparent( widget, FALSE );
	Widget_Show( scrollbar->widget );
	Widget_Event_Connect( scrollbar->widget, EVENT_DRAG, ScrollBar_Drag );
}
Exemplo n.º 3
0
int main(void)
{
	int i;
	char str[10];
	LCUI_RGB color[6]={{255,255,255},{127,127,127}, {255,0,0}, {255,165,0},
			{30,144,255}, {65,200,65} };
	LCUI_Widget *window, *widget[6], *label[6];
	
	LCUI_Init();
	window = Widget_New( "window" );
	for(i=0; i<6; ++i) {
		widget[i] = Widget_New( NULL );
		label[i] = Widget_New( "label" );
		sprintf(str, "Area %d" , i);
		Label_Text( label[i], str);
		Widget_Container_Add( widget[i], label[i] );
		Window_ClientArea_Add( window, widget[i] );
		Widget_Resize( widget[i], Size(80,80) );
		Widget_SetPosType( widget[i], POS_TYPE_STATIC );
		Widget_SetAlign( label[i], ALIGN_MIDDLE_CENTER, Pos(0,0) );
		Widget_SetBorder( widget[i], Border(1,BORDER_STYLE_SOLID,RGB(0,0,0)) );
		Widget_SetBackgroundTransparent( widget[i], FALSE );
		Widget_SetBackgroundColor( widget[i], color[i] );
		Widget_Show( label[i] );
		Widget_Show( widget[i] );
	}
	
	Window_SetTitleText( window, "测试部件布局-2" ); 
	Widget_Resize( window, Size(320, 240) );
	Widget_Event_Connect( Window_GetCloseButton(window), EVENT_CLICKED, destroy );
	
	Widget_Show( window );
	
	return LCUI_Main();
}
Exemplo n.º 4
0
Arquivo: button.c Projeto: yydaor/LCUI
static void Button_ExecDefalutUpdate( LCUI_Widget *widget )
{
	LCUI_Border border;
	LCUI_RGB border_color;

	switch( widget->state ) {
	case WIDGET_STATE_NORMAL:
		Widget_SetBackgroundColor( widget, RGB(230,230,230) );
		/* 获得焦点的按钮,使用另一种颜色的边框 */
		if( Widget_GetFocus(widget) ) {
			border_color = RGB(50,150,255);
		} else {
			border_color = RGB(172,172,172);
		}
		break;
	case WIDGET_STATE_OVERLAY :
		Widget_SetBackgroundColor( widget, RGB(232,242,252) );
		border_color = RGB(126,180,234);
		break;
	case WIDGET_STATE_ACTIVE :
		Widget_SetBackgroundColor( widget, RGB(207,230,252) );
		border_color = RGB(86,157,229);
		break;
	case WIDGET_STATE_DISABLE :
		Widget_SetBackgroundColor( widget, RGB(200,200,200) );
		border_color = RGB(172,172,172);
		break;
		default : break;
	}
	border = Border(1, BORDER_STYLE_SOLID, border_color );
	Widget_SetBorder( widget, border );
	Widget_SetBackgroundTransparent( widget, FALSE );
}
Exemplo n.º 5
0
/** 捕捉键盘按键输入 */
static void StartCatchKey( LCUI_Widget *btn )
{
	if( tip_box ) {
		return;
	}
	/* 创建提示框 */
	tip_box = Widget_New(NULL);
	tip_label = Widget_New("label");
	/* 将label部件添加至提示框中 */
	Widget_Container_Add( tip_box, tip_label );
	/* 设置提示框中显示的文本 */
	Label_TextW( tip_label, TEXT_PLEASE_PRESS_KEY );
	/* 设置提示框位置、尺寸及样式 */
	Widget_SetAlign( tip_label, ALIGN_MIDDLE_CENTER, Pos(0,0) );
	Widget_SetAlign( tip_box, ALIGN_MIDDLE_CENTER, Pos(0,0) );
	Widget_Resize( tip_box, TIPBOX_SIZE );
	Widget_SetBackgroundTransparent( tip_box, FALSE );
	Widget_SetBorder( tip_box, Border(1,BORDER_STYLE_SOLID,RGB(200,200,200)) );
	/* 连接LCUI_KEYDOWN事件,以在键盘按键被按下时进行响应 */
	keyboard_connect_id = LCUISysEvent_Connect( LCUI_KEYDOWN, ProcKeyDown, btn );

	Widget_Show( tip_label );
	Widget_SetModal( tip_box, TRUE );
	Widget_Show( tip_box );
}
Exemplo n.º 6
0
static void Window_OnUpdate( LCUI_Widget *window )
{
	LCUI_Window *wnd;
	LCUI_Border border;
	char h_str[20];

	wnd = (LCUI_Window*)Widget_GetPrivateData( window );
	border = Border( 1, BORDER_STYLE_SOLID, RGB(200,200,200) );
	border.top_width = TOP_PANDDING;
	/* 若窗口已获得焦点 */
	if( Widget_GetFocus( window ) ) {
		border.top_color = wnd->theme_color;
		border.bottom_color = wnd->theme_color;
		border.left_color = wnd->theme_color;
		border.right_color = wnd->theme_color;
		Widget_SetShadow( window, BoxShadow(0,0,8,wnd->theme_color) );
	} else {
		Widget_SetShadow( window, BoxShadow(0,0,8,ARGB(120,200,200,200)) );
	}
	Widget_SetBorder( window, border );
	/* 更新窗口标题栏上的关闭按钮 */
	Widget_Update( wnd->btn_close );
	sprintf( h_str, "%dpx", Widget_GetContainerHeight(window)-35 );
	Widget_SetSize( wnd->client_area, "100%", h_str );
}
Exemplo n.º 7
0
static LCUI_Widget create_widget( void )
{
	LCUI_Widget w, root;
	w = LCUIWidget_New( NULL );
	root = LCUIWidget_GetRoot();
	Widget_Append( root, w );
	Widget_Resize( w, WIDGET_WIDTH, WIDGET_HEIGHT );
	Widget_SetPosition( w, SV_ABSOLUTE );
	Widget_SetBoxSizing( w, SV_BORDER_BOX );
	Widget_SetBorder( w, 1, SV_SOLID, RGB( 100, 100, 100 ) );
	Widget_SetStyle( w, key_background_color, RGB( 200, 200, 200 ), color );
	return w;
}
Exemplo n.º 8
0
void GameWindow_InitLicenseWindow(void)
{
	window = Widget_New("window");
	label_license = Widget_New("label");
	textbox_license = Widget_New("text_box");
	box = Widget_New(NULL);
	btn_ok = Widget_New("button");

	Window_ClientArea_Add( window, label_license );
	Window_ClientArea_Add( window, box );
	Window_ClientArea_Add( window, btn_ok );
	Widget_Container_Add( box, textbox_license );
	
	Widget_SetBackgroundColor( label_license, RGB(255,255,255) );
	Widget_SetBackgroundTransparent( label_license, FALSE );
	
	Widget_SetAlign( label_license, ALIGN_TOP_CENTER, Pos(0,0) );
	Widget_SetAlign( box, ALIGN_TOP_CENTER, Pos(0,8) );
	Widget_SetAlign( btn_ok, ALIGN_BOTTOM_CENTER, Pos(0,-5) );

	Label_TextW( label_license, TEXT_LICENSE );
	Button_TextW( btn_ok, TEXT_OK );
	TextBox_SetAutoWrap( textbox_license, TRUE );
	TextBox_SetMultiline( textbox_license, TRUE );
	TextBox_SetReadOnly( textbox_license, TRUE );
	TextBox_SetUsingStyleTags( textbox_license, TRUE );
	TextBox_TextW( textbox_license, license_text );
	TextBox_ShowCursor( textbox_license, FALSE );

	Widget_SetStyleID( window, WINDOW_STYLE_LINE );
	Widget_SetPadding( Window_GetClientArea(window), Padding(10,10,10,10) );
	Widget_SetAutoSize( btn_ok, FALSE, 0 );

	Widget_SetBorder( box, Border(1,BORDER_STYLE_SOLID,RGB(200,200,200)) );
	Widget_SetPadding( box, Padding(10,10,10,10) );
	Widget_SetSize( box, "100%", "280px" );
	Widget_SetSize( textbox_license, "100%", "100%" );

	Widget_Resize( window, WINDOW_SIZE );
	Widget_Resize( btn_ok, BTN_SIZE );

	Widget_ConnectEvent( btn_ok, EVENT_CLICKED, btn_ok_on_clicked );

	Widget_Show( textbox_license );
	Widget_Show( box );
	Widget_Show( label_license );
	Widget_Show( btn_ok );
}
Exemplo n.º 9
0
int main(void)
{
	LCUI_Thread t;
	LCUI_Widget *window, *widget;
	
	LCUI_Init();
	window = Widget_New( "window" );
	widget = Widget_New( NULL );
	Window_SetTitleText( window, "测试部件布局-1" );
	Window_ClientArea_Add( window, widget );
	Widget_Resize( widget, Size(120, 120) );
	Widget_Resize( window, Size(320, 240) );
	Widget_SetBackgroundTransparent( widget, FALSE );
	Widget_SetBorder( widget, Border(1, BORDER_STYLE_SOLID, RGB(0,0,0)) );
	Widget_SetBackgroundColor( widget, RGB(255,0,0) );
	
	Widget_Show( widget );
	Widget_Show( window );
	Widget_Event_Connect( Window_GetCloseButton(window), EVENT_CLICKED, destroy );
	LCUIThread_Create( &t, thread, widget );
	
	return LCUI_Main();
}
Exemplo n.º 10
0
Arquivo: mora.c Projeto: yydaor/LCUI
static void
widgets_configure( void )
{
	/* 设定标题栏显示的文本 */
	Window_SetTitleText( window, TEXT_WND_TITLE );
	Window_SetTitleIcon( window, &icon );
	Widget_Resize( window, WND_SIZE );
	/* 将部件加入至相应的容器 */
	Widget_Container_Add( btn_area, btn_s );
	Widget_Container_Add( btn_area, btn_j );
	Widget_Container_Add( btn_area, btn_b );
	Widget_Container_Add( btn_area, btn_next );
	Window_ClientArea_Add( window, label );
	Window_ClientArea_Add( window, l_vs );
	Window_ClientArea_Add( window, me_pic_box );
	Window_ClientArea_Add( window, cpu_pic_box );
	Window_ClientArea_Add( window, btn_area );

	/* 设定label部件显示的文本内容 */
	Label_Text( label,  TEXT_TIP );
	
	/* 设定label部件中的字体大小为55像素,颜色为红色 */
	Label_Text( l_vs, TEXT_VS );
	/* 禁用按钮的自动尺寸调整 */
	Widget_SetAutoSize( btn_b, FALSE, 0 );
	Widget_SetAutoSize( btn_s, FALSE, 0 );
	Widget_SetAutoSize( btn_j, FALSE, 0 );
	Widget_SetAutoSize( btn_next, FALSE, 0 );
	/* 调整这些部件的大小 */
	Widget_SetSize( btn_b, "78px", "30px" );
	Widget_SetSize( btn_s, "77px", "30px" );
	Widget_SetSize( btn_j, "77px", "30px" );
	Widget_SetSize( btn_next, "78px", "30px" );
	Widget_SetSize( btn_area, NULL, "30px" );
	Widget_SetDock( btn_area, DOCK_TYPE_BOTTOM );
	Widget_Resize( me_pic_box, Size(110, 140) );
	Widget_Resize( cpu_pic_box, Size(110, 140) );
	/* 自定义这四个按钮的风格 */
	Button_CustomStyle(	btn_b, &btn_normal, &btn_over, 
				&btn_down, &btn_focus, NULL); 
	Button_CustomStyle(	btn_s, &btn_normal, &btn_over,
				&btn_down, &btn_focus, NULL); 
	Button_CustomStyle(	btn_j, &btn_normal, &btn_over, 
				&btn_down, &btn_focus, NULL); 
	Button_CustomStyle(	btn_next, &btn_normal, &btn_over, 
				&btn_down, &btn_focus, NULL); 
	/* 设定部件的定位类型 */
	Widget_SetPosType( btn_s, POS_TYPE_STATIC );
	Widget_SetPosType( btn_j, POS_TYPE_STATIC );
	Widget_SetPosType( btn_b, POS_TYPE_STATIC );
	Widget_SetPosType( btn_next, POS_TYPE_STATIC );
	/* 设定布局 */
	Widget_SetAlign(me_pic_box, ALIGN_MIDDLE_LEFT, Pos(5, -5));
	Widget_SetAlign(cpu_pic_box, ALIGN_MIDDLE_RIGHT, Pos(-5, -5));
	Widget_SetAlign(label, ALIGN_TOP_CENTER, Pos(0, 3));
	Widget_SetAlign(l_vs, ALIGN_MIDDLE_CENTER, Pos(0, 0));
	/* 设定部件的边框及颜色 */
	Widget_SetBorder(me_pic_box, Border(1, BORDER_STYLE_SOLID, RGB(0,0,0)));
	Widget_SetBorder(cpu_pic_box, Border(1, BORDER_STYLE_SOLID, RGB(0,0,0)));
	/* 关联这些按钮的单击事件 */ 
	Widget_Event_Connect(btn_s, EVENT_CLICKED, select_stone );
	Widget_Event_Connect(btn_j, EVENT_CLICKED, select_knife );
	Widget_Event_Connect(btn_b, EVENT_CLICKED, select_cloth );
	Widget_Event_Connect(btn_next, EVENT_CLICKED, next );
	Widget_Event_Connect(Window_GetCloseButton(window), EVENT_CLICKED, destroy);
}
Exemplo n.º 11
0
/** 初始化window部件相关数据 */
static void Window_OnInit( LCUI_Widget *window )
{
	LCUI_Window *wnd;
	LCUI_Graph btn_bg;
	LCUI_TextStyle style;
	LCUI_Border border;
	
	wnd = Widget_NewPrivateData( window, LCUI_Window );

	wnd->theme_color = COLOR_EMERALD;
	wnd->theme_color.a = 128;
	wnd->titlebar = Widget_New(NULL); 
	wnd->client_area = Widget_New(NULL); 
	wnd->btn_close = Widget_New(WIDGET_CLOSE_BUTTON); 
	wnd->icon = Widget_New(NULL);
	wnd->text = Label_New();

	wnd->titlebar->focus = FALSE;
	wnd->icon->focus = FALSE;
	wnd->text->focus = FALSE;
	Widget_SetFocus( wnd->client_area );
	Widget_SetClickable( wnd->icon, FALSE );
	Widget_SetClickable( wnd->text, FALSE );
	Widget_SetClickable( wnd->titlebar, FALSE );
	Widget_SetClickable( wnd->client_area, FALSE );

	Graph_Init( &btn_bg );
	/* 载入按钮背景 */
	LoadCloseButtonIMG( &btn_bg );
	/* close按钮显示在左上角 */
	Widget_SetAlign( wnd->btn_close, ALIGN_TOP_RIGHT, Pos(0,0) );
	Widget_Resize( wnd->btn_close, Size(30, 30) );

	Widget_SetBackgroundImage( wnd->btn_close, &btn_bg );
	Widget_SetBackgroundLayout( wnd->btn_close, LAYOUT_CENTER );
	Widget_SetBackgroundTransparent( wnd->icon, TRUE );
	Widget_SetBackgroundTransparent( wnd->titlebar, TRUE );
	Widget_SetBackgroundTransparent( wnd->client_area, FALSE );
	Widget_SetBackgroundTransparent( window, FALSE );
	Widget_SetBackgroundColor( window, RGB(255,255,255) );
	Widget_SetBackgroundLayout( wnd->icon, LAYOUT_ZOOM );
	Widget_SetDock( wnd->titlebar, DOCK_TYPE_TOP );
	Widget_SetDock( wnd->client_area, DOCK_TYPE_BOTTOM );
	Widget_SetPadding( window, Padding(TOP_PANDDING,1,1,1) );
	Widget_SetPadding( wnd->client_area, Padding(1,1,1,1) );
	Widget_SetSize( wnd->titlebar, "100%", "35px" );
	
	Border_Init( &border );
	border.top_width = 0;
	border.bottom_width = 1;
	border.left_width = 1;
	border.right_width = 1;
	border.bottom_color = RGB(200,200,200);
	border.left_color = RGB(255,255,255);
	border.right_color = RGB(255,255,255);
	Widget_SetBorder( wnd->titlebar, border );

	TextStyle_Init( &style );
	TextStyle_FontSize( &style, 18 );
	Label_SetTextStyle( wnd->text, style );

	/* 放入至容器 */
	Widget_Container_Add( wnd->titlebar, wnd->icon );
	Widget_Container_Add( wnd->titlebar, wnd->text );
	Widget_Container_Add( wnd->titlebar, wnd->btn_close );
	Widget_Container_Add( window, wnd->titlebar );
	Widget_Container_Add( window, wnd->client_area );

	Widget_Resize( window, Size(100, 50) );
	Widget_Resize( wnd->icon, Size(24,24) );
	
	Widget_SetAlign( window, ALIGN_MIDDLE_CENTER, Pos(0,0) );
	Widget_SetAlign( wnd->icon, ALIGN_MIDDLE_LEFT, Pos(6,0) );
	Widget_SetAlign( wnd->text, ALIGN_MIDDLE_LEFT, Pos(6,0) );

	/* 关联拖动事件,让鼠标能够拖动标题栏并使窗口移动 */
	Widget_ConnectEvent( window, EVENT_DRAG, Window_ExecMove );
	/* 
	 * 由于需要在窗口获得/失去焦点时进行相关处理,因此需要将回调函数 与部件
	 * 的FOCUS_IN和FOCUS_OUT事件 进行关联
	 * */
	Widget_ConnectEvent( window, EVENT_FOCUSOUT, Window_OnFocusOut );
	Widget_ConnectEvent( window, EVENT_FOCUSIN, Window_OnFocusIn );
	
	Widget_Show( wnd->btn_close );
	Widget_Show( wnd->icon );
	Widget_Show( wnd->text );
	Widget_Show( wnd->titlebar );
	Widget_Show( wnd->client_area );
}
Exemplo n.º 12
0
static void
Window_ExecUpdate( LCUI_Widget *win_p )
{
	LCUI_Size size;
	LCUI_Graph *graph;
	LCUI_Border border;
	LCUI_Widget *titlebar, *btn, *client_area;
	LCUI_RGB border_color, back_color;
	
	btn = Window_GetCloseButton(win_p);
	titlebar = Window_GetTitleBar(win_p);
	client_area = Window_GetClientArea(win_p);
	graph = Widget_GetSelfGraph( win_p );
	/* 按不同的风格来处理 */ 
	switch( win_p->style_id ) {
	    case WINDOW_STYLE_NONE:  /* 没有边框 */
		/* 先计算坐标和尺寸 */
		Widget_SetDock( client_area, DOCK_TYPE_FILL );
		Widget_Hide( titlebar );/* 隐藏标题栏 */
		Widget_Show( client_area );/* 客户区需要显示 */
		break;
			
	    case WINDOW_STYLE_LINE: /* 线条边框 */
		Widget_SetBorder(win_p,
		 Border(1, BORDER_STYLE_SOLID, RGB(50,50,50)));
		Widget_SetPadding( win_p, Padding(1,1,1,1) );
		Widget_SetDock( client_area, DOCK_TYPE_FILL );
		Widget_Hide( titlebar );
		Widget_Show( client_area );
		break;

	    case WINDOW_STYLE_PURE_BLUE: 
		back_color = RGB(30,160,225); 
		border_color = RGB(0,130,195);
		goto union_draw_method;
	    case WINDOW_STYLE_PURE_GREEN:
		back_color = RGB(140,190,40);
		border_color = RGB(110,160,10);
		goto union_draw_method;
	    case WINDOW_STYLE_PURE_RED: 
		back_color = RGB(230,20,0);
		border_color = RGB(200,0,0);
		goto union_draw_method;
	    case WINDOW_STYLE_PURE_ORANGE: 
		back_color = RGB(240,150,10);
		border_color = RGB(210,120,0); 
		goto union_draw_method;
	    case WINDOW_STYLE_PURE_PURPLE:
		back_color = RGB(110,20,95);
		border_color = RGB(80,0,65); 
union_draw_method:;
		/* 若窗口未获得焦点 */
		if( !Widget_GetFocus( win_p ) ) {
			back_color = RGB(235,235,235);
			border_color = RGB(211,211,211);
		}
		/* 更新窗口标题栏上的关闭按钮 */
		Widget_Update( btn );
		border = Border(1, BORDER_STYLE_SOLID, border_color);
		Widget_SetBorder( client_area, border);
		Widget_SetBorder( win_p, border);
		Widget_SetBackgroundColor( win_p, back_color );
		Graph_FillColor( graph, back_color );
		Widget_SetBackgroundColor( client_area, RGB(255,255,255) );
		Widget_SetBackgroundImage( titlebar, NULL );
		Widget_SetBackgroundLayout( titlebar, 0 );
		Widget_SetBackgroundTransparent( titlebar, TRUE );
		Widget_SetBackgroundTransparent( client_area, FALSE );
		Widget_SetPadding( win_p, Padding(1,4,4,4) );
		Widget_SetPadding( client_area, Padding(1,1,1,1) );
		size = Widget_GetContainerSize( win_p );
		Widget_Resize( titlebar, Size(size.h, 25) );
		Widget_Resize( client_area, Size(size.w, size.h - 25) );
		Widget_SetDock( titlebar, DOCK_TYPE_TOP ); 
		Widget_SetDock( client_area, DOCK_TYPE_BOTTOM );
		Widget_Show( titlebar );
		Widget_Show( client_area ); 
		break;
	    default:
			//
		break;
	}
}
Exemplo n.º 13
0
/** 初始化键位设置窗口 */
void GameWindow_InitSetKeyboardWindow(void)
{
	/* 创建所需的GUI部件 */
	window = Widget_New("window");
	box = Widget_New(NULL);
	label = Widget_New("label");
	label_left = Widget_New("label");
	label_right = Widget_New("label");
	label_up = Widget_New("label");
	label_down = Widget_New("label");
	label_jump = Widget_New("label");
	label_defense = Widget_New("label");
	label_a_atk = Widget_New("label");
	label_b_atk = Widget_New("label");
	btn_left = Widget_New("button");
	btn_right = Widget_New("button");
	btn_up = Widget_New("button");
	btn_down = Widget_New("button");
	btn_a_atk = Widget_New("button");
	btn_b_atk = Widget_New("button");
	btn_jump = Widget_New("button");
	btn_defense = Widget_New("button");
	btn_ok = Widget_New("button");
	btn_reset = Widget_New("button");
	
	Widget_Container_Add( box, btn_left );
	Widget_Container_Add( box, btn_right );
	Widget_Container_Add( box, btn_up );
	Widget_Container_Add( box, btn_down );
	Widget_Container_Add( box, btn_jump );
	Widget_Container_Add( box, btn_defense );
	Widget_Container_Add( box, btn_a_atk );
	Widget_Container_Add( box, btn_b_atk );
	Widget_Container_Add( box, label_left );
	Widget_Container_Add( box, label_right );
	Widget_Container_Add( box, label_up );
	Widget_Container_Add( box, label_down );
	Widget_Container_Add( box, label_jump );
	Widget_Container_Add( box, label_defense );
	Widget_Container_Add( box, label_a_atk );
	Widget_Container_Add( box, label_b_atk );
	Window_ClientArea_Add( window, box );
	Window_ClientArea_Add( window, label );
	Window_ClientArea_Add( window, btn_ok );
	Window_ClientArea_Add( window, btn_reset );
	
	Widget_SetAutoSize( btn_left, FALSE, 0 );
	Widget_SetAutoSize( btn_right, FALSE, 0 );
	Widget_SetAutoSize( btn_up, FALSE, 0 );
	Widget_SetAutoSize( btn_down, FALSE, 0 );
	Widget_SetAutoSize( btn_jump, FALSE, 0 );
	Widget_SetAutoSize( btn_a_atk, FALSE, 0 );
	Widget_SetAutoSize( btn_b_atk, FALSE, 0 );
	Widget_SetAutoSize( btn_defense, FALSE, 0 );
	Widget_SetAutoSize( btn_ok, FALSE, 0 );

	Widget_Resize( btn_left, KEYBTN_SIZE );
	Widget_Resize( btn_right, KEYBTN_SIZE );
	Widget_Resize( btn_up, KEYBTN_SIZE );
	Widget_Resize( btn_down, KEYBTN_SIZE );
	Widget_Resize( btn_jump, KEYBTN_SIZE );
	Widget_Resize( btn_a_atk, KEYBTN_SIZE );
	Widget_Resize( btn_b_atk, KEYBTN_SIZE );
	Widget_Resize( btn_defense, KEYBTN_SIZE );
	Widget_Resize( btn_ok, BTN_SIZE );
	Widget_Resize( btn_reset, BTN_SIZE );
	
	Widget_Move( btn_left, Pos(0,50+22) );
	Widget_Move( btn_right, Pos(100,50+22) );
	Widget_Move( btn_up, Pos(50,0+22) );
	Widget_Move( btn_down, Pos(50,50+22) );
	Widget_Move( btn_jump, Pos(200,50+22) );
	Widget_Move( btn_a_atk, Pos(200,0+22) );
	Widget_Move( btn_b_atk, Pos(250,0+22) );
	Widget_Move( btn_defense, Pos(250,50+22) );
	
	Widget_Move( label_left, Pos(10,125) );
	Widget_Move( label_right, Pos(110,125) );
	Widget_Move( label_up, Pos(60,0) );
	Widget_Move( label_down, Pos(60,125) );
	Widget_Move( label_a_atk, Pos(210,0) );
	Widget_Move( label_b_atk, Pos(260,0) );
	Widget_Move( label_jump, Pos(210,125) );
	Widget_Move( label_defense, Pos(260,125) );

	UpdateKeyBtn();
	/* 设置各种文本 */
	Label_TextW( label_left, TEXT_LEFT );
	Label_TextW( label_right, TEXT_RIGHT );
	Label_TextW( label_up, TEXT_UP );
	Label_TextW( label_down, TEXT_DOWN );
	Label_TextW( label_jump, TEXT_JUMP );
	Label_TextW( label_defense, TEXT_DEFENSE );
	Label_TextW( label_a_atk, TEXT_A_ATK );
	Label_TextW( label_b_atk, TEXT_B_ATK );
	/* 设置窗口 */
	Widget_SetStyleID( window, WINDOW_STYLE_LINE );
	Widget_Resize( window, WINDOW_SIZE );
	Widget_SetPadding( Window_GetClientArea(window), Padding(10,10,10,10) );

	Label_TextW( label, TEXT_SET_KEYBOARD );
	Widget_SetBackgroundColor( label, RGB(255,255,255) );
	Widget_SetBackgroundTransparent( label, FALSE );

	Button_TextW( btn_ok, TEXT_OK );
	Button_TextW( btn_reset, TEXT_RESET );

	Widget_SetSize( box, "100%", "165px" );
	Widget_SetBorder( box, Border(1,BORDER_STYLE_SOLID,RGB(200,200,200)) );
	Widget_SetPadding( box, Padding(10,10,10,10) );

	Widget_SetAlign( box, ALIGN_TOP_CENTER, Pos(0,12) );
	Widget_SetAlign( label, ALIGN_TOP_CENTER, Pos(0,0) );
	Widget_SetAlign( btn_ok, ALIGN_BOTTOM_CENTER, Pos(-50,-5) );
	Widget_SetAlign( btn_reset, ALIGN_BOTTOM_CENTER, Pos(50,-5) );
	/* 为键位按钮连接事件 */
	Widget_ConnectEvent( btn_ok, EVENT_CLICKED, btn_ok_on_clicked );
	Widget_ConnectEvent( btn_reset, EVENT_CLICKED, btn_reset_on_clicked );
	Widget_ConnectEvent( btn_left, EVENT_CLICKED, btn_key_on_clicked );
	Widget_ConnectEvent( btn_right, EVENT_CLICKED, btn_key_on_clicked );
	Widget_ConnectEvent( btn_up, EVENT_CLICKED, btn_key_on_clicked );
	Widget_ConnectEvent( btn_down, EVENT_CLICKED, btn_key_on_clicked );
	Widget_ConnectEvent( btn_b_atk, EVENT_CLICKED, btn_key_on_clicked );
	Widget_ConnectEvent( btn_a_atk, EVENT_CLICKED, btn_key_on_clicked );
	Widget_ConnectEvent( btn_jump, EVENT_CLICKED, btn_key_on_clicked );
	Widget_ConnectEvent( btn_defense, EVENT_CLICKED, btn_key_on_clicked );
	
	Widget_Show( btn_left );
	Widget_Show( btn_right );
	Widget_Show( btn_up );
	Widget_Show( btn_down );
	Widget_Show( btn_jump );
	Widget_Show( btn_a_atk );
	Widget_Show( btn_b_atk );
	Widget_Show( btn_defense );
	Widget_Show( label_left );
	Widget_Show( label_right );
	Widget_Show( label_up );
	Widget_Show( label_down );
	Widget_Show( label_jump );
	Widget_Show( label_a_atk );
	Widget_Show( label_b_atk );
	Widget_Show( label_defense );
	Widget_Show( btn_ok );
	Widget_Show( btn_reset );
	Widget_Show( box );
	Widget_Show(label );
}