|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // TWalkWindowTreeBase and associated classes definitions |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __WALKWINDOWTREE_H__ |
|
19 #define __WALKWINDOWTREE_H__ |
|
20 |
|
21 #include "server.h" |
|
22 |
|
23 class CWsWindow; |
|
24 class CWsWindowBase; |
|
25 class RWsTextCursor; |
|
26 |
|
27 class TWalkWindowTreeBase |
|
28 { |
|
29 public: |
|
30 virtual TBool DoIt(CWsWindow *aWin)=0; |
|
31 }; |
|
32 |
|
33 class TResumableWalkWindowTreeBase |
|
34 { |
|
35 public: |
|
36 virtual TBool DoIt(CWsWindow *aWin)=0; |
|
37 private: // walk state |
|
38 friend class CWsWindowBase; |
|
39 CWsWindowBase* iWin; |
|
40 CWsWindowBase* iEnd; |
|
41 CWsWindowBase* iNextChild; |
|
42 CWsWindowBase* iParent; |
|
43 }; |
|
44 |
|
45 class TWalkWindowTreeRegionBase : public TWalkWindowTreeBase |
|
46 { |
|
47 public: |
|
48 enum TTranslucentBehaviour |
|
49 { |
|
50 EDontWalkTranslucent, //< Default behaviour - stop when you reach a window |
|
51 EWalkTranslucent, //< Walk through translucent parts of windows |
|
52 }; |
|
53 protected: |
|
54 TWalkWindowTreeRegionBase(RWsRegion *aRegion, TTranslucentBehaviour aTranslucentBehaviour = EDontWalkTranslucent); |
|
55 TBool DoIt(CWsWindow *aWin); |
|
56 virtual void DoIt2(CWsWindow *aWin)=0; |
|
57 virtual TBool DoIt3(CWsWindow *aWin); |
|
58 protected: |
|
59 TTranslucentBehaviour iTranslucentBehaviour; |
|
60 RWsRegion *iRegion; |
|
61 RWsRegion *iSubRegion; |
|
62 }; |
|
63 |
|
64 /** |
|
65 This tree walker calculates the visible regions of all windows and schedules |
|
66 redraws for anywhere which has changed. |
|
67 */ |
|
68 class TWalkWindowTreeUpdateRegions : public TWalkWindowTreeBase |
|
69 { |
|
70 public: |
|
71 TWalkWindowTreeUpdateRegions(CScreen & aScreen); |
|
72 TBool DoIt(CWsWindow * aWin); |
|
73 void Walk(); |
|
74 |
|
75 private: |
|
76 CScreen & iScreen; |
|
77 RWsRegion iVisible; |
|
78 RWsRegion iTop; |
|
79 RWsRegion iRemainsOfFadableScreen; // The remains after the accumulation of already faded regions |
|
80 }; |
|
81 |
|
82 /** |
|
83 This schedules the visible regions of all windows walked for redraw. |
|
84 */ |
|
85 class TWalkWindowTreeScheduleRedraws : public TWalkWindowTreeBase |
|
86 { |
|
87 public: |
|
88 enum |
|
89 { // bit mask |
|
90 ERedrawFilterNoFilter = 0, |
|
91 ERedrawFilterOmitDSA = 0x001 |
|
92 }; |
|
93 |
|
94 public: |
|
95 TWalkWindowTreeScheduleRedraws(); |
|
96 TWalkWindowTreeScheduleRedraws( TUint32 aFilter ); |
|
97 TBool DoIt(CWsWindow * aWin); |
|
98 |
|
99 private: |
|
100 TUint32 iScheduleRedrawFilter; |
|
101 }; |
|
102 |
|
103 /** |
|
104 This offsets all the transparent regions |
|
105 */ |
|
106 class TWalkWindowTreeOffsetTransparentRegions : public TWalkWindowTreeBase |
|
107 { |
|
108 public: |
|
109 TWalkWindowTreeOffsetTransparentRegions(const TPoint& aOffset); |
|
110 TBool DoIt(CWsWindow * aWin); |
|
111 |
|
112 private: |
|
113 const TPoint & iOffset; |
|
114 }; |
|
115 |
|
116 /** |
|
117 This recalculates the user opaque regions |
|
118 */ |
|
119 class TWalkWindowTreeRecalcOpaque : public TWalkWindowTreeBase |
|
120 { |
|
121 public: |
|
122 TWalkWindowTreeRecalcOpaque(); |
|
123 TBool DoIt(CWsWindow * aWin); |
|
124 }; |
|
125 |
|
126 // Tree walkers which schedule a set of windows to be drawn derive from this |
|
127 class TWalkWindowTreeSchedule: public TWalkWindowTreeBase |
|
128 { |
|
129 public: |
|
130 TWalkWindowTreeSchedule(); |
|
131 CWsWindow * HeadWindow() const; |
|
132 virtual const TRegion * Region(const CWsWindow* aWin) const = 0; |
|
133 protected: |
|
134 CWsWindow* iHead; |
|
135 }; |
|
136 |
|
137 // This walker uses regions to work out the minimum set of pixels that need updating |
|
138 // It requires memory allocation, and so can fail. Check ScheduledRegionsOk before |
|
139 // relying on the results. |
|
140 class TWalkWindowTreeScheduleRegions: public TWalkWindowTreeSchedule |
|
141 { |
|
142 public: |
|
143 TWalkWindowTreeScheduleRegions(RWsRegion *aRegion, const TRegion& aTopLayer); |
|
144 TBool DoIt(CWsWindow *aWin); |
|
145 TBool ScheduledRegionsOk() const; |
|
146 const TRegion * Region(const CWsWindow* aWin) const; |
|
147 private: |
|
148 RWsRegion *iRegion; |
|
149 const TRegion &iTopLayer; |
|
150 TBool iScheduledRegionsOk; |
|
151 }; |
|
152 |
|
153 // This walker uses the screens fallback mechanism. This does not require memory |
|
154 // allocation and so should never fail, but is significantly less efficient than the |
|
155 // region based walker. |
|
156 class TWalkWindowTreeScheduleFallback: public TWalkWindowTreeSchedule |
|
157 { |
|
158 public: |
|
159 TWalkWindowTreeScheduleFallback(CScreen::CFallbackMap * aFallbackMap); |
|
160 TBool DoIt(CWsWindow *aWin); |
|
161 const TRegion * Region(const CWsWindow* aWin) const; |
|
162 private: |
|
163 CScreen::CFallbackMap * iFallbackMap; |
|
164 }; |
|
165 |
|
166 class TWalkWindowTreeFocusChanged : public TWalkWindowTreeBase |
|
167 { |
|
168 public: |
|
169 TWalkWindowTreeFocusChanged(TBool aNewFocusState); |
|
170 TBool DoIt(CWsWindow *aWin); |
|
171 // Data |
|
172 private: |
|
173 TBool iNewFocusState; |
|
174 }; |
|
175 |
|
176 class TResumableWalkWindowTreeFindInvalid : public TResumableWalkWindowTreeBase |
|
177 { |
|
178 public: |
|
179 TResumableWalkWindowTreeFindInvalid(CWsWindowRedraw** aResult); |
|
180 TBool DoIt(CWsWindow* aWin); |
|
181 // Data |
|
182 private: |
|
183 CWsWindowRedraw** iResult; |
|
184 }; |
|
185 |
|
186 class TWalkWindowTreeDisconnect : public TWalkWindowTreeBase |
|
187 { |
|
188 public: |
|
189 TWalkWindowTreeDisconnect(RWsTextCursor *aCursor); |
|
190 TBool DoIt(CWsWindow *aWin); |
|
191 private: |
|
192 RWsTextCursor *iTextCursor; |
|
193 }; |
|
194 |
|
195 class TWalkWindowTreeIsObscured : public TWalkWindowTreeBase |
|
196 { |
|
197 public: |
|
198 TWalkWindowTreeIsObscured(TBool &aResult); |
|
199 TBool DoIt(CWsWindow *aWin); |
|
200 // Data |
|
201 TBool *iResult; |
|
202 }; |
|
203 |
|
204 class TWalkWindowTreeSetNonFading : public TWalkWindowTreeBase |
|
205 { |
|
206 public: |
|
207 TWalkWindowTreeSetNonFading(TBool aNonFading); |
|
208 TBool DoIt(CWsWindow *aWin); |
|
209 // Data |
|
210 const TBool iNonFading; |
|
211 }; |
|
212 |
|
213 class TWalkWindowTreeSetFaded : public TWalkWindowTreeBase |
|
214 { |
|
215 public: |
|
216 TWalkWindowTreeSetFaded(TBool aFaded,CWsWindowBase* aWin,TUint8 aBlackMap,TUint8 aWhiteMap); |
|
217 TBool DoIt(CWsWindow *aWin); |
|
218 // Data |
|
219 const TUint8 iBlackMap; |
|
220 const TUint8 iWhiteMap; |
|
221 const TBool iFaded; |
|
222 const CWsWindowGroup* iGroup; |
|
223 }; |
|
224 |
|
225 class TWalkWindowTreePurgeEvents : public TWalkWindowTreeBase |
|
226 { |
|
227 public: |
|
228 TWalkWindowTreePurgeEvents(); |
|
229 TBool DoIt(CWsWindow *aWin); |
|
230 }; |
|
231 |
|
232 class TWalkWindowTreeCalcInvalidGraphics: public TWalkWindowTreeRegionBase |
|
233 { |
|
234 public: |
|
235 TWalkWindowTreeCalcInvalidGraphics(RWsRegion *aRegion,TRegion &aDirty,const TArray<TGraphicDrawerId>& aInvalid); |
|
236 void CalcInvalid(CScreen& aScreen); |
|
237 TBool CreateSubRegion(); |
|
238 void DoIt2(CWsWindow */*aWin*/) {} |
|
239 TBool DoIt3(CWsWindow *aWin); |
|
240 void DestroyRegions(); |
|
241 private: |
|
242 TRegion& iDirty; |
|
243 const TArray<TGraphicDrawerId>& iInvalid; |
|
244 }; |
|
245 |
|
246 #if defined(_DEBUG) |
|
247 class TWalkWindowTreeCheck : public TWalkWindowTreeBase |
|
248 { |
|
249 public: |
|
250 TBool DoIt(CWsWindow *aWin); |
|
251 }; |
|
252 |
|
253 #endif |
|
254 |
|
255 class TWalkWindowTreeRedrawStoreSize : public TWalkWindowTreeBase |
|
256 { |
|
257 public: |
|
258 TWalkWindowTreeRedrawStoreSize(); |
|
259 TBool DoIt(CWsWindow *aWin); |
|
260 TInt iTotalSize; |
|
261 }; |
|
262 |
|
263 |
|
264 // We can't do a proper find_if unless we are prepared to write our own |
|
265 // mem_fun, but this isn't a bad start |
|
266 class TWalkWindowTreeFindWithFlag : public TWalkWindowTreeBase |
|
267 { |
|
268 public: |
|
269 TWalkWindowTreeFindWithFlag(TUint aFlag) : iFlag(aFlag), iFound(0) { } |
|
270 TBool DoIt(CWsWindow *aWin); |
|
271 CWsWindow * Found() { return iFound; } |
|
272 private: |
|
273 TUint iFlag; |
|
274 CWsWindow * iFound; |
|
275 }; |
|
276 |
|
277 class TWalkWindowTreeFindByHandle : public TWalkWindowTreeBase |
|
278 { |
|
279 public: |
|
280 TWalkWindowTreeFindByHandle(TUint32 aHandle) : iHandle(aHandle) { } |
|
281 TBool DoIt(CWsWindow * aWin); |
|
282 CWsWindow * Found() { return iFound; } |
|
283 private: |
|
284 TUint32 iHandle; |
|
285 CWsWindow * iFound; |
|
286 }; |
|
287 |
|
288 class TWalkWindowTreeReactivateGcs : public TWalkWindowTreeBase |
|
289 { |
|
290 public: |
|
291 TBool DoIt(CWsWindow *aWin); |
|
292 }; |
|
293 |
|
294 class TWalkWindowTreeScheduleFadeNoRedraw : public TWalkWindowTreeBase |
|
295 { |
|
296 public: |
|
297 TWalkWindowTreeScheduleFadeNoRedraw(); |
|
298 TBool DoIt(CWsWindow *aWin); |
|
299 }; |
|
300 |
|
301 #endif |