56
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef HGSCROLLER_H_
|
|
20 |
#define HGSCROLLER_H_
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <coecntrl.h>
|
|
24 |
#include <coemain.h>
|
|
25 |
|
|
26 |
#include <aknphysicsobserveriface.h>
|
|
27 |
#include <aknlongtapdetector.h>
|
|
28 |
#include <akncollection.h>
|
|
29 |
#include <ganes/HgBufferOwnerIface.h>
|
|
30 |
#include <ganes/HgScrollbarObserverIface.h>
|
|
31 |
|
|
32 |
// FORWARD DECLARATIONS
|
|
33 |
class CAknPhysics;
|
|
34 |
class MHgScrollBufferObserver;
|
|
35 |
class MHgSelectionObserver;
|
|
36 |
class MHgMarkingObserver;
|
|
37 |
class CHgItem;
|
|
38 |
class CHgScrollbar;
|
|
39 |
class CGulIcon;
|
|
40 |
class CHgScrollBufferManager;
|
|
41 |
class THgPopupDrawer;
|
|
42 |
class CHgIndicatorManager;
|
|
43 |
class CHgDrawUtils;
|
|
44 |
class CHgKeyUtils;
|
|
45 |
class CHgTextFind;
|
|
46 |
class CAknItemActionMenu;
|
|
47 |
class CFont;
|
|
48 |
|
|
49 |
// CLASS DECLARATION
|
|
50 |
class CHgScroller :
|
|
51 |
public CCoeControl,
|
|
52 |
public MHgBufferOwner,
|
|
53 |
public MHgScrollbarObserver,
|
|
54 |
public MCoeForegroundObserver,
|
|
55 |
public MAknPhysicsObserver,
|
|
56 |
public MAknLongTapDetectorCallBack,
|
|
57 |
public MAknCollection
|
|
58 |
{
|
|
59 |
public:
|
|
60 |
|
|
61 |
// Flags that define possible scroller modes
|
|
62 |
enum THgScrollerMode
|
|
63 |
{
|
|
64 |
EHgScrollerSelectionMode = 0x0001,
|
|
65 |
EHgScrollerSearchWithQWERTY = 0x0002,
|
|
66 |
EHgScrollerKeyMarkingDisabled = 0x0004,
|
|
67 |
EHgScrollerScreenFreeze = 0x0008,
|
|
68 |
EHgScrollerForceDoubleClick = 0x0010,
|
|
69 |
EHgScrollerFlatStatusPane = 0x0020
|
|
70 |
};
|
|
71 |
|
|
72 |
// Scrollbar types
|
|
73 |
enum THgScrollBarType
|
|
74 |
{
|
|
75 |
EHgScrollerScrollBar = 0,
|
|
76 |
EHgScrollerLetterStrip,
|
|
77 |
EHgScrollerTimeStrip,
|
|
78 |
EHgScrollerLetterStripLite
|
|
79 |
};
|
|
80 |
|
|
81 |
public: // Destructor.
|
|
82 |
IMPORT_C virtual ~CHgScroller();
|
|
83 |
|
|
84 |
public: // CCoeControl
|
|
85 |
void Draw(const TRect& aRect ) const;
|
|
86 |
void SizeChanged();
|
|
87 |
void HandlePointerEventL( const TPointerEvent& aEvent );
|
|
88 |
TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
|
|
89 |
virtual TCoeInputCapabilities InputCapabilities() const;
|
|
90 |
virtual void FocusChanged(TDrawNow aDrawNow);
|
|
91 |
virtual void HandleResourceChange(TInt aType);
|
|
92 |
|
|
93 |
protected: // MAknPhysicsObserver
|
|
94 |
void ViewPositionChanged( const TPoint& aNewPosition,
|
|
95 |
TBool aDrawNow,
|
|
96 |
TUint aFlags );
|
|
97 |
void PhysicEmulationEnded();
|
|
98 |
TPoint ViewPosition() const;
|
|
99 |
|
|
100 |
private: // MHgBufferOwner
|
|
101 |
void Release(TInt aReleaseStart, TInt aReleaseEnd);
|
|
102 |
|
|
103 |
private: // MHgScrollbarObserver
|
|
104 |
void ScrollBarPositionChanged( const TPoint& aNewPosition );
|
|
105 |
void HandleNaviStripChar( const TChar& aChar );
|
|
106 |
|
|
107 |
protected: // MAknLongTapDetectorCallBack
|
|
108 |
void HandleLongTapEventL( const TPoint& aPenEventLocation,
|
|
109 |
const TPoint& aPenEventScreenLocation);
|
|
110 |
|
|
111 |
protected: // MAknCollection
|
|
112 |
TUint CollectionState() const;
|
|
113 |
void ItemActionMenuClosed();
|
|
114 |
TInt CollectionExtension( TUint aExtensionId, TAny*& a0, TAny* a1 );
|
|
115 |
|
|
116 |
public: // NEW FUNCTIONS
|
|
117 |
/**
|
|
118 |
* Re-inits the grid display area. DSA version.
|
|
119 |
*
|
|
120 |
* @param aRect New display rect
|
|
121 |
* @param aSession Window server session for DSA
|
|
122 |
*/
|
|
123 |
IMPORT_C void InitScreenL( const TRect& aRect, RWsSession& aSession );
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Re-inits the grid display area. Non-DSA version.
|
|
127 |
*
|
|
128 |
* @param aRect New display rect
|
|
129 |
*/
|
|
130 |
IMPORT_C void InitScreenL( const TRect& aRect );
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Refreshes screen.
|
|
134 |
* @param aIndex Index that was modified.
|
|
135 |
*/
|
|
136 |
IMPORT_C void RefreshScreen( TInt aIndex );
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Gives the first index on the screen.
|
|
140 |
*
|
|
141 |
* Note: The index is not guaranteed to be in the range of the scroller items.
|
|
142 |
* Index can be negative if the scroller is scrolled to the way up or
|
|
143 |
* over the count - 1 if scrolled way down.
|
|
144 |
*
|
|
145 |
* @return The index of the first item on the screen.
|
|
146 |
*/
|
|
147 |
IMPORT_C TInt FirstIndexOnScreen();
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Sets the first index on the screen.
|
|
151 |
*
|
|
152 |
* @param aFirstIndexOnScreen The index of the first item on the screen.
|
|
153 |
*/
|
|
154 |
IMPORT_C void SetFirstIndexOnScreen( TInt aFirstIndexOnScreen );
|
|
155 |
|
|
156 |
/**
|
|
157 |
* How many items fit on one screen.
|
|
158 |
* @return Item count.
|
|
159 |
*/
|
|
160 |
IMPORT_C TInt ItemsOnScreen();
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Get item at specified index.
|
|
164 |
*
|
|
165 |
* @param aIndex Index of the item that is returned
|
|
166 |
* @return Reference to item.
|
|
167 |
*/
|
|
168 |
IMPORT_C CHgItem& ItemL( TInt aIndex );
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Resets item at the index position. Old item is deleted.
|
|
172 |
*
|
|
173 |
* @param aItem New item. Ownership transferred.
|
|
174 |
* @param aIndex The index of the item.
|
|
175 |
*/
|
|
176 |
IMPORT_C void SetItem(CHgItem* aItem, TInt aIndex);
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Adds Item.
|
|
180 |
*
|
|
181 |
* @param aItem New item. Ownership transferred.
|
|
182 |
*/
|
|
183 |
IMPORT_C void AddItem(CHgItem* aItem);
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Inserts item at index postion.
|
|
187 |
*
|
|
188 |
* @param aItem New item. Ownership transferred.
|
|
189 |
* @param aIndex The index of the item.
|
|
190 |
*/
|
|
191 |
IMPORT_C void InsertItem(CHgItem* aItem, TInt aIndex);
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Removes item at index position. Removed item is deleted.
|
|
195 |
*
|
|
196 |
* @param aIndex The index of the item.
|
|
197 |
*/
|
|
198 |
IMPORT_C void RemoveItem(TInt aIndex);
|
|
199 |
|
|
200 |
/**
|
|
201 |
* @return Selected index (KErrNotFound if nothing is selected)
|
|
202 |
*/
|
|
203 |
IMPORT_C TInt SelectedIndex();
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Sets selected index.
|
|
207 |
* @param aIndex new selected index. Selection is also made visible.
|
|
208 |
*/
|
|
209 |
IMPORT_C void SetSelectedIndex( TInt aIndex );
|
|
210 |
|
|
211 |
/**
|
|
212 |
* Marks item at index position.
|
|
213 |
* @param aIndex Index of the item that is marked.
|
|
214 |
*/
|
|
215 |
IMPORT_C void Mark( TInt aIndex );
|
|
216 |
|
|
217 |
/**
|
|
218 |
* Unmarks item at index position.
|
|
219 |
* @param aIndex Index of the item that is unmarked.
|
|
220 |
*/
|
|
221 |
IMPORT_C void UnMark( TInt aIndex );
|
|
222 |
|
|
223 |
/**
|
|
224 |
* Marks all items.
|
|
225 |
*/
|
|
226 |
IMPORT_C void MarkAll();
|
|
227 |
|
|
228 |
/**
|
|
229 |
* Unmarks all items.
|
|
230 |
*/
|
|
231 |
IMPORT_C void UnMarkAll();
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Gets all marked item indexes.
|
|
235 |
* @param aIndexes On return contains the indexes of marked items.
|
|
236 |
*/
|
|
237 |
IMPORT_C void GetMarkedItemsL( RArray<TInt>& aIndexes );
|
|
238 |
|
|
239 |
/**
|
|
240 |
* Enables Buffering.
|
|
241 |
* @param aObserver Buffer change observer.
|
|
242 |
* @param aBufferSize The size of the buffer.
|
|
243 |
* @param aBufferTreshold The minimum change needed for buffer to be modified.
|
|
244 |
*/
|
|
245 |
IMPORT_C void EnableScrollBufferL( MHgScrollBufferObserver& aObserver,
|
|
246 |
TInt aBufferSize,
|
|
247 |
TInt aBufferTreshold );
|
|
248 |
|
|
249 |
/**
|
|
250 |
* Sets selection observer.
|
|
251 |
* @param aObserver Selection observer.
|
|
252 |
*/
|
|
253 |
IMPORT_C void SetSelectionObserver( MHgSelectionObserver& aObserver );
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Sets marking observer.
|
|
257 |
* @param aObserver marking observer.
|
|
258 |
*/
|
|
259 |
IMPORT_C void SetMarkingObserver( MHgMarkingObserver& aObserver );
|
|
260 |
|
|
261 |
/**
|
|
262 |
* Removes all items and presents empty text
|
|
263 |
* */
|
|
264 |
IMPORT_C void Reset();
|
|
265 |
|
|
266 |
/**
|
|
267 |
* Resizes Grid/List.
|
|
268 |
* @param aItemCount New Count of items.
|
|
269 |
*/
|
|
270 |
IMPORT_C void ResizeL( TInt aItemCount );
|
|
271 |
|
|
272 |
/**
|
|
273 |
* Set text that is displayed when there are no items in the view.
|
|
274 |
* @param aEmptyText Empty text.
|
|
275 |
*/
|
|
276 |
IMPORT_C void SetEmptyTextL( const TDesC& aEmptyText );
|
|
277 |
|
|
278 |
/**
|
|
279 |
* Fetch item count.
|
|
280 |
* @return Total number of items.
|
|
281 |
*/
|
|
282 |
IMPORT_C TInt ItemCount() const;
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Set scrollbar type.
|
|
286 |
* @param aType ScrollBar type
|
|
287 |
*/
|
|
288 |
IMPORT_C void SetScrollBarTypeL( THgScrollBarType aType );
|
|
289 |
|
|
290 |
/**
|
|
291 |
* Set mode flags. Possible values are defined in THgScrollerMode.
|
|
292 |
* @param aFlags flags to bet set.
|
|
293 |
*/
|
|
294 |
IMPORT_C void SetFlags( TInt aFlags );
|
|
295 |
|
|
296 |
/**
|
|
297 |
* Clear mode flags. Possible values are defined in THgScrollerMode.
|
|
298 |
* @param aFlags flags to be cleared.
|
|
299 |
*/
|
|
300 |
IMPORT_C void ClearFlags( TInt aFlags );
|
|
301 |
|
|
302 |
/**
|
|
303 |
* Get flags. Possible values are defined in THgScrollerMode.
|
|
304 |
* @return Current flags.
|
|
305 |
*/
|
|
306 |
IMPORT_C TInt Flags();
|
|
307 |
|
|
308 |
/**
|
|
309 |
* Highlights item based on the descriptor given.
|
|
310 |
* @param aHighlightText Text to be searched.
|
|
311 |
* @return Was aHighlightText found.
|
|
312 |
*/
|
|
313 |
IMPORT_C TBool HightlightItem( const TDesC& aHighlightText );
|
|
314 |
|
|
315 |
/**
|
|
316 |
* Sets new default icon.
|
|
317 |
* @param aDefaultIcon New default icon to be used in scroller.
|
|
318 |
*/
|
|
319 |
IMPORT_C void SetDefaultIconL( CGulIcon* aDefaultIcon );
|
|
320 |
|
|
321 |
/**
|
|
322 |
* Disables Scrollbuffer.
|
|
323 |
*/
|
|
324 |
IMPORT_C void DisableScrollBuffer();
|
|
325 |
|
|
326 |
/**
|
|
327 |
*
|
|
328 |
*/
|
|
329 |
IMPORT_C void SetMenuProviderL( MObjectProvider* aMenuProvider );
|
|
330 |
|
|
331 |
// Selection modes. Used in internal key marking implemention.
|
|
332 |
enum TSelectionMode
|
|
333 |
{
|
|
334 |
ENoSelection = 0,
|
|
335 |
ESelectionPossible,
|
|
336 |
ESelectionMark,
|
|
337 |
ESelectionUnMark
|
|
338 |
};
|
|
339 |
|
|
340 |
/**
|
|
341 |
* Set selection mode. Used in internal key marking implemention.
|
|
342 |
* @param aMode New selection mode.
|
|
343 |
*/
|
|
344 |
void SetSelectionMode( TSelectionMode aMode );
|
|
345 |
|
|
346 |
/**
|
|
347 |
* Get current selection mode. Used in internal key marking implemention.
|
|
348 |
* @return Current selection mode.
|
|
349 |
*/
|
|
350 |
TSelectionMode SelectionMode() const;
|
|
351 |
|
|
352 |
protected: // Pure Virtual Functions
|
|
353 |
virtual TInt GetSelected( TPoint aPosition ) const = 0;
|
|
354 |
virtual void HandleSizeChanged() = 0;
|
|
355 |
virtual void InitItemsL() = 0;
|
|
356 |
virtual TSize TotalSize() const = 0;
|
|
357 |
virtual void DoDraw( const TRect& aRect ) const = 0;
|
|
358 |
virtual TBool DoHandleKeyEvent( const TKeyEvent& aKeyEvent ) = 0;
|
|
359 |
virtual void FitSelectionToView() = 0;
|
|
360 |
virtual TInt CurrentIndex() = 0;
|
|
361 |
virtual TBool IsDisplayed( TInt aIndex ) = 0;
|
|
362 |
virtual void FitTopItemToView( TInt aIndex ) = 0;
|
|
363 |
virtual void HandleScrollbarVisibilityChange(TBool aVisible) = 0;
|
|
364 |
|
|
365 |
protected: // Constructors
|
|
366 |
CHgScroller( TInt aItemCount,
|
|
367 |
CGulIcon* aDefaultIcon );
|
|
368 |
|
|
369 |
void ConstructL (const TRect& aRect, RWsSession* aSession );
|
|
370 |
|
|
371 |
protected:
|
|
372 |
void InitPhysicsL();
|
|
373 |
virtual void HandleViewPositionChanged( TBool aUpdateScrollbar = ETrue );
|
|
374 |
void InitDrawBuffer() const;
|
|
375 |
void SelectionChanged();
|
|
376 |
void FitRowToView( TInt aRow );
|
|
377 |
TBool HasHighlight() const;
|
|
378 |
static TInt MarqueeCallback( TAny* aSelf );
|
|
379 |
|
|
380 |
private:
|
|
381 |
TKeyResponse HandleKeyEvent(const TKeyEvent& aKeyEvent);
|
|
382 |
|
|
383 |
void HandleItemCountChanged();
|
|
384 |
void HandleSelectionL();
|
|
385 |
|
|
386 |
TBool HandleScrollbarEventL( const TPointerEvent& aEvent );
|
|
387 |
void HandleDownEventL( const TPointerEvent& aEvent );
|
|
388 |
void HandleDragEventL( const TPointerEvent& aEvent );
|
|
389 |
void HandleUpEventL( const TPointerEvent& aEvent );
|
|
390 |
|
|
391 |
void KeyEventDown();
|
|
392 |
void KeyEventUp();
|
|
393 |
|
|
394 |
void InitGraphicsL();
|
|
395 |
void InitScrollbarL();
|
|
396 |
|
|
397 |
void HandleGainingForeground();
|
|
398 |
void HandleLosingForeground();
|
|
399 |
|
|
400 |
/**
|
|
401 |
* Launches the highlight timer.
|
|
402 |
*/
|
|
403 |
void LaunchHighlightTimer();
|
|
404 |
|
|
405 |
/**
|
|
406 |
* Callback method for highlight timer.
|
|
407 |
*
|
|
408 |
* @param aPtr Pointer to an instance of CHgScroller class.
|
|
409 |
*
|
|
410 |
* @return System wide error code.
|
|
411 |
*/
|
|
412 |
static TInt HighlightTimerCallback( TAny* aPtr );
|
|
413 |
|
|
414 |
/**
|
|
415 |
* Sets highlight to focused item.
|
|
416 |
*/
|
|
417 |
void SetHighlightL();
|
|
418 |
|
|
419 |
/**
|
|
420 |
* Callback method for key scrolling timer.
|
|
421 |
*
|
|
422 |
* @param aPtr Pointer to an instance of CHgScroller class.
|
|
423 |
*
|
|
424 |
* @return System wide error code.
|
|
425 |
*/
|
|
426 |
static TInt KeyScrollingTimerCallback( TAny* aPtr );
|
|
427 |
|
|
428 |
/**
|
|
429 |
* Move view based on key scolling mode.
|
|
430 |
*/
|
|
431 |
void DoKeyScrolling();
|
|
432 |
|
|
433 |
/**
|
|
434 |
* Sets item highlight and stops the scrolling timer.
|
|
435 |
*/
|
|
436 |
void StopKeyScrolling();
|
|
437 |
|
|
438 |
void ReleasePopupFont();
|
|
439 |
|
|
440 |
protected:
|
|
441 |
CAknPhysics* iPhysics; // Physics engine. Own
|
|
442 |
CHgScrollBufferManager* iManager; // Own
|
|
443 |
CHgScrollbar* iScrollbar; // Scrollbar. Own
|
|
444 |
CHgIndicatorManager* iIndicatorManager; // Utility for drawing indicators. Own
|
|
445 |
CHgDrawUtils* iDrawUtils; // Drawing utility. Own
|
|
446 |
CHgTextFind* iTextFind; // Text find utility to communicate with FEP. Own
|
|
447 |
CAknLongTapDetector* iDetector; // Longtap detector for single click. Own
|
|
448 |
CAknItemActionMenu* iActionMenu; // Item action menu for single click. Not Own
|
|
449 |
CFont* iPopupFont; // font to be used with popup drawer
|
|
450 |
|
|
451 |
// Observers
|
|
452 |
MHgSelectionObserver* iSelectionObserver; // Not Own
|
|
453 |
MHgMarkingObserver* iMarkingObserver; // Not Own
|
|
454 |
|
|
455 |
// Arrays
|
|
456 |
RPointerArray<CHgItem> iItems; // Items
|
|
457 |
|
|
458 |
// For dragging
|
|
459 |
TPoint iStart; // Drag start position
|
|
460 |
TTime iStartTime; // Drag start time
|
|
461 |
TPoint iPrev; // Previous pointer event position.
|
|
462 |
|
|
463 |
// The Rest.
|
|
464 |
CGulIcon* iDefaultIcon; // Default item icon
|
|
465 |
|
|
466 |
TPoint iViewPosition; // Current view position
|
|
467 |
|
|
468 |
TBool iLandscapeScrolling; // Scrolling landscape?
|
|
469 |
|
|
470 |
TInt iWidth; // The width of the view
|
|
471 |
TInt iHeight; // The height of the view
|
|
472 |
TInt iRowHeight; // Row height (square images)
|
|
473 |
TInt iItemCount; // Total number of items
|
|
474 |
TInt iItemsOnScreen;
|
|
475 |
|
|
476 |
TInt iCurrentRow; // The number of the first row that is drawn
|
|
477 |
TInt iSelectedIndex; // The index of the selected item
|
|
478 |
|
|
479 |
TInt iKeyRepeats; // How many key repeasts have been received
|
|
480 |
|
|
481 |
TSize iImageSize; // Image Size
|
|
482 |
TSize iIndicatorSize; // Size of the indicator in list or grid
|
|
483 |
|
|
484 |
enum TKeyScrollingState
|
|
485 |
{
|
|
486 |
ENoKeyScrolling = 0,
|
|
487 |
EKeyScrollingUp,
|
|
488 |
EKeyScrollingDown,
|
|
489 |
EKeyScrollingLeft,
|
|
490 |
EKeyScrollingRight
|
|
491 |
} iKeyScrollingState; // State of the key scrolling
|
|
492 |
|
|
493 |
TInt iFlags; // Possible mode flags
|
|
494 |
|
|
495 |
HBufC* iEmptyText; // text for empty list or grid.
|
|
496 |
|
|
497 |
THgPopupDrawer* iPopupDrawer;
|
|
498 |
TBool iPanning;
|
|
499 |
TBool iShowHighlight;
|
|
500 |
|
|
501 |
THgScrollBarType iScrollBarType; // Scrollbar type
|
|
502 |
|
|
503 |
RBuf iUpperCaseTitle; // Used in search for uppercase conversion
|
|
504 |
RBuf iPopupText1;
|
|
505 |
RBuf iPopupText2;
|
|
506 |
|
|
507 |
TBool iResetViewPosition; // ETrue on the first time run, and when iViewPosition must be reset.
|
|
508 |
TBool iPointerDown;
|
|
509 |
|
|
510 |
CPeriodic* iHighlightTimer; // Higlight timer, own.
|
|
511 |
TBool iSelectionToFocusedItem; // Is focused item clicked
|
|
512 |
TInt iFocusedIndex; // highlight timer updates this value
|
|
513 |
|
|
514 |
CHgKeyUtils* iKeyUtils; // MSK key handler, own
|
|
515 |
|
|
516 |
TSelectionMode iSelectionMode;
|
|
517 |
|
|
518 |
CPeriodic* iKeyScrollingTimer; // Timer for key scrolling, own.
|
|
519 |
TInt iOldWinPos;
|
|
520 |
|
|
521 |
};
|
|
522 |
|
|
523 |
#endif /*HGSCROLLER_H_*/
|