Beispiel #1
0
int main( int argc, char **argv )
{
    int i;

    LCUI_Init(0,0,0);
    /* 创建部件 */
    window  = Widget_New("window");
    label   = Widget_New("label");
    button	= Widget_New("button");
    for(i=0; i<5; ++i) {
        checkbox[i] = Widget_New("check_box");
    }
    CheckBox_TextW( checkbox[0], L"编程" );
    CheckBox_TextW( checkbox[1], L"电影" );
    CheckBox_TextW( checkbox[2], L"动漫" );
    CheckBox_TextW( checkbox[3], L"音乐" );
    CheckBox_TextW( checkbox[4], L"睡觉" );

    Button_TextW( button, L"提交" );
    Window_SetTitleTextW( window, L"测试复选框部件") ;
    window->resize(window, Size(320, 240));
    /* 禁用按钮部件的自动尺寸调整,因为要自定义尺寸 */
    Widget_SetAutoSize( button, FALSE, 0 );
    Widget_Resize(button, Size(60, 25));
    /* 将窗口客户区作为这些部件的容器 */
    Window_ClientArea_Add(window, label);
    Window_ClientArea_Add(window, button);
    for(i=0; i<5; i++) {
        Window_ClientArea_Add(window, checkbox[i]);
    }
    /* 调整部件的布局*/
    Widget_SetAlign(label, ALIGN_MIDDLE_CENTER, Pos(0,-20));
    Widget_SetAlign(button, ALIGN_MIDDLE_CENTER, Pos(0,60));
    Widget_SetAlign(checkbox[0], ALIGN_MIDDLE_CENTER, Pos(-120 ,5));
    Widget_SetAlign(checkbox[1], ALIGN_MIDDLE_CENTER, Pos(-60 ,5));
    Widget_SetAlign(checkbox[2], ALIGN_MIDDLE_CENTER, Pos(0 ,5));
    Widget_SetAlign(checkbox[3], ALIGN_MIDDLE_CENTER, Pos(60 ,5));
    Widget_SetAlign(checkbox[4], ALIGN_MIDDLE_CENTER, Pos(120 ,5));

    Label_TextW(label, L"你都有哪些兴趣爱好?\n");
    /* 显示部件 */
    Widget_Show(label);
    Widget_Show(button);
    for(i=0; i<5; ++i) {
        Widget_Show(checkbox[i]);
    }
    Widget_Show(window);
    /* 为按钮部件关联点击事件,被关联的函数是view_result,它会在点击按钮后被调用 */
    Widget_ConnectEvent( button, EVENT_CLICKED, view_result );
    Widget_ConnectEvent( Window_GetCloseButton(window), EVENT_CLICKED, destroy );
    return LCUI_Main();
}
Beispiel #2
0
int main( int argc, char **argv )
{
	int i;
	wchar_t text[5][10] = { L"蓝色", L"绿色", L"红色", L"橙色", L"紫色" };
	LCUI_Pos offset_pos[5]={{-120,0},{-60,0},{0,0},{60,0},{120,0}};

	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"测试窗口的风格切换" );
	/* 创建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_TextW( 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_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();
}
Beispiel #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(); 
}
Beispiel #4
0
int main(int argc, char **argv)
{
	LCUI_Thread thread;
	LCUI_Widget *window, *progbar;
	
	LCUI_Init(800,600,0);
	
	window = Widget_New("window");
	progbar = Widget_New("progress_bar");

	Window_SetTitleTextW(window, L"测试进度条部件");
	Widget_Resize(window, Size(320, 240));
	Window_ClientArea_Add(window, progbar);
	Widget_SetAlign(progbar, ALIGN_MIDDLE_CENTER, Pos(0,0)); 
	Widget_Resize(progbar, Size(300, 25));

	LCUIThread_Create(&thread, change_progress, (void*)progbar);
	Widget_Event_Connect( Window_GetCloseButton(window), EVENT_CLICKED, destroy );

	Widget_Show(progbar);
	Widget_Show(window);
	return LCUI_Main();
}