|
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 #ifndef C_CPENINPUTSELECTIONLIST_H |
|
18 #define C_CPENINPUTSELECTIONLIST_H |
|
19 |
|
20 #include <peninputlayoutbasecontrol.h> |
|
21 #include <AknLayout2Def.h> |
|
22 #include <AknsConstants.h> |
|
23 |
|
24 class CPenInputSelectionList : public CFepUiBaseCtrl |
|
25 { |
|
26 public: |
|
27 struct SItem |
|
28 { |
|
29 SItem(TRect aRect, const TDesC& aText) |
|
30 :iRect(aRect), iText(aText) |
|
31 { |
|
32 } |
|
33 |
|
34 TRect iRect; |
|
35 const TDesC& iText; |
|
36 }; |
|
37 |
|
38 enum TSelectionListBmpType |
|
39 { |
|
40 EBmpNormal, |
|
41 EBmpNormalMask, |
|
42 EBmpHighlight, |
|
43 EBmpHighlightMask, |
|
44 EBmpLastType = EBmpHighlightMask |
|
45 }; |
|
46 |
|
47 public: |
|
48 IMPORT_C static CPenInputSelectionList* NewL(CFepUiLayout* aUiLayout, |
|
49 TInt aControlId, |
|
50 TPoint aTopLeftPoint, |
|
51 TSize aItemSize, |
|
52 TInt aItemHorizontalMargin); |
|
53 |
|
54 IMPORT_C ~CPenInputSelectionList(); |
|
55 |
|
56 IMPORT_C void SizeChanged(TPoint aTopLeftPoint, |
|
57 TSize aItemSize, |
|
58 TInt aItemHorizontalMargin); |
|
59 |
|
60 // control rect is calculated by item count |
|
61 IMPORT_C void SetItemsL(const RPointerArray<HBufC>& aItemList); |
|
62 |
|
63 IMPORT_C void AddItemL(const TDesC& aItem); |
|
64 |
|
65 IMPORT_C void RemoveItem(TInt aItemIndex); |
|
66 |
|
67 IMPORT_C void RemoveAllItems(); |
|
68 |
|
69 IMPORT_C void ConstructFromResourceL(); |
|
70 |
|
71 IMPORT_C void SetTextProperty(const CFont* aFont, |
|
72 TRgb aFontColor); |
|
73 |
|
74 IMPORT_C CFepUiBaseCtrl* HandlePointerDownEventL(const TPoint& aPoint); |
|
75 IMPORT_C CFepUiBaseCtrl* HandlePointerUpEventL(const TPoint& aPoint); |
|
76 IMPORT_C CFepUiBaseCtrl* HandlePointerMoveEventL(const TPoint& aPoint); |
|
77 |
|
78 IMPORT_C void Display(); |
|
79 |
|
80 IMPORT_C void CloseWindow(); |
|
81 |
|
82 inline void SetTextLineLayout(TAknTextLineLayout aTextLine); |
|
83 |
|
84 inline void SetEventIdForItemSelected(TInt aEventId); |
|
85 |
|
86 inline void SetBgFrId(TAknsItemID aFrId, TAknsItemID aCenterFrId); |
|
87 |
|
88 void Draw(); |
|
89 |
|
90 private: |
|
91 |
|
92 CPenInputSelectionList(CFepUiLayout* aUiLayout, |
|
93 TInt aControlId, |
|
94 TPoint aTopLeftPoint, |
|
95 TSize aItemSize, |
|
96 TInt aItemHorizontalMargin); |
|
97 |
|
98 void ConstructL(); |
|
99 |
|
100 void RecalculateCtrlRect(); |
|
101 |
|
102 // get item whose region contains the point |
|
103 TInt HitTest(const TPoint& aPoint); |
|
104 |
|
105 void DrawItem(TInt aItemIndex); |
|
106 |
|
107 void CalculateFrameRects(const TRect aRect, TRect& aOuterRect, TRect& aInnerRect) const; |
|
108 private: |
|
109 |
|
110 RArray<SItem> iItemList; |
|
111 TPoint iTopLeftPoint; |
|
112 TSize iItemSize; |
|
113 TInt iItemHorizontalMargin; |
|
114 TInt iBaselineOffset; |
|
115 const CFont* iFont; |
|
116 TRgb iFontColor; |
|
117 TAknTextLineLayout iTextLine; |
|
118 |
|
119 TInt iFocusItemIndex; |
|
120 |
|
121 RPointerArray<CFbsBitmap> iBmpList; |
|
122 |
|
123 TInt iEventId; |
|
124 TBool iTextLineSet; |
|
125 TAknsItemID iFrId; |
|
126 TAknsItemID iCenterFrId; |
|
127 }; |
|
128 |
|
129 inline void CPenInputSelectionList::SetTextLineLayout(TAknTextLineLayout aTextLine) |
|
130 { |
|
131 iTextLine = aTextLine; |
|
132 iTextLineSet = ETrue; |
|
133 } |
|
134 |
|
135 inline void CPenInputSelectionList::SetEventIdForItemSelected(TInt aEventId) |
|
136 { |
|
137 iEventId = aEventId; |
|
138 } |
|
139 |
|
140 inline void CPenInputSelectionList::SetBgFrId(TAknsItemID aFrId, TAknsItemID aCenterFrId) |
|
141 { |
|
142 iFrId = aFrId; |
|
143 iCenterFrId = aCenterFrId; |
|
144 } |
|
145 |
|
146 #endif // C_CPENINPUTSELECTIONLIST_H |