Beispiel #1
0
int main(int argc, char*argv[]) 
{
	LCUI_Init(argc, argv);
	
	window = Create_Widget("window");
	scrollbar = Create_Widget("scrollbar");
	label = Create_Widget("label");
	/* 设定窗口标题的文本 */
	Set_Window_Title_Text(window, "测试滚动条"); 
	/* 改变窗口的尺寸 */
	window->resize(window, Size(320, 240));
	Resize_Widget( scrollbar, Size(10, 100) );
	ScrollBar_Set_MaxSize( scrollbar, 400 );
	/* 设置部件布局 */
	Set_Widget_Align( label, ALIGN_MIDDLE_CENTER, Pos(-20,0) );
	Set_Widget_Align( scrollbar, ALIGN_MIDDLE_CENTER, Pos(0,0) );
	
	Label_Text( label, "0" );
	
	/* 将窗口客户区作为部件的容器添加进去 */
	Window_Client_Area_Add(window, label);
	Window_Client_Area_Add(window, scrollbar); 
	/* 将回调函数与滚动条部件连接 */
	ScrollBar_Connect( scrollbar, callback_func, NULL );
	/* 显示部件 */
	scrollbar->show(scrollbar);
	window->show(window); 
	label->show(label);
	return LCUI_Main(); /* 进入主循环 */
}
Beispiel #2
0
int main(int argc,char*argv[])
{ 
	/* 声明几个部件 */
	LCUI_Widget	*window, 
					*label,
					*logo,
					*img;
					
	int			 width, height; 
	/* 自定义默认字体文件位置 */
	//Set_Default_Font("msyh.ttf");
	/* 初始化LCUI */ 
	LCUI_Init(argc, argv);
	/* 创建一个LCUI程序窗口 */
	width  = 320;//Get_Screen_Width(); /* 窗口的宽度 */
	height = 240;//Get_Screen_Height();; /* 窗口的高度 */
	
	/* 创建部件 */
	window		= Create_Widget("window");
	label		= Create_Widget("label");
	logo		= Create_Widget("picture_box");
	img			= Create_Widget("picture_box");
	
	//Set_Widget_Border_Style(window, BORDER_STYLE_NONE);
	Resize_Widget(img, Size(180, 180));
	Resize_Widget(logo, Size(128,128));
	Resize_Widget(window, Size(width, height));
	 
	Set_Window_Title_Text(window, "LCUI");
	
	Set_Widget_Backcolor(window, RGB(94,200,255));
	Set_PictureBox_Size_Mode(logo, SIZE_MODE_CENTER);
	Set_PictureBox_Image_From_File(logo, "logo_128x128.png"); 
	
	Set_Label_Text(label, "LCUI 正在载入...");
	Set_Label_Font(label, 15, NULL);
	Set_Widget_Align(logo, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Set_Widget_Align(label, ALIGN_MIDDLE_CENTER, Pos(0, +70));
    /* 将这三个部件放入窗口客户区中 */
	Window_Client_Area_Add(window, label);
	Window_Client_Area_Add(window, img); 
	Window_Client_Area_Add(window, logo);
	
	pthread_t t;
    LCUI_Thread_Create(&t, NULL, change_graph, (void*)img); 
	/* 显示部件以及窗口 */
	Show_Widget(label);
	Show_Widget(logo);
	Show_Widget(window); 
	LCUI_Main(); /* 进入主循环 */
	return 0;
}
Beispiel #3
0
int main(int argc,char*argv[])
/* 主函数,程序的入口 */
{ 
	LCUI_Widget	*window, 
					*label,
					*pic_box,
					*fore_box; /* 使用指向widget部件的指针 */
					
	int			 width, height; 
	/* 自定义默认字体文件位置 */
	//Set_Default_Font("msyh.ttf");
	/* 初始化LCUI */ 
	LCUI_Init(argc, argv);
	/* 创建一个LCUI程序窗口 */
	width  = 320; /* 窗口的宽度 */
	height = 240; /* 窗口的高度 */
	/* 创建部件 */
	window		= Create_Widget("window");
	label		= Create_Widget("label");
	pic_box		= Create_Widget("picture_box");
	fore_box	= Create_Widget("picture_box");
	 
	Resize_Widget(fore_box, Size(190, 190));
	Resize_Widget(pic_box, Size(135,135));
	Resize_Widget(window, Size(width, height));
	 
	Set_Window_Title_Text(window, "头像");
	
	LCUI_Graph pic;
	Graph_Init(&pic); 
	Set_PictureBox_Size_Mode(pic_box, SIZE_MODE_STRETCH); 
	Set_PictureBox_Image_From_File(pic_box, "image.jpg");
	Set_PictureBox_Image_From_File(fore_box, "border.png");
	 
	Set_Label_Text(label, "蛋疼的头像");
	Set_Label_Font(label, 16, NULL);
	
	Set_Widget_Align(pic_box, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Set_Widget_Align(fore_box, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Set_Widget_Align(label, ALIGN_MIDDLE_CENTER, Pos(0, +75));
	
	Window_Client_Area_Add(window, label);
	Window_Client_Area_Add(window, pic_box); 
	Window_Client_Area_Add(window, fore_box);
	
	Show_Widget(label);
	Show_Widget(pic_box);
	Show_Widget(fore_box);
	Show_Widget(window); 
	return LCUI_Main(); 
}
Beispiel #4
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();
}
Beispiel #5
0
int main(int argc, char*argv[])
{
    FILE *fp;
    char buff[256];
    LCUI_Widget *window, *textbox;

    LCUI_Init(argc, argv);

    window  = Create_Widget("window");
    textbox = Create_Widget("text_box");

    Set_Window_Title_Text(window, "测试文本框部件");
    window->resize( window, Size(320, 240) );
    Window_Client_Area_Add( window, textbox );
    /* 启用多行文本显示 */
    TextBox_Multiline( textbox, TRUE );
    textbox->set_align( textbox, ALIGN_MIDDLE_CENTER, Pos(0,0) );
    /* 打开README.md文件,并将内容读取至文本框上显示 */
    fp = fopen("../README.md", "r");
    if( fp ) {
        while(fgets( buff, sizeof(buff), fp )) {
            TextBox_Text_Append( textbox, buff );
        }
        fclose( fp );
    }
    Set_Widget_Dock( textbox, DOCK_TYPE_FILL );
    textbox->show(textbox);
    window->show(window);
    return LCUI_Main();
}
Beispiel #6
0
int LCUIWidget::_Window::addToClientArea( LCUIWidget &object )
{
	if( parent->isError() ) {
		return WIDGET_IS_NULL;
	}
	Window_Client_Area_Add(parent->getWidget(), object.getWidget());
	return 0;
}
Beispiel #7
0
int main(int argc, char*argv[])
/* 主函数,程序的入口 */
{
    LCUI_Init(argc, argv);
    LCUI_Widget *w1, *w2, *w3;
    /* 创建部件 */
    w1  = Create_Widget("window");
    w2  = Create_Widget("window");
    w3  = Create_Widget("window");
    /* 改变窗口的尺寸 */
    Resize_Widget(w1, Size(320, 240));
    Resize_Widget(w2, Size(200, 140));
    Resize_Widget(w3, Size(120, 100));
    Set_Window_Title_Text(w1, "窗口1");
    Set_Window_Title_Text(w2, "窗口2");
    Set_Window_Title_Text(w3, "窗口3");
    Window_Client_Area_Add(w2, w3);
    Window_Client_Area_Add(w1, w2);
    Show_Widget(w1); 
    Show_Widget(w2); 
    Show_Widget(w3); 
    LCUI_Main(); /* 进入主循环 */ 
    return 0;
}
Beispiel #8
0
int main(int argc, char*argv[]) 
{
	/* 目前传递给LCUI_Init()函数的参数没用,以后会完善,比如指定字体路径,是否显示鼠标游标等 */
    LCUI_Init(argc, argv);
    LCUI_Widget *window, *label;
    LCUI_Graph pic;
    /* 初始化结构体 */
    Graph_Init(&pic);
    /* 载入库中自带的图形数据,这个图形是18x18尺寸的LCUI的图标 */
    Load_Graph_Icon_LCUI_18x18(&pic);
    /* 创建部件 */
    window  = Create_Widget("window");
    label   = Create_Widget("label");
    
    /* 设定窗口标题的文本 */
    Set_Window_Title_Text(window, "测试窗口");
    /* 设定窗口标题的图标 */
    Set_Window_Title_Icon(window, &pic);
    /* 改变窗口的尺寸 */
    window->resize(window, Size(320, 240));
    /* 将窗口客户区作为label部件的容器添加进去 */
    Window_Client_Area_Add(window, label);
    /* 居中显示 */
    label->set_align(label, ALIGN_MIDDLE_CENTER, Pos(0,0));
    /* 
     * 设定label部件显示的文本
     * <color=R,G,B>文字</color> 表示的是:“文字”将使用自定义颜色 
     * Set_Label_Text函数使用方法和sprintf函数基本一样,支持控制符
     **/
    Set_Label_Text(label, 
                "Hello,World!\n"
                "<color=255,0,0>世</color>"
                "<color=100,155,0>界</color>"
                "<color=0,0,0>,</color>"
                "<color=0,255,0>你</color>"
                "<color=0,100,155>好</color>"
                "<color=0,0,255>!</color>\n"); 
    
    /* 
     * 改变label部件的字体大小,单位为pixel(像素),不是pt(点数)
     * 第三个参数是自定义使用的字体文件,我设定为NULL,表示不使用。
     **/
    Set_Label_Font(label, 24, NULL);
    /* 显示部件 */
    label->show(label);
    window->show(window);
    return LCUI_Main(); /* 进入主循环 */
}
Beispiel #9
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();
}