First public contribution.
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // CWsWindow and associated classes definitions
26 #define LOG_WINDOW_FADE_START(wswin)
27 #define LOG_WINDOW_FADE_REGION(region)
28 #define LOG_WINDOW_FADE_END(wswin)
32 #define LOG_WINDOW_FADE_START(wswin) LogFadeStart(wswin)
33 #define LOG_WINDOW_FADE_REGION(region) LogFadeRegion(region)
34 #define LOG_WINDOW_FADE_END(wswin) LogFadeEnd(wswin)
36 class TTruncateOverflow : public TDesOverflow
39 virtual void Overflow(TDes&) {};
42 void LogRegion(const TRegion* aRegion);
43 void LogFadeStart(const CWsWindow* aWsWin);
44 void LogFadeRegion(const TRegion* aRegion);
45 void LogFadeEnd(const CWsWindow* aWsWin);
49 void AnnotateWindowRedrawStart(const CWsWindow& aWsWin, const TRegion& aRegion);
50 void AnnotateWindowRedrawEnd(const CWsWindow& aWsWin);
51 void AnnotateWindowAnimRedrawStart(const CWsWindow& aWsWin, const CWsAnim& aAnim, const TRegion& aRegion);
52 void AnnotateWindowAnimRedrawEnd(const CWsWindow& aWsWin, const CWsAnim& aAnim);
53 void AnnotateSpriteRedrawStart(const CWsWindow& aWsWin, const CWsSpriteBase& aSprite, const TRegion& aRegion);
54 void AnnotateSpriteRedrawEnd(const CWsWindow& aWsWin, const CWsSpriteBase& aSprite);
56 class MWsGraphicsContext;
59 class CWsWindow : public CWsWindowBase, public MWsWindow
61 friend class TWalkWindowTreeDisconnect;
62 friend class CWsRootWindow;
63 friend class TWalkWindowTreeFindWithFlag;
65 CWsWindow(CWsClient* aOwner,WH_HANDLES aType, CScreen* aScreen);
68 inline const TRect& Rel() const;
69 inline const TRect& Abs() const;
70 inline CWsWindow *PrevSiblingMultiParent() const;
71 inline CWsWindow *NextSiblingMultiParent() const;
72 inline TUint PointerFilter() const;
73 inline TBool HasPointerGrab() const;
74 inline TBool ShutDownInProgress() const;
75 inline TRgb BackColor() const;
76 virtual void AreaCovered(TRegion &aRegion);
77 const TRegion* VisibleRegionIfValid() const;
78 const TRegion& VisibleRegion() const;
79 void ClearVisibleRegion();
80 void SetVisibleRegion(const TRegion& aNewVisibleRegion, const TRegion* aTop);
81 void SetFadeableRegion(const TRegion& aNewFadeableRegion, const TRegion& aTop);
83 virtual void GenerateWindowRegion(RWsRegion &aRegion) const=0;
84 TRect FullRect() const;
85 inline TBool ClientSetInvisible() const;
86 inline TBool IsVisible() const;
87 inline TBool DragDropCapture() const;
88 inline CWsBackedUpWindow *Backup() const;
89 TDisplayMode DisplayMode() const;
90 inline TInt UsingPointerBuffer() const;
91 virtual TDblQue<TPointerKeyList> *PointerKeyList() const;
92 inline CWsWindowRedraw *Redraw() const;
93 inline TBool IsTopClientWindow() const;
94 TDisplayMode SetRequiredDisplayModeL(TDisplayMode aDisplayMode);
95 inline TBool IsActive() const;
96 TInt AddDSA(CWsDirectScreenAccess& aDirect);
97 void RemoveDSA(CWsDirectScreenAccess& aDirect);
100 inline const TSglQue<CWsDirectScreenAccess>& DSAs() const;
102 void PossibleVisibilityChangedEvent(TBool aForceSend);
103 void SetNonFading(TBool aNonFading);
104 void SetFadeBehind(TBool aFade);
105 inline void GetFadingParams(TUint8& aBlackMap,TUint8& aWhiteMap) const;
106 inline TBool IsTranslucent() const;
107 inline TBool HasAlpha() const;
108 inline TBool HasBeenDrawnToScreen() const;
109 inline void SetDrawnToScreen(TBool aDrawn);
110 void FocusChanged(TBool aNewFocusState);
111 void ClipRectToViewport(TRect& aRect) const;
112 void SetNextScheduled(CWsWindow * aWin);
113 CWsWindow * NextScheduled() const;
114 inline const TRegion& ScheduledRegion() const;
115 inline const TRegion& ScheduledSpriteRegion() const;
116 TBool SetScheduledRegion(const TRegion& aRegion);
117 void ClearScheduledRegion();
118 void ClearScheduledSpriteRegion();
119 static TBool ReleaseMemory(MWsMemoryRelease::TMemoryReleaseLevel aLevel);
120 TBool ReadyToDraw() const;
121 void Render(MWsGraphicsContext& aGc, const TRegion& aWindowRegion, const TRegion& aWindowChildNodeRegion);
124 inline TBool IsNonFading() const;
125 const TRegion& QuickFadeRegion() const;
126 void Fade(MWsGraphicsContext * aGc, const TRegion& aRegion);
128 inline void SetValidRedraw();
129 inline TBool IsValidRedraw() const;
130 inline TBool HasElement() const;
131 inline TBool IsFading() const;
132 inline TBool HasAnimation() const;
133 inline TBool IsBackgroundClearEnabled() const;
134 void AddDirtyWindowRegion(const TRegion& aRegion);
135 void AddDirtySpriteRegion(const TRegion& aRegion);
136 const TRegion& DirtyWindowRegion() const;
137 const TRegion& DirtySpriteRegion() const;
138 void ScheduleDirtyWindowRegion();
139 void ScheduleDirtySpriteRegion();
140 void SetupVisibleRegionTracking(TBool aRegister);
141 inline TBool IsTrackingVisibleRegion() const;
142 const TRegion& FadableRegion() const;
144 public: // from CWsWindowBase
145 TBool IsDSAHost() const;
146 void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const;
148 public: // from MWsWindow
149 TPoint Origin() const;
150 TRect AbsRect() const;
152 TUint32 Handle() const;
153 MWsScreen * WsScreen() const;
154 void Invalidate(const TRect *) {}
155 MWsWindow * FindChildByHandle(TUint32 aHandle);
156 TInt OrdinalPriority() const;
159 TPoint InquireOffset(TUint32 aHandle) const;
160 void Shutdown(); // Part of two phase destruction
161 void FocusChangedL(TBool aNewFocusState);
162 void RemoveFromAccessList();
163 void InsertIntoAccessListOldestEnd();
164 void InsertIntoAccessListRecentEnd();
165 void DeactivateAllSprites();
167 void StatusDump(TDes &aBuf);
168 void ResetVisibleRegion();
169 void AbortDsaIfRequired(const TRegion& aNewRegion, const TRegion* aTop);
170 void RestartAnimations(const TRegion& aNewRegion);
173 TBool iInteresting; // Often useful while debugging for conditional breakpoints.
179 RWsRegionBuf<1> iVisibleRegion;
180 TUint iPointerFilter;
181 TInt iPointerCapturePriority;
183 CWsWindowRedraw *iRedraw;
184 TSglQue<CWsDirectScreenAccess> iDSAs;
185 CWsWindow * iNextScheduled;
186 RWsRegionBuf<1> iScheduledRegion;
187 RWsRegionBuf<1> iScheduledSpriteRegion;
188 // The access list is a "most recently drawn" ordering list of all redraw msg windows.
189 static CWsWindow * iAccessListRecentEnd;
190 static CWsWindow * iAccessListOldestEnd;
191 CWsWindow * iAccessListPrev;
192 CWsWindow * iAccessListNext;
195 RWsRegionBuf<1> iQuickFadeRegion;
196 RWsRegionBuf<1> iFadableRegion; // Region which can be faded (Visible region minus already faded regions)
197 RWsRegionBuf<1> iDirtyWindowRegion;
198 RWsRegionBuf<1> iDirtySpriteRegion;
199 TInt iVisibleRegionTrackingCounter;
201 /** The list of graphic contexts associated with this window. The list is managed by calling the
202 GcActivated() and GcDeactivated() functions.
203 This is a linked list. The CWsGc class contains a pointer to the next item: CWsGc::iNextWinGc.
206 CWsAnim *iAnimList; // Start of linked list of animated objects attached to the window
209 #include "wnredraw.h"
211 inline TBool CWsWindow::IsVisible() const
213 return(!(iFlags&EFlagHidden));
216 inline TBool CWsWindow::ClientSetInvisible() const
218 return(iFlags&EFlagInvisible);
221 inline TBool CWsWindow::DragDropCapture() const
223 return(iFlags&EFlagPointerCaptureDragDrop);
226 inline TRgb CWsWindow::BackColor() const
228 return(iRedraw->BackColor());
231 inline TInt CWsWindow::UsingPointerBuffer() const
233 return(iFlags&EFlagUsingPointerBuffer);
236 inline CWsWindowRedraw *CWsWindow::Redraw() const
241 inline const TRect& CWsWindow::Rel() const
246 inline const TRect& CWsWindow::Abs() const
251 inline TBool CWsWindow::IsTopClientWindow() const
253 return(iFlags&EFlagIsTopClientWindow);
256 inline TUint CWsWindow::PointerFilter() const
258 return(iPointerFilter);
261 inline TBool CWsWindow::HasPointerGrab() const
263 return(iFlags&EFlagPointerGrab);
266 inline TBool CWsWindow::ShutDownInProgress() const
268 return(iFlags&EFlagShutDownInProgress);
271 inline CWsBackedUpWindow *CWsWindow::Backup() const
273 return(iRedraw->Backup());
276 inline CWsWindow *CWsWindow::PrevSiblingMultiParent() const
278 return((CWsWindow *)CWsWindowBase::PrevSiblingMultiParent());
281 inline CWsWindow *CWsWindow::NextSiblingMultiParent() const
283 return((CWsWindow *)CWsWindowBase::NextSiblingMultiParent());
286 inline TBool CWsWindow::IsActive() const
288 return iFlags&EFlagActive;
291 inline TBool CWsWindow::IsTranslucent() const
293 return (iFlags & static_cast<TUint>(EFlagHasAlpha)) != 0;
296 inline TBool CWsWindow::HasAlpha() const
298 return (iFlags & static_cast<TUint>(EFlagHasAlpha)) !=0;
301 inline TBool CWsWindow::HasBeenDrawnToScreen() const
303 return (iFlags & static_cast<TUint>(EFlagDrawnToScreen)) != 0;
306 inline void CWsWindow::SetDrawnToScreen(TBool aDrawn)
309 iFlags |= static_cast<TUint>(EFlagDrawnToScreen);
311 iFlags &= ~static_cast<TUint>(EFlagDrawnToScreen);
314 inline const TRegion& CWsWindow::ScheduledRegion() const
316 return iScheduledRegion;
319 inline const TRegion& CWsWindow::ScheduledSpriteRegion() const
321 return iScheduledSpriteRegion;
325 inline const TSglQue<CWsDirectScreenAccess>& CWsWindow::DSAs() const
331 inline TBool CWsWindow::IsNonFading() const
333 return (iFlags&EFlagNonFadingWindow);
336 inline void CWsWindow::GetFadingParams(TUint8& aBlackMap,TUint8& aWhiteMap) const
337 {aBlackMap=iBlackMap;aWhiteMap=iWhiteMap;}
339 inline TBool CWsWindow::HasElement() const
341 return (Redraw())?(Redraw()->HasElement()):(EFalse);
344 inline TBool CWsWindow::IsFading() const
346 return (!IsNonFading() && (iFadeCount > 0));
349 inline void CWsWindow::SetValidRedraw()
351 iFlags |= EFlagValidRedraw;
354 inline TBool CWsWindow::IsValidRedraw() const
356 return (iFlags & EFlagValidRedraw);
359 inline TBool CWsWindow::HasAnimation() const
361 return (NULL != iAnimList);
364 inline TBool CWsWindow::IsBackgroundClearEnabled() const
366 return Redraw()->IsBackgroundClearEnabled();
369 inline TBool CWsWindow::IsTrackingVisibleRegion() const
371 WS_ASSERT_DEBUG(iVisibleRegionTrackingCounter>=0,EWsPanicVisibleRegionTracking);
372 return iVisibleRegionTrackingCounter;