|
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 HGGRID_H_ |
|
20 #define HGGRID_H_ |
|
21 |
|
22 // INCLUDES |
|
23 #include <ganes/HgScroller.h> |
|
24 |
|
25 class CHgGridLayoutData; |
|
26 |
|
27 // CLASS DECLARATION |
|
28 class CHgGrid : public CHgScroller |
|
29 { |
|
30 public: // CONSTRUCTORS & DESTRUCTOR |
|
31 |
|
32 /** |
|
33 * Creates new HgGrid. |
|
34 * |
|
35 * @param aRect Rect that the control draws onto. |
|
36 * @param aItemCount Total count of items in the grid |
|
37 * @param aDefaultIcon Default icon to be used. |
|
38 * @param aSession Window server session for DSA. Default is NULL and DSA is disabled. |
|
39 * |
|
40 * @return HgGrid-object |
|
41 */ |
|
42 IMPORT_C static CHgGrid* NewL( |
|
43 const TRect& aRect, |
|
44 TInt aItemCount, |
|
45 CGulIcon* aDefaultIcon = NULL, |
|
46 RWsSession* aSession = NULL ); |
|
47 |
|
48 /** |
|
49 * Destructor. |
|
50 */ |
|
51 IMPORT_C virtual ~CHgGrid ( ); |
|
52 |
|
53 public: |
|
54 |
|
55 /** |
|
56 * Returns preferred image size that should be used when passing images. |
|
57 */ |
|
58 IMPORT_C static TSize PreferredImageSize(); |
|
59 |
|
60 /** |
|
61 * Set landscape scrolling support. If enabled lanscape scrolling |
|
62 * is on only in landscape orientation. InitScreenL must be called after |
|
63 * this to relayout the grid. |
|
64 * |
|
65 * @param aSupportLandscapeScrolling Landscape scrolling supported or not. |
|
66 */ |
|
67 IMPORT_C void SetLandscapeScrollingSupport( TBool aSupportLandscapeScrolling ); |
|
68 |
|
69 protected: // CHgScroller |
|
70 TInt GetSelected( TPoint aPosition ) const; |
|
71 void HandleSizeChanged(); |
|
72 void InitItemsL(); |
|
73 TSize TotalSize() const; |
|
74 void DoDraw(const TRect& aRect ) const; |
|
75 TBool DoHandleKeyEvent( const TKeyEvent& aEvent ); |
|
76 void FitSelectionToView(); |
|
77 void FitTopItemToView( TInt aIndex ); |
|
78 TInt CurrentIndex(); |
|
79 TBool IsDisplayed( TInt aIndex ); |
|
80 |
|
81 private: // Constructors |
|
82 CHgGrid( TInt aItemCount, |
|
83 CGulIcon* aDefaultIcon ); |
|
84 |
|
85 void ConstructL (const TRect& aRect, RWsSession* aSession ); |
|
86 |
|
87 private: |
|
88 void DrawHighlight( const TRect& aOuterRect ) const; |
|
89 |
|
90 void HandleDownArrow(); |
|
91 void HandleUpArrow(); |
|
92 void HandleRightArrow(); |
|
93 void HandleLeftArrow(); |
|
94 void SelectDefaultItem(); |
|
95 |
|
96 TRect GridRect() const; |
|
97 void DrawCols( TInt aRow, const TRect& aRect, TInt aYPos ) const; |
|
98 void DrawRows( TInt aCol, const TRect& aRect, TInt aXPos ) const; |
|
99 void DrawItem( TInt aIndex, const TRect& aRect ) const; |
|
100 |
|
101 void CalculateSizes(); |
|
102 void ChangeSelectedIndex( TInt aMove ); |
|
103 |
|
104 private: // DATA |
|
105 CHgGridLayoutData* iLayoutData; |
|
106 |
|
107 TInt iRows; // Total number of rows to display |
|
108 TInt iCols; // Total number of cols to display |
|
109 |
|
110 TInt iRowWidth; |
|
111 TBool iLandScapeScrollingSupported; |
|
112 }; |
|
113 |
|
114 #endif // HGGRID_H_ |
|
115 // End of File |