UCGUI分析视窗管理器初始化和重绘过程

1、WM_Init函数分析

void WM_Init(void) {
	if (!_IsInited) {
	  NextDrawWin = WM__FirstWin = WM_HWIN_NULL;
	  GUI_Context.WM__pUserClipRect = NULL;
	  WM__NumWindows = WM__NumInvalidWindows =0;
	  /* Make sure we have at least one window. This greatly simplifies the
		  drawing routines as they do not have to check if the window is valid.
	  */
    #if GUI_NUM_LAYERS == 1
      WM__ahDesktopWin[0] = WM_CreateWindow(0, 0, GUI_XMAX, GUI_YMAX, WM_CF_SHOW, cbBackWin, 0);//创建桌面窗体
      WM__aBkColor[0] = GUI_INVALID_COLOR;//桌面窗体背景色无效
      WM_InvalidateWindow(WM__ahDesktopWin[0]); //桌面窗体无效
    #else
    {
      int i;
      for (i = 0; i < GUI_NUM_LAYERS; i++) {
        WM__ahDesktopWin[i] = WM_CreateWindowAsChild(0, 0, GUI_XMAX, GUI_YMAX, WM_UNATTACHED, WM_CF_SHOW, cbBackWin, 0);
        WM__aBkColor[i] = GUI_INVALID_COLOR;
        WM_InvalidateWindow(WM__ahDesktopWin[i]); /* Required because a desktop window has no parent. */
      }
    }
    #endif
    //WM__CHWinModal和WM__CHWinLast添加到链表中
    WM__AddCriticalHandle(&WM__CHWinModal);
    WM__AddCriticalHandle(&WM__CHWinLast);
    #if GUI_SUPPORT_MOUSE
      WM__AddCriticalHandle(&WM__CHWinMouseOver);
    #endif

    WM_SelectWindow(WM__ahDesktopWin[0]);//选择桌面窗体
	  WM_Activate();//激活视窗管理器
    _IsInited =1;//初始标志设置为1
	}
}

2、 创建桌面窗体时是调用WM_CreateWindowAsChild。
①动态内存申请窗体句柄
②窗体总个数加1
③设置矩形区域和回到函数
④发送消息

2、 重绘调用过程

->GUI_Exec();
-->while (GUI_Exec1())
--->if (WM_Exec())
---->while (WM_Exec1())
----->_DrawNext();
------>if (WM__Paint(iWin, pWin))
------->WM__PaintWinAndOverlays(&Info);	
-------->_Paint1(hWin, pWin); 
//最后调用这部分代码,通过剪切算法重绘窗体。
WM_ITERATE_START(&pWin->InvalidRect) {
  Msg.hWin   = hWin;
  Msg.MsgId  = WM_PAINT;
  Msg.Data.p = (GUI_RECT*)&pWin->InvalidRect;
  WM_SetDefault();
  WM__SendMessage(hWin, &Msg);
} WM_ITERATE_END();			     

上一篇:没有libstdc的C RTTI.可能吗?


下一篇:TranslateMessage(&msg); WINAPI