/********************************************************************* * * Public module internal code * ********************************************************************** */ void WM__MoveWindow(WM_HWIN hWin, int dx, int dy) { GUI_RECT r; WM_Obj* pWin; pWin = WM_HANDLE2PTR(hWin); r = pWin->Rect; GUI_MoveRect(&pWin->Rect, dx, dy); /* Invalidate old and new area ... */ if (pWin->Status & WM_SF_ISVIS) { WM_InvalidateArea(&pWin->Rect); /* Invalidate new area */ WM_InvalidateArea(&r) ; /* Invalidate old area */ } WM__SendMsgNoData(hWin, WM_MOVE); /* Notify window it has been moved */ _MoveAllChildren(pWin->hFirstChild, dx, dy); /* Children need to be moved along ...*/ }
/********************************************************************* * * Pull window in foreground (top of stack) * ********************************************************************** */ void WM_BringToTop(WM_HWIN hWin) { WM_HWIN hPrev, hLast; WM_Obj* pWin; WM_Obj* pLast; if (hWin) { WM_LOCK(); pWin = WM_H2P(hWin); /* First of all check if window is already top of stack */ if (pWin->hNext && pWin->hParent) { /* unlink hWin */ if ((hPrev = WM__GetPrevSibling(hWin)) != 0) { WM_Obj* pPrev; pPrev = WM_H2P(hPrev); pPrev->hNext = pWin->hNext; } else { WM_Obj* pParent; pParent= WM_H2P(pWin->hParent); pParent->hFirstChild = pWin->hNext; } /* Link last sibling */ hLast = WM__GetLastSibling(hWin); pLast = WM_H2P(hLast); pLast->hNext = hWin; pWin->hNext = 0; /* Send message in order to make sure top window will be drawn */ WM_InvalidateArea(&pWin->Rect); /* Invalidate new area */ } WM_UNLOCK(); } }
void WM_ResizeWindow(WM_HWIN hWin, int dx, int dy) { GUI_RECT r; WM_LOCK(); r = WM_HANDLE2PTR(hWin)->Rect; if (dx>0) r.x1+=dx; if (dy>0) r.y1+=dy; WM_HANDLE2PTR(hWin)->Rect.x1+=dx; WM_HANDLE2PTR(hWin)->Rect.y1+=dy; WM_InvalidateArea(&r); /* Send size message to the window */ WM__SendMsgNoData(hWin, WM_SIZE); WM_UNLOCK(); }
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(); }