|
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 * ccappcommlaunchercustomlistboxitemdrawer.h |
|
19 * |
|
20 * Created on: 2009-10-30 |
|
21 * Author: dev |
|
22 */ |
|
23 |
|
24 #ifndef CCAPPCOMMLAUNCHERCUSTOMLISTBOXITEMDRAWER_H_ |
|
25 #define CCAPPCOMMLAUNCHERCUSTOMLISTBOXITEMDRAWER_H_ |
|
26 |
|
27 #include <eikclb.h> |
|
28 #include <eikfrlb.h> |
|
29 #include <eikslb.h> |
|
30 #include <AknGrid.h> |
|
31 #include <AknUtils.h> |
|
32 #include <eiklbi.h> |
|
33 |
|
34 |
|
35 #include <eiklbv.h> |
|
36 #include <eiktxlbm.h> |
|
37 #include <eiktxlbx.h> |
|
38 |
|
39 |
|
40 |
|
41 class TAknTextLineLayout; |
|
42 class MAknsSkinInstance; |
|
43 class MAknsControlContext; |
|
44 |
|
45 class CCCAppCommLauncherCustomListBoxData; |
|
46 |
|
47 class CCCAppCommLauncherCustomListBoxItemDrawer : public CTextListItemDrawer |
|
48 { |
|
49 public: |
|
50 |
|
51 /** |
|
52 * C++ default constructor. |
|
53 * |
|
54 * @param aTextListBoxModel The list box model class. |
|
55 * @param aFont Font to be used in listbox. |
|
56 * @param aFormattedCellData Pointer to the list layout drawer class. |
|
57 */ |
|
58 CCCAppCommLauncherCustomListBoxItemDrawer( |
|
59 MTextListBoxModel* aTextListBoxModel, |
|
60 const CFont* aFont, |
|
61 CCCAppCommLauncherCustomListBoxData* aFormattedCellData); |
|
62 |
|
63 /** |
|
64 * Destructor. |
|
65 */ |
|
66 ~CCCAppCommLauncherCustomListBoxItemDrawer(); |
|
67 |
|
68 /** |
|
69 * Gets the list layout drawer. |
|
70 * |
|
71 * @return Pointer to the list layout drawer object. |
|
72 */ |
|
73 CCCAppCommLauncherCustomListBoxData* FormattedCellData() const; |
|
74 |
|
75 /** |
|
76 * Gets the list layout drawer. |
|
77 * |
|
78 * @return Pointer to the list layout drawer object. |
|
79 */ |
|
80 CCCAppCommLauncherCustomListBoxData* ColumnData() const; |
|
81 // for compability with columnlistbox itemdrawer |
|
82 |
|
83 /** |
|
84 * Draws an empty item to the list box. |
|
85 * |
|
86 * @param aItemIndex Not used. |
|
87 * @param aItemRectPos Position for the list box item rectangle. |
|
88 * @param aViewIsDimmed Not used. |
|
89 */ |
|
90 virtual void DrawEmptyItem(TInt aItemIndex, TPoint aItemRectPos, |
|
91 TBool aViewIsDimmed) const; |
|
92 |
|
93 /** |
|
94 * This function sets top item index. |
|
95 * |
|
96 * @param aTop Item index value. |
|
97 */ |
|
98 void SetTopItemIndex(TInt aTop); |
|
99 |
|
100 /** |
|
101 * List item index and color and style properties. |
|
102 */ |
|
103 struct SListProperties |
|
104 { |
|
105 /** List box item index. */ |
|
106 TInt iItem; // must be first |
|
107 |
|
108 /** Colour and style properties for the list item. */ |
|
109 TListItemProperties iProperties; |
|
110 }; |
|
111 |
|
112 /** |
|
113 * Clears all properties. |
|
114 */ |
|
115 void ClearAllPropertiesL(); |
|
116 |
|
117 /** |
|
118 * The SetProperties is convenience method for normal cases. |
|
119 * NOTE that it does NOT work correctly if you can insert/delete |
|
120 * items from the list -- You need to update all properties if |
|
121 * any changes to the item text array happen! Often it is convenient |
|
122 * to override the @c Properties() method. Further, use this only |
|
123 * for small lists. |
|
124 * |
|
125 * It has been implemented as sorted list of (index,Property) pairs. |
|
126 * |
|
127 * If you're using find, aItemIndex for this method is the same as you give |
|
128 * in @c MdcaPoint() points the default @c Properties() does conversion |
|
129 * between indexes. |
|
130 * |
|
131 * @param aItemIndex List box item index. |
|
132 * @param properties Colour and style properties for the list box item. |
|
133 */ |
|
134 void SetPropertiesL(TInt aItemIndex, TListItemProperties properties); |
|
135 |
|
136 /** |
|
137 * Function for getting properties of a certain list box item. |
|
138 * |
|
139 * @param aItemIndex The listbox item index. |
|
140 * @return Colour and style properties of wanted |
|
141 * list box item. |
|
142 */ |
|
143 virtual TListItemProperties Properties(TInt aItemIndex) const; |
|
144 |
|
145 /** |
|
146 * Gets list box item cell size. |
|
147 * |
|
148 * @return The list box item cell size. |
|
149 */ |
|
150 TSize LafItemSize() { return iItemCellSize; } |
|
151 |
|
152 public: // from CTextListItemDrawer |
|
153 |
|
154 /** |
|
155 * From @c CTextListItemDrawer. |
|
156 * |
|
157 * Draw an item in a list box. |
|
158 * |
|
159 * @param aItemIndex The index into the model's item array of the item |
|
160 * to draw. |
|
161 * @param aItemTextRect The item’s text rectangle. |
|
162 * @param aItemIsCurrent @c ETrue if the item is current. @c EFalse |
|
163 * otherwise. |
|
164 * @param aViewIsEmphasized @c ETrue if the view is emphasized. @c EFalse |
|
165 * otherwise. |
|
166 * @param aItemIsSelected @c ETrue if the item is selected. @c EFalse |
|
167 * otherwise. |
|
168 */ |
|
169 void DrawItemText(TInt aItemIndex,const TRect& aItemTextRect, |
|
170 TBool aItemIsCurrent, TBool aViewIsEmphasized, |
|
171 TBool aItemIsSelected) const; |
|
172 |
|
173 /** |
|
174 * From @c CTextListItemDrawer. |
|
175 * |
|
176 * Draws an item tick mark. |
|
177 * |
|
178 * A tick mark is used in multiple selection lists to indicate the item is |
|
179 * selected. |
|
180 * |
|
181 * This function is invoked by the framework to draw an item mark if |
|
182 * @c iDrawMark is set. The mark should be drawn into this list item |
|
183 * drawer's graphics context; by default, @c DrawItemMark() draws a tick |
|
184 * using the standard symbol font. |
|
185 * |
|
186 * This function does not need to be re-implemented for derived classes |
|
187 * which do not draw item marks. |
|
188 * |
|
189 * @param aItemIsSelected Whether the item to draw for is selected. |
|
190 * @param aViewIsDimmed Whether the item is dimmed. |
|
191 * @param aMarkPos Position of the mark. |
|
192 */ |
|
193 void DrawItemMark(TBool aItemIsSelected, TBool aViewIsDimmed, |
|
194 const TPoint& aMarkPos) const; |
|
195 |
|
196 public: // from CListItemDrawer |
|
197 |
|
198 /** |
|
199 * From @c CListItemDrawer. |
|
200 * |
|
201 * Gets the minimum size of a cell based on the font and the number of |
|
202 * characters in the cell. |
|
203 * |
|
204 * @return The minimum size for a cell in pixels. |
|
205 */ |
|
206 TSize MinimumCellSize() const; |
|
207 |
|
208 /** |
|
209 * From @c CListItemDrawer. |
|
210 * |
|
211 * Gets the width in pixels of the specified item. |
|
212 * |
|
213 * @param aItemIndex The index of the item for which the width is obtained. |
|
214 * @return The specified item's width in pixels. |
|
215 */ |
|
216 TInt ItemWidthInPixels(TInt aItemIndex) const; |
|
217 |
|
218 /** |
|
219 * From @c CListItemDrawer. |
|
220 * |
|
221 * Sets the item cell size. |
|
222 * |
|
223 * The cell size is the on-screen size of the entire item, including its |
|
224 * text and its item mark. |
|
225 * |
|
226 * @param aSizeInPixels New size for the item cell. |
|
227 */ |
|
228 void SetItemCellSize(const TSize& aSizeInPixels); |
|
229 |
|
230 protected: |
|
231 |
|
232 /** |
|
233 * Draws current item rectangle. |
|
234 * |
|
235 * @param aRect Current item rectangle. |
|
236 */ |
|
237 void DrawCurrentItemRect(const TRect& aRect) const; |
|
238 |
|
239 /** |
|
240 * @c WordWrapListItem is used with @c CAknDouble* style listboxes. |
|
241 * If listbox does not have 2nd line defined, @c WordWrapListItem |
|
242 * wraps 1st line to 2nd line, if text does not fit to 1st line. |
|
243 * If listbox does have 2nd line defined, this method truncates |
|
244 * both lines. |
|
245 * |
|
246 * @internal |
|
247 * @param aTarget Where to place wrapped item string |
|
248 * @param aItemString Text to be wrapped |
|
249 * @param aFirstIndex index of 1st subcell to wrap |
|
250 * @param aSecondIndex index of 2nd subcell |
|
251 */ |
|
252 void WordWrapListItem( TPtr& aTarget, |
|
253 const TDesC &aItemString, |
|
254 TInt aFirstIndex, |
|
255 TInt aSecondIndex, |
|
256 TInt aItemIndex ) const; |
|
257 /** |
|
258 * @internal |
|
259 */ |
|
260 void DrawBackgroundAndSeparatorLines( const TRect& aItemTextRect ) const; |
|
261 |
|
262 |
|
263 private: |
|
264 |
|
265 void CCCAppCommLauncherCustomListBoxItemDrawer_Reserved(); |
|
266 |
|
267 protected: |
|
268 |
|
269 /** |
|
270 * Top item index. |
|
271 */ |
|
272 TInt iTopItemIndex; |
|
273 |
|
274 /** |
|
275 * Array for list box item's properties. |
|
276 * Own. |
|
277 */ |
|
278 CArrayFix<SListProperties>* iPropertyArray; |
|
279 |
|
280 private: |
|
281 |
|
282 TInt iSpare; |
|
283 }; |
|
284 |
|
285 |
|
286 |
|
287 #endif /* CCAPPCOMMLAUNCHERCUSTOMLISTBOXITEMDRAWER_H_ */ |