📄 wm.lst
字号:
if (hParent) {
pParent = WM_H2P(hParent);
pChild = WM_H2P(hChild);
hi = pParent->hFirstChild;
if (hi == 0) { /* No child yet ... Makes things easy ! */
pParent->hFirstChild = hChild;
return; /* Early out ... We are done */
}
if (!OnTop) {
pi = WM_H2P(hi);
if (pi->Status & WM_SF_STAYONTOP) {
pChild->hNext = hi;
pParent->hFirstChild = hChild;
return; /* Early out ... We are done */
}
}
/* put if at the end of the list or after the last non "STAY-ON-TOP" child */
do {
WM_Obj* pNext;
WM_HWIN hNext;
pi = WM_H2P(hi);
if ((hNext = pi->hNext) == 0) {
pi->hNext = hChild;
break;
}
if (!OnTop) {
pNext = WM_H2P(hNext);
if (pNext->Status & WM_SF_STAYONTOP) {
pi->hNext = hChild;
pChild->hNext = hNext;
break;
}
}
hi = hNext;
} while (1);
}
}
/*******************************************************************
*
C51 COMPILER V8.05a WM 04/11/2008 14:19:41 PAGE 6
*
*/
static void _DeleteAllChildren(WM_HWIN hChild) {
while (hChild) {
WM_Obj* pChild = WM_H2P(hChild);
WM_HWIN hNext = pChild->hNext;
WM_DeleteWindow(hChild);
hChild = hNext;
}
}
/*******************************************************************
*
*
*/
static void _DeleteInSiblingList(WM_HWIN hWin) {
WM_Obj* pWin;
WM_Obj* pParent;
WM_Obj* pi;
WM_HWIN hParent;
WM_HWIN hi;
pWin = WM_H2P(hWin);
if (pWin->hParent) {
hParent = pWin->hParent;
pParent = WM_H2P(hParent);
hi = pParent->hFirstChild;
if (hi == hWin) {
pi = WM_H2P(hi);
pParent->hFirstChild = pi->hNext;
} else {
while (hi) {
pi = WM_H2P(hi);
if (pi->hNext == hWin) {
pi->hNext = pWin->hNext;
return;
}
hi = pi->hNext;
}
}
}
}
/*********************************************************************
*
* Module internal routines
*
**********************************************************************
*/
void WM__Client2Screen(const WM_Obj* pWin, GUI_RECT *pRect) {
GUI_MoveRect(pRect, pWin->Rect.x0, pWin->Rect.y0);
}
int WM__IsWindow(WM_HWIN hWin) {
WM_HWIN iWin;
int r = 0;
for (iWin = WM__FirstWin; iWin; iWin = WM_H2P(iWin)->hNextLin) {
if (iWin == hWin) {
r = 1;
break;
}
C51 COMPILER V8.05a WM 04/11/2008 14:19:41 PAGE 7
}
return r;
}
/*******************************************************************
*
*
*/
void WM__RemoveFromLinList(WM_HWIN hWin) {
WM_Obj* piWin;
WM_HWIN hiWin, hNext;
for (hiWin = WM__FirstWin; hiWin; ) {
piWin = WM_H2P(hiWin);
hNext = piWin->hNextLin;
if (hNext == hWin) {
piWin->hNextLin = WM_H2P(hWin)->hNextLin;
break;
}
hiWin = hNext;
}
}
/*******************************************************************
*
*
*/
void _AddToLinList(WM_HWIN hNew) {
WM_Obj* pFirst;
WM_Obj* pNew;
if (WM__FirstWin) {
pFirst = WM_H2P(WM__FirstWin);
pNew = WM_H2P(hNew);
pNew->hNextLin = pFirst->hNextLin;
pFirst->hNextLin = hNew;
} else {
WM__FirstWin = hNew;
}
}
/*********************************************************************
Check if the rectangle has some content (is non-zero)
Returns 0 if the Rectangle has no content, else 1.
*/
int WM__RectIsNZ(const GUI_RECT* pr) {
if (pr->x0 > pr->x1)
return 0;
if (pr->y0 > pr->y1)
return 0;
return 1;
}
/*
********************************************************************
* *
* Sending messages *
* *
********************************************************************
*/
C51 COMPILER V8.05a WM 04/11/2008 14:19:41 PAGE 8
void WM_SendMessage(WM_HWIN hWin, WM_MESSAGE* pMsg) {
WM_Obj* pWin;
WM_LOCK();
if (hWin) {
pWin = WM_H2P(hWin);
/* Do some checking to avoid program crashes due to user
programming errors */
#if GUI_DEBUG_LEVEL > 0
if (!pWin->Status)
goto Done;
#endif
if (pWin->cb != NULL) {
pMsg->hWin = hWin;
IsInCallback = 1;
(*pWin->cb)(pMsg);
IsInCallback = 0;
}
}
#if GUI_DEBUG_LEVEL > 0
Done:
#endif
WM_UNLOCK();
}
/*******************************************************************
*
*
*/
void WM__SendMsgNoData(WM_HWIN hWin, U8 MsgId) {
WM_MESSAGE Msg;
Msg.hWin = hWin;
Msg.MsgId = MsgId;
WM_SendMessage(hWin, &Msg);
}
/* Get client rectangle in windows coordinates. This means that the
upper left corner is always at (0,0). */
void WM__GetClientRectWin(const WM_Obj* pWin, GUI_RECT* pRect) {
pRect->x0 = pRect->y0 = 0;
pRect->x1 = pWin->Rect.x1 - pWin->Rect.x0;
pRect->y1 = pWin->Rect.y1 - pWin->Rect.y0;
}
static void WM__GetInvalidRectAbs(WM_Obj* pWin, GUI_RECT* pRect) {
*pRect = pWin->InvalidRect;
GUI_MoveRect (pRect, pWin->Rect.x0, pWin->Rect.y0);
}
/*
*****************************************************************
* *
* Invalidation functions *
* *
*****************************************************************
*/
C51 COMPILER V8.05a WM 04/11/2008 14:19:41 PAGE 9
/* Invalidate, using window coordinates */
static void WM_InvalidateBWin1(WM_HWIN hWin, const GUI_RECT*pRect) {
GUI_RECT r;
WM_Obj* pWin = WM_H2P(hWin);
WM__GetClientRectWin(pWin, &r);
if (pRect)
GUI__IntersectRect(&r, pRect);
if (WM__RectIsNZ(&r)) {
if (pWin->Status & WM_SF_INVALID) {
GUI_MergeRect(&pWin->InvalidRect, &pWin->InvalidRect, &r);
} else {
pWin->InvalidRect = r;
pWin->Status |= WM_SF_INVALID;
WM__NumInvalidWindows++;
/* Debug code: shows invalid areas */
#if (WM_SHOW_INVALID)
{
GUI_CONTEXT Context = GUI_Context;
WM_SelectWindow(hWin);
GUI_SetBkColor(GUI_GREEN);
GUI_ClearRect(r.x0, r.y0, r.x1, r.y1);
GUI_Context = Context;
}
#endif
}
}
}
/* Invalidate, using desktop coordinates (only this window,
not the ones below !!!)
*/
static void WM_InvalidateBWin1Abs(WM_HWIN hWin, const GUI_RECT*pRect) {
GUI_RECT r = *pRect;
WM_LOCK();
GUI_MoveRect(&r, -WM_H2P(hWin)->Rect.x0, -WM_H2P(hWin)->Rect.y0);
WM_InvalidateBWin1(hWin, &r);
WM_UNLOCK();
}
/*
Invalidate a certain section of the display. One main reason for this is
that a window has been moved or destroyed.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -