void WM_DeleteWindow (WM_HWIN Win) { WM_Obj* pWin; if (!Win) return; WM_LOCK(); if (WM__IsWindow(Win)) { pWin = WM_H2P(Win); ResetNextDrawWin(); /* Make sure the window will no longer receive drawing messages */ /* Make sure that focus is set to an existing window */ if (WM__hWinFocus == Win) { WM__hWinFocus = 0; } if (Win == WM__hCapture) { WM__hCapture = 0; } /* Delete all children */ _DeleteAllChildren(pWin->hFirstChild); _DeleteInSiblingList(Win); /* Send WM_DELETE message to window in order to inform window itself */ WM__SendMsgNoData(Win, WM_DELETE); /* tell window about it */ /* Inform other modules if necessary */ if (WM__pfDeleteWindowHook) { (*WM__pfDeleteWindowHook)(Win); } /* Remove window from window stack */ if (pWin->Status & WM_SF_INVALID) { WM__NumInvalidWindows--; } WM__RemoveFromLinList(Win); /* Clear area used by this window */ WM_InvalidateArea(&pWin->Rect); /* Free window memory */ WM__NumWindows--; WM_FREE(Win); /* Select a valid window */ WM_SelectWindow(WM__FirstWin); } else { GUI_DEBUG_WARN("WM_DeleteWindow: Invalid handle"); } WM_UNLOCK(); }
/***************************************************************************** * FUNCTION - ShowErrorMessage_C * DESCRIPTION: Displays an error message. * Further actions (Rebooting or ignoring errors when not debugging) depend * on the caller (or the caller of the caller...). * * Called by embOS\D3018X\OS_Error and Factory::FatalErrorOccured() * ****************************************************************************/ extern "C" void ShowErrorMessage_C(const char* errorDescription = "-") { int i; char sz_msg[250]; WM_HWIN win; WM_HWIN win_next; GUI_RECT rect; WM_SelectWindow(WM_GetDesktopWindow()); win = WM_GetFirstChild(WM_GetDesktopWindow()); while(win != (WM_HWIN) NULL) { win_next = WM_GetNextSibling(win); WM_DeleteWindow(win); win = win_next; } WM_SetStayOnTop(WM_GetDesktopWindow(),1); WM_BringToTop(WM_GetDesktopWindow()); GUI_SetBkColor(GUI_WHITE); GUI_SetColor(GUI_BLACK); GUI_SetFont(&Helvetica_57_13); GUI_Clear(); sprintf(sz_msg, "Fatal error.\n\n %s", errorDescription); rect.x0 = 0; rect.y0 = 10; rect.x1 = 239; rect.y1 = 319; for (i=0; i<5; i++) { GUI_Clear(); GUI_Delay(100); GUI_DispStringInRect(sz_msg,&rect,GUI_TA_VCENTER|GUI_TA_HCENTER); GUI_Delay(500); } }
/******************************************************************* * * _ShowHiResPixels This is frame-function for the callback. It creates the window and handles the rotation of polygons and colors. */ static void _ShowHiResPixels(void) { WM_HWIN hWindow; const GUI_FONT *font_old; float pi, step, angle; int i, tm; pi = 3.1415926f; step = pi / 180; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetTextAlign(GUI_TA_HCENTER); font_old = GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringAt("AA_HiResPixels - Sample", 160, 5); GUI_SetFont(font_old); GUI_SetColor(GUI_RED); GUI_DispStringHCenterAt("not\nantialised", 65, 100); GUI_SetColor(GUI_GREEN); GUI_DispStringHCenterAt("antialised", 160, 100); GUI_SetColor(GUI_BLUE); GUI_DispStringHCenterAt("antialised\nwith high\nresolution", 255, 100); hWindow = WM_CreateWindow(35, 140, 250, 60, WM_CF_SHOW | WM_CF_MEMDEV, &_cbWindow, 0); WM_SelectWindow(hWindow); GUI_AA_SetFactor(AA_FACTOR); while (1) { for (i=0, angle=0; i<360; i++) { tm = GUI_GetTime(); angle += step; GUI_RotatePolygon(_aPolygonHiRes, _aPolygonHiRes_src, POLY_POINTS, angle); GUI_RotatePolygon(_aPolygon, _aPolygon_src, POLY_POINTS, angle); _CalcColor(); WM_InvalidateWindow(hWindow); while (((GUI_GetTime()-tm) < 50) || (WM_Exec1() != 0)); } } WM_DeleteWindow(hWindow); }
/********************************************************************* * * _Main */ static void _Main(void) { int xSize; int ySize; /* 设置要用于绘制的活动窗口 */ WM_SelectWindow(WM_HBKWIN); GUI_Clear(); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) //GUI_CURSOR_Show(); #endif // // Create and configure Control and Information window // xSize = LCD_GetXSize();// ySize = LCD_GetYSize();// if(win_foucus_button_x) _hDialogControl = GUI_CreateDialogBox(_aFrameWinControl, GUI_COUNTOF(_aFrameWinControl), &_cbFrameWinControl, WM_HBKWIN, 0, 0); //_hDialogInfo = GUI_CreateDialogBox(_aFrameWinInfo, GUI_COUNTOF(_aFrameWinInfo), &_cbFrameWinInfo, WM_HBKWIN, (xSize >> 1) - 1, 0); else _hDialogDis = GUI_CreateDialogBox(_aFrameWinDis, GUI_COUNTOF(_aFrameWinDis), &_cbFrameWinDis, WM_HBKWIN, 0, 0); /*是窗口不可见*/ //WM_SetFocus(_hDialogDis); //WM_HideWindow(_hDialogInfo); // // Show Intro ///* 使窗口无效 */ // //WM_HideWindow(_hDialogDis); //else //WM_HideWindow(_hDialogControl); WM_InvalidateWindow(_hDialogDis); /* 禁用存储设备用于重绘 */ WM_DisableMemdev(WM_HBKWIN); //WM_HideWindow(_hDialogControl); /* 执行回调函数(通常用以重绘) */ GUI_Exec1(); /* 允许存储设备用于重绘 */ WM_EnableMemdev(WM_HBKWIN); /*GUIDEMO_Intro(); // // Run the demos // for (_iDemo = 0; _GUIDemoConfig.apFunc[_iDemo]; _iDemo++) { _ClearHalt(); GUIDEMO_UpdateControlText(); (*_GUIDemoConfig.apFunc[_iDemo])(); _iDemoMinor = 0; _Pressed = 0; } _iDemo = 0;*/ // // Cleanup // // // WM_DeleteWindow(_hDialogInfo); #if (GUI_SUPPORT_CURSOR | GUI_SUPPORT_TOUCH) GUI_CURSOR_Hide(); #endif }
void Window::Select() const{ WM_SelectWindow(id); }
WM_HWIN WM_CreateWindowAsChild( int x0, int y0, int width, int height ,WM_HWIN hWinParent ,U16 Style ,WM_CALLBACK* cb ,int NumExtraBytes) { WM_Obj* pWin; WM_HWIN hWin; WM_LOCK(); Style |= WM__CreateFlags; /* Get Parent info */ if (!hWinParent) { if (WM__NumWindows) { hWinParent = WM_HBKWIN; } } if (hWinParent) { GUI_RECT Rect; WM_MESSAGE Msg; Msg.MsgId = WM_GETCLIENTRECT_ABS; Msg.Data.p = &Rect; WM_SendMessage(hWinParent, &Msg); x0 += Rect.x0; y0 += Rect.y0; if (width==0) width = Rect.x1-Rect.x0+1; if (height==0) height = Rect.y1-Rect.y0+1; } if ((hWin = (WM_HWIN) WM_ALLOC(NumExtraBytes+sizeof(WM_Obj))) == 0) { GUI_DEBUG_ERROROUT("WM_CreateWindow: No memory to create window"); } else { WM__NumWindows++; pWin = WM_H2P(hWin); memset (pWin, 0, sizeof(WM_Obj)); /* erase this data structure The explicit zero-init is no longer needed since the entire data structure is already zeroed. The advantage is that it reduces program size. */ pWin->Rect.x0 = x0; pWin->Rect.y0 = y0; pWin->Rect.x1 = x0+width-1; pWin->Rect.y1 = y0+height-1; pWin->Status = WM_SF_INUSE; /* Mark window as in use */ pWin->cb = cb; /* Add to linked lists */ pWin->hParent = hWinParent; _AddChild(hWinParent, hWin, Style & WM_CF_STAYONTOP); _AddToLinList(hWin); /* Put Window on top (or bottom) of windows stack */ if (Style & WM_CF_ACTIVATE /*| (cb==NULL)*/) { WM_SelectWindow(hWin); /* This is not needed if callbacks are being used, but it does not cost a lot and makes life easier ... */ } /* Mark client area as invalid */ WM__SendMsgNoData(hWin, WM_CREATE); /* Handle the Style flags, one at a time */ if (Style & WM_CF_SHOW) { WM_ShowWindow(hWin); } /* Hide if parent is not visible */ if (hWinParent) { WM_Obj* pWinParent = WM_H2P(hWinParent); if (!(pWinParent->Status & WM_SF_ISVIS)) { WM_HideWindow(hWin); } } /* Copy the flags which can simply be accepted */ pWin->Status |= (Style & (WM_SF_MEMDEV|WM_SF_STAYONTOP|WM_SF_HASTRANS)); } WM_UNLOCK(); return hWin; }