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