1 /* |
|
2 * ============================================================================ |
|
3 * Name : hgteleportfastswapgrid.h |
|
4 * Part of : Hg Teleport |
|
5 * Description : Teleport Fast Swap area UI |
|
6 * Version : %version: 12 % |
|
7 * |
|
8 * Copyright © 2009 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 #ifndef HGTELEPORTFASTSWAPGRID_H_ |
|
21 #define HGTELEPORTFASTSWAPGRID_H_ |
|
22 |
|
23 #include <AknGrid.h> |
|
24 #include <aknconsts.h> |
|
25 #include "hgteleportdevicestate.h" |
|
26 |
|
27 class CAknsFrameBackgroundControlContext; |
|
28 class CHgTeleportFastSwapTimer; |
|
29 |
|
30 /** |
|
31 * Observer for handling fast swap grid events |
|
32 */ |
|
33 class MHgTeleportFastSwapGridObserver |
|
34 { |
|
35 public: |
|
36 /** |
|
37 * Called when close icon is tapped on the grid item. |
|
38 * |
|
39 * @param aItemIdx index of the the item for which close icon |
|
40 * has been tapped |
|
41 */ |
|
42 virtual void HandleCloseEventL( TInt aItemIdx ) = 0; |
|
43 }; |
|
44 |
|
45 |
|
46 class MHgTeleportFastSwapTimerObserver |
|
47 { |
|
48 public: |
|
49 /** |
|
50 * Called when timer is completed |
|
51 */ |
|
52 virtual void TimerCompletedL( CHgTeleportFastSwapTimer* aSource ) = 0; |
|
53 }; |
|
54 |
|
55 |
|
56 /** |
|
57 * Avkon grid implementing custom item drawer |
|
58 */ |
|
59 class CHgTeleportFastSwapGrid: |
|
60 public CAknGrid, |
|
61 public MHgDeviceStateObserver |
|
62 { |
|
63 public: // enums |
|
64 enum TFastSwapGridBehaviour |
|
65 { |
|
66 // Highlight always visible |
|
67 EHybrid, |
|
68 |
|
69 // Touch only highlight handling |
|
70 ETouchOnly |
|
71 }; |
|
72 |
|
73 public: // Constructor and destructor |
|
74 CHgTeleportFastSwapGrid(); |
|
75 ~CHgTeleportFastSwapGrid(); |
|
76 void ConstructL( const CCoeControl* aParent ); |
|
77 |
|
78 public: // From CCoeControl |
|
79 void HandlePointerEventL( const TPointerEvent &aPointerEvent ); |
|
80 TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); |
|
81 void HandleResourceChange( TInt aType ); |
|
82 void SizeChanged(); |
|
83 |
|
84 public: //From MHgDeviceStateObserver |
|
85 /** |
|
86 * Called when a change, to which the observer is registered, |
|
87 * has happened. |
|
88 */ |
|
89 virtual void HandleDeviceStateChanged( TChangeType aChangeType ); |
|
90 |
|
91 public: // New functions |
|
92 |
|
93 /** |
|
94 * Sets fast swap grid observer |
|
95 */ |
|
96 void SetFastSwapGridObserver( MHgTeleportFastSwapGridObserver* aObserver ); |
|
97 |
|
98 /** |
|
99 * Set indexes of items which can be closed. |
|
100 * Copies item index array. |
|
101 */ |
|
102 void SetCloseItemsL( RArray<TInt>& aItemIndex ); |
|
103 |
|
104 /** |
|
105 * Checks if the item of given index is closable |
|
106 */ |
|
107 TBool CanCloseItem( TInt aItemIndex ); |
|
108 |
|
109 /** |
|
110 * Checks if the given item's close icon has been tapped. |
|
111 */ |
|
112 TBool IsItemCloseHit( TInt aItemIndex ); |
|
113 |
|
114 /** |
|
115 * Resets index of the item that has been close icon hit |
|
116 */ |
|
117 void ResetCloseHit(); |
|
118 |
|
119 /** |
|
120 * Sets grid behaviour |
|
121 * |
|
122 * @param aBehaviour behaviour to be set |
|
123 */ |
|
124 void SetGridBehaviour( TFastSwapGridBehaviour aBehaviour ); |
|
125 |
|
126 /** |
|
127 * Getter for grid behaviour |
|
128 * |
|
129 * @return girds behaviour |
|
130 */ |
|
131 TFastSwapGridBehaviour GridBehaviour(); |
|
132 |
|
133 /** |
|
134 * Shows highlight. In touch only behaviour highlight |
|
135 * will be shown only for ammount of time. |
|
136 */ |
|
137 void ShowHighlight(); |
|
138 |
|
139 /** |
|
140 * Hides highlight. |
|
141 */ |
|
142 void HideHighlight(); |
|
143 |
|
144 /** |
|
145 * Checks if the highlight is currently visible. |
|
146 * |
|
147 * @return ETrue if highlight is visible |
|
148 * EFalse if highlight is not visible |
|
149 */ |
|
150 TBool IsHighlightVisible(); |
|
151 |
|
152 /** |
|
153 * Sets visible view, items outside of view will not be drawn |
|
154 */ |
|
155 void SetVisibleViewRect( const TRect aRect ); |
|
156 |
|
157 /** |
|
158 * Returns visible view. Items outside of visible rectangle are not drawn. |
|
159 */ |
|
160 TRect VisibleViewRect(); |
|
161 |
|
162 private: // From CAknGrid |
|
163 virtual void CreateItemDrawerL(); |
|
164 |
|
165 private: // New functions |
|
166 |
|
167 /** |
|
168 * Loads close icon bitmap and mask |
|
169 */ |
|
170 void LoadCloseIcon(); |
|
171 |
|
172 /** |
|
173 * Redraws grid and parent controls |
|
174 */ |
|
175 void Redraw(); |
|
176 |
|
177 private: // Data |
|
178 // Background context for grid |
|
179 CAknsFrameBackgroundControlContext* iBgContext; |
|
180 |
|
181 // Close icon handling |
|
182 RArray<TInt> iCloseItems; |
|
183 TInt iCloseIconHitIdx; |
|
184 MHgTeleportFastSwapGridObserver* iFastSwapGridObserver; |
|
185 |
|
186 // Highlight handling |
|
187 TFastSwapGridBehaviour iBehaviour; |
|
188 TBool iHighlightVisible; |
|
189 |
|
190 // Visible view rectangle (horizontal scrolling support) |
|
191 TRect iVisibleViewRect; |
|
192 }; |
|
193 |
|
194 |
|
195 |
|
196 /** |
|
197 * Custom item drawer for drawing grid items |
|
198 */ |
|
199 class CHgTeleportGridItemDrawer: public CFormattedCellListBoxItemDrawer |
|
200 { |
|
201 |
|
202 public: // Constructor and destructor |
|
203 CHgTeleportGridItemDrawer( CHgTeleportFastSwapGrid* aGrid, |
|
204 CFormattedCellListBoxData* aData ); |
|
205 ~CHgTeleportGridItemDrawer(); |
|
206 |
|
207 public: // New functions |
|
208 |
|
209 /** |
|
210 * Sets close icon drawn for items that can be closed. |
|
211 * Ownership transferred. |
|
212 */ |
|
213 void SetCloseIcon( CFbsBitmap* aBmp, CFbsBitmap* aMask ); |
|
214 |
|
215 /** |
|
216 * Returns close icon coordinates for the given item rectangle |
|
217 */ |
|
218 TRect GetCloseIconRect( const TRect& aItemRect ) const; |
|
219 |
|
220 /** |
|
221 * Sets screen offset for the item drawer to not draw items on the |
|
222 * grid edges |
|
223 */ |
|
224 void SetEdgeOffset( TInt aLeftOffset, TInt aRightOffset ); |
|
225 |
|
226 private: // From CFormattedCellListBoxItemDrawer |
|
227 void DrawActualItem( TInt aItemIndex, const TRect& aActualItemRect, |
|
228 TBool aItemIsCurrent, TBool aViewIsEmphasized, |
|
229 TBool aViewIsDimmed, TBool aItemIsSelected ) const; |
|
230 private: // New functions |
|
231 /** |
|
232 * Checks if the item rectangle is visible in the view. |
|
233 * |
|
234 * @param aItemRect rectangle of the item to be checked |
|
235 * @return ETrue if rectangle is fully or partially visible |
|
236 * EFalse if rectangle is not visible |
|
237 */ |
|
238 TBool IsItemRectVisible( const TRect& aItemRect ) const; |
|
239 |
|
240 private: // Data |
|
241 // Not owned |
|
242 CHgTeleportFastSwapGrid* iGrid; |
|
243 // Owned |
|
244 CFbsBitmap* iCloseIcon; |
|
245 CFbsBitmap* iCloseIconMask; |
|
246 |
|
247 TRect iScreenRect; |
|
248 TInt iLeftOffset; |
|
249 TInt iRightOffset; |
|
250 }; |
|
251 |
|
252 |
|
253 |
|
254 /** |
|
255 * Timer class for handling highlight bevaiour |
|
256 */ |
|
257 class CHgTeleportFastSwapTimer : public CTimer |
|
258 { |
|
259 public: |
|
260 // Constructor |
|
261 CHgTeleportFastSwapTimer( MHgTeleportFastSwapTimerObserver& aObserver ); |
|
262 // Destructor |
|
263 ~CHgTeleportFastSwapTimer(); |
|
264 // 2nd phase constructor |
|
265 void ConstructL(); |
|
266 |
|
267 private: // From CTimer |
|
268 void RunL(); |
|
269 |
|
270 private: // Data |
|
271 MHgTeleportFastSwapTimerObserver* iObserver; // not own |
|
272 }; |
|
273 |
|
274 #endif /* HGTELEPORTFASTSWAPGRID_H_ */ |
|