/********************************************************************* * * _EffectRequiresRedraw * * Purpose * Check if the effect to draw is inside the invalid rectangle. * Returns: * 0 if nothing need to be done. * 1 if the effect needs to be drawn */ static int _EffectRequiresRedraw(const WIDGET* pWidget, const GUI_RECT * pRect) { int EffectSize = pWidget->pEffect->EffectSize; GUI_RECT InvalidRect; InvalidRect = pWidget->Win.InvalidRect; WM__Client2Screen(&pWidget->Win, &InvalidRect); /* Check if there a part of the effect is inside the invalid rectangle */ if ((pRect->x0 + EffectSize) > InvalidRect.x0) { return 1; /* Overlap ... Drawing required */ } if ((pRect->x1 - EffectSize) < InvalidRect.x1) { return 1; /* Overlap ... Drawing required */ } if ((pRect->y0 + EffectSize) > InvalidRect.y0) { return 1; /* Overlap ... Drawing required */ } if ((pRect->y1 - EffectSize) < InvalidRect.y1) { return 1; /* Overlap ... Drawing required */ } return 0; /* No overlap ! */ }
const GUI_RECT* WM_SetUserClipRect(const GUI_RECT* pRect) { const GUI_RECT* pRectReturn; GUI_RECT r; WM_Obj* pAWin; WM_LOCK(); pRectReturn = GUI_Context.WM__pUserClipRect; GUI_Context.WM__pUserClipRect = pRect; /* Activate it ... */ if (pRect) { r = *pRect; pAWin = WM_HANDLE2PTR(GUI_Context.hAWin); WM__Client2Screen(pAWin, &r); LCD_SetClipRectEx(&r); } else { WM_GetWindowRect(&r); LCD_SetClipRectEx(&r); } WM_UNLOCK(); return pRectReturn; }
int WM__InitIVRSearch(const GUI_RECT* pMaxRect) { GUI_RECT r; WM_Obj* pAWin; /* If WM is not active -> nothing to do, leave cliprect alone */ if (WM_IsActive==0) return 1; /* If we entered multiple times, leave Cliprect alone */ if (++ClipContext.EntranceCnt > 1) return 1; pAWin = WM_H2P(GUI_Context.hAWin); ClipContext.Cnt = -1; /* When using callback mechanism, it is legal to reduce drawing area to the invalid area ! */ if (IsInCallback) { WM__GetInvalidRectAbs(pAWin, &r); } else { /* Not using callback mechanism, therefor allow entire rectangle */ if (pAWin->Status & WM_SF_ISVIS) { r = pAWin->Rect; } else { --ClipContext.EntranceCnt; return 0; /* window is not even visible ! */ } } /* If the drawing routine has specified a rectangle, use it to reduce the rectangle */ if (pMaxRect) { GUI__IntersectRect(&r, pMaxRect); } /* If user has reduced the cliprect size, reduce the rectangle */ if (GUI_Context.WM__pUserClipRect) { GUI_RECT rUser = *(GUI_Context.WM__pUserClipRect); WM__Client2Screen(pAWin, &rUser); GUI__IntersectRect(&r, &rUser); } /* Iterate over all ancestors and clip at their borders */ _ClipAtParentBorders(&r, pAWin); /* Store the rectangle and find the first rectangle of the area */ ClipContext.ClientRect = r; return WM__GetNextIVR(); }
WM_HWIN WM_CreateWindowAsChild( int x0, int y0, int width, int height ,WM_HWIN hParent, U16 Style, WM_CALLBACK* cb ,int NumExtraBytes) { WM_Obj* pWin; WM_HWIN hWin; WM_LOCK(); Style |= WM__CreateFlags; /* Get Parent info */ if (!hParent) { if (WM__NumWindows) { hParent = WM_HBKWIN; } } if (hParent) { GUI_RECT Rect; // Rect = WM_H2P(hParent)->Rect; WM_GetInsideRect(hParent, &Rect); WM__Client2Screen(WM_H2P(hParent), &Rect); 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 = hParent; _AddChild(hParent, 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 (hParent) { WM_Obj* pWinParent = WM_H2P(hParent); 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; }