Ejemplo n.º 1
0
int test_thread( void )
{
	int ret = 0;
	TestWorkerRec worker;

	TestWorker_Init( &worker );
	LCUIThread_Create( &worker.thread, TestWorker_Thread, &worker );
	LCUI_Sleep( 1 );
	TestWorker_Send( &worker, "hello" );
	LCUI_MSleep( 200 );
	TestWorker_Send( &worker, "world" );
	LCUI_Sleep( 1 );
	TestWorker_Send( &worker, "this" );
	LCUI_MSleep( 500 );
	TestWorker_Send( &worker, "is" );
	LCUI_Sleep( 1 );
	TestWorker_Send( &worker, "test" );
	LCUI_MSleep( 100 );
	TestWorker_Send( &worker, "bye!" );
	LCUI_Sleep( 1 );
	TestWorker_Destroy( &worker );
	CHECK( worker.data_count == 7 );
	return ret;
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
Archivo: clock.c Proyecto: 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);
}