/** 销毁事件容器实例 */ void $(Destroy)( LCUI_EventBox box ) { RBTree_Destroy( &box->event_name ); RBTree_Destroy( &box->event_handler ); RBTree_Destroy( &box->event_slot ); LinkedList_Destroy( &box->events[0] ); LinkedList_Destroy( &box->events[1] ); }
static void DestroyEventSlot( void *data ) { LCUI_EventSlot *slot = (LCUI_EventSlot*)data; free( slot->name ); slot->name = NULL; LinkedList_Destroy( &slot->handlers ); }
/** 部件析构函数 */ static void $(OnDestroy)( void *arg ) { LCUI_WidgetEvent e; LCUI_Widget widget = (LCUI_Widget)arg; Widget_DestroyTaskBox( widget ); LCUIEventBox_Destroy( widget->event ); widget->event = NULL; LinkedList_Destroy( &widget->children ); LinkedList_Destroy( &widget->children_show ); DirtyRectList_Destroy( &widget->dirty_rects ); /* 如果是从根级部件中移出,则触发 WET_REMOVE 事件 */ if( widget->parent == LCUIRootWidget ) { e.type_name = "TopLevelWidget"; e.target = widget; Widget_PostEvent( LCUIRootWidget, &e, (int*)WET_REMOVE ); } }
/* 销毁程序占用的资源 */ static void LCUIApp_Destroy(void) { if( LinkedList_GetTotal(&MainApp.loop_list) > 0 ) { /* 等待其它线程上的主循环都完全退出 */ LCUICond_Wait( &MainApp.loop_list_empty ); } /* 开始清理 */ LCUICond_Destroy( &MainApp.loop_list_empty ); LCUICond_Destroy( &MainApp.loop_cond ); LCUIMutex_Destroy( &MainApp.loop_mutex ); LCUIMutex_Destroy( &MainApp.loop_changed ); LCUIMutex_Destroy( &MainApp.task_run_mutex ); LCUIMutex_Destroy( &MainApp.task_list_mutex ); LinkedList_Destroy( &MainApp.loop_list ); }
/** 更新各种图形元素的显示 */ static void LCUIDisplay_Update(void) { int i, n, j, m; LCUI_Rect *p_rect; SurfaceRecord *p_sr; LCUI_DirtyRectList rlist; LCUI_PaintContext paint; DirtyRectList_Init( &rlist ); n = LinkedList_GetTotal( &display.surfaces ); /* 遍历当前的 surface 记录列表 */ for( i=0; i<n; ++i ) { LinkedList_Goto( &display.surfaces, i ); p_sr = (SurfaceRecord*) LinkedList_Get( &display.surfaces ); if( !p_sr->widget || !p_sr->surface || !Surface_IsReady(p_sr->surface) ) { continue; } /* 更新表面 */ Surface_Update( p_sr->surface ); /* 收集无效区域记录 */ Widget_ProcInvalidArea( p_sr->widget, &rlist ); m = LinkedList_GetTotal( &rlist ); DEBUG_MSG("proc invalid area, m = %d\n", m); LinkedList_Goto( &rlist, 0 ); /* 在 surface 上逐个重绘无效区域 */ for( j=0; j<m; ++j ) { p_rect = (LCUI_Rect*)LinkedList_Get( &rlist ); paint = Surface_BeginPaint( p_sr->surface, p_rect ); DEBUG_MSG( "[%s]: render rect: (%d,%d,%d,%d), %d\n", p_sr->widget->type, paint->rect.left, paint->rect.top, paint->rect.w, paint->rect.h, j ); Widget_Render( p_sr->widget, paint ); Surface_EndPaint( p_sr->surface, paint ); LinkedList_Delete( &rlist ); } if( m > 0 ) { Surface_Present( p_sr->surface ); } } LinkedList_Destroy( &rlist ); }
/** 停用键盘输入模块 */ void LCUIModule_Keyboard_End( void ) { LinkedList_Destroy( &key_state_record ); LCUIMutex_Destroy( &record_mutex ); }
/** 销毁样式标签栈 */ void StyleTagStack_Destroy( LCUI_StyleTagStack *tags ) { LinkedList_Destroy( tags ); }
/** 停用键盘输入模块 */ int LCUI_ExitKeyboard( void ) { LinkedList_Destroy( &key_state_record ); LCUIMutex_Destroy( &record_mutex ); return 0; }
def(void, Destroy) { LinkedList_Destroy(&this->events, LinkedList_OnDestroy_For(this, ref(DestroyEvent))); }