|
1 /* |
|
2 * Copyright (c) 2008 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: Definition of class CFscContactActionMenuList. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_FSCCONTACTACTIONMENULIST_H |
|
19 #define C_FSCCONTACTACTIONMENULIST_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 #include <coecntrl.h> |
|
24 #include <eiklbo.h> |
|
25 |
|
26 #include "fsccontactactionmenudefines.h" |
|
27 #include "tfsccontactactionmenutimedvalue.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class MFscContactActionMenuListObserver; |
|
31 class MFscContactActionMenuModel; |
|
32 class CFscContactActionMenuListBox; |
|
33 class CFont; |
|
34 class CAknsFrameBackgroundControlContext; |
|
35 |
|
36 /** |
|
37 * Contact Action Menu List implementation. |
|
38 * |
|
39 * @since S60 3.1 |
|
40 */ |
|
41 class CFscContactActionMenuList |
|
42 : public CCoeControl, |
|
43 public MEikListBoxObserver |
|
44 { |
|
45 |
|
46 public: // Public constructor and destructor |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 * |
|
51 * @param aObserver Menu list's observer |
|
52 * @param aModel Menu's model |
|
53 * @param aAiMode ETrue in AI mode |
|
54 * @param aPositionGiver |
|
55 * @param aOpenedFromMR ETrue, if menu was opened from meeting request. |
|
56 * |
|
57 * @return New instance of the component |
|
58 */ |
|
59 static CFscContactActionMenuList* NewL( |
|
60 MFscContactActionMenuListObserver* aObserver, |
|
61 MFscContactActionMenuModel* aModel, |
|
62 TBool aAiMode, |
|
63 MFsActionMenuPositionGiver* aPositionGiver = 0, |
|
64 TBool aOpenedFromMR = EFalse ); |
|
65 |
|
66 /** |
|
67 * Destructor. |
|
68 */ |
|
69 virtual ~CFscContactActionMenuList(); |
|
70 |
|
71 public: // From CCoeControl |
|
72 |
|
73 /** |
|
74 * OfferKeyEventL |
|
75 * |
|
76 * @param aKeyEvent Key event |
|
77 * @param aType Event type |
|
78 * |
|
79 * @return key response |
|
80 */ |
|
81 virtual TKeyResponse OfferKeyEventL( |
|
82 const TKeyEvent& aKeyEvent,TEventCode aType ); |
|
83 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
84 |
|
85 /** |
|
86 * HandleResourceChange |
|
87 * |
|
88 * @param aType resource change type |
|
89 */ |
|
90 virtual void HandleResourceChange( TInt aType ); |
|
91 |
|
92 /** |
|
93 * CountComponentControls |
|
94 * |
|
95 * @return component controls count |
|
96 */ |
|
97 virtual TInt CountComponentControls() const; |
|
98 |
|
99 /** |
|
100 * ComponentControl |
|
101 * |
|
102 * @param aIndex Control's index |
|
103 * @return control |
|
104 */ |
|
105 virtual CCoeControl* ComponentControl( TInt aIndex ) const; |
|
106 |
|
107 public: // From MEikListBoxObserver |
|
108 |
|
109 /** |
|
110 * HandleListBoxEventL |
|
111 * |
|
112 * @param aListBox listbox |
|
113 * @param aEventType event type |
|
114 */ |
|
115 void HandleListBoxEventL( |
|
116 CEikListBox* aListBox, TListBoxEvent aEventType ); |
|
117 |
|
118 public: // Public methods |
|
119 |
|
120 /* |
|
121 * Show list |
|
122 * |
|
123 * @param aPosition Position of the list |
|
124 * @param aIndex Index of selected item when menu list is shown |
|
125 */ |
|
126 void ShowL( |
|
127 TFscContactActionMenuPosition aPosition, |
|
128 TInt aIndex ); |
|
129 |
|
130 /* |
|
131 * Hide list |
|
132 * @param aSlide Boolean param to specify hiding style |
|
133 */ |
|
134 void Hide( TBool aSlide = ETrue ); |
|
135 |
|
136 /* |
|
137 * Selected item |
|
138 * |
|
139 * @return Selected item index |
|
140 */ |
|
141 TInt SelectedItemIndex(); |
|
142 |
|
143 /* |
|
144 * Item count in the menu |
|
145 * |
|
146 * @return item count |
|
147 */ |
|
148 TInt ItemCount(); |
|
149 |
|
150 private: // Private constructors |
|
151 |
|
152 /** |
|
153 * Constructor. |
|
154 * |
|
155 * @param aObserver Menu list's observer |
|
156 * @param aModel Menu's model |
|
157 * @param aAiMode ETrue in AI mode |
|
158 * @param aPositionGiver |
|
159 * @param aOpenedFromMR ETrue, if menu is opened from meeting request. |
|
160 */ |
|
161 CFscContactActionMenuList( |
|
162 MFscContactActionMenuListObserver* aObserver, |
|
163 MFscContactActionMenuModel* aModel, |
|
164 TBool aAiMode, |
|
165 MFsActionMenuPositionGiver* aPositionGiver, |
|
166 TBool aOpenedFromMR ); |
|
167 |
|
168 /** |
|
169 * Second phase constructor. |
|
170 */ |
|
171 void ConstructL(); |
|
172 |
|
173 /* |
|
174 * Layouts popup window. |
|
175 */ |
|
176 void LayoutPopupWindow( const TBool aLayoutChange = EFalse ); |
|
177 |
|
178 /* |
|
179 * Given rect's width is modified by content. |
|
180 */ |
|
181 void AdjustByContent( TRect& aRect ); |
|
182 |
|
183 /* |
|
184 * Layouts list. |
|
185 * |
|
186 * @leave In case of error may leave. |
|
187 */ |
|
188 void LayoutListL(); |
|
189 |
|
190 /** |
|
191 * Returns calculated left margin width in pixels. |
|
192 */ |
|
193 TInt LeftMargin( const TRect& aMenuPane, const TRect& aG1 ) const; |
|
194 |
|
195 /** |
|
196 * Returns calculated right margin width in pixels. |
|
197 */ |
|
198 TInt RightMargin( const TRect& aMenuPane, const TRect& aT1 ) const; |
|
199 |
|
200 /** |
|
201 * Returns calculated middle margin width in pixels. |
|
202 */ |
|
203 TInt MiddleMargin( const TRect& aMenuPane, const TRect& aG1 ) const; |
|
204 |
|
205 /** |
|
206 * Layouts list. |
|
207 * |
|
208 * @return Possible error code. |
|
209 */ |
|
210 TInt LayoutList(); |
|
211 |
|
212 /** |
|
213 * Construct controls of the list |
|
214 */ |
|
215 void ConstructControlsL(); |
|
216 |
|
217 /** |
|
218 * Clear controls of the list |
|
219 */ |
|
220 void ClearControls(); |
|
221 |
|
222 private: // Private methods |
|
223 |
|
224 /** |
|
225 * Update list content |
|
226 */ |
|
227 void UpdateListContentL( const TSize& aIconSize ); |
|
228 |
|
229 /** |
|
230 * Update menu offset depending on current menu state |
|
231 */ |
|
232 void SetupMenuOffset(); |
|
233 |
|
234 /** |
|
235 * Update colors based on current skin |
|
236 */ |
|
237 void UpdateColors(); |
|
238 |
|
239 /** |
|
240 * Count maximum text width of current list items |
|
241 * |
|
242 * @return max text width in pixels |
|
243 */ |
|
244 TInt MaxListTextWidth(); |
|
245 |
|
246 /** |
|
247 * Update window position. Method is called by CPeriodic |
|
248 * |
|
249 * @param aPtr Pointer to menu list instance |
|
250 * @return Error code |
|
251 */ |
|
252 static TInt UpdateWindowPosition( TAny *aPtr ); |
|
253 |
|
254 private: // from CCoeControl |
|
255 |
|
256 /* |
|
257 * @see CCoeControl::SizeChanged |
|
258 */ |
|
259 void SizeChanged(); |
|
260 |
|
261 private: // data |
|
262 |
|
263 /** |
|
264 * State of the menu |
|
265 */ |
|
266 enum TState |
|
267 { |
|
268 EOut, // Hidden |
|
269 ESlidingOut, |
|
270 EIn, // Visible |
|
271 ESlidingIn |
|
272 } iState; |
|
273 |
|
274 /** |
|
275 * List box |
|
276 * Owned |
|
277 */ |
|
278 CFscContactActionMenuListBox* iListBox; |
|
279 |
|
280 /** |
|
281 * Menu list's observer |
|
282 * Not owned |
|
283 */ |
|
284 MFscContactActionMenuListObserver* iObserver; |
|
285 |
|
286 /** |
|
287 * Menu's model |
|
288 * Not owned |
|
289 */ |
|
290 MFscContactActionMenuModel* iModel; |
|
291 |
|
292 /** |
|
293 * Menu's position |
|
294 */ |
|
295 TFscContactActionMenuPosition iPosition; |
|
296 |
|
297 TPoint iCustomPosition; |
|
298 |
|
299 /** |
|
300 * Menu font |
|
301 * Not owned |
|
302 */ |
|
303 const CFont* iFont; |
|
304 |
|
305 /** |
|
306 * Timer for slide in/out effect |
|
307 * Owned |
|
308 */ |
|
309 CPeriodic* iPeriodic; |
|
310 |
|
311 /** |
|
312 * Window's original rect |
|
313 */ |
|
314 TRect iOrigMenuRect; |
|
315 |
|
316 /** |
|
317 * Window's position offset |
|
318 */ |
|
319 TFscContactActionMenuTimedValue iMenuOffset; |
|
320 |
|
321 /** |
|
322 * Boolean flag to tell whether extra key events should |
|
323 * be notified and skipped. |
|
324 */ |
|
325 TBool iAiMode; |
|
326 |
|
327 /** |
|
328 * Skin ids |
|
329 */ |
|
330 TAknsItemID iListItemId; |
|
331 TAknsItemID iListBottomId; |
|
332 TAknsItemID iHighlightId; |
|
333 TAknsItemID iHighlightCenterId; |
|
334 |
|
335 TBool iListHasConsumedPointed; |
|
336 TBool iHasBeenDragged; |
|
337 |
|
338 MFsActionMenuPositionGiver* iPositionGiver; |
|
339 |
|
340 TBool iOpenedFromMR; |
|
341 }; |
|
342 |
|
343 #endif // C_FSCCONTACTACTIONMENULIST_H |
|
344 |
|
345 |