Example #1
0
LCUI_API void
Window_TitleBar_Add(LCUI_Widget *window, LCUI_Widget *widget)
/* 功能:将部件添加至窗口标题栏 */
{
	LCUI_Widget *w = Window_GetTitleBar(window);
	Widget_Container_Add(w, widget);
}
Example #2
0
/* 动态改变进度条的数据 */
static void change_progress( void *arg )
{
	char str[15];
	int i, max = 100;
	LCUI_Widget *label;
	LCUI_Widget *widget;
	
	/* 创建一个label部件 */
	widget = (LCUI_Widget *)arg;
	label = Widget_New("label");
	/* 放到进度条里 */
	Widget_Container_Add( widget, label );
	/* 并且居中 */
	Widget_SetAlign( label, ALIGN_MIDDLE_CENTER, Pos(0,0) ); 
	/* 显示它 */
	Widget_Show( label );

	/* 设置最大值 */
	ProgressBar_SetMaxValue(widget, max); 
	for( i=0; i<max; i+=rand()%5 ) {
		/* 设置当前值 */
		ProgressBar_SetValue(widget, i); 
		/* 转换成字符串 */
		sprintf( str, "%d%%", (int)(i*100.0/max) );
		/* 设置显示的文本 */
		Label_Text( label, str );
		/* 暂停0.1秒 */
		LCUI_MSleep(100);
	}
	ProgressBar_SetValue( widget, max );
	Label_Text( label, "100%" );
	LCUIThread_Exit(NULL);
}
Example #3
0
File: button.c Project: yydaor/LCUI
/* 初始化按钮部件的数据 */
static void
Button_Init( LCUI_Widget *widget )
{
	int valid_state;
	LCUI_Button *button;
	
	button = WidgetPrivData_New(widget, sizeof(LCUI_Button));
	/* 初始化图像数据 */ 
	Graph_Init(&button->btn_disable);
	Graph_Init(&button->btn_normal);
	Graph_Init(&button->btn_focus);
	Graph_Init(&button->btn_down);
	Graph_Init(&button->btn_over);
	
	valid_state = (WIDGET_STATE_NORMAL | WIDGET_STATE_ACTIVE);
	valid_state |= (WIDGET_STATE_DISABLE | WIDGET_STATE_OVERLAY);
	Widget_SetValidState( widget, valid_state );
	button->label = Widget_New("label");/* 创建label部件 */ 
	/* 将按钮部件作为label部件的容器 */
	Widget_Container_Add(widget, button->label);
	/* label部件居中显示 */
	Widget_SetAlign(button->label, ALIGN_MIDDLE_CENTER, Pos(0,0));
	Widget_Show(button->label); /* 显示label部件 */
	/* 启用自动尺寸调整,以适应内容 */
	Widget_SetAutoSize( widget, TRUE, AUTOSIZE_MODE_GROW_AND_SHRINK);
	Widget_SetStyleID( widget, BUTTON_STYLE_DEFAULT );
	/* 关联EVENT_FOCUSOUT事件,以在按钮失去焦点时重绘按钮 */
	Widget_Event_Connect( widget, EVENT_FOCUSOUT, Button_ProcFocusOut );
}
Example #4
0
LCUI_API void
Window_ClientArea_Add(LCUI_Widget *window, LCUI_Widget *widget)
/* 功能:将部件添加至窗口客户区 */
{
	LCUI_Widget *w = Window_GetClientArea(window);
	Widget_Container_Add(w, widget);
}
Example #5
0
int main(int argc, char *argv[])
{
	int i;
	LCUI_Init( argc, argv );
	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];
	
	window = Create_Widget( "window" );
	for(i=0; i<6; ++i) {
		widget[i] = Create_Widget( NULL );
		label[i] = Create_Widget( "label" );
		Label_Text( label[i], "Area %d" , i);
		Widget_Container_Add( widget[i], label[i] );
		Window_Client_Area_Add( window, widget[i] );
		Resize_Widget( widget[i], Size(80,80) );
		Set_Widget_PosType( widget[i], POS_TYPE_STATIC );
		Set_Widget_Align( label[i], ALIGN_MIDDLE_CENTER, Pos(0,0) );
		Set_Widget_Border( widget[i], RGB(0,0,0), Border(1,1,1,1) );
		Set_Widget_BG_Mode( widget[i], BG_MODE_FILL_BACKCOLOR );
		Set_Widget_Backcolor( widget[i], color[i] );
		Show_Widget( label[i] );
		Show_Widget( widget[i] );
	}
	
	Set_Window_Title_Text( window, "测试部件布局-2" ); 
	Resize_Widget( window, Size(320, 240) );
	
	Show_Widget( window );
	
	return LCUI_Main();
}
Example #6
0
/*
 * 创建一个部件,作为滚动条的容器
 * 再创建一个部件,作为滚动条
 * 限制滚动条的移动范围
 * */
static void 
ScrollBar_Init( LCUI_Widget *widget )
{
	LCUI_ScrollBar *scrollbar;
	
	scrollbar = Widget_Create_PrivData(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 = Create_Widget("button");
	/* 禁用部件的自动尺寸调整 */
	Widget_AutoSize( scrollbar->widget, FALSE, 0 );
	
	Widget_Container_Add( widget, scrollbar->widget );
	Set_Widget_Size( scrollbar->widget, "100%", "100%" );
	Limit_Widget_Pos( scrollbar->widget, Pos(0,0), Pos(0,0) ); 
	Set_Widget_Border( widget, RGB(100,100,100), Border(1,1,1,1) );
	Set_Widget_Padding( widget, Padding(1,1,1,1) );
	Set_Widget_Backcolor( widget, RGB(200,200,200) );
	Set_Widget_BG_Mode( widget, BG_MODE_FILL_BACKCOLOR );
	Show_Widget( scrollbar->widget );
	Widget_Drag_Event_Connect( scrollbar->widget, ScrollBar_Drag );
}
Example #7
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 );
}
/** 捕捉键盘按键输入 */
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 );
}
Example #9
0
/************************* 基本的部件处理 ********************************/
static void 
TextBox_Init( LCUI_Widget *widget )
/* 初始化文本框相关数据 */
{
	LCUI_TextBox *textbox;
	
	textbox = Widget_Create_PrivData(widget, sizeof(LCUI_TextBox));
	textbox->text = Create_Widget( "label" );
	Widget_Container_Add( widget, textbox->text ); 
}
Example #10
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 );
}
Example #11
0
static void thread(void *arg)
{
	LCUI_Widget *widget, *label;
	
	widget = (LCUI_Widget*)arg; 
	label = Widget_New( "label" );
	Widget_Container_Add( widget, label );
	Widget_SetAlign( label, ALIGN_MIDDLE_CENTER, Pos(0,0) );
	Widget_Show( label );
	while(LCUI_Active()) {
		Label_Text( label, "DOCK_TYPE_TOP" );
		Widget_SetDock( widget, DOCK_TYPE_TOP ); 
		Widget_SetSize( widget, "120px", "120px" ); 
		/* 还原尺寸 */
		LCUI_Sleep(1);
		Label_Text( label, "DOCK_TYPE_LEFT" );
		Widget_SetDock( widget, DOCK_TYPE_LEFT ); 
		Widget_SetSize( widget, "120px", "120px" ); 
		LCUI_Sleep(1);
		Label_Text( label, "DOCK_TYPE_RIGHT" );
		Widget_SetDock( widget, DOCK_TYPE_RIGHT ); 
		Widget_SetSize( widget, "120px", "120px" ); 
		LCUI_Sleep(1);
		Label_Text( label, "DOCK_TYPE_BOTTOM" );
		Widget_SetDock( widget, DOCK_TYPE_BOTTOM ); 
		Widget_SetSize( widget, "120px", "120px" ); 
		LCUI_Sleep(1);
		Label_Text( label, "DOCK_TYPE_FILL" );
		Widget_SetDock( widget, DOCK_TYPE_FILL ); 
		Widget_SetSize( widget, "120px", "120px" ); 
		LCUI_Sleep(1);
		Label_Text( label, "DOCK_TYPE_NONE" );
		Widget_SetDock( widget, DOCK_TYPE_NONE ); 
		Widget_SetSize( widget, "120px", "120px" );  
		LCUI_Sleep(1);
	}
	LCUIThread_Exit(NULL);
}
Example #12
0
static void 
TextBox_Init( LCUI_Widget *widget )
/* 初始化文本框相关数据 */
{
	LCUI_TextBox *textbox;
	
	textbox = Widget_Create_PrivData(widget, sizeof(LCUI_TextBox));
	
	textbox->text = Create_Widget( "label" );
	textbox->cursor = Create_Widget( NULL );
	textbox->scrollbar[0] = Create_Widget( "scrollbar" );
	textbox->scrollbar[1] = Create_Widget( "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;
	
	Label_AutoSize( textbox->text, FALSE, 0 );
	Set_Widget_Size( 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] );
	/* 设置滚动条的尺寸 */
	Set_Widget_Size( textbox->scrollbar[0], "10px", NULL );
	Set_Widget_Size( textbox->scrollbar[1], NULL, "10px" );
	Set_Widget_Align( textbox->scrollbar[0], ALIGN_TOP_RIGHT, Pos(0,0) );
	Set_Widget_Align( textbox->scrollbar[1], ALIGN_BOTTOM_LEFT, Pos(0,0) );
	/* 滚动条设为横向 */
	ScrollBar_Set_Direction( textbox->scrollbar[1], 1 );
	/* 将回调函数与滚动条连接 */
	ScrollBar_Connect( textbox->scrollbar[0], TextBox_VertScroll_TextLayer, widget );
	ScrollBar_Connect( textbox->scrollbar[1], TextBox_HoriScroll_TextLayer, widget );
	Show_Widget( textbox->text );
	
	Queue_Init( &textbox->text_block_buff, sizeof(LCUI_TextBlock), destroy_textblock );
	
	TextLayer_Using_StyleTags( Label_Get_TextLayer(textbox->text), FALSE );
	Set_Widget_Padding( widget, Padding(2,2,2,2) );
	Set_Widget_Backcolor( textbox->cursor, RGB(0,0,0) );
	Set_Widget_BG_Mode( textbox->cursor, BG_MODE_FILL_BACKCOLOR );
	
	Resize_Widget( 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_Drag_Event_Connect( widget, TextBox_TextLayer_Click );
	/* 关联 FOCUS_OUT 和 FOCUS_IN 事件 */
	Widget_FocusOut_Event_Connect( widget, hide_textbox_cursor, NULL );
	Widget_FocusIn_Event_Connect( widget, _put_textbox_cursor, NULL );
	/* 关联按键输入事件 */
	Widget_Keyboard_Event_Connect( widget, TextBox_Input );
	/* 默认不启用多行文本模式 */
	TextBox_Multiline( widget, FALSE );
}
Example #13
0
/* 初始化单选框部件的数据 */
static void 
RadioButton_Init( LCUI_Widget widget )
{
	int valid_state;
	LCUI_Widget container[2];
	LCUI_RadioButton *radio_button;
	
	radio_button = Widget_NewPrivData(widget, sizeof(LCUI_RadioButton));
	radio_button->on = FALSE;
	/* 初始化图片数据 */ 
	Graph_Init(&radio_button->img_off_disable);
	Graph_Init(&radio_button->img_off_normal);
	Graph_Init(&radio_button->img_off_focus);
	Graph_Init(&radio_button->img_off_down);
	Graph_Init(&radio_button->img_off_over);
	Graph_Init(&radio_button->img_on_disable);
	Graph_Init(&radio_button->img_on_normal);
	Graph_Init(&radio_button->img_on_focus);
	Graph_Init(&radio_button->img_on_down);
	Graph_Init(&radio_button->img_on_over);
	
	radio_button->mutex = NULL;
	
	radio_button->label = Widget_New("label");/* 创建label部件 */
	radio_button->imgbox = Widget_New("picture_box"); /* 创建图像框部件 */
	/* 创建两个容器,用于调整上面两个部件的位置 */
	container[0] = Widget_New(NULL);
	container[1] = Widget_New(NULL);
	
	/* 启用这些部件的自动尺寸调整的功能 */
	Widget_SetAutoSize( widget, TRUE, AUTOSIZE_MODE_GROW_AND_SHRINK );
	Widget_SetAutoSize( container[0], TRUE, AUTOSIZE_MODE_GROW_AND_SHRINK );
	Widget_SetAutoSize( container[1], TRUE, AUTOSIZE_MODE_GROW_AND_SHRINK );
	
	Widget_Container_Add(container[0], radio_button->imgbox);
	Widget_Container_Add(container[1], radio_button->label);
	Widget_Container_Add(widget, container[0]);
	Widget_Container_Add(widget, container[1]);
	
	/* 调整尺寸 */
	Widget_Resize(radio_button->imgbox, Size(15, 15));
	/* 调整布局 */
	Widget_SetAlign(container[0], ALIGN_MIDDLE_LEFT, Pos(0,0));
	Widget_SetAlign(container[1], ALIGN_MIDDLE_LEFT, Pos(17,0));
	Widget_SetAlign(radio_button->imgbox, ALIGN_MIDDLE_CENTER, Pos(0,0));
	Widget_SetAlign(radio_button->label, ALIGN_MIDDLE_CENTER, Pos(0,0));
	
	PictureBox_SetSizeMode(radio_button->imgbox, SIZE_MODE_STRETCH);
	
	/* 显示之 */
	Widget_Show(radio_button->label);
	Widget_Show(radio_button->imgbox);
	Widget_Show(container[0]);
	Widget_Show(container[1]);
	
	Widget_ConnectEvent( widget, EVENT_CLICKED, RadioButton_Click );
	
	valid_state = (WIDGET_STATE_NORMAL | WIDGET_STATE_ACTIVE);
	valid_state |= (WIDGET_STATE_DISABLE | WIDGET_STATE_OVERLAY);
	Widget_SetValidState( widget, valid_state);
}
Example #14
0
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 );
}
Example #15
0
/* 初始化复选框部件的数据 */
static void 
CheckBox_Init(LCUI_Widget *widget)
{
	int valid_state;
	LCUI_Widget *container[2];
	LCUI_CheckBox *check_box;
	
	check_box = Widget_NewPrivData(widget, sizeof(LCUI_CheckBox));
	
	check_box->on = FALSE;
	/* 初始化图像数据 */ 
	Graph_Init(&check_box->img_off_disable);
	Graph_Init(&check_box->img_off_normal);
	Graph_Init(&check_box->img_off_focus);
	Graph_Init(&check_box->img_off_down);
	Graph_Init(&check_box->img_off_over);
	Graph_Init(&check_box->img_on_disable);
	Graph_Init(&check_box->img_on_normal);
	Graph_Init(&check_box->img_on_focus);
	Graph_Init(&check_box->img_on_down);
	Graph_Init(&check_box->img_on_over);
	/* 创建所需的部件 */
	check_box->label = Widget_New("label");
	check_box->imgbox = Widget_New("picture_box");  
	/* 创建两个容器,用于调整上面两个部件的位置 */
	container[0] = Widget_New(NULL);
	container[1] = Widget_New(NULL);
	
	/* 启用这些部件的自动尺寸调整的功能 */
	Widget_SetAutoSize( widget, TRUE, AUTOSIZE_MODE_GROW_AND_SHRINK );
	Widget_SetAutoSize( container[0], TRUE, AUTOSIZE_MODE_GROW_AND_SHRINK );
	Widget_SetAutoSize( container[1], TRUE, AUTOSIZE_MODE_GROW_AND_SHRINK );
	
	Widget_Container_Add(container[0], check_box->imgbox);
	Widget_Container_Add(container[1], check_box->label);
	Widget_Container_Add(widget, container[0]);
	Widget_Container_Add(widget, container[1]);
	
	/* 调整尺寸 */
	Widget_Resize(check_box->imgbox, Size(15, 15));
	//Widget_Resize(container[0], Size(18,18));
	//Widget_Resize(widget, Size(18,18));
	/* 调整布局 */
	Widget_SetAlign(container[0], ALIGN_MIDDLE_LEFT, Pos(0,0));
	Widget_SetAlign(container[1], ALIGN_MIDDLE_LEFT, Pos(17,0));
	Widget_SetAlign(check_box->imgbox, ALIGN_MIDDLE_CENTER, Pos(0,0));
	Widget_SetAlign(check_box->label, ALIGN_MIDDLE_CENTER, Pos(0,0));
	/* 设置图像框的尺寸模式为拉伸 */
	PictureBox_SetSizeMode(check_box->imgbox, SIZE_MODE_STRETCH);
	
	/* 显示之 */
	Widget_Show(check_box->label);
	Widget_Show(check_box->imgbox);
	Widget_Show(container[0]);
	Widget_Show(container[1]);
	/* 关联鼠标左键点击事件 */
	Widget_Event_Connect( widget, EVENT_CLICKED, CheckBox_SwitchState );
	/* 响应状态改变 */
	valid_state = (WIDGET_STATE_NORMAL | WIDGET_STATE_ACTIVE);
	valid_state |= (WIDGET_STATE_DISABLE | WIDGET_STATE_OVERLAY);
	Widget_SetValidState( widget, valid_state );
}
Example #16
0
static void CreateGUI( LCUI_Widget *win )
{
	/* 创建部件 */
	time_box	= Widget_New(NULL);
	pic_bg		= Widget_New(NULL);
	pic_l1		= Widget_New(NULL);
	pic_l2		= Widget_New(NULL);
	pic_c		= Widget_New(NULL);
	pic_btn		= Widget_New(NULL);
	pic_btn_line	= Widget_New(NULL);
	pic_btn		= Widget_New(NULL);
	pic_r1		= Widget_New(NULL);
	pic_r2		= Widget_New(NULL);
	date_label	= Widget_New("label");
	wday_label	= Widget_New("label");
	/* 设置这些部件的初始背景图 */
	Widget_SetBackgroundImage( pic_bg, &img_bg );
	Widget_SetBackgroundImage( pic_btn_line, &img_btn_bg );
	Widget_SetBackgroundLayout( pic_btn_line, LAYOUT_CENTER );
	Widget_SetBackgroundImage( pic_btn, &img_btn );
	Widget_SetBackgroundImage( pic_l1, &img_digital[0] );
	Widget_SetBackgroundImage( pic_l2, &img_digital[0] );
	Widget_SetBackgroundImage( pic_r1, &img_digital[0] );
	Widget_SetBackgroundImage( pic_r2, &img_digital[0] );
	Widget_SetBackgroundImage( pic_c,  &img_dot );
	/* 调整尺寸 */
	Widget_Resize( time_box,	Size(162, 38) );
	Widget_Resize( pic_bg,		Size(300, 90) );
	Widget_Resize( pic_btn_line,	Size(245, 66) );
	Widget_Resize( pic_btn,		Size(46, 66) );
	Widget_Resize( pic_l1,		Size(33, 36) );
	Widget_Resize( pic_l2,		Size(33, 36) );
	Widget_Resize( pic_c,		Size(30, 38) );
	Widget_Resize( pic_r1,		Size(33, 36) );
	Widget_Resize( pic_r2,		Size(33, 36) );
	/* 调整布局 */
	Widget_SetAlign( pic_l1, ALIGN_MIDDLE_CENTER, Pos(-66,0) );
	Widget_SetAlign( pic_l2, ALIGN_MIDDLE_CENTER, Pos(-33,0) );
	Widget_SetAlign( pic_c, ALIGN_MIDDLE_CENTER, Pos(0,0) );
	Widget_SetAlign( pic_r1, ALIGN_MIDDLE_CENTER, Pos(33,0) );
	Widget_SetAlign( pic_r2, ALIGN_MIDDLE_CENTER, Pos(66,0) );
	Widget_SetAlign( time_box, ALIGN_MIDDLE_CENTER, Pos(0,-50) );
	Widget_SetAlign( pic_bg, ALIGN_MIDDLE_CENTER, Pos(0,5) );
	Widget_SetAlign(date_label, ALIGN_MIDDLE_CENTER, Pos(0,35-50) );
	Widget_SetAlign( wday_label, ALIGN_TOP_CENTER, Pos(0,5) );
	Widget_SetAlign( pic_btn_line, ALIGN_BOTTOM_CENTER, Pos(0,-10) );
	/* 放入容器 */
	Widget_Container_Add( time_box, pic_l1 );
	Widget_Container_Add( time_box, pic_l2 );
	Widget_Container_Add( time_box, pic_c );
	Widget_Container_Add( time_box, pic_r1 );
	Widget_Container_Add( time_box, pic_r2 );
	Widget_Container_Add( pic_btn_line, pic_btn );

	Window_ClientArea_Add( win, pic_bg );
	Window_ClientArea_Add( win, time_box );
	Window_ClientArea_Add( win, date_label );
	Window_ClientArea_Add( win, wday_label );
	Window_ClientArea_Add (win, pic_btn_line );
	/* 限制移动范围 */
	Widget_LimitPos(pic_btn, Pos(0,0), Pos(195,0));
	Widget_ConnectEvent(pic_btn, EVENT_DRAG, move_pic_btn);

	Widget_Show(pic_bg);
	Widget_Show(pic_l1);
	Widget_Show(pic_l2);
	Widget_Show(pic_c);
	Widget_Show(pic_r1);
	Widget_Show(pic_r2);
	Widget_Show(time_box);
	Widget_Show(wday_label);
	Widget_Show(date_label);
	Widget_Show(pic_btn);
	Widget_Show(pic_btn_line);

	UpdateTimeView(NULL);
}
Example #17
0
File: mora.c Project: 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);
}
Example #18
0
int main(int argc, char*argv[])
{
    int mode;
    LCUI_Widget *window, *text[2], *tb_username, *tb_password;
    LCUI_Widget *area, *login_btn;
    LCUI_Widget *fore_pb, *back_pb;

    LCUI_Init(argc, argv);
    /* 创建所需的部件 */
    window = Create_Widget("window");
    area = Create_Widget(NULL);
    tb_password = Create_Widget("text_box");
    tb_username = Create_Widget("text_box");
    text[0] = Create_Widget("label");
    text[1] = Create_Widget("label");
    fore_pb = Create_Widget("picture_box");
    back_pb = Create_Widget("picture_box");
    login_btn = Create_Widget("button");
    /* 设置界面上显示的文本 */
    Set_Window_Title_Text(window, "用户登录");
    Label_Text( text[0], "帐号:" );
    Label_Text( text[1], "密码:" );
    Set_Button_Text( login_btn, "登录" );
    /* 调整部件的尺寸 */
    Resize_Widget( login_btn, Size(50, 50) );
    Resize_Widget( window, Size(320, 240) );
    Resize_Widget( back_pb, Size(128, 128));
    Resize_Widget( fore_pb, Size(95,95));
    Resize_Widget( area, Size(225,50) );
    /* 设置这两个图片框内显示的图片 */
    Set_PictureBox_Size_Mode( back_pb, SIZE_MODE_STRETCH );
    Set_PictureBox_Size_Mode( fore_pb, SIZE_MODE_STRETCH );
    Set_PictureBox_Image_From_File( back_pb, "faceback.png" );
    Set_PictureBox_Image_From_File( fore_pb, "image.jpg" );

    /* 限制文本框内的字符总数为32个 */
    TextBox_Text_Set_MaxLength( tb_username, 32 );
    TextBox_Text_Set_MaxLength( tb_password, 32 );
    tb_password->resize( tb_password, Size(125, 22) );
    TextBox_Text_Set_PasswordChar( tb_password, L'●' );
    /* 限制文本框输入的字符 */
    mode = ONLY_0_TO_9 | ONLY_A_TO_Z | ONLY_a_TO_z | ONLY_UNDERLINE;
    TextBox_Text_Limit( tb_username, mode );
    tb_username->resize( tb_username, Size(125, 22) );
    /* 将部件添加至相应的容器中 */
    Widget_Container_Add( area, text[0] );
    Widget_Container_Add( area, text[1] );
    Widget_Container_Add( area, login_btn );
    Widget_Container_Add( back_pb, fore_pb );
    Widget_Container_Add( area, tb_username );
    Widget_Container_Add( area, tb_password );
    Window_Client_Area_Add( window, back_pb );
    Window_Client_Area_Add( window, area );
    /* 设置部件的布局 */
    area->set_align( area, ALIGN_MIDDLE_CENTER, Pos(0,60) );
    login_btn->set_align( login_btn, ALIGN_MIDDLE_RIGHT, Pos(0,0) );
    back_pb->set_align( fore_pb, ALIGN_MIDDLE_CENTER, Pos(-2,-2) );
    back_pb->set_align( back_pb, ALIGN_MIDDLE_CENTER, Pos(0,-35) );
    text[0]->set_align( text[0], ALIGN_MIDDLE_LEFT, Pos(0,-12) );
    text[1]->set_align( text[1], ALIGN_MIDDLE_LEFT, Pos(0,12) );
    tb_username->set_align( tb_username, ALIGN_MIDDLE_LEFT, Pos(35,-12) );
    tb_password->set_align( tb_password, ALIGN_MIDDLE_LEFT, Pos(35,12) );
    /* 设置边框 */
    Set_Widget_Border( fore_pb, RGB(120,120,120), Border(1,1,1,1) );
    /* 显示这些部件 */
    Show_Widget( back_pb );
    Show_Widget( fore_pb );
    Show_Widget( login_btn );
    Show_Widget( area );
    tb_password->show( tb_password );
    tb_username->show( tb_username );
    text[0]->show( text[0] );
    text[1]->show( text[1] );
    window->show( window );
    /* 进入主循环 */
    return LCUI_Main();
}
Example #19
0
File: clock.c Project: yydaor/LCUI
void update_clock(void *arg)
{
	time_t rawtime;
	struct tm * timeinfo;
	LCUI_Graph h_temp, m_temp, clock_bg, hour_pointer, minute_pointer;
	LCUI_Widget *widget;
	LCUI_Widget *bg, *hour, *minute; 
	int h_angle, m_angle;
	
	widget = (LCUI_Widget *)arg;
	/* 初始化图形数据结构 */
	Graph_Init(&clock_bg);
	Graph_Init(&minute_pointer);
	Graph_Init(&hour_pointer);
	Graph_Init(&h_temp);
	Graph_Init(&m_temp);
	/* 创建几个部件 */
	bg = Widget_New("picture_box");
	hour = Widget_New("picture_box");
	minute = Widget_New("picture_box");
	/* PictureBox部件居中显示图片 */
	PictureBox_SetSizeMode(bg, SIZE_MODE_CENTER);
	PictureBox_SetSizeMode(hour, SIZE_MODE_CENTER);
	PictureBox_SetSizeMode(minute, SIZE_MODE_CENTER);
	/* 载入图片,保存图形数据 */
	Load_Image("new_daytime_background.png", &clock_bg);
	Load_Image("new_daytime_hour.png", &hour_pointer);
	Load_Image("new_daytime_minute.png", &minute_pointer);
	/* 设定PictureBox部件显示的图形 */
	PictureBox_SetImage(bg, &clock_bg);
	PictureBox_SetImage(hour, &hour_pointer);
	PictureBox_SetImage(minute, &minute_pointer);
	/* 将这些部件添加至相应容器中 */
	Widget_Container_Add(bg, hour);
	Widget_Container_Add(bg, minute);
	/* 将部件添加至窗口客户区中 */
	Window_ClientArea_Add(widget, bg);
	/* 改变部件尺寸,使用固定的尺寸 */
	Widget_Resize(bg, Size(280, 280));
	Widget_Resize(hour, Size(120, 120));
	Widget_Resize(minute, Size(120, 120));
	/* 改变部件的布局方式,都是居中显示 */
	Widget_SetAlign(bg, ALIGN_MIDDLE_CENTER, Pos(0, 0));
	Widget_SetAlign(hour, ALIGN_MIDDLE_CENTER, Pos(0, 0));
	Widget_SetAlign(minute, ALIGN_MIDDLE_CENTER, Pos(0, 0));
	/* 显示 */
	Widget_Show(hour);
	Widget_Show(minute);
	Widget_Show(bg);
	
	while(1) {
	time ( &rawtime );
	timeinfo = localtime ( &rawtime ); /* 获取系统当前时间 */
	/* 计算时针分针的角度 */
	h_angle = 360*timeinfo->tm_hour / 12.0;
	m_angle = 360*timeinfo->tm_min / 60.0;
	h_angle += m_angle / 60;
	/* 根据这个角度来旋转图形 */
	Graph_Rotate(&hour_pointer, h_angle, &h_temp);
	Graph_Rotate(&minute_pointer, m_angle, &m_temp);
	/* 更改PictureBox部件显示的图形 */
	PictureBox_SetImage(hour, &h_temp);
	PictureBox_SetImage(minute, &m_temp);
	LCUI_Sleep(1);/* 暂停1秒 */
	}
	
	LCUIThread_Exit(NULL);
}
Example #20
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 );
}
Example #21
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 );
}
Example #22
0
/** 将部件添加至窗口客户区内 */
LCUI_API void Window_ClientArea_Add( LCUI_Widget *window, LCUI_Widget *w )
{
	LCUI_Window *wnd;
	wnd = (LCUI_Window*)Widget_GetPrivateData( window );
	Widget_Container_Add( wnd->client_area, w );
}