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 ); }
static void CloseButton_OnUpdate( LCUI_Widget *widget ) { LCUI_Graph img; LCUI_Color color; LCUI_Widget *wnd; Graph_Init( &img ); LoadCloseButtonIMG( &img ); wnd = Widget_GetParent( widget, WIDGET_WINDOW ); if( wnd ) { /* 若所在窗口并未获得焦点 */ if( !Widget_GetFocus(wnd) ) { color = RGB(200,200,200); } else { LCUI_Window *wnd_data; wnd_data = (LCUI_Window*)Widget_GetPrivateData( wnd ); color = wnd_data->theme_color; } } else { color = RGB(255,0,0); } switch(widget->state) { case WIDGET_STATE_NORMAL: Graph_FillColor( &img, RGB(150,150,150) ); Widget_SetBackgroundImage( widget, &img ); Widget_SetBackgroundLayout( widget, LAYOUT_CENTER ); Widget_SetBackgroundTransparent( widget, TRUE ); break; case WIDGET_STATE_ACTIVE: color.red = _ALPHA_BLEND( 0, color.red, 100 ); color.green = _ALPHA_BLEND( 0, color.green, 100 ); color.blue = _ALPHA_BLEND( 0, color.blue, 100 ); Graph_FillColor( &img, RGB(255,255,255) ); Widget_SetBackgroundImage( widget, &img ); Widget_SetBackgroundColor( widget, color ); Widget_SetBackgroundLayout( widget, LAYOUT_CENTER ); Widget_SetBackgroundTransparent( widget, FALSE ); break; case WIDGET_STATE_OVERLAY: Graph_FillColor( &img, RGB(255,255,255) ); Widget_SetBackgroundImage( widget, &img ); Widget_SetBackgroundColor( widget, color ); Widget_SetBackgroundLayout( widget, LAYOUT_CENTER ); Widget_SetBackgroundTransparent( widget, FALSE ); case WIDGET_STATE_DISABLE: default:break; } Graph_Free( &img ); }
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(); }
/* * 创建一个部件,作为滚动条的容器 * 再创建一个部件,作为滚动条 * 限制滚动条的移动范围 * */ 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 ); }
int main(int argc, char **argv) { LCUI_Widget *window; /* 载入图像资源 */ LoadIMG(); /* 初始化LCUI */ LCUI_Init(350,280,0); /* 创建窗口 */ window = Widget_New("window"); /* 设置窗口背景色 */ Widget_SetBackgroundColor( window, RGB(255,255,255) ); /* 调整窗口尺寸 */ Widget_Resize( window, Size(320, 240) ); /* 设置窗口为线条边框风格 */ Widget_SetStyleID( window, WINDOW_STYLE_NONE ); /* 将界面创建至窗口内 */ CreateGUI( window ); /* 设置定时器,用于定时更新时间显示 */ LCUITimer_Set( 1000, UpdateTimeView, NULL, TRUE ); /* 设置定时器,用于更新滑块的位置 */ LCUITimer_Set( 20, PicBtn_UpdatePos, NULL, TRUE ); /* 显示窗口 */ Widget_Show( window ); /* 在LCUI退出时释放图像资源 */ LCUIApp_AtQuit( FreeIMG ); return LCUI_Main(); }
/* 更新当前文本框的样式 */ 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 ); }
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 ); }
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(); }
static void TextBox_Init( LCUI_Widget *widget ) /* 初始化文本框相关数据 */ { LCUI_TextBox *textbox; widget->valid_state = WIDGET_STATE_ACTIVE | WIDGET_STATE_OVERLAY; widget->valid_state |= (WIDGET_STATE_NORMAL | WIDGET_STATE_DISABLE); textbox = WidgetPrivData_New(widget, sizeof(LCUI_TextBox)); textbox->text = Widget_New( "label" ); textbox->cursor = Widget_New( NULL ); textbox->scrollbar[0] = Widget_New( "scrollbar" ); textbox->scrollbar[1] = Widget_New( "scrollbar" ); /* 不可获得焦点 */ textbox->text->focus = FALSE; textbox->cursor->focus = FALSE; textbox->scrollbar[0]->focus = FALSE; textbox->scrollbar[1]->focus = FALSE; textbox->limit_mode = 0; textbox->block_size = 256; textbox->show_placeholder = FALSE; LCUIWString_Init( &textbox->placeholder ); TextStyle_Init( &textbox->placeholder_style ); TextStyle_FontColor( &textbox->placeholder_style, RGB(100,100,100) ); Label_AutoSize( textbox->text, FALSE, 0 ); Widget_SetSize( textbox->text, "100%", "100%" ); /* 添加至相应的容器 */ Widget_Container_Add( textbox->text, textbox->cursor ); Widget_Container_Add( widget, textbox->text ); Widget_Container_Add( widget, textbox->scrollbar[0] ); Widget_Container_Add( widget, textbox->scrollbar[1] ); /* 设置滚动条的尺寸 */ Widget_SetSize( textbox->scrollbar[0], "10px", NULL ); Widget_SetSize( textbox->scrollbar[1], NULL, "10px" ); Widget_SetAlign( textbox->scrollbar[0], ALIGN_TOP_RIGHT, Pos(0,0) ); Widget_SetAlign( textbox->scrollbar[1], ALIGN_BOTTOM_LEFT, Pos(0,0) ); /* 滚动条设为横向 */ ScrollBar_SetDirection( textbox->scrollbar[1], 1 ); /* 将回调函数与滚动条连接 */ ScrollBar_Connect( textbox->scrollbar[0], TextBox_TextLayer_VertScroll, widget ); ScrollBar_Connect( textbox->scrollbar[1], TextBox_HoriScroll_TextLayer, widget ); Widget_Show( textbox->text ); Queue_Init( &textbox->text_block_buff, sizeof(LCUI_TextBlock), destroy_textblock ); TextLayer_UsingStyleTags( Label_GetTextLayer(textbox->text), FALSE ); Widget_SetPadding( widget, Padding(2,2,2,2) ); Widget_SetBackgroundColor( textbox->cursor, RGB(0,0,0) ); Widget_SetBackgroundTransparent( textbox->cursor, FALSE ); Widget_SetBackgroundTransparent( widget, FALSE ); Widget_Resize( textbox->cursor, Size(1, 14) ); /* 设置可点击区域的alpha值要满足的条件 */ Set_Widget_ClickableAlpha( textbox->cursor, 0, 1 ); Set_Widget_ClickableAlpha( textbox->text, 0, 1 ); /* 设定定时器,每1秒闪烁一次 */ if( __timer_id == -1 ) { __timer_id = set_timer( 500, blink_cursor, TRUE ); } Widget_Event_Connect( widget, EVENT_DRAG, TextBox_TextLayer_Click ); /* 关联 FOCUS_OUT 和 FOCUS_IN 事件 */ Widget_Event_Connect( widget, EVENT_FOCUSOUT, _putout_textbox_cursor ); Widget_Event_Connect( widget, EVENT_FOCUSIN, _putin_textbox_cursor ); /* 关联按键输入事件 */ Widget_Event_Connect( widget, EVENT_KEYBOARD, TextBox_Input ); /* 默认不启用多行文本模式 */ TextBox_Multiline( widget, FALSE ); }
/** 初始化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 ); }
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; } }
/** 初始化键位设置窗口 */ 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 ); }