コード例 #1
0
ファイル: test_widget_2.c プロジェクト: yydaor/LCUI
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();
}
コード例 #2
0
ファイル: window.c プロジェクト: gateslu/LCUI
static void 
Window_TitleBar_Init(LCUI_Widget *titlebar)
/* 功能:初始化窗口标题栏 */
{
	LCUI_Graph img;
	LCUI_TitleBar *t;
	
	Graph_Init(&img);
	t = Widget_NewPrivData(titlebar, sizeof(LCUI_TitleBar));
	t->icon_box = Widget_New("picture_box");
	t->label = Widget_New("label");
	/* 窗口图标和标题文字不可获得焦点,并忽略鼠标点击 */
	t->label->focus = FALSE;
	t->icon_box->focus = FALSE;
	Widget_SetClickableAlpha( t->label, 0, 1 );
	Widget_SetClickableAlpha( t->icon_box, 0, 1 );
	
	Widget_Container_Add(titlebar, t->icon_box);
	Widget_Container_Add(titlebar, t->label);
	
	Widget_Resize(t->icon_box, Size(18,18));
	PictureBox_SetSizeMode(t->icon_box, SIZE_MODE_CENTER);
	
	Widget_Show(t->icon_box);
	Widget_Show(t->label);
	
	Widget_SetAlign(t->icon_box, ALIGN_MIDDLE_LEFT, Pos(0,0));
	Widget_SetAlign(t->label, ALIGN_MIDDLE_LEFT, Pos(2,-2));
}
コード例 #3
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 );
}
コード例 #4
0
ファイル: test_radiobtn.c プロジェクト: rokite/LCUI
int main(int argc, char **argv)
{
    int i;
    LCUI_Init(0,0,0);
    /* 创建部件 */
    window = Widget_New("window");
    age_label = Widget_New("label");
    button = Button_New("提交");
    age_rb[0] = RadioButton_New("A. 15岁以下");
    age_rb[1] = RadioButton_New("B. 15-20岁");
    age_rb[2] = RadioButton_New("C. 21-25岁");
    age_rb[3] = RadioButton_New("D. 26-30岁");
    age_rb[4] = RadioButton_New("E. 31-40岁");
    age_rb[5] = RadioButton_New("F. 40岁以上");
    /* 设定窗口标题的文本 */
    Window_SetTitleText(window, "测试复选框部件");
    /* 改变尺寸 */
    Widget_Resize(window, Size(320, 240));
    Widget_SetAutoSize( button, FALSE, 0 );
    Widget_Resize(button, Size(60, 25));
    /* 将窗口客户区作为这些部件的容器 */
    Window_ClientArea_Add(window, age_label);
    Window_ClientArea_Add(window, button);
    for(i=0; i<6; i++) {
        Window_ClientArea_Add(window, age_rb[i]);
    }
    /* 调整部件的布局*/
    Widget_SetAlign(age_label, ALIGN_MIDDLE_CENTER, Pos(0,-40));
    Widget_SetAlign(button, ALIGN_MIDDLE_CENTER, Pos(0,60));
    Widget_SetAlign(age_rb[0], ALIGN_MIDDLE_LEFT, Pos(5,-20));
    Widget_SetAlign(age_rb[1], ALIGN_MIDDLE_LEFT, Pos(100,-20));
    Widget_SetAlign(age_rb[2], ALIGN_MIDDLE_LEFT, Pos(200,-20));
    Widget_SetAlign(age_rb[3], ALIGN_MIDDLE_LEFT, Pos(5,0));
    Widget_SetAlign(age_rb[4], ALIGN_MIDDLE_LEFT, Pos(100,0));
    Widget_SetAlign(age_rb[5], ALIGN_MIDDLE_LEFT, Pos(200,0));
    Label_Text(age_label, "你的年龄段是?");

    RadioButton_CreateMutex(age_rb[0], age_rb[1]);
    RadioButton_CreateMutex(age_rb[0], age_rb[2]);
    RadioButton_CreateMutex(age_rb[0], age_rb[3]);
    RadioButton_CreateMutex(age_rb[0], age_rb[4]);
    RadioButton_CreateMutex(age_rb[0], age_rb[5]);

    /* 显示部件 */
    Widget_Show(age_label);
    Widget_Show(button);
    Widget_Show(age_rb[0]);
    for(i=0; i<6; ++i) {
        Widget_Show(age_rb[i]);
    }
    Widget_Show(window);
    Widget_ConnectEvent( button, EVENT_CLICKED, view_result );
    Widget_ConnectEvent( Window_GetCloseButton(window), EVENT_CLICKED, destroy );
    LCUI_Main();
    return 0;
}
コード例 #5
0
ファイル: window.c プロジェクト: gateslu/LCUI
/* 初始化window部件相关数据 */
static void 
Window_Init( LCUI_Widget *win_p )
{
	LCUI_Widget *titlebar;
	LCUI_Widget *client_area;
	LCUI_Widget *btn_close;
	LCUI_Window *win;
	static LCUI_Graph btn_bg; 
	
	win = (LCUI_Window*)Widget_NewPrivData(win_p, sizeof(LCUI_Window));
	
	titlebar = Widget_New("titlebar"); 
	client_area = Widget_New(NULL); 
	btn_close = Widget_New("button"); 
	titlebar->focus = FALSE;
	Widget_SetFocus( client_area );

	Graph_Init( &btn_bg );
	/* 载入按钮背景 */
	Window_GetCloseButtonBG( &btn_bg );
	/* 显示在左上角 */
	Widget_SetAlign(btn_close, ALIGN_TOP_RIGHT, Pos(0, 0)); 
	/* 将尺寸改成和图片一样 */
	Widget_SetAutoSize( btn_close, FALSE, 0 );
	Widget_Resize(btn_close, Size(44, 20));
	Widget_SetBackgroundImage( btn_close, &btn_bg );
	Widget_SetBackgroundLayout( btn_close, LAYOUT_CENTER );
	/* 没有背景图就填充背景色 */
	Widget_SetBackgroundTransparent( win_p, FALSE );
	/* 部件的风格ID */
	Widget_SetStyleID( win_p, WINDOW_STYLE_PURE_BLUE );
	Widget_SetStyleID( btn_close, BUTTON_STYLE_FLAT );
	/* 保存部件指针 */
	win->client_area = client_area;
	win->titlebar = titlebar;
	win->btn_close = btn_close;
	/* 放入至容器 */
	Widget_Container_Add(titlebar, btn_close);
	Widget_Container_Add(win_p, titlebar);
	Widget_Container_Add(win_p, client_area);
	/* 窗口初始尺寸 */
	Widget_Resize(win_p, Size(100, 50));
	Widget_Show(btn_close);
	/* 关联拖动事件,让鼠标能够拖动标题栏并使窗口移动 */
	Widget_Event_Connect(titlebar, EVENT_DRAG, Window_ExecMove );
	/* 
	 * 由于需要在窗口获得/失去焦点时进行相关处理,因此需要将回调函数 与部件
	 * 的FOCUS_IN和FOCUS_OUT事件 进行关联
	 * */
	Widget_Event_Connect( win_p, EVENT_FOCUSOUT, Window_FocusOut );
	Widget_Event_Connect( win_p, EVENT_FOCUSIN, Window_FocusIn );
	/* 设置窗口部件的初始位置 */
	Widget_SetAlign( win_p, ALIGN_MIDDLE_CENTER, Pos(0,0) );
}
コード例 #6
0
ファイル: test_checkbox.c プロジェクト: rokite/LCUI
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();
}
コード例 #7
0
ファイル: test_window.c プロジェクト: yydaor/LCUI
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(); 
}
コード例 #8
0
ファイル: test_videomode.c プロジェクト: FrankHB/LCUI
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(); 
}
コード例 #9
0
ファイル: gamewnd_license.c プロジェクト: iomato/PunchAndKick
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 );
}
コード例 #10
0
ファイル: screenlock.c プロジェクト: FrankHB/LCUI
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();
}
コード例 #11
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 );
}
コード例 #12
0
ファイル: button.c プロジェクト: 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 );
}
コード例 #13
0
ファイル: test_progressbar.c プロジェクト: fshunj/LCUI
/* 动态改变进度条的数据 */
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);
}
コード例 #14
0
ファイル: checkbox.c プロジェクト: fshunj/LCUI
/* 创建一个带文本内容的复选框 */
LCUI_API LCUI_Widget*
CheckBox_New( const char *text )
{
	LCUI_Widget *widget;
	widget = Widget_New("check_box");
	CheckBox_Text(widget, text);
	return widget;
}
コード例 #15
0
ファイル: button.c プロジェクト: yydaor/LCUI
/* 创建一个带文本内容的按钮 */
LCUI_API LCUI_Widget*
Button_New( const char *text )
{
	LCUI_Widget *widget;
	widget = Widget_New("button");
	Button_Text(widget, text);
	return widget;
}
コード例 #16
0
ファイル: radiobutton.c プロジェクト: hbao/LCUI
/* 创建一个带文本内容的单选框 */
LCUI_API LCUI_Widget*
RadioButton_New( const char *text )
{
	LCUI_Widget widget;
	widget = Widget_New("radio_button");
	RadioButton_Text(widget, text);
	return widget;
}
コード例 #17
0
ファイル: test_viewimage.c プロジェクト: yydaor/LCUI
int main( int argc, char*argv[] )
{ 
	LCUI_Graph pic;
	int width = 320, height = 240;
	LCUI_Widget *window, *label, *pic_box, *fore_box;
	
	LCUI_Init();
	Graph_Init(&pic); 
	
	window	 = Widget_New("window");
	label	 = Widget_New("label");
	pic_box	 = Widget_New("picture_box");
	fore_box = Widget_New("picture_box");
	 
	Widget_Resize(fore_box, Size(190, 190));
	Widget_Resize(pic_box, Size(135,135));
	Widget_Resize(window, Size(width, height));
	 
	Window_SetTitleText(window, "头像");
	
	PictureBox_SetSizeMode(pic_box, SIZE_MODE_STRETCH); 
	PictureBox_SetImageFile(pic_box, "image.jpg");
	PictureBox_SetImageFile(fore_box, "border.png");
	 
	Label_Text(label, "蛋疼的头像");
	
	Widget_SetAlign(pic_box, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Widget_SetAlign(fore_box, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Widget_SetAlign(label, ALIGN_MIDDLE_CENTER, Pos(0, +75));
	
	Window_ClientArea_Add(window, label);
	Window_ClientArea_Add(window, pic_box); 
	Window_ClientArea_Add(window, fore_box);
	
	Widget_Event_Connect( Window_GetCloseButton(window), EVENT_CLICKED, destroy );
	
	Widget_Show(label);
	Widget_Show(pic_box);
	Widget_Show(fore_box);
	Widget_Show(window); 
	return LCUI_Main(); 
}
コード例 #18
0
ファイル: window.c プロジェクト: gateslu/LCUI
/* 新建一个窗口 */
LCUI_API LCUI_Widget*
Window_New( const char *title, LCUI_Graph *icon, LCUI_Size size )
{
	LCUI_Widget *wnd;
	wnd = Widget_New("window");
	if( wnd == NULL ) {
		return NULL;
	}
	Window_SetTitleText( wnd, title );
	Window_SetTitleIcon( wnd, icon );
	Widget_Resize( wnd, size );
	return wnd;
}
コード例 #19
0
ファイル: test_progressbar.c プロジェクト: fshunj/LCUI
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();
}
コード例 #20
0
ファイル: test_widget_1.c プロジェクト: yydaor/LCUI
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();
}
コード例 #21
0
ファイル: clock.c プロジェクト: yydaor/LCUI
int main(void)
{
	LCUI_Widget *window;
	LCUI_Thread t;
	
	setenv( "LCUI_FONTFILE", "../../fonts/msyh.ttf", FALSE );
	LCUI_Init();
	window = Widget_New("window");
	Widget_Resize(window, Size(320, 320));
	Window_SetTitleText(window, "时钟");
	LCUIThread_Create(&t, update_clock, (void*)window); 
	Widget_Event_Connect(Window_GetCloseButton(window), EVENT_CLICKED, destroy);
	Widget_Show(window); 
	return LCUI_Main();
}
コード例 #22
0
ファイル: test_widget_1.c プロジェクト: yydaor/LCUI
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);
}
コード例 #23
0
ファイル: mora.c プロジェクト: yydaor/LCUI
static void
widgets_structure( void )
{
	/* 创建一个窗口 */
	window = Widget_New("window"); 
	
	/* 创建label部件,用于显示文字 */ 
	label = Widget_New("label");
	l_vs = Widget_New("label");
	/* 创建几个按钮 */
	btn_b = Button_New( TEXT_CLOTH ); 
	btn_s = Button_New( TEXT_STONE );
	btn_j = Button_New( TEXT_KNIFE );
	btn_next = Button_New( NEXT_ONE );
	btn_area = Widget_New( NULL );
	cpu_pic_box = Widget_New("picture_box");
	me_pic_box = Widget_New("picture_box");
	
}
コード例 #24
0
ファイル: checkbox.c プロジェクト: fshunj/LCUI
/* 初始化复选框部件的数据 */
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 );
}
コード例 #25
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 );
}
コード例 #26
0
ファイル: clock.c プロジェクト: 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);
}
コード例 #27
0
ファイル: radiobutton.c プロジェクト: hbao/LCUI
/* 初始化单选框部件的数据 */
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);
}
コード例 #28
0
ファイル: screenlock.c プロジェクト: FrankHB/LCUI
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);
}
コード例 #29
0
ファイル: window.c プロジェクト: FrankHB/LCUI
/** 初始化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 );
}
コード例 #30
0
ファイル: test_messagebox.c プロジェクト: yydaor/LCUI
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();
}