Ejemplo n.º 1
0
static void
RadioButton_Click( LCUI_Widget widget, LCUI_WidgetEvent *unused )
{ 
	if(RadioButton_IsOff(widget)) {
		RadioButton_SetOn(widget); 
	}
}
Ejemplo n.º 2
0
int main(void) 
{
	int i; 
	char text[5][10] = { "蓝色","绿色", "红色", "橙色", "紫色" };
	LCUI_Pos offset_pos[5]={{-120,0},{-60,0},{0,0},{60,0},{120,0}};	

	LCUI_Init();
	
	main_window = Widget_New( "window" ); 
	btn_ok = Widget_New( "button" );
	label = Widget_New( "label" );
	/* 设置窗口的尺寸以及标题栏文本 */
	Widget_Resize( main_window, Size(320, 240) ); 
	Window_SetTitleText( main_window, "测试窗口的风格切换" ); 
	/* 创建5个单选框部件 */
	for(i=0; i<5; ++i) {
		rdbtn[i] = Widget_New( "radio_button" );
		Window_ClientArea_Add( main_window, rdbtn[i] );
		Widget_SetAlign( rdbtn[i], ALIGN_MIDDLE_CENTER, offset_pos[i] );
		RadioButton_Text( rdbtn[i], text[i] );
		Widget_Show( rdbtn[i] );
	}
	/* 为单选框建立互斥关系 */
	RadioButton_CreateMutex(rdbtn[0], rdbtn[1]);
	RadioButton_CreateMutex(rdbtn[0], rdbtn[2]);
	RadioButton_CreateMutex(rdbtn[0], rdbtn[3]);
	RadioButton_CreateMutex(rdbtn[0], rdbtn[4]);
	RadioButton_SetOn( rdbtn[0] );
	/* 禁用按钮部件的自动尺寸调整 */
	Widget_SetAutoSize( btn_ok, FALSE, 0 );
	Widget_Resize( btn_ok, Size(100, 30) );
	/* 将部件加入窗口客户区 */
	Window_ClientArea_Add( main_window, btn_ok );
	Window_ClientArea_Add( main_window, label );
	/* 设置部件的布局 */
	Widget_SetAlign( btn_ok, ALIGN_MIDDLE_CENTER, Pos(0,50) );
	Widget_SetAlign( label, ALIGN_MIDDLE_CENTER, Pos(0,-50) ); 
	/* 设置部件的文本 */
	Button_Text( btn_ok, "应用" ); 
	Label_Text( label, "选择窗口配色:" );
	/* 为按钮的点击事件关联回调函数 */
	Widget_Event_Connect( btn_ok, EVENT_CLICKED, switch_style );
	Widget_Event_Connect( Window_GetCloseButton(main_window), EVENT_CLICKED, destroy );
	/* 显示部件 */
	Widget_Show( btn_ok );
	Widget_Show( label );
	Widget_Show( main_window );
	/* 进入主循环 */
	return LCUI_Main(); 
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
	int i; 
	LCUI_Pos offset;
	wchar_t text[3][40] = { L"默认模式",L"全屏模式,800x600 分辨率", L"窗口模式,800x600 窗口"};
	LCUI_Init(0,0,0);
	
	main_window = Widget_New( "window" ); 
	btn_ok = Widget_New( "button" );
	label = Widget_New( "label" );
	/* 设置窗口的尺寸以及标题栏文本 */
	Widget_Resize( main_window, Size(320, 240) ); 
	Window_SetTitleTextW( main_window, L"测试视频模式的切换" ); 
	offset.x = 20;
	/* 创建3个单选框部件 */
	for(offset.y=-22,i=0; i<3; ++i,offset.y+=22) {
		rdbtn[i] = Widget_New( "radio_button" );
		Window_ClientArea_Add( main_window, rdbtn[i] );
		Widget_SetAlign( rdbtn[i], ALIGN_MIDDLE_LEFT, offset );
		RadioButton_TextW( rdbtn[i], text[i] );
		Widget_Show( rdbtn[i] );
	}
	/* 为单选框建立互斥关系 */
	RadioButton_CreateMutex(rdbtn[0], rdbtn[1]);
	RadioButton_CreateMutex(rdbtn[0], rdbtn[2]);
	RadioButton_SetOn( rdbtn[0] );
	/* 禁用按钮部件的自动尺寸调整 */
	Widget_SetAutoSize( btn_ok, FALSE, 0 );
	Widget_Resize( btn_ok, Size(100, 30) );
	/* 将部件加入窗口客户区 */
	Window_ClientArea_Add( main_window, btn_ok );
	Window_ClientArea_Add( main_window, label );
	/* 设置部件的布局 */
	Widget_SetAlign( btn_ok, ALIGN_MIDDLE_CENTER, Pos(0,70) );
	Widget_SetAlign( label, ALIGN_MIDDLE_CENTER, Pos(0,-50) ); 
	/* 设置部件的文本 */
	Button_TextW( btn_ok, L"应用" ); 
	Label_TextW( label, L"选择视频模式:" );
	/* 为按钮的点击事件关联回调函数 */
	Widget_ConnectEvent( btn_ok, EVENT_CLICKED, switch_style );
	Widget_ConnectEvent( Window_GetCloseButton(main_window), EVENT_CLICKED, destroy );
	/* 显示部件 */
	Widget_Show( btn_ok );
	Widget_Show( label );
	Widget_Show( main_window );
	/* 进入主循环 */
	return LCUI_Main(); 
}
Ejemplo n.º 4
0
int main(void)
{
	int  i, x, y = 3;
	
	LCUI_Init();
	
	window = Window_New( "测试MessageBox", NULL, Size(320,240) );
	label_btn = Widget_New( "label" );
	label_icon = Widget_New( "label" );
	btn = Widget_New( "button" );
	
	Window_ClientArea_Add( window, label_btn );
	Label_Text( label_btn, "请选择按钮类型:" );
	Widget_Move( label_btn, Pos(5,y) );
	Widget_Show( label_btn );
	
	for(i=0; i<6; ++i) {
		rb_btn[i] = RadioButton_New( rb_btn_text[i] );
		if( i>0 ) {
			RadioButton_CreateMutex( rb_btn[0], rb_btn[i] );
		} else {
			RadioButton_SetOn( rb_btn[0] );
		}
		Window_ClientArea_Add( window, rb_btn[i] );
		y += 16;
		Widget_Move( rb_btn[i], Pos(5,y) );
		Widget_Show( rb_btn[i] );
	}
	
	y += 16;
	Window_ClientArea_Add( window, label_icon );
	Label_Text( label_icon, "请选择图标类型:" );
	Widget_Move( label_icon, Pos(5,y) );
	Widget_Show( label_icon );
	
	for(i=0; i<5; ++i) {
		rb_icon[i] = RadioButton_New( rb_icon_text[i] );
		if( i>0 ) {
			RadioButton_CreateMutex( rb_icon[0], rb_icon[i] );
		} else {
			RadioButton_SetOn( rb_icon[0] );
		}
		Window_ClientArea_Add( window, rb_icon[i] );
		/* 计算当前单选框的坐标 */
		if(i%2 == 0) {
			y += 16;
			x = 5;
		} else {
			x = 150;
		}
		Widget_Move( rb_icon[i], Pos(x,y) );
		Widget_Show( rb_icon[i] );
	}
	
	Button_Text( btn, "显示MessageBox" );
	Widget_SetAlign( btn, ALIGN_BOTTOM_CENTER, Pos(0,-3) );
	Widget_Resize( btn, Size(80, 20) );
	Window_ClientArea_Add( window, btn );
	Widget_Show( btn );
	
	Widget_Event_Connect( btn, EVENT_CLICKED, show_msgbox );
	Widget_Event_Connect( Window_GetCloseButton(window), EVENT_CLICKED, program_quit );
	Widget_Show( window );
	return LCUI_Main();
}