Beispiel #1
0
static void ProgressBar_Init(LCUI_Widget *widget)
/* 功能:初始化进度条的数据结构体 */
{
	LCUI_ProgressBar *pb = (LCUI_ProgressBar*)
				Widget_Create_PrivData
				(widget, sizeof(LCUI_ProgressBar));
	pb->thread = 0;
	Graph_Init(&pb->fore_graph); 
	Graph_Init(&pb->flash_image);
	pb->img_move_speed = 200;
	pb->sleep_time = 100000;
	pb->max_value = 1;
	pb->value = 0;
	
	LCUI_Widget *f_pb, *img_pb;
	f_pb = Create_Widget("picture_box"); 
	img_pb = Create_Widget("picture_box");
	/* 以自己为容器,将这些部件放进去 */
	Widget_Container_Add(f_pb, img_pb);
	Widget_Container_Add(widget, f_pb); 
	/* 没有背景图时就填充背景色 */
	Set_Widget_BG_Mode(widget, BG_MODE_FILL_BACKCOLOR);
	Set_Widget_Border(widget, RGB(50,50,50), Border(1,1,1,1));
	
	Set_Widget_Style(widget, "classic"); /* 进度条为经典风格 */
	
	Set_PictureBox_Size_Mode(f_pb, SIZE_MODE_STRETCH); 
	
	Show_Widget(f_pb); 
	Show_Widget(img_pb);
	
	pb->fore_pic_box = f_pb; 
	pb->img_pic_box = img_pb;
}
Beispiel #2
0
static void Window_TitleBar_Init(LCUI_Widget *titlebar)
/* 功能:初始化窗口标题栏 */
{
    LCUI_Graph img;
    LCUI_TitleBar *t;

    Graph_Init(&img);
    t = Widget_Create_PrivData(titlebar, sizeof(LCUI_TitleBar));
    t->icon_box = Create_Widget("picture_box");
    t->label = Create_Widget("label");

    Widget_Container_Add(titlebar, t->icon_box);
    Widget_Container_Add(titlebar, t->label);

    Resize_Widget(t->icon_box, Size(18,18));
    Set_PictureBox_Size_Mode(t->icon_box, SIZE_MODE_CENTER);

    Show_Widget(t->icon_box);
    Show_Widget(t->label);

    Set_Widget_Align(t->icon_box, ALIGN_MIDDLE_LEFT, Pos(0,0));
    Set_Widget_Align(t->label, ALIGN_MIDDLE_LEFT, Pos(2,-2));
    Load_Graph_Default_TitleBar_BG(&img);
    Set_Widget_Background_Image(titlebar, &img, LAYOUT_STRETCH);
}
Beispiel #3
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 #4
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 #5
0
void *change_graph(void *arg)
/* 功能:改变显示的图形 */
{
	LCUI_Widget *widget = (LCUI_Widget *)arg;
	int i;
	LCUI_Graph frame, temp;
	Graph_Init(&frame);/* 初始化 */
	Load_Image("ring.png", &frame);/* 载入之 */  
	/* 居中显示图形 */
	Set_Widget_Align(widget, ALIGN_MIDDLE_CENTER, Pos(0, -20));
	Set_PictureBox_Size_Mode(widget, SIZE_MODE_CENTER);
	Show_Widget(widget);
	while(1)
	{
		Set_PictureBox_Image_From_Graph(widget, &frame);
		for(i=10; i<=360; i+=10)
		{
			Rotate_Graph(&frame, i, &temp);
			Set_PictureBox_Image_From_Graph(widget, &temp);
			usleep(20000);
		}
	}
	LCUI_Thread_Exit(NULL);
}
Beispiel #6
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();
}