|
1 /******************************************************************************* |
|
2 * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - S60 implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 |
|
13 #ifndef SWTUIUTILS_H |
|
14 #define SWTUIUTILS_H |
|
15 |
|
16 |
|
17 #include <AknPopupFader.h> |
|
18 #include "eswtwidgetscore.h" |
|
19 |
|
20 |
|
21 class CAknNavigationDecorator; |
|
22 |
|
23 |
|
24 /** |
|
25 * CSwtUiUtils |
|
26 * @lib eswt.dll |
|
27 */ |
|
28 NONSHARABLE_CLASS(CSwtUiUtils) |
|
29 : public CBase |
|
30 , public MSwtUiUtils |
|
31 , public MEikStatusPaneObserver |
|
32 , public MAknFadedComponent |
|
33 { |
|
34 public: |
|
35 /** |
|
36 * Two phase constructor |
|
37 */ |
|
38 static CSwtUiUtils* NewL(MSwtDisplay& aDisplay); |
|
39 |
|
40 /** |
|
41 * Destructor |
|
42 */ |
|
43 ~CSwtUiUtils(); |
|
44 |
|
45 /** |
|
46 * Register shell. |
|
47 * @param aShell |
|
48 */ |
|
49 void RegisterShellL(MSwtShell& aShell); |
|
50 |
|
51 /** |
|
52 * Unregister shell. |
|
53 * @param aShell |
|
54 */ |
|
55 void UnregisterShell(MSwtShell& aShell); |
|
56 |
|
57 /** |
|
58 * Try setting a shell active. See CanBeActive(). |
|
59 * @param aShell The Shell to be made active. |
|
60 * @param aSetFocus Instructs the newly activated Shell to try and set |
|
61 * the focus on one of its children. |
|
62 * @return whether the Shell was actually made active. |
|
63 */ |
|
64 TBool SetActiveShell(MSwtShell& aShell, TBool aSetFocus); |
|
65 |
|
66 /** |
|
67 * Test if a shell can become active taking into account the current |
|
68 * active shell. For instance only modal Shells can become active |
|
69 * when there is already an active Shell. |
|
70 * @param aShell |
|
71 * @param aStrictCheck controls if modality is a factor |
|
72 */ |
|
73 TBool CanBeActive(MSwtShell& aShell, TBool aStrictCheck = ETrue) const; |
|
74 |
|
75 /** |
|
76 * Test if a shell can be displayed as top most (behind active child). |
|
77 * @param aShell |
|
78 */ |
|
79 TBool CanBeTopMost(MSwtShell& aShell) const; |
|
80 |
|
81 /** |
|
82 * Inform that the shell's activity may have changed. |
|
83 * @param aShell |
|
84 */ |
|
85 void ShellActivabilityChanged(MSwtShell& aShell); |
|
86 |
|
87 /** |
|
88 * Sets the pointerGrabbingControl |
|
89 * Calling with NULL of course unsets. |
|
90 */ |
|
91 void SetPointerCaptureControl(MSwtControl* aControl); |
|
92 |
|
93 /** |
|
94 * Returns the current control that is grabbing the pointer events. |
|
95 */ |
|
96 MSwtControl* PointerCaptureControl(); |
|
97 |
|
98 /** |
|
99 * Sets next focused control. This function is called when app lost focus, which stores |
|
100 * a pointer of control that can be focused when app gains focus again. |
|
101 * Calling with NULL of course unsets. |
|
102 * @param aNextFocusedControl The pointer of control that can be focused when app gains focus again. |
|
103 */ |
|
104 void SetNextFocusedControl(MSwtControl* aNextFocusedControl); |
|
105 |
|
106 /** |
|
107 * Returns the control that will gain focus when app gains focus again. |
|
108 */ |
|
109 MSwtControl* NextFocusedControl(); |
|
110 |
|
111 /** |
|
112 * Changes the application focus and sets the given shell to be active. |
|
113 * @param aShell The shell to be activated after gaining to focus. |
|
114 * @param aForeground brings application to foreground if True |
|
115 */ |
|
116 void ChangeAppFocus(MSwtShell& aShell, TBool aForeground); |
|
117 |
|
118 /** |
|
119 * Browser engine dll loading must be done dynamically due to WSD. |
|
120 * This function returns the interface creation function of the dll. |
|
121 * The browser dll is loaded the first time this function is called. |
|
122 */ |
|
123 TLibraryFunction BrowserDllEntryL(); |
|
124 |
|
125 /** |
|
126 * Returns number of active browsers in applicaition. |
|
127 */ |
|
128 TInt ActiveBrowserCount() const; |
|
129 |
|
130 /** |
|
131 * Notifies UiUtils that new instance of Browser was created |
|
132 * and therefore previous garbage browser (and its shell |
|
133 * if neccessary) can be removed. |
|
134 */ |
|
135 void NotifyNewBrowserCreated(); |
|
136 |
|
137 /** |
|
138 * Browser instance must be deleted only just before the application exits. |
|
139 * If attempted earlier, the browser engine dll will crash due to WSD. |
|
140 * This function sets the browser instance to be kept in limbo till app exit. |
|
141 */ |
|
142 void GarbageCollect(MSwtBrowser& aBrowser); |
|
143 |
|
144 /** |
|
145 * Aside with browser we must collect also the window that contains it. |
|
146 */ |
|
147 void GarbageCollect(MSwtShell& aShell); |
|
148 |
|
149 private: |
|
150 /** |
|
151 * First phase constructor. |
|
152 */ |
|
153 CSwtUiUtils(MSwtDisplay& aDisplay); |
|
154 |
|
155 /** |
|
156 * Second phase constructor. |
|
157 */ |
|
158 void ConstructL(); |
|
159 |
|
160 /** |
|
161 * Set active shell. |
|
162 * @param aShell |
|
163 * @param aSetFocus |
|
164 */ |
|
165 void DoSetActiveShell(MSwtShell& aShell, TBool aSetFocus); |
|
166 |
|
167 /** |
|
168 * Search for a shell capable of being active and activate it. The Shell |
|
169 * list is searched in reverse order because this should match the |
|
170 * Shells Z-order. |
|
171 * @return TBool If no Shell found, return EFalse. |
|
172 */ |
|
173 TBool FindAndActivateShell(); |
|
174 |
|
175 /** |
|
176 * Test if a shell is application modal. |
|
177 * @param aShell |
|
178 * @return TBool |
|
179 */ |
|
180 static TBool IsApplicationModal(MSwtShell& aShell); |
|
181 |
|
182 /** |
|
183 * Free memory from eSwt Browser and its children. |
|
184 * @param aComposite The pointer to composite |
|
185 * @return void |
|
186 */ |
|
187 void FreeBrowserRamL(MSwtComposite* aComposite, TInt aEventType); |
|
188 |
|
189 /** |
|
190 * Move a Shell at the end of the Shell queue. |
|
191 */ |
|
192 void MoveToEndOfQueue(MSwtShell& aShell); |
|
193 |
|
194 /** |
|
195 * Highest inline control default font. See InlineReferenceFontHeight. |
|
196 */ |
|
197 const CFont& InlineReferenceFont() const; |
|
198 |
|
199 void HideIndicator(TInt aId); |
|
200 void HideIndicators(); |
|
201 |
|
202 // From MSwtUiUtils |
|
203 public: |
|
204 TRgb GetSystemColor(TSwtColorId aId) const; |
|
205 TFontSpec SystemFontSpec() const; |
|
206 TInt RunMessageBoxDlgLD(MSwtDisplay& aDisplay, const TDesC& aTitle, |
|
207 const TDesC& aMessage, TInt aStyle) const; |
|
208 MSwtShell* GetActiveShell() const |
|
209 { |
|
210 return iActiveShell; |
|
211 }; |
|
212 MSwtShell* GetParentTopShellOfActiveShell() const; |
|
213 MSwtShell* TopMostTopShell() const; |
|
214 TSwtPeer GetActiveShellPeer() const; |
|
215 inline const RPointerArray<MSwtShell>& Shells() const; |
|
216 CSwtPeerArray* GetShellPeersL() const; |
|
217 TSwtPeer GetFocusControl() const; |
|
218 MSwtShell& GetControlTopShell(const MSwtControl& aControl) const; |
|
219 void DrawFocusRect(MSwtGc& aGc, const TRect& aRect) const; |
|
220 CEikButtonGroupContainer& Cba() const; |
|
221 void UpdateStatusPaneL(); |
|
222 TBool IsAppFocused() const; |
|
223 const HBufC* GetCommandOkTitleL() const; |
|
224 const HBufC* GetCommandCancelTitleL() const; |
|
225 TInt GetPointerEventStateMask(TUint aPointerEventModifiers) const; |
|
226 MSwtShell* FadingShell() const |
|
227 { |
|
228 return iFadingShell; |
|
229 }; |
|
230 TMargins8 InlineReferencePadding() const; |
|
231 TInt InlineReferenceFontHeight() const; |
|
232 void SetAppNameL(const TDesC* aAppName); |
|
233 TSize GetBestImageSize(TInt aImageType); |
|
234 void HandleResourceChangedL(TInt aType); |
|
235 TInt ScrollBarBreadth(const CEikScrollBar* aBar); |
|
236 TBool NaviKeyInput() const; |
|
237 void SetNaviKeyInput(TBool aStatus); |
|
238 void SetCbaVisible(TBool aVisible); |
|
239 MSwtControl* GetPointerGrabbingControl(); |
|
240 |
|
241 protected: |
|
242 void HandleFreeRamEventL(TInt aEventType); |
|
243 |
|
244 // From MSwtAppFocusObserver |
|
245 public: |
|
246 void HandleAppFocusChangeL(TBool aFocused); |
|
247 |
|
248 // From MEikStatusPaneObserver |
|
249 public: |
|
250 void HandleStatusPaneSizeChange(); |
|
251 |
|
252 private: |
|
253 void SetShellFade(MSwtShell* aShell, TBool aStatus); |
|
254 TBool CanBeFaded(MSwtShell* aShell) const; |
|
255 |
|
256 // From MAknFadedComponent |
|
257 public: |
|
258 TInt CountFadedComponents(); |
|
259 CCoeControl* FadedComponent(TInt aIndex); |
|
260 |
|
261 // Data |
|
262 private: |
|
263 /** |
|
264 * Display reference needed for getting CEikEnv for now. |
|
265 */ |
|
266 MSwtDisplay& iDisplay; |
|
267 |
|
268 /** |
|
269 * All shells. |
|
270 * Not own. |
|
271 */ |
|
272 RPointerArray<MSwtShell> iShells; |
|
273 |
|
274 /** |
|
275 * The currently active shell. Can be NULL. |
|
276 * Not own. |
|
277 */ |
|
278 MSwtShell* iActiveShell; |
|
279 |
|
280 /** |
|
281 * The next shell to be made active. Can be NULL. |
|
282 * See HandleFocusLost(), HandleFocusLost() |
|
283 * Not own. |
|
284 */ |
|
285 MSwtShell* iNextActiveShell; |
|
286 |
|
287 /** |
|
288 * The next control to focus. |
|
289 * Not own. |
|
290 */ |
|
291 MSwtControl* iNextFocusedControl; |
|
292 |
|
293 /** |
|
294 * Focus lost flag. |
|
295 * See HandleFocusLost(), HandleFocusLost(). |
|
296 */ |
|
297 TBool iFocusLost; |
|
298 |
|
299 /** |
|
300 * CBA, cannot be NULL |
|
301 * Own. |
|
302 */ |
|
303 CEikButtonGroupContainer* iCba; |
|
304 |
|
305 /** |
|
306 * The NaviDecorator which contain the text set by SetNaviPaneText() |
|
307 * Not own. |
|
308 */ |
|
309 CAknNavigationDecorator* iNaviDecorator; |
|
310 |
|
311 /** |
|
312 * The Status Pane |
|
313 * Not own. |
|
314 */ |
|
315 CEikStatusPane* iStatusPane; |
|
316 |
|
317 /** |
|
318 * Pointer to the control that has been |
|
319 * set pointer capturing with setCapture. |
|
320 * Not Own |
|
321 */ |
|
322 MSwtControl* iPointerCaptureControl; |
|
323 |
|
324 /** |
|
325 * Browser engine dll. |
|
326 */ |
|
327 RLibrary iBrowserEngineLib; |
|
328 |
|
329 /** |
|
330 * Entry point of browser engine dll. |
|
331 */ |
|
332 TLibraryFunction iBrowserDllEntry; |
|
333 |
|
334 /** |
|
335 * Number of currently existing browser instances. |
|
336 */ |
|
337 TInt iCurrentBrowserCount; |
|
338 |
|
339 /** |
|
340 * Browser instance must be deleted only just before the application exits. |
|
341 * If attempted earlier, the browser engine dll will crash due to WSD. |
|
342 * This is the browser instance to be kept in limbo till app exit. |
|
343 */ |
|
344 MSwtBrowser* iBrowserGarbage; |
|
345 |
|
346 /** |
|
347 * Shell instance to be also garbage collected together with browser. |
|
348 * The browser needs to have the parent window alive till destroyed. |
|
349 */ |
|
350 MSwtShell* iBrowserShellGarbage; |
|
351 |
|
352 /** |
|
353 * Flag signalling whether Browser's parent shell was requested to |
|
354 * collect. |
|
355 */ |
|
356 TBool iShellGarbageCollectionRequested; |
|
357 |
|
358 /** |
|
359 * The string of status text separator. |
|
360 */ |
|
361 HBufC* iSeparatorString; |
|
362 |
|
363 /** |
|
364 * Keep track of top most shells. |
|
365 */ |
|
366 MSwtShell* iLastTopMostShell; |
|
367 |
|
368 /** |
|
369 * Used to fade the whole system behind modal child shells. |
|
370 */ |
|
371 TAknPopupFader iFader; |
|
372 |
|
373 /** |
|
374 * The Shell which fades behind. |
|
375 */ |
|
376 MSwtShell* iFadingShell; |
|
377 |
|
378 /** |
|
379 * Used by display appName to set the title for status pane. |
|
380 * Own. |
|
381 */ |
|
382 TDesC* iAppName; |
|
383 |
|
384 /** |
|
385 * Cached scrollbar breadth. Valid till next resolution change. |
|
386 */ |
|
387 TInt iScrollBarBreadth; |
|
388 |
|
389 /** |
|
390 * Inline reference stuff |
|
391 */ |
|
392 mutable const CFont* iInlineFont; |
|
393 mutable TInt iInlineFontHeight; |
|
394 mutable TMargins8 iInlinePadding; |
|
395 |
|
396 /** |
|
397 * Key input flag. |
|
398 */ |
|
399 TBool iNaviKeyInput; |
|
400 }; |
|
401 |
|
402 /** |
|
403 * Return the existing shells |
|
404 */ |
|
405 inline const RPointerArray<MSwtShell>& CSwtUiUtils::Shells() const |
|
406 { |
|
407 return iShells; |
|
408 } |
|
409 |
|
410 |
|
411 #endif // SWTUIUTILS_H |