|
1 /* |
|
2 * Copyright (c) 2007 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: CMmListBox |
|
15 * Version : %version: MM_22.1.14 % << Don't touch! Updated by Synergy at check-out. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef C_MMLISTBOX_H |
|
21 #define C_MMLISTBOX_H |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <aknlists.h> |
|
26 #include <e32cmn.h> |
|
27 |
|
28 class CMmListBoxModel; |
|
29 class CMmListBoxItemDrawer; |
|
30 class CMmMarqueeAdapter; |
|
31 class CMmWidgetContainer; |
|
32 class CMmTemplateLibrary; |
|
33 |
|
34 /** |
|
35 * CMmListBox |
|
36 * |
|
37 * @code |
|
38 * @endcode |
|
39 * @lib mmwidgets |
|
40 * @since S60 v3.0 |
|
41 * @ingroup group_mmwidgets |
|
42 */ |
|
43 NONSHARABLE_CLASS( CMmListBox ) : public CEikFormattedCellListBoxTypedef |
|
44 { |
|
45 public: |
|
46 /** |
|
47 * Two-phased constructor. |
|
48 * |
|
49 * @since S60 v3.0 |
|
50 * @param aParent Parent control. |
|
51 * @param aFlags Flags. |
|
52 * @param aTemplateLibrary Template library for drawer. |
|
53 * @return List box. |
|
54 */ |
|
55 static CMmListBox* NewL( const CCoeControl* aParent, TInt aFlags, |
|
56 CMmTemplateLibrary* aTemplateLibrary ); |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 * |
|
61 * @since S60 v3.0 |
|
62 * @param aParent Parent control. |
|
63 * @param aFlags Flags. |
|
64 * @param aTemplateLibrary Template library for drawer. |
|
65 * @return List box. |
|
66 */ |
|
67 static CMmListBox* NewLC( const CCoeControl* aParent, TInt aFlags, |
|
68 CMmTemplateLibrary* aTemplateLibrary ); |
|
69 |
|
70 /** |
|
71 * Destructor. |
|
72 * |
|
73 * @since S60 v3.0 |
|
74 */ |
|
75 virtual ~CMmListBox(); |
|
76 |
|
77 /** |
|
78 * Gets the listbox model. |
|
79 * |
|
80 * @since S60 v3.0 |
|
81 * @return Listbox model. |
|
82 */ |
|
83 CMmListBoxModel * MmModel(); |
|
84 |
|
85 /** |
|
86 * Sets the listbox model. |
|
87 * |
|
88 * @since S60 v3.0 |
|
89 * @param aMmModel The model to be set. |
|
90 */ |
|
91 void SetMmModel( CMmListBoxModel* aMmModel ); |
|
92 |
|
93 /** |
|
94 * Creates the view class instance. |
|
95 * |
|
96 * @since S60 v3.0 |
|
97 * @return Listbox view. |
|
98 */ |
|
99 CListBoxView* MakeViewClassInstanceL(); |
|
100 |
|
101 /** |
|
102 * Creates the item drawer for listbox. |
|
103 * |
|
104 * @param aTemplateLibrary Template library for drawer. |
|
105 * @since S60 v3.0 |
|
106 */ |
|
107 void CreateItemDrawerL( CMmTemplateLibrary* aTemplateLibrary ); |
|
108 |
|
109 /** |
|
110 * Sets the flag. |
|
111 * |
|
112 * @since S60 v3.0 |
|
113 * @param aFlag Avkon list flag |
|
114 */ |
|
115 void SetListFlag( TInt aFlag ); |
|
116 |
|
117 /** |
|
118 * Clears the flag. |
|
119 * |
|
120 * @since S60 v3.0 |
|
121 * @param aFlag Avkon list flag |
|
122 */ |
|
123 void ClearListFlag( TInt aFlag ); |
|
124 |
|
125 |
|
126 public: // from base class CCoeControl. |
|
127 |
|
128 /** |
|
129 * From CCoeControl. |
|
130 * Handles pointer events. |
|
131 * |
|
132 * @since S60 v3.0 |
|
133 * @param aPointerEvent Pointer event. |
|
134 */ |
|
135 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
136 |
|
137 /** |
|
138 * From base class. |
|
139 * |
|
140 * @since S60 v3.0 |
|
141 * @param aKeyEvent Key event. |
|
142 * @param aType Event code. |
|
143 */ |
|
144 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
145 TEventCode aType ); |
|
146 |
|
147 /** |
|
148 * Adjusts the given rectangle. |
|
149 * |
|
150 * @since S60 v3.0 |
|
151 * @param aRect Rectangle to be adjusted. |
|
152 * @return Error code. |
|
153 */ |
|
154 TInt AdjustRectHeightToWholeNumberOfItems( TRect& aRect ) const; |
|
155 |
|
156 /** |
|
157 * Sets item drawer and view background context. |
|
158 * |
|
159 * @since S60 v3.0 |
|
160 * @param aBgContext Background context. |
|
161 */ |
|
162 void SetItemDrawerAndViewBgContext( |
|
163 CAknsBasicBackgroundControlContext * aBgContext ); |
|
164 |
|
165 /** |
|
166 * Updates scrollbar. |
|
167 * |
|
168 * @since S60 v3.0 |
|
169 */ |
|
170 void UpdateScrollBarsL(); |
|
171 |
|
172 /** |
|
173 * Special version of Update scrollbar that never calls DrawNow() |
|
174 */ |
|
175 void UpdateScrollBarsNoRedrawL(); |
|
176 |
|
177 /** |
|
178 * Checks if all items fit in view rectangle. |
|
179 * |
|
180 * @since S60 v3.0 |
|
181 * @return Do all items fit in view rectangle. |
|
182 */ |
|
183 TBool AllItemsFitInViewRect(); |
|
184 |
|
185 /** |
|
186 * Handles scrollbar visibility change. |
|
187 * |
|
188 * @since S60 v3.0 |
|
189 * @return Is redraw needed. |
|
190 */ |
|
191 TBool HandleScrollbarVisibilityChangeL(); |
|
192 |
|
193 /** |
|
194 * Sets marquee adapter. |
|
195 * |
|
196 * @since S60 v3.0 |
|
197 * @param aAdapter Marquee adapter. |
|
198 */ |
|
199 void SetMarqueeAdapter( CMmMarqueeAdapter* aAdapter ); |
|
200 |
|
201 /** |
|
202 * Notifies that marquee is being drawn. |
|
203 * |
|
204 * @since S60 v3.0 |
|
205 * @param aIsMarqueeBeingDrawn Is marquee being drawn. |
|
206 */ |
|
207 void SetMarqueeDrawing( TBool aIsMarqueeBeingDrawn ); |
|
208 |
|
209 /** |
|
210 * Handles item removal. redraws view, updates scrollbar. |
|
211 * |
|
212 * @since S60 v3.0 |
|
213 */ |
|
214 void HandleItemRemovalL(); |
|
215 |
|
216 /** |
|
217 * Redraws items in view if it is necessary. |
|
218 * |
|
219 * @since S60 v3.0 |
|
220 * @param aPreviousCurrent Previously current item index. |
|
221 * @param aCurrent Current item index. |
|
222 * |
|
223 * @return true if anything was drawn. |
|
224 */ |
|
225 TBool RedrawIfNecessary( TInt aPreviousCurrent, TInt aCurrent ); |
|
226 |
|
227 /** |
|
228 * Overridden from base class to allow for drawing scrollbar |
|
229 * background in mirrored layout. |
|
230 * |
|
231 * @param aRect clipping rect |
|
232 */ |
|
233 void Draw(const TRect& aRect) const; |
|
234 |
|
235 /** |
|
236 * Draws the listbox view. |
|
237 * |
|
238 * @since S60 v5.0 |
|
239 */ |
|
240 void DrawView(); |
|
241 |
|
242 /** |
|
243 * Set the vertical item offset; |
|
244 * @param aOffset The offset to set to the widget. |
|
245 * |
|
246 * @since S60 v5.0 |
|
247 */ |
|
248 void SetVerticalItemOffset( TInt aOffset ); |
|
249 |
|
250 /** |
|
251 * Gets the current widget vertical item offset. |
|
252 * |
|
253 * @since S60 v5.0 |
|
254 * @return The current widget vertical item offset. |
|
255 */ |
|
256 TInt VerticalItemOffset() const; |
|
257 |
|
258 /** |
|
259 * Simply sets the item height members in widget and view. |
|
260 */ |
|
261 void SetItemHeight( TInt aItemHeight ); |
|
262 |
|
263 /** |
|
264 * Updates scrollbar thumbs. |
|
265 */ |
|
266 void UpdateScrollBarThumbs(); |
|
267 |
|
268 /** |
|
269 * Counts the number of component controls which this component owns. |
|
270 */ |
|
271 TInt CountComponentControls() const; |
|
272 |
|
273 /** |
|
274 * Disables/enables child component (scrollbar) drawing. |
|
275 */ |
|
276 void SetDisableChildComponentDrawing( TBool aDisable ); |
|
277 |
|
278 private: |
|
279 /** |
|
280 * Default constructor. |
|
281 * |
|
282 * @since S60 v3.0 |
|
283 */ |
|
284 CMmListBox(); |
|
285 |
|
286 /** |
|
287 * 2nd phase constructor. |
|
288 * |
|
289 * @since S60 v3.0 |
|
290 * @param aParent Parent control. |
|
291 * @param aFlags Flags. |
|
292 * @param aTemplateLibrary Template library for drawer. |
|
293 */ |
|
294 void ConstructL( const CCoeControl* aParent, TInt aFlags, |
|
295 CMmTemplateLibrary* aTemplateLibrary ); |
|
296 |
|
297 /** |
|
298 * Handles pointer events when edit mode is enabled. |
|
299 * |
|
300 * This method is only called during edit mode. It selectively passes |
|
301 * only some of the pointer events to CAknGrid::HandlePointerEventL |
|
302 * in order to disable flicking and panning. |
|
303 * |
|
304 * @param aPointerEvent pointer event |
|
305 */ |
|
306 void HandlePointerEventInEditModeL( const TPointerEvent& aPointerEvent ); |
|
307 |
|
308 /** |
|
309 * Scrolls the view if pointer is close to the top/bottom edge. |
|
310 * |
|
311 * This method is used only when edit mode is active. In a way it |
|
312 * brings back the focus based scrolling behavior that was present |
|
313 * in CAknGrid before ODE scrolling was introduced. |
|
314 */ |
|
315 void HandleScrollingInEditMode( const TPointerEvent& aPointerEvent ); |
|
316 |
|
317 /** |
|
318 * Checks if pointer position is within the scroll-triggering area. |
|
319 * |
|
320 * @param aPointerEvent pointer event |
|
321 * @return true if pointer above the top scrolling threshold. |
|
322 */ |
|
323 TBool IsPointerInTopScrollingThreshold( |
|
324 const TPointerEvent& aPointerEvent ) const; |
|
325 |
|
326 /** |
|
327 * Checks if pointer position is within the scroll-triggering area. |
|
328 * |
|
329 * @param aPointerEvent pointer event |
|
330 * @return true if pointer below the bottom scrolling threshold. |
|
331 */ |
|
332 TBool IsPointerInBottomScrollingThreshold( |
|
333 const TPointerEvent& aPointerEvent ) const; |
|
334 |
|
335 /** |
|
336 * Scrolls the view if the pointer is near top/bottom edge of the screen. |
|
337 * |
|
338 * Assumes that current item index is the index of the item under the |
|
339 * pointer. The time value returned is based on the distance of the pointer |
|
340 * from the top/bottom edge of the grid view (this makes the scrolling speed |
|
341 * dependent of how close the pointer is to the edge). |
|
342 * If there is no need to continue scrolling because the beginning/end of |
|
343 * the list has already been reached, 0 is returned. |
|
344 * |
|
345 * @param aPointerEvent pointer event |
|
346 * @return time to wait before calling this method again (in microseconds) |
|
347 * or 0 if already at the beginning/end of the list |
|
348 */ |
|
349 TInt ScrollIfNeeded( const TPointerEvent& aPointerEvent ); |
|
350 |
|
351 /** |
|
352 * Ensures that elements are drawn correctly when mirrored layout is |
|
353 * used and scrollbar is visible by shifting ViewRect to the right. |
|
354 */ |
|
355 void FixViewForMirroredLayout(); |
|
356 |
|
357 /** |
|
358 * Redraws the background under the vertical scrollbar in mirrored layout. |
|
359 * |
|
360 * The reason such method is needed is that view rectangle is shifted |
|
361 * to the right in mirrored layout and does not cover the scrollbar |
|
362 * area. In normal (non-mirrored) mode this method does nothing. |
|
363 */ |
|
364 void RedrawScrollbarBackground() const; |
|
365 |
|
366 private: // Data |
|
367 /** |
|
368 * Item drawer. |
|
369 */ |
|
370 CMmListBoxItemDrawer* iMmDrawer; |
|
371 |
|
372 /** |
|
373 * Multimedia Menu model. |
|
374 */ |
|
375 CMmListBoxModel* iMmModel; |
|
376 |
|
377 /** |
|
378 * marquee adapter. |
|
379 */ |
|
380 CMmMarqueeAdapter* iMarqueeAdapter; |
|
381 |
|
382 /** |
|
383 * Blocks scrollbar drawing. When this flag is set scrollbars components |
|
384 * are blocked in the CountComponentControls() method; |
|
385 */ |
|
386 TBool iDisableChildComponentDrawing; |
|
387 }; |
|
388 |
|
389 #endif // MMLISTBOX_H |