Exemple #1
0
static void LoadIMG(void)
{
	int i;
	char filepath[1024];
	for(i=0; i<10; ++i) {
		sprintf( filepath, "drawable/time_%d.png", i );
		Graph_Init( &img_digital[i] );
		Graph_LoadImage( filepath, &img_digital[i] );
	}
	Graph_Init( &img_dot );
	Graph_Init( &img_btn );
	Graph_Init( &img_btn_bg );
	Graph_Init( &img_bg );
	Graph_LoadImage( "drawable/time_dot.png", &img_dot );
	Graph_LoadImage( "drawable/btn.png", &img_btn );
	Graph_LoadImage( "drawable/btn_bg.png", &img_btn_bg );
	Graph_LoadImage( "drawable/bg.png", &img_bg );
}
Exemple #2
0
int main( int argc, char **argv )
{
	LCUI_Widget w, root, text;
	LCUI_Graph desktop_image;

	InitConsoleWindow();
	LCUI_Init();
	LCUIDisplay_SetMode( LDM_WINDOWED );
	LCUIDisplay_SetSize( 960, 540 );
	w = LCUIWidget_New("debug-widget");
	text = LCUIWidget_New("textview");
	Widget_Append( w, text );
	TextView_SetTextW( text, L"测试文本内容,呵呵达!\nABCDEFG,abcdefg,[color=#ff0000]color font[/color]");
	Widget_Top( w );
	Widget_Show( w );
	Widget_Resize( w, 320, 240 );
	Widget_Move( w, 200, 200 );
	Widget_SetTitleW( w, L"测试" );
	Graph_Init( &desktop_image );
	Graph_LoadImage( "images/background-image.png", &desktop_image );
	root = LCUIWidget_GetRoot();

	Widget_PullStyle( root, WSS_BACKGROUND );
	root->style.background.color = RGB(255,242,223);
	root->style.background.image = desktop_image;
	root->style.background.size.using_value = TRUE;
	root->style.background.size.value = SV_COVER;
	Widget_PushStyle( root, WSS_BACKGROUND );

	Widget_PullStyle( w, WSS_BACKGROUND | WSS_SHADOW | WSS_BORDER );
	w->style.background.color.value = 0xccffffff;
	w->style.background.size.w.scale = 0.50; 
	w->style.background.size.h.px = 200;
	w->style.background.size.w.type = SVT_SCALE;
	w->style.background.size.h.type = SVT_PX;
	w->style.background.size.using_value = FALSE;
	w->style.background.position.using_value = TRUE;
	w->style.background.position.value = SV_BOTTOM_CENTER;
	w->style.shadow.color = ARGB(200,0,122,204);
	w->style.shadow.x = 2;
	w->style.shadow.y = 2;
	w->style.shadow.spread = 0;
	w->style.shadow.blur = 8;
	w->style.border.top.width = 1;
	w->style.border.right.width = 1;
	w->style.border.bottom.width = 1;
	w->style.border.left.width = 1;
	w->style.border.top.color = RGB(0,122,204);
	w->style.border.right.color = RGB(0,122,204);
	w->style.border.bottom.color = RGB(0,122,204);
	w->style.border.left.color = RGB(0,122,204);
	Widget_PushStyle( w, WSS_BACKGROUND | WSS_SHADOW | WSS_BORDER );
	//LCUITimer_Set( 5000, onTimer, NULL, TRUE );
	return LCUI_Main();
}
Exemple #3
0
static void ExecLoadImage( void *arg1, void *arg2 )
{
	char *path = arg2;
	LCUI_Graph image;
	LCUI_Widget widget = arg1;
	ImageCache cache;

	Graph_Init( &image );
	if( Graph_LoadImage( path, &image ) != 0 ) {
		return;
	}
	cache = NEW(ImageCacheRec, 1);
	cache->ref_count = 0;
	cache->image = image;
	cache->path = path;
	RBTree_CustomInsert( &images, path, cache );
	AddRef( widget, cache );
	Graph_Quote( &widget->computed_style.background.image,
		     &cache->image, NULL );
	Widget_AddTask( widget, WTT_BODY );
}
Exemple #4
0
/* 设定图片文件中的图像为PictureBox部件显示的图像 */
LCUI_API int
PictureBox_SetImageFile( LCUI_Widget *widget, char *image_file )
{
	int ret;
	graph_data data;
	LCUI_PictureBox *pic_box;
	LCUI_Graph *graph;
	
	pic_box = Widget_GetPrivData(widget);
	if( !graph_mem_init ) {
		Queue_Init( &picbox_graph_mem, 
			sizeof(graph_data), destroy_graph_data);
		graph_mem_init = TRUE;
	}
	/* 如果在记录中没找到该部件,那么就分配内存,否则,直接使用那块内存 */
	ret = find_widget_data(widget);
	if(ret == -1) {
		data.image = (LCUI_Graph*) calloc(1, sizeof(LCUI_Graph));
		data.widget = widget;
		Queue_Add(&picbox_graph_mem, &data); 
	} else {
		data = *(graph_data*)Queue_Get(&picbox_graph_mem, ret); 
	}
	graph = data.image;
	
	pic_box->image_state = IMAGE_STATE_LOADING; /* 图片状态为正在载入 */
	PictureBox_SetImage(widget, NULL);
	ret = Graph_LoadImage( image_file, graph );/* 载入图片文件 */
	if( ret == 0 ) {
		/* 载入成功 */
		pic_box->image_state = IMAGE_STATE_SUCCESS; 
		PictureBox_SetImage(widget, graph);
	} else {
		/* 载入失败 */
		pic_box->image_state = IMAGE_STATE_FAIL;
		PictureBox_SetImage(widget, NULL);
	}
	return ret;
}