/** 创建一个事件容器实例 */ 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; }
/** 初始化程序数据结构体 */ static void LCUIApp_Init(void) { LCUICond_Init( &MainApp.loop_cond ); LCUIMutex_Init( &MainApp.loop_changed ); LCUIMutex_Init( &MainApp.loop_mutex ); LinkedList_Init( &MainApp.loop_list, sizeof(LCUI_MainLoop)); LinkedList_SetDataNeedFree( &MainApp.loop_list, FALSE ); LCUIMutex_Init( &MainApp.task_run_mutex ); LCUIMutex_Init( &MainApp.task_list_mutex ); LinkedList_Init( &MainApp.task_list, sizeof(LCUI_Task) ); LinkedList_SetDestroyFunc( &MainApp.task_list, DestroyTask ); }
/** 构造函数 */ static void $(Init)( LCUI_Widget widget ) { widget->style.z_index = 0; widget->style.x.type = SVT_NONE; widget->style.y.type = SVT_NONE; widget->style.width.type = SVT_AUTO; widget->style.height.type = SVT_AUTO; widget->style.box_sizing = CONTENT_BOX; widget->style.opacity = 1.0; widget->style.margin.top.px = 0; widget->style.margin.right.px = 0; widget->style.margin.bottom.px = 0; widget->style.margin.left.px = 0; widget->style.margin.top.type = SVT_PX; widget->style.margin.right.type = SVT_PX; widget->style.margin.bottom.type = SVT_PX; widget->style.margin.left.type = SVT_PX; widget->style.padding.top.px = 0; widget->style.padding.right.px = 0; widget->style.padding.bottom.px = 0; widget->style.padding.left.px = 0; widget->style.padding.top.type = SVT_PX; widget->style.padding.right.type = SVT_PX; widget->style.padding.bottom.type = SVT_PX; widget->style.padding.left.type = SVT_PX; widget->event = LCUIEventBox_Create(); memset( &widget->base, 0, sizeof(widget->base)); widget->parent = NULL; widget->title = NULL; widget->event = LCUIEventBox_Create(); Widget_InitTaskBox( widget ); Background_Init( &widget->style.background ); BoxShadow_Init( &widget->style.shadow ); Border_Init( &widget->style.border ); LinkedList_Init( &widget->children, sizeof(struct LCUI_WidgetFull) ); LinkedList_Init( &widget->children_show, 0 ); LinkedList_SetDestroyFunc( &widget->children, $(OnDestroy) ); LinkedList_SetDataNeedFree( &widget->children, TRUE ); LinkedList_SetDataNeedFree( &widget->children_show, FALSE ); DirtyRectList_Init( &widget->dirty_rects ); Graph_Init( &widget->graph ); }