예제 #1
0
static void AsyncLoadImage( LCUI_Widget widget, const char *path )
{
	ImageCache cache;
	LCUI_Task task = {0};
	LCUI_Style *s = &widget->cached_style->sheet[key_background_image];

	if( !is_inited ) {
		RBTree_Init( &images );
		RBTree_Init( &refs );
		RBTree_OnJudge( &refs, OnCompareWidget );
		RBTree_OnJudge( &images, OnComparePath );
		RBTree_OnDestroy( &refs, free );
		RBTree_OnDestroy( &images, OnDestroyCache );
		is_inited = TRUE;
	}
	if( s->is_valid && s->type == SVT_STRING ) {
		cache = RBTree_CustomGetData( &images, s->string );
		if( cache ) {
			DelRef( widget, cache );
		}
	}
	cache = RBTree_CustomGetData( &images, path );
	if( cache ) {
		AddRef( widget, cache );
		Graph_Quote( &widget->computed_style.background.image,
			     &cache->image, NULL );
		Widget_AddTask( widget, WTT_BODY );
		return;
	}
	task.func = ExecLoadImage;
	task.arg[0] = widget;
	task.arg[1] = strdup( path );
	LCUI_AddTask( &task );
}
예제 #2
0
파일: event.c 프로젝트: aem3372/LCUI
/** 创建一个事件容器实例 */
LCUI_EventBox $(Create)(void)
{
	LCUI_EventBox box;
	box = NEW_ONE(struct LCUI_EventBoxRec_);
	box->event_id = 100;
	box->handler_id = 100;
	box->current = 0;
	RBTree_Init( &box->event_slot );
	RBTree_Init( &box->event_name );
	RBTree_Init( &box->event_handler );
	RBTree_Init( &box->used_evnet_id );
	RBTree_OnJudge( &box->event_name, CompareEventName );
	RBTree_OnDestroy( &box->event_handler, DestroyEventHandler );
	RBTree_OnDestroy( &box->event_slot, DestroyEventSlot );
	RBTree_SetDataNeedFree( &box->event_handler, 0 );
	RBTree_SetDataNeedFree( &box->event_name, 0 );
	RBTree_SetDataNeedFree( &box->used_evnet_id, 0 );
	LinkedList_Init( &box->events[0], sizeof(LCUI_Event) );
	LinkedList_Init( &box->events[1], sizeof(LCUI_Event) );
	LinkedList_SetDataNeedFree( &box->events[0], 1 );
	LinkedList_SetDataNeedFree( &box->events[1], 1 );
	LinkedList_SetDestroyFunc( &box->events[0], DestroyEvent );
	LinkedList_SetDestroyFunc( &box->events[1], DestroyEvent );
	return box;
}