|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Declares main container control for Widget Manager application. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef WMMAINCONTAINER_H |
|
20 #define WMMAINCONTAINER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32cmn.h> |
|
24 #include <f32file.h> |
|
25 #include <coecobs.h> |
|
26 #include <coecntrl.h> |
|
27 #include <AknsUtils.h> |
|
28 #include <gulicon.h> |
|
29 #include <eiklbo.h> // MEikListBoxObserver |
|
30 #include <aknsfld.h> // MAdaptiveSearchTextObserver |
|
31 #include "wmwidgetloaderao.h" |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CWmPlugin; |
|
35 class CWmListBox; |
|
36 class CAknsBasicBackgroundControlContext; |
|
37 class CAknViewAppUi; |
|
38 class CAknSearchField; |
|
39 class CCoeControl; |
|
40 class CAknSearchField; |
|
41 class CWmPortalButton; |
|
42 class CWmMainContainerView; |
|
43 class CWmConfiguration; |
|
44 |
|
45 /** |
|
46 * Container class for WmMainContainer |
|
47 * |
|
48 * @class CWmMainContainer WmMainContainer.h |
|
49 */ |
|
50 NONSHARABLE_CLASS( CWmMainContainer ) : public CCoeControl, |
|
51 public MEikListBoxObserver, |
|
52 public MAdaptiveSearchTextObserver, |
|
53 public MWmWidgetloaderObserver |
|
54 { |
|
55 public: // constructors and destructor |
|
56 |
|
57 /* |
|
58 * Two-phased constructor. |
|
59 * |
|
60 * @param aRect container rect |
|
61 * @param aWmPlugin wm plugin |
|
62 */ |
|
63 static CWmMainContainer* NewL( |
|
64 const TRect& aRect, |
|
65 CWmPlugin& aWmPlugin ); |
|
66 |
|
67 /* |
|
68 * Two-phased constructor. |
|
69 * |
|
70 * @param aRect container rect |
|
71 * @param aWmPlugin wm plugin |
|
72 */ |
|
73 static CWmMainContainer* NewLC( |
|
74 const TRect& aRect, |
|
75 CWmPlugin& aWmPlugin ); |
|
76 |
|
77 /** Destructor */ |
|
78 virtual ~CWmMainContainer(); |
|
79 |
|
80 private: |
|
81 /** constructor */ |
|
82 CWmMainContainer( |
|
83 CWmPlugin& aWmPlugin ); |
|
84 |
|
85 /** 2nd phase constructor */ |
|
86 void ConstructL( |
|
87 const TRect& aRect ); |
|
88 |
|
89 public: // new functions |
|
90 |
|
91 /** |
|
92 * @return true, if widgets loading operation is ongoing. |
|
93 */ |
|
94 TBool IsLoadingWidgets(); |
|
95 |
|
96 /** |
|
97 * @return true, if portal button is currently selected |
|
98 */ |
|
99 TBool PortalSelected(); |
|
100 |
|
101 /** |
|
102 * @return true, if a widget in list is currently selected |
|
103 */ |
|
104 TBool WidgetSelected(); |
|
105 |
|
106 /** |
|
107 * @return true, ADD command is possible |
|
108 */ |
|
109 TBool CanDoAdd(); |
|
110 |
|
111 /** |
|
112 * @return true, if UNINSTALL command is possible |
|
113 */ |
|
114 TBool CanDoUninstall(); |
|
115 |
|
116 /** |
|
117 * @return true, if LAUNCH command is possible |
|
118 */ |
|
119 TBool CanDoLaunch(); |
|
120 |
|
121 /** |
|
122 * @return true, if FIND command is possible |
|
123 */ |
|
124 TBool CanDoFind(); |
|
125 |
|
126 /** |
|
127 * @return true, if SORT command is possible |
|
128 */ |
|
129 TBool CanDoSort(); |
|
130 |
|
131 /** |
|
132 * @return true, if DETAILS command is possible |
|
133 */ |
|
134 TBool CanDoDetails(); |
|
135 |
|
136 /** |
|
137 * @return true, if HELP command is possible |
|
138 */ |
|
139 TBool CanDoHelp(); |
|
140 |
|
141 /** |
|
142 * executes widget details dialog launch |
|
143 */ |
|
144 void LaunchDetailsDialogL(); |
|
145 |
|
146 /** |
|
147 * executes widget addition to home screen |
|
148 */ |
|
149 void AddWidgetToHomeScreenL(); |
|
150 |
|
151 /** |
|
152 * executes widget launch |
|
153 */ |
|
154 void LaunchWidgetL(); |
|
155 |
|
156 /** |
|
157 * executes findbox activation |
|
158 */ |
|
159 void ActivateFindPaneL( TBool aActivateAdaptive = EFalse ); |
|
160 |
|
161 /** |
|
162 * executes findbox deactivation |
|
163 */ |
|
164 void DeactivateFindPaneL(TBool aLayout = ETrue); |
|
165 |
|
166 /** |
|
167 * sorts the widget list in alphabetical order |
|
168 */ |
|
169 void SortListAlphabeticallyL(); |
|
170 |
|
171 /** |
|
172 * executes widget uninstall |
|
173 */ |
|
174 void UninstallWidgetL(); |
|
175 |
|
176 /** |
|
177 * opens currently selected portal |
|
178 */ |
|
179 void OpenPortalL(); |
|
180 |
|
181 /** |
|
182 * Selection key (middle soft key) |
|
183 */ |
|
184 void SelectL(); |
|
185 |
|
186 /** |
|
187 * Show widget manager help |
|
188 */ |
|
189 void ShowHelpL(); |
|
190 |
|
191 /** |
|
192 * handles situation when widget list has changed. |
|
193 * in practice reloads the widget list from the widgets API |
|
194 * and redraws the screen. |
|
195 */ |
|
196 void HandleWidgetListChanged(); |
|
197 |
|
198 public: |
|
199 |
|
200 /** |
|
201 * Handles focus changed events. |
|
202 * |
|
203 * @see CCoeControl::FocusChanged |
|
204 */ |
|
205 void FocusChanged( TDrawNow aDrawNow ); |
|
206 |
|
207 /** |
|
208 * Handles key events. |
|
209 * |
|
210 * @see CCoeControl::OfferKeyEventL |
|
211 */ |
|
212 TKeyResponse OfferKeyEventL( |
|
213 const TKeyEvent& aKeyEvent, |
|
214 TEventCode aType ); |
|
215 |
|
216 /** |
|
217 * Handles a change to the control's resources |
|
218 * |
|
219 * @see CCoeControl::HandleResourceChange |
|
220 */ |
|
221 void HandleResourceChange( TInt aType ); |
|
222 |
|
223 /** |
|
224 * Handles pointer events. |
|
225 * |
|
226 * @see CCoeControl::HandlePointerEventL |
|
227 */ |
|
228 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
229 |
|
230 /** |
|
231 * Moves focus to the OVI button |
|
232 * @param aIndex 0=first button, 1=second (if it exists) |
|
233 */ |
|
234 void SetFocusToPortalButton( TInt aIndex ); |
|
235 |
|
236 /** |
|
237 * Moves focus to the widgets list, alternatively also setting the currently |
|
238 * selected item. |
|
239 * @param aIndex the item in widgets list to highlight during setting focus. |
|
240 * By default the previously selected item will be highlighted. |
|
241 */ |
|
242 void SetFocusToWidgetList( TInt aIndex = KErrUnknown ); |
|
243 |
|
244 /* |
|
245 * Tells if user inputs should be handeled or not. If ret is EFalse wm |
|
246 * can ignore user inputs. This is becouse closing view is async and user |
|
247 * might give some inputs before view is closed. |
|
248 */ |
|
249 TBool ClosingDown(); |
|
250 |
|
251 /* |
|
252 * To set iClosingDown. See above. |
|
253 */ |
|
254 void SetClosingDown( TBool aClosingDown ); |
|
255 |
|
256 /** |
|
257 * access to WM configuration |
|
258 */ |
|
259 CWmConfiguration& Configuration(); |
|
260 |
|
261 /** |
|
262 * Process foregound events. |
|
263 * @param aForeground ETrue indicates foreground |
|
264 */ |
|
265 void ProcessForegroundEvent( TBool aForeground ); |
|
266 |
|
267 /** |
|
268 * access to WM list |
|
269 */ |
|
270 CWmListBox& WmListBox(); |
|
271 |
|
272 protected: // from base class CCoeControl |
|
273 |
|
274 /** |
|
275 * Sets the control's extent, specifying a rectangle. |
|
276 * |
|
277 * @see CCoeControl::SizeChanged |
|
278 */ |
|
279 void SizeChanged(); |
|
280 |
|
281 private: // from base class CCoeControl |
|
282 |
|
283 /* |
|
284 * Draws the control. |
|
285 * |
|
286 * @see CCoeControl::Draw |
|
287 */ |
|
288 void Draw( const TRect& aRect ) const; |
|
289 |
|
290 /** |
|
291 * Suppy Mop object for control context |
|
292 * @param TTypeUid aId |
|
293 */ |
|
294 TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
295 |
|
296 private: // from MEikListBoxObserver |
|
297 |
|
298 /** |
|
299 * List box observer interface. |
|
300 * |
|
301 * @see MEikListBoxObserver::HandleListBoxEventL |
|
302 */ |
|
303 void HandleListBoxEventL( |
|
304 CEikListBox* aListBox, |
|
305 TListBoxEvent aEventType); |
|
306 |
|
307 private: // from MAdaptiveSearchTextObserver |
|
308 /** |
|
309 * Adaptive search observer interface. |
|
310 * |
|
311 * @see MAdaptiveSearchTextObserver::AdaptiveSearchTextChanged |
|
312 */ |
|
313 void AdaptiveSearchTextChanged( CAknSearchField* aSearchField ); |
|
314 |
|
315 private: // New functions |
|
316 |
|
317 void AddControlL( CCoeControl* aControl, TInt aControlId ); |
|
318 void InitializeControlsL( const TRect& aRect ); |
|
319 void LayoutControls(); |
|
320 void StartLoadingWidgetsL(); |
|
321 void RemoveCtrlsFromStack(); |
|
322 void UpdateFocusMode(); |
|
323 void ResetFocus( TDrawNow aDrawNow = ENoDrawNow ); |
|
324 CCoeControl* FindChildControlByPoint( const TPoint& aPoint ); |
|
325 void HandleFindSizeChanged(); |
|
326 TKeyResponse MoveFocusByKeys( |
|
327 const TKeyEvent& aKeyEvent, |
|
328 TEventCode aType ); |
|
329 TKeyResponse HandleButtonKeyEventL( |
|
330 const TKeyEvent& aKeyEvent, |
|
331 TEventCode aType ); |
|
332 TKeyResponse HandleListKeyEventL( |
|
333 const TKeyEvent& aKeyEvent, |
|
334 TEventCode aType ); |
|
335 TKeyResponse HandleSearchKeyEventL( |
|
336 const TKeyEvent& aKeyEvent, |
|
337 TEventCode aType ); |
|
338 TInt OperatorButtonHigherPriority( TInt aIndex ); |
|
339 |
|
340 public: // from MWmWidgetloaderObserver |
|
341 void LoadDoneL( TBool aWidgetListChanged ); |
|
342 |
|
343 private: |
|
344 |
|
345 /** |
|
346 * the plugin root |
|
347 */ |
|
348 CWmPlugin& iWmPlugin; |
|
349 |
|
350 /** |
|
351 * the widgets list |
|
352 */ |
|
353 CWmListBox* iWidgetsList; |
|
354 |
|
355 /** |
|
356 * search filed |
|
357 */ |
|
358 CAknSearchField* iFindbox; |
|
359 |
|
360 /** |
|
361 * search filed visibility switch |
|
362 */ |
|
363 TBool iFindPaneIsVisible; |
|
364 |
|
365 /** |
|
366 * background |
|
367 */ |
|
368 CAknsBasicBackgroundControlContext* iBgContext; |
|
369 |
|
370 /** |
|
371 * portal button |
|
372 * (if there is only one button, this is it) |
|
373 */ |
|
374 CWmPortalButton* iPortalButtonOne; |
|
375 |
|
376 /** |
|
377 * portal button |
|
378 * (if there is only one button, this is NULL) |
|
379 */ |
|
380 CWmPortalButton* iPortalButtonTwo; |
|
381 |
|
382 /** whether we are orientated in landscape */ |
|
383 TBool iLandscape; |
|
384 |
|
385 /** whether we have mirrored layout */ |
|
386 TBool iMirrored; |
|
387 |
|
388 /** focus modes */ |
|
389 enum TWmFocusMode |
|
390 { |
|
391 ENowhere, |
|
392 EPortal, |
|
393 EList, |
|
394 EFind |
|
395 }; |
|
396 |
|
397 /** |
|
398 * current widget manager focus mode |
|
399 */ |
|
400 TWmFocusMode iFocusMode; |
|
401 |
|
402 /** |
|
403 * AO for loading widgets into the list UI |
|
404 */ |
|
405 CWmWidgetLoaderAo* iWidgetLoader; |
|
406 |
|
407 /** |
|
408 * If this is set to ETrue it means wmview is closing and all user inputs |
|
409 * should be ignored. |
|
410 */ |
|
411 TBool iClosingDown; |
|
412 |
|
413 /** |
|
414 * The configuration |
|
415 */ |
|
416 CWmConfiguration* iConfiguration; |
|
417 |
|
418 #ifdef _WM_UNIT_TEST |
|
419 friend class CWmUnitTest; |
|
420 #endif |
|
421 }; |
|
422 |
|
423 #endif // WMMAINCONTAINER_H |
|
424 |
|
425 // End of File |