95 * |
95 * |
96 * @since S60 v3.0 |
96 * @since S60 v3.0 |
97 * @return Listbox view. |
97 * @return Listbox view. |
98 */ |
98 */ |
99 CListBoxView* MakeViewClassInstanceL(); |
99 CListBoxView* MakeViewClassInstanceL(); |
100 |
100 |
101 /** |
101 /** |
102 * Creates the item drawer for listbox. |
102 * Creates the item drawer for listbox. |
103 * |
103 * |
104 * @param aTemplateLibrary Template library for drawer. |
104 * @param aTemplateLibrary Template library for drawer. |
105 * @since S60 v3.0 |
105 * @since S60 v3.0 |
106 */ |
106 */ |
107 void CreateItemDrawerL( CMmTemplateLibrary* aTemplateLibrary ); |
107 void CreateItemDrawerL( CMmTemplateLibrary* aTemplateLibrary ); |
108 |
108 |
109 /** |
109 /** |
110 * Sets the flag. |
110 * Sets the flag. |
111 * |
111 * |
112 * @since S60 v3.0 |
112 * @since S60 v3.0 |
113 * @param aFlag Avkon list flag |
113 * @param aFlag Avkon list flag |
114 */ |
114 */ |
115 void SetListFlag( TInt aFlag ); |
115 void SetListFlag( TInt aFlag ); |
116 |
116 |
117 /** |
117 /** |
118 * Clears the flag. |
118 * Clears the flag. |
119 * |
119 * |
120 * @since S60 v3.0 |
120 * @since S60 v3.0 |
121 * @param aFlag Avkon list flag |
121 * @param aFlag Avkon list flag |
122 */ |
122 */ |
123 void ClearListFlag( TInt aFlag ); |
123 void ClearListFlag( TInt aFlag ); |
124 |
124 |
125 |
125 |
126 public: // from base class CCoeControl. |
126 public: // from base class CCoeControl. |
127 |
127 |
128 /** |
128 /** |
129 * From CCoeControl. |
129 * From CCoeControl. |
130 * Handles pointer events. |
130 * Handles pointer events. |
131 * |
131 * |
132 * @since S60 v3.0 |
132 * @since S60 v3.0 |
133 * @param aPointerEvent Pointer event. |
133 * @param aPointerEvent Pointer event. |
134 */ |
134 */ |
135 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
135 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
136 |
136 |
137 /** |
137 /** |
138 * From base class. |
138 * From base class. |
139 * |
139 * |
140 * @since S60 v3.0 |
140 * @since S60 v3.0 |
141 * @param aKeyEvent Key event. |
141 * @param aKeyEvent Key event. |
142 * @param aType Event code. |
142 * @param aType Event code. |
143 */ |
143 */ |
144 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
144 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
145 TEventCode aType ); |
145 TEventCode aType ); |
146 |
146 |
147 /** |
147 /** |
148 * Adjusts the given rectangle. |
148 * Adjusts the given rectangle. |
149 * |
149 * |
150 * @since S60 v3.0 |
150 * @since S60 v3.0 |
151 * @param aRect Rectangle to be adjusted. |
151 * @param aRect Rectangle to be adjusted. |
152 * @return Error code. |
152 * @return Error code. |
153 */ |
153 */ |
154 TInt AdjustRectHeightToWholeNumberOfItems( TRect& aRect ) const; |
154 TInt AdjustRectHeightToWholeNumberOfItems( TRect& aRect ) const; |
155 |
155 |
156 /** |
156 /** |
157 * Sets item drawer and view background context. |
157 * Sets item drawer and view background context. |
158 * |
158 * |
159 * @since S60 v3.0 |
159 * @since S60 v3.0 |
160 * @param aBgContext Background context. |
160 * @param aBgContext Background context. |
161 */ |
161 */ |
162 void SetItemDrawerAndViewBgContext( |
162 void SetItemDrawerAndViewBgContext( |
163 CAknsBasicBackgroundControlContext * aBgContext ); |
163 CAknsBasicBackgroundControlContext * aBgContext ); |
164 |
164 |
165 /** |
165 /** |
166 * Updates scrollbar. |
166 * Updates scrollbar. |
167 * |
167 * |
168 * @since S60 v3.0 |
168 * @since S60 v3.0 |
169 */ |
169 */ |
170 void UpdateScrollBarsL(); |
170 void UpdateScrollBarsL(); |
171 |
171 |
172 /** |
172 /** |
173 * Special version of Update scrollbar that never calls DrawNow() |
173 * Special version of Update scrollbar that never calls DrawNow() |
174 */ |
174 */ |
175 void UpdateScrollBarsNoRedrawL(); |
175 void UpdateScrollBarsNoRedrawL(); |
176 |
176 |
177 /** |
177 /** |
178 * Checks if all items fit in view rectangle. |
178 * Checks if all items fit in view rectangle. |
179 * |
179 * |
180 * @since S60 v3.0 |
180 * @since S60 v3.0 |
181 * @return Do all items fit in view rectangle. |
181 * @return Do all items fit in view rectangle. |
182 */ |
182 */ |
183 TBool AllItemsFitInViewRect(); |
183 TBool AllItemsFitInViewRect(); |
184 |
184 |
185 /** |
185 /** |
186 * Handles scrollbar visibility change. |
186 * Handles scrollbar visibility change. |
187 * |
187 * |
188 * @since S60 v3.0 |
188 * @since S60 v3.0 |
189 * @return Is redraw needed. |
189 * @return Is redraw needed. |
190 */ |
190 */ |
191 TBool HandleScrollbarVisibilityChangeL(); |
191 TBool HandleScrollbarVisibilityChangeL(); |
192 |
192 |
193 /** |
193 /** |
194 * Sets marquee adapter. |
194 * Sets marquee adapter. |
195 * |
195 * |
196 * @since S60 v3.0 |
196 * @since S60 v3.0 |
197 * @param aAdapter Marquee adapter. |
197 * @param aAdapter Marquee adapter. |
198 */ |
198 */ |
199 void SetMarqueeAdapter( CMmMarqueeAdapter* aAdapter ); |
199 void SetMarqueeAdapter( CMmMarqueeAdapter* aAdapter ); |
200 |
200 |
201 /** |
201 /** |
202 * Notifies that marquee is being drawn. |
202 * Notifies that marquee is being drawn. |
203 * |
203 * |
204 * @since S60 v3.0 |
204 * @since S60 v3.0 |
205 * @param aIsMarqueeBeingDrawn Is marquee being drawn. |
205 * @param aIsMarqueeBeingDrawn Is marquee being drawn. |
206 */ |
206 */ |
207 void SetMarqueeDrawing( TBool aIsMarqueeBeingDrawn ); |
207 void SetMarqueeDrawing( TBool aIsMarqueeBeingDrawn ); |
208 |
208 |
209 /** |
209 /** |
210 * Handles item removal. redraws view, updates scrollbar. |
210 * Handles item removal. redraws view, updates scrollbar. |
211 * |
211 * |
212 * @since S60 v3.0 |
212 * @since S60 v3.0 |
213 */ |
213 */ |
214 void HandleItemRemovalL(); |
214 void HandleItemRemovalL(); |
215 |
215 |
216 /** |
216 /** |
217 * Redraws items in view if it is necessary. |
217 * Redraws items in view if it is necessary. |
218 * |
218 * |
219 * @since S60 v3.0 |
219 * @since S60 v3.0 |
220 * @param aPreviousCurrent Previously current item index. |
220 * @param aPreviousCurrent Previously current item index. |
221 * @param aCurrent Current item index. |
221 * @param aCurrent Current item index. |
222 * |
222 * |
223 * @return true if anything was drawn. |
223 * @return true if anything was drawn. |
224 */ |
224 */ |
225 TBool RedrawIfNecessary( TInt aPreviousCurrent, TInt aCurrent ); |
225 TBool RedrawIfNecessary( TInt aPreviousCurrent, TInt aCurrent ); |
226 |
226 |
227 /** |
227 /** |
228 * Overridden from base class to allow for drawing scrollbar |
228 * Overridden from base class to allow for drawing scrollbar |
229 * background in mirrored layout. |
229 * background in mirrored layout. |
230 * |
230 * |
231 * @param aRect clipping rect |
231 * @param aRect clipping rect |
232 */ |
232 */ |
233 void Draw(const TRect& aRect) const; |
233 void Draw(const TRect& aRect) const; |
234 |
234 |
235 /** |
235 /** |
236 * Draws the listbox view. |
236 * Draws the listbox view. |
237 * |
237 * |
238 * @since S60 v5.0 |
238 * @since S60 v5.0 |
239 */ |
239 */ |
240 void DrawView(); |
240 void DrawView(); |
241 |
241 |
242 /** |
242 /** |
243 * Set the vertical item offset; |
243 * Set the vertical item offset; |
244 * @param aOffset The offset to set to the widget. |
244 * @param aOffset The offset to set to the widget. |
245 * |
245 * |
246 * @since S60 v5.0 |
246 * @since S60 v5.0 |
247 */ |
247 */ |
248 void SetVerticalItemOffset( TInt aOffset ); |
248 void SetVerticalItemOffset( TInt aOffset ); |
249 |
249 |
250 /** |
250 /** |
251 * Gets the current widget vertical item offset. |
251 * Gets the current widget vertical item offset. |
252 * |
252 * |
253 * @since S60 v5.0 |
253 * @since S60 v5.0 |
254 * @return The current widget vertical item offset. |
254 * @return The current widget vertical item offset. |
255 */ |
255 */ |
256 TInt VerticalItemOffset() const; |
256 TInt VerticalItemOffset() const; |
257 |
257 |
258 /** |
258 /** |
259 * Simply sets the item height members in widget and view. |
259 * Simply sets the item height members in widget and view. |
260 */ |
260 */ |
261 void SetItemHeight( TInt aItemHeight ); |
261 void SetItemHeight( TInt aItemHeight ); |
262 |
262 |
263 /** |
263 /** |
264 * Updates scrollbar thumbs. |
264 * Updates scrollbar thumbs. |
265 */ |
265 */ |
266 void UpdateScrollBarThumbs(); |
266 void UpdateScrollBarThumbs(); |
267 |
267 |
268 /** |
268 /** |
269 * Counts the number of component controls which this component owns. |
269 * Counts the number of component controls which this component owns. |
270 */ |
270 */ |
271 TInt CountComponentControls() const; |
271 TInt CountComponentControls() const; |
272 |
272 |
273 /** |
273 /** |
274 * Disables/enables child component (scrollbar) drawing. |
274 * Disables/enables child component (scrollbar) drawing. |
275 */ |
275 */ |
276 void SetDisableChildComponentDrawing( TBool aDisable ); |
276 void SetDisableChildComponentDrawing( TBool aDisable ); |
277 |
277 |
278 /** |
278 /** |
279 * Handles scrolling event. |
279 * Handles scrolling event. |
280 * |
280 * |
281 * @since S60 v3.0 |
281 * @since S60 v3.0 |
282 * @param aScrollBar Scrollbar being scrolled. |
282 * @param aScrollBar Scrollbar being scrolled. |
283 * @param aEventType Type of scrollbar event. |
283 * @param aEventType Type of scrollbar event. |
284 */ |
284 */ |
285 void HandleScrollEventL( CEikScrollBar* aScrollBar, |
285 void HandleScrollEventL( CEikScrollBar* aScrollBar, |
286 TEikScrollEvent aEventType ); |
286 TEikScrollEvent aEventType ); |
287 |
287 |
288 private: |
288 private: |
289 /** |
289 /** |
290 * Default constructor. |
290 * Default constructor. |
291 * |
291 * |
292 * @since S60 v3.0 |
292 * @since S60 v3.0 |
293 */ |
293 */ |
294 CMmListBox(); |
294 CMmListBox(); |
295 |
295 |
296 /** |
296 /** |
297 * 2nd phase constructor. |
297 * 2nd phase constructor. |
298 * |
298 * |
299 * @since S60 v3.0 |
299 * @since S60 v3.0 |
300 * @param aParent Parent control. |
300 * @param aParent Parent control. |
301 * @param aFlags Flags. |
301 * @param aFlags Flags. |
302 * @param aTemplateLibrary Template library for drawer. |
302 * @param aTemplateLibrary Template library for drawer. |
303 */ |
303 */ |
304 void ConstructL( const CCoeControl* aParent, TInt aFlags, |
304 void ConstructL( const CCoeControl* aParent, TInt aFlags, |
305 CMmTemplateLibrary* aTemplateLibrary ); |
305 CMmTemplateLibrary* aTemplateLibrary ); |
306 |
306 |
307 /** |
307 /** |
308 * Handles pointer events when edit mode is enabled. |
308 * Handles pointer events when edit mode is enabled. |
309 * |
309 * |
310 * This method is only called during edit mode. It selectively passes |
310 * This method is only called during edit mode. It selectively passes |
311 * only some of the pointer events to CAknGrid::HandlePointerEventL |
311 * only some of the pointer events to CAknGrid::HandlePointerEventL |
312 * in order to disable flicking and panning. |
312 * in order to disable flicking and panning. |
313 * |
313 * |
314 * @param aPointerEvent pointer event |
314 * @param aPointerEvent pointer event |
315 */ |
315 */ |
316 void HandlePointerEventInEditModeL( const TPointerEvent& aPointerEvent ); |
316 void HandlePointerEventInEditModeL( const TPointerEvent& aPointerEvent ); |
317 |
317 |
318 /** |
318 /** |
319 * Scrolls the view if pointer is close to the top/bottom edge. |
319 * Scrolls the view if pointer is close to the top/bottom edge. |
320 * |
320 * |
321 * This method is used only when edit mode is active. In a way it |
321 * This method is used only when edit mode is active. In a way it |
322 * brings back the focus based scrolling behavior that was present |
322 * brings back the focus based scrolling behavior that was present |
323 * in CAknGrid before ODE scrolling was introduced. |
323 * in CAknGrid before ODE scrolling was introduced. |
324 */ |
324 */ |
325 void HandleScrollingInEditMode( const TPointerEvent& aPointerEvent ); |
325 void HandleScrollingInEditMode( const TPointerEvent& aPointerEvent ); |
326 |
326 |
327 /** |
327 /** |
328 * Checks if pointer position is within the scroll-triggering area. |
328 * Checks if pointer position is within the scroll-triggering area. |
329 * |
329 * |
330 * @param aPointerEvent pointer event |
330 * @param aPointerEvent pointer event |
331 * @return true if pointer above the top scrolling threshold. |
331 * @return true if pointer above the top scrolling threshold. |
332 */ |
332 */ |
333 TBool IsPointerInTopScrollingThreshold( |
333 TBool IsPointerInTopScrollingThreshold( |
334 const TPointerEvent& aPointerEvent ) const; |
334 const TPointerEvent& aPointerEvent ) const; |
335 |
335 |
336 /** |
336 /** |
337 * Checks if pointer position is within the scroll-triggering area. |
337 * Checks if pointer position is within the scroll-triggering area. |
338 * |
338 * |
339 * @param aPointerEvent pointer event |
339 * @param aPointerEvent pointer event |
340 * @return true if pointer below the bottom scrolling threshold. |
340 * @return true if pointer below the bottom scrolling threshold. |
341 */ |
341 */ |
342 TBool IsPointerInBottomScrollingThreshold( |
342 TBool IsPointerInBottomScrollingThreshold( |
343 const TPointerEvent& aPointerEvent ) const; |
343 const TPointerEvent& aPointerEvent ) const; |
344 |
344 |
345 /** |
345 /** |
346 * Scrolls the view if the pointer is near top/bottom edge of the screen. |
346 * Scrolls the view if the pointer is near top/bottom edge of the screen. |
347 * |
347 * |
348 * Assumes that current item index is the index of the item under the |
348 * Assumes that current item index is the index of the item under the |
349 * pointer. The time value returned is based on the distance of the pointer |
349 * pointer. The time value returned is based on the distance of the pointer |
350 * from the top/bottom edge of the grid view (this makes the scrolling speed |
350 * from the top/bottom edge of the grid view (this makes the scrolling speed |
351 * dependent of how close the pointer is to the edge). |
351 * dependent of how close the pointer is to the edge). |
352 * If there is no need to continue scrolling because the beginning/end of |
352 * If there is no need to continue scrolling because the beginning/end of |
353 * the list has already been reached, 0 is returned. |
353 * the list has already been reached, 0 is returned. |
354 * |
354 * |
355 * @param aPointerEvent pointer event |
355 * @param aPointerEvent pointer event |
356 * @return time to wait before calling this method again (in microseconds) |
356 * @return time to wait before calling this method again (in microseconds) |
357 * or 0 if already at the beginning/end of the list |
357 * or 0 if already at the beginning/end of the list |
358 */ |
358 */ |
359 TInt ScrollIfNeeded( const TPointerEvent& aPointerEvent ); |
359 TInt ScrollIfNeeded( const TPointerEvent& aPointerEvent ); |
360 |
360 |
361 /** |
|
362 * Minimal scrolling (setting top item index and vertical offset) with |
|
363 * boundary checking and WITHOUT redrawing. |
|
364 * |
|
365 * @param aDistanceInPixels Distance to scroll. |
|
366 */ |
|
367 void ScrollWithoutRedraw( TInt aDistanceInPixels ); |
|
368 |
|
369 /** |
361 /** |
370 * Ensures that elements are drawn correctly when mirrored layout is |
362 * Ensures that elements are drawn correctly when mirrored layout is |
371 * used and scrollbar is visible by shifting ViewRect to the right. |
363 * used and scrollbar is visible by shifting ViewRect to the right. |
372 */ |
364 */ |
373 void FixViewForMirroredLayout(); |
365 void FixViewForMirroredLayout(); |
374 |
366 |
375 /** |
367 /** |
376 * Redraws the background under the vertical scrollbar in mirrored layout. |
368 * Redraws the background under the vertical scrollbar in mirrored layout. |
377 * |
369 * |
378 * The reason such method is needed is that view rectangle is shifted |
370 * The reason such method is needed is that view rectangle is shifted |
379 * to the right in mirrored layout and does not cover the scrollbar |
371 * to the right in mirrored layout and does not cover the scrollbar |
380 * area. In normal (non-mirrored) mode this method does nothing. |
372 * area. In normal (non-mirrored) mode this method does nothing. |
381 */ |
373 */ |
382 void RedrawScrollbarBackground() const; |
374 void RedrawScrollbarBackground() const; |
383 |
375 |
384 /** |
376 /** |
385 * Does actual handling of scroll events. |
377 * Does actual handling of scroll events. |
386 * |
378 * |
387 * @param aScrollBar Scrollbar being scrolled. |
379 * @param aScrollBar Scrollbar being scrolled. |
388 * @param aEventType Type of scrollbar event. |
380 * @param aEventType Type of scrollbar event. |
389 */ |
381 */ |
390 void ProcessScrollEventL( CEikScrollBar* aScrollBar, |
382 void ProcessScrollEventL( CEikScrollBar* aScrollBar, |
391 TEikScrollEvent aEventType ); |
383 TEikScrollEvent aEventType ); |
392 |
384 |
|
385 /** |
|
386 * Handles periodic events from @c iRedrawTimer. |
|
387 * Such events are generated at equal time intervals while |
|
388 * the view is being scrolled using the scrollbar. |
|
389 * This function typically calls @c ProcessScrollEventL, |
|
390 * which actually scrolls the view and causes a redraw. |
|
391 */ |
|
392 void HandleRedrawTimerEventL(); |
|
393 |
|
394 private: |
|
395 /** |
|
396 * Callback function for @c iRedrawTimer. |
|
397 * It simply calls @c HandleRedrawTimerEventL and returns 0. |
|
398 * |
|
399 * @param aPtr A pointer to CMmListBox object. |
|
400 * @return 0 (always). |
|
401 */ |
|
402 static TInt RedrawTimerCallback( TAny* aPtr ); |
|
403 |
393 private: // Data |
404 private: // Data |
394 /** |
405 /** |
395 * Item drawer. |
406 * Item drawer. |
396 */ |
407 */ |
397 CMmListBoxItemDrawer* iMmDrawer; |
408 CMmListBoxItemDrawer* iMmDrawer; |
398 |
409 |
399 /** |
410 /** |
400 * Multimedia Menu model. |
411 * Multimedia Menu model. |
401 */ |
412 */ |
402 CMmListBoxModel* iMmModel; |
413 CMmListBoxModel* iMmModel; |
403 |
414 |
404 /** |
415 /** |
405 * marquee adapter. |
416 * marquee adapter. |
406 */ |
417 */ |
407 CMmMarqueeAdapter* iMarqueeAdapter; |
418 CMmMarqueeAdapter* iMarqueeAdapter; |
408 |
419 |
409 /** |
420 /** |
410 * Blocks scrollbar drawing. When this flag is set scrollbars components |
421 * Blocks scrollbar drawing. When this flag is set scrollbars components |
411 * are blocked in the CountComponentControls() method; |
422 * are blocked in the CountComponentControls() method; |
412 */ |
423 */ |
413 TBool iDisableChildComponentDrawing; |
424 TBool iDisableChildComponentDrawing; |
414 |
425 |
415 /** |
426 /** |
416 * This member is only used in edit mode to store the position of the pointer |
427 * This member is only used in edit mode to store the position of the pointer |
417 * during EButton1Down event. |
428 * during EButton1Down event. |
418 */ |
429 */ |
419 TPoint iButton1DownPos; |
430 TPoint iButton1DownPos; |
420 }; |
431 |
421 |
432 /** |
|
433 * ETrue if the view is being scrolled with the scrollbar. |
|
434 */ |
|
435 TBool iScrollbarThumbIsBeingDragged; |
|
436 |
|
437 /** |
|
438 * Stores the number of scrollbar events that were ignored. |
|
439 * It is only used while scrolling the view using scrollbar, |
|
440 * in such situation the scroll events that this object receives |
|
441 * are ignored, and actual scrolling is done only when |
|
442 * iRedrawTimer completes. |
|
443 */ |
|
444 TInt iSkippedScrollbarEventsCount; |
|
445 |
|
446 /** |
|
447 * A timer that initiates redraws at certain time intervals. |
|
448 * It is used to refresh the view while scrolling with |
|
449 * the scrollbar. |
|
450 */ |
|
451 CPeriodic* iRedrawTimer; |
|
452 }; |
|
453 |
422 #endif // MMLISTBOX_H |
454 #endif // MMLISTBOX_H |