1 /* |
|
2 * ============================================================================ |
|
3 * Name : hgteleportfastswaparea.h |
|
4 * Part of : Hg Teleport |
|
5 * Description : Teleport Fast Swap area UI |
|
6 * Version : %version: sa1spcx1#45 % |
|
7 * |
|
8 * Copyright © 2008 Nokia. All rights reserved. |
|
9 * This material, including documentation and any related computer |
|
10 * programs, is protected by copyright controlled by Nokia. All |
|
11 * rights are reserved. Copying, including reproducing, storing, |
|
12 * adapting or translating, any or all of this material requires the |
|
13 * prior written consent of Nokia. This material also contains |
|
14 * confidential information which may not be disclosed to others |
|
15 * without the prior written consent of Nokia. |
|
16 * ============================================================================ |
|
17 * |
|
18 */ |
|
19 |
|
20 //macro TASKSWITCHER_USE_CUSTOM_LAYOUT |
|
21 #if !defined ( TASKSWITCHER_USE_CUSTOM_LAYOUT ) |
|
22 //#define TASKSWITCHER_USE_CUSTOM_LAYOUT 1 |
|
23 #endif |
|
24 |
|
25 |
|
26 #ifndef HGTELEPORTFASTSWAPAREA_H |
|
27 #define HGTELEPORTFASTSWAPAREA_H |
|
28 |
|
29 #include <e32base.h> |
|
30 #include <eikmobs.h> |
|
31 #include "hgteleportdevicestate.h" |
|
32 #include "hgfswclientobserver.h" |
|
33 #include "hgteleportfastswapgrid.h" |
|
34 #include "hgteleporteventcontrolerobserver.h" |
|
35 |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CHgFswClient; |
|
39 class CHgFswEntry; |
|
40 class CAknStylusPopUpMenu; |
|
41 class CAknQueryDialog; |
|
42 class CHgTeleportEventControler; |
|
43 class MHgTeleportDataChangeObserver; |
|
44 |
|
45 #ifdef TASKSWITCHER_USE_CUSTOM_LAYOUT |
|
46 const TInt KFswItemHeight = 250; |
|
47 const TInt KFswItemWidth = 240; |
|
48 const TInt KFswImageSize = 200; |
|
49 const TInt KFswTextHeight = 20; |
|
50 const TInt KFswBorderSize = 10; |
|
51 const TInt KFswHeadingHeight = 50; |
|
52 #endif |
|
53 |
|
54 /** |
|
55 * Teleport Fast Swap area UI. |
|
56 */ |
|
57 class CHgTeleportFastSwapArea: public CCoeControl, |
|
58 public MEikMenuObserver, |
|
59 public MHgFswObserver, |
|
60 public MEikListBoxObserver, |
|
61 public MHgTeleportFastSwapGridObserver, |
|
62 private MHgTeleportEventControlerObserver, |
|
63 public MHgDeviceStateObserver, |
|
64 public MHgTeleportFastSwapTimerObserver |
|
65 { |
|
66 public: |
|
67 /** |
|
68 * Two-phase constructor. |
|
69 * |
|
70 * @param aRect Area where fast swap info & list should draw itself. |
|
71 * @param aParent Parent CoeControl. |
|
72 */ |
|
73 static CHgTeleportFastSwapArea* NewL( const TRect& aRect, |
|
74 CCoeControl& aParent, CHgTeleportDeviceState& aDeviceState, |
|
75 CHgTeleportEventControler& aEventHandler); |
|
76 |
|
77 /** |
|
78 * @copydoc NewL |
|
79 */ |
|
80 static CHgTeleportFastSwapArea* NewLC( const TRect& aRect, |
|
81 CCoeControl& aParent, CHgTeleportDeviceState& aDeviceState, |
|
82 CHgTeleportEventControler& aEventHandler); |
|
83 |
|
84 /** |
|
85 * Destructor. |
|
86 */ |
|
87 ~CHgTeleportFastSwapArea(); |
|
88 |
|
89 /** |
|
90 * Called from appview when coming to foreground. |
|
91 */ |
|
92 void HandleSwitchToForegroundEvent(); |
|
93 |
|
94 /** |
|
95 * Called from appview when going to background. |
|
96 */ |
|
97 void HandleSwitchToBackgroundEvent(); |
|
98 |
|
99 /** |
|
100 * Called after construction to set up additional properties, |
|
101 * like the control observer. |
|
102 */ |
|
103 void Setup( MCoeControlObserver& aControlObserver ); |
|
104 |
|
105 /** |
|
106 * Saves the index of the currently selected (highlighted) item. |
|
107 */ |
|
108 void SaveSelectedIndex(); |
|
109 |
|
110 /** |
|
111 * Restores the selection (highlight) position. |
|
112 */ |
|
113 void RestoreSelectedIndex(); |
|
114 |
|
115 // Functions to perform activate, close, close others operations. |
|
116 // They are public so same functionality can be implemented in the |
|
117 // Options menu (appui) for example. |
|
118 |
|
119 /** |
|
120 * Index of highlighted item or KErrNotFound. |
|
121 */ |
|
122 TInt SelectedIndex() const; |
|
123 |
|
124 /** |
|
125 * Brings the app corresponding to the item at given index into foreground. |
|
126 */ |
|
127 void SwitchToApp( TInt aIndex ); |
|
128 |
|
129 /** |
|
130 * Sends close msg to given app. |
|
131 * @param aIndex index |
|
132 * @param aSuppressRendering content is not refreshed if ETrue |
|
133 */ |
|
134 void TryCloseAppL( TInt aIndex, TBool aSuppressRendering = EFalse ); |
|
135 |
|
136 /** |
|
137 * Sends close msg to given app if user confirms the query. |
|
138 */ |
|
139 void TryCloseAppWithQueryL( TInt aIndex ); |
|
140 |
|
141 /** |
|
142 * Tries to Close all applications that cn be closed |
|
143 */ |
|
144 void TryCloseAllL(); |
|
145 |
|
146 /** |
|
147 * True if it is allowed to ask the given app to close. |
|
148 * @param aIndex index |
|
149 */ |
|
150 TBool CanClose( TInt aIndex ) const; |
|
151 |
|
152 /** |
|
153 * @param aSelectedItem item for which pop up is shown |
|
154 * |
|
155 * @return ETrue, when number of closable apps is >= 2 or there is at least |
|
156 * one closable item and non closable item is selected. |
|
157 * @return EFalse, when number of closable apps is < 2. |
|
158 */ |
|
159 TBool CanCloseAll( TInt aSelectedItem ) const; |
|
160 |
|
161 /** |
|
162 * Returns the number of items in the list. |
|
163 */ |
|
164 TInt Count() const; |
|
165 |
|
166 /** |
|
167 * Returns the underlying Ganes control pointer. |
|
168 */ |
|
169 CCoeControl* GetChildControl() { return iGrid; } |
|
170 |
|
171 /** |
|
172 * Sets the data-changed observer. |
|
173 */ |
|
174 void SetDataChangeObserver( MHgTeleportDataChangeObserver* aDcObserver ); |
|
175 |
|
176 /* |
|
177 * Handling short/long app key. |
|
178 */ |
|
179 void HandleAppKey(TInt aType); |
|
180 |
|
181 private: |
|
182 |
|
183 /** |
|
184 * @copydoc NewL |
|
185 */ |
|
186 void ConstructL( const TRect& aRect ); |
|
187 |
|
188 /** |
|
189 * C++ constructor. |
|
190 */ |
|
191 CHgTeleportFastSwapArea(CCoeControl& aParent, |
|
192 CHgTeleportDeviceState& aDeviceState, |
|
193 CHgTeleportEventControler& aEventHandler); |
|
194 |
|
195 // From MEikListBoxObserver |
|
196 void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); |
|
197 |
|
198 public: |
|
199 /** |
|
200 * Implements drag gesture handling |
|
201 * @see MHgTeleportEventControlerObserver |
|
202 */ |
|
203 void MoveOffset(const TPoint&); |
|
204 |
|
205 /** |
|
206 * Implements tap gesture handling |
|
207 * @see MHgTeleportEventControlerObserver |
|
208 */ |
|
209 void TapL(const TPoint&); |
|
210 |
|
211 /** |
|
212 * Implements long tap gesture handling |
|
213 * @see MHgTeleportEventControlerObserver |
|
214 */ |
|
215 void LongTapL(const TPoint&); |
|
216 |
|
217 /** |
|
218 * Implements drag gesture handling |
|
219 * @see MHgTeleportEventControlerObserver |
|
220 */ |
|
221 void Drag(const AknTouchGestureFw::MAknTouchGestureFwDragEvent& aEvent); |
|
222 |
|
223 /** |
|
224 * Implements animation stop handling |
|
225 * @see MHgTeleportEventControlerObserver |
|
226 */ |
|
227 void Stop(); |
|
228 |
|
229 /** |
|
230 * Implements view position getter. Returns point in the middle of the |
|
231 * grid view window. |
|
232 * |
|
233 * @see MHgTeleportEventControlerObserver |
|
234 */ |
|
235 TPoint ViewPos()const; |
|
236 |
|
237 public: |
|
238 // from CCoeControl |
|
239 TInt CountComponentControls() const; |
|
240 CCoeControl* ComponentControl(TInt aIndex) const; |
|
241 void FocusChanged( TDrawNow aDrawNow ); |
|
242 void SizeChanged(); |
|
243 void Draw( const TRect& aRect ) const; |
|
244 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
245 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
246 |
|
247 private: |
|
248 // From MHgFswObserver |
|
249 void HandleFswContentChanged(); |
|
250 |
|
251 // From MEikMenuObserver |
|
252 void ProcessCommandL( TInt aCommandId ); |
|
253 void SetEmphasis( CCoeControl*, TBool ) { } |
|
254 |
|
255 // From MHgTeleportFastSwapGridObserver |
|
256 void HandleCloseEventL(TInt aItemIdx); |
|
257 |
|
258 // From MHgDeviceStateObserver |
|
259 void HandleDeviceStateChanged( TChangeType aChangeType ); |
|
260 |
|
261 // From MHgTeleportFastSwapTimerObserver |
|
262 void TimerCompletedL( CHgTeleportFastSwapTimer* aSource ); |
|
263 |
|
264 // new functions |
|
265 |
|
266 /** |
|
267 * Makes a copy of the given bitmap. |
|
268 * Also scaled to the given size, but maintains aspect ratio, |
|
269 * so the size of the returned bitmap may be less then aSize. |
|
270 */ |
|
271 CFbsBitmap* CopyBitmapL( TInt aFbsHandle, TSize aSize ); |
|
272 |
|
273 /** |
|
274 * Called from HandleFswContentChanged. |
|
275 */ |
|
276 void HandleFswContentChangedL(); |
|
277 |
|
278 /** |
|
279 * Shows the content from iArray on the screen. |
|
280 */ |
|
281 void RenderContentL(); |
|
282 |
|
283 /** |
|
284 * Creates the ganes grid control. |
|
285 */ |
|
286 void ReCreateGridL(); |
|
287 |
|
288 /** |
|
289 * Returns rectangles for fast swap area controls |
|
290 */ |
|
291 void GetFastSwapAreaRects( RArray<TAknLayoutRect>& aRects ); |
|
292 |
|
293 /** |
|
294 * Creates a stylus popup instance (iPopup) if not yet done. |
|
295 */ |
|
296 void PreCreatePopupL(); |
|
297 |
|
298 /** |
|
299 * Shows the stylus popup menu if not yet visible. |
|
300 * @param aIndex index of item in the grid |
|
301 * @param aPoint position for the popup |
|
302 */ |
|
303 TBool ShowPopupL( TInt aIndex, const TPoint& aPoint ); |
|
304 |
|
305 /** |
|
306 * Shows the app close confirmation query. |
|
307 * @param aIndex index of item in the grid |
|
308 * @return ETrue if accepted EFalse if canceled |
|
309 */ |
|
310 TBool ConfirmCloseL( TInt aIndex ); |
|
311 |
|
312 /** |
|
313 * Sends the data-changed notification. |
|
314 */ |
|
315 void NotifyChange(); |
|
316 |
|
317 /** |
|
318 * Chage application order. |
|
319 * move Homescreen to first left position. |
|
320 */ |
|
321 void SwapApplicationOrder( RPointerArray<CHgFswEntry>& aArray ); |
|
322 |
|
323 /** |
|
324 * Retrieves and returns size for image graphics. |
|
325 */ |
|
326 TSize PreferredImageSize(); |
|
327 |
|
328 /** |
|
329 * Retrieves number of items in grid |
|
330 */ |
|
331 TInt GridItemCount(); |
|
332 |
|
333 /** |
|
334 * Calculates the correct size if aspect ratio needs to be preserved. |
|
335 */ |
|
336 TSize CalculateSizePreserveRatio(const TSize& aTargetAreaSize, |
|
337 const TSize& aSourceSize); |
|
338 |
|
339 /** |
|
340 * Selects next item in grid |
|
341 */ |
|
342 void SelectNextItem(); |
|
343 |
|
344 /** |
|
345 * Highlight current grid'd item and redraw |
|
346 */ |
|
347 void ShowHighlight(); |
|
348 |
|
349 /** |
|
350 * Centralise most centered item so it was most exposed on the view. |
|
351 * Centered element is being selected by grid. |
|
352 * Animation to the centered element is made after aRedrawDelay time. |
|
353 * |
|
354 * @param aRedrawDelay - animation delay. |
|
355 */ |
|
356 void CenterItem( TInt aRedrawDelay); |
|
357 |
|
358 /** |
|
359 * Returns full grid view size. |
|
360 */ |
|
361 TSize GridWorldSize(); |
|
362 |
|
363 /** |
|
364 * Updates grid, called for manual grid scroll update |
|
365 * |
|
366 * @param aForceRedraw if set to ETrue - redraw will be forced |
|
367 * @param aAnimate set to ETrue to enable animation |
|
368 */ |
|
369 void UpdateGrid( TBool aForceRedraw = EFalse, |
|
370 TBool aAnimate = ETrue ); |
|
371 |
|
372 /** |
|
373 * Returns grid view size |
|
374 */ |
|
375 TSize ViewSize(); |
|
376 |
|
377 /** |
|
378 * Returns the position of the given item inside grid world rect. |
|
379 * Returns point in the middle of the view rectangle. |
|
380 * |
|
381 * @param aItemIdx index of the item for which calculation will be done |
|
382 */ |
|
383 TPoint ItemViewPosition( TInt aItemIdx ); |
|
384 |
|
385 /** |
|
386 * Returns index of the shown item, based on the logical |
|
387 * position of the grids view. Item that is closest to the |
|
388 * middle of screen is returned. |
|
389 * |
|
390 * @param aViewPos grids view position. This must be point in |
|
391 * the middle of the view rectangle |
|
392 * @return index of the item |
|
393 */ |
|
394 TInt ViewToVisibleItem( const TPoint aViewPos ); |
|
395 |
|
396 /** |
|
397 * Launches increasing pop-up feedback. |
|
398 */ |
|
399 void LaunchPopupFeedback(); |
|
400 |
|
401 private: // Data |
|
402 |
|
403 // parent control |
|
404 CCoeControl& iParent; |
|
405 |
|
406 // device state |
|
407 // not own |
|
408 CHgTeleportDeviceState& iDeviceState; |
|
409 |
|
410 // grid, own |
|
411 CHgTeleportFastSwapGrid* iGrid; |
|
412 |
|
413 // fsw client, own |
|
414 CHgFswClient* iFSClient; |
|
415 // fsw content, ptrs owned |
|
416 RPointerArray<CHgFswEntry> iArray; |
|
417 |
|
418 // index of selected (highlighted) item in the grid |
|
419 // when the fsw was last focused |
|
420 TInt iSavedSelectedIndex; |
|
421 |
|
422 // fsw popup (activate, close, etc.), own |
|
423 CAknStylusPopUpMenu* iPopup; |
|
424 // the aIndex argument of ShowPopupL is stored here |
|
425 TInt iAppIndexForPopup; |
|
426 |
|
427 // query shown when pressing Clear key in fsw, own |
|
428 CAknQueryDialog* iConfirmCloseQuery; |
|
429 |
|
430 // Timestamp of the last application close operation |
|
431 TTime iTimeOfLastClose; |
|
432 |
|
433 // Observer ptr, may be NULL, not owned |
|
434 MHgTeleportDataChangeObserver* iDcObserver; |
|
435 |
|
436 //Input events handler |
|
437 CHgTeleportEventControler& iEvtHandler; |
|
438 |
|
439 TInt iMaxItemsOnScreen; |
|
440 TInt iPreviousNoOfItems; |
|
441 |
|
442 // Tap event |
|
443 TPointerEvent iTapEvent; |
|
444 CHgTeleportFastSwapTimer* iHighlightTimer; |
|
445 TBool iLongTap; |
|
446 |
|
447 // Grid scrolling |
|
448 TInt iGridItemWidth; |
|
449 |
|
450 CHgTeleportFastSwapTimer* iRedrawTimer; // owned |
|
451 |
|
452 CHgTeleportFastSwapTimer* iUpdateGridTimer;//owned |
|
453 |
|
454 // Key event handling |
|
455 TBool iConsumeEvent; |
|
456 TBool iKeyEvent; |
|
457 }; |
|
458 |
|
459 #endif // HGTELEPORTFASTSWAPAREA_H |
|