|
1 /* |
|
2 * Copyright (c) 2007 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: Single column style core data row. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_AKNSINGLECOLUMNSTYLECOREDATAROW_H |
|
20 #define C_AKNSINGLECOLUMNSTYLECOREDATAROW_H |
|
21 |
|
22 #include <babitflags.h> |
|
23 |
|
24 #include "akntreeleaf.h" |
|
25 |
|
26 |
|
27 /** |
|
28 * Single column style core data row. |
|
29 * |
|
30 * Single column style core data rows can contain a single row of text |
|
31 * consisting of up to three three different columns. The number of visible |
|
32 * columns depends on used layout and column list settings. In addition to |
|
33 * the text columns, the row can contain a leaf icon and two optional icons. |
|
34 * Each of these icons can also have an alternate representation, which is |
|
35 * used when the item is highlighted. |
|
36 * |
|
37 * As core data row is derived from @c CAknTreeLeaf class, other tree |
|
38 * items cannot be added to it as its children. |
|
39 * |
|
40 * @lib aknhlist.lib |
|
41 * @since S60 v5.0 |
|
42 */ |
|
43 NONSHARABLE_CLASS( CAknSingleColumnStyleCoreDataRow ) : public CAknTreeLeaf |
|
44 { |
|
45 |
|
46 public: |
|
47 |
|
48 /** Single style core data row flags. */ |
|
49 enum TItemFlags |
|
50 { |
|
51 /** Third text column is enabled. */ |
|
52 EThirdColumnEnabled = 0x00010000, |
|
53 /** Core data row is emphasised. */ |
|
54 EEmphasis = 0x00020000 |
|
55 }; |
|
56 |
|
57 /** Icon types for single column style core data row. */ |
|
58 enum TIconType |
|
59 { |
|
60 /** Leaf icon. */ |
|
61 EIcon, |
|
62 /** First optional icon. */ |
|
63 EOptIcon1, |
|
64 /** Second optional icon. */ |
|
65 EOptIcon2, |
|
66 /** Highlighted leaf icon. */ |
|
67 EHighlightedIcon, |
|
68 /** Highlighted first optional icon. */ |
|
69 EHighlightedOptIcon1, |
|
70 /** Highlighted second optional icon. */ |
|
71 EHighlightedOptIcon2 |
|
72 }; |
|
73 |
|
74 /** |
|
75 * Two phased constructor. Creates an instance of single column style |
|
76 * core data row and leaves the newly created object in the cleanup |
|
77 * stack. Core data rows constucted with this constructor, by default, |
|
78 * have third text column disabled. |
|
79 * |
|
80 * @param aFirstColumn Text for the first column of core data row. |
|
81 * |
|
82 * @param aSecondColumn Text for the second column of core data row. |
|
83 * |
|
84 * @param aFlags Flags. |
|
85 * |
|
86 * @return Pointer to the newly created object. |
|
87 * |
|
88 * @post Pointer to the newly created object is left in cleanup stack. |
|
89 * |
|
90 * @leave KErrNoMemory Not enough memory. |
|
91 */ |
|
92 static CAknSingleColumnStyleCoreDataRow* NewLC( const TDesC& aFirstColumn, |
|
93 const TDesC& aSecondColumn, TUint32 aFlags ); |
|
94 |
|
95 /** |
|
96 * Two phased constructor. Creates an instance of single column style |
|
97 * core data row and leaves the newly created object in the cleanup |
|
98 * stack. Core data rows constructed with this constructor, by default, |
|
99 * have third text column enabled. |
|
100 * |
|
101 * @param aFirstColumn Text for the first column of core data row. |
|
102 * |
|
103 * @param aSecondColumn Text for the second column of core data row. |
|
104 * |
|
105 * @param aThirdColumn Text for the third column of core data row. |
|
106 * |
|
107 * @param aFlags Flags. |
|
108 * |
|
109 * @return Pointer to the newly created object. |
|
110 * |
|
111 * @post Pointer to the newly created object is left in cleanup stack. |
|
112 * |
|
113 * @leave KErrNoMemory Not enough memory. |
|
114 */ |
|
115 static CAknSingleColumnStyleCoreDataRow* NewLC( const TDesC& aFirstColumn, |
|
116 const TDesC& aSecondColumn, const TDesC& aThirdColumn, |
|
117 TUint32 aFlags ); |
|
118 |
|
119 /** |
|
120 * Destructor. |
|
121 */ |
|
122 virtual ~CAknSingleColumnStyleCoreDataRow(); |
|
123 |
|
124 /** |
|
125 * Text on specified core data row text column. |
|
126 * |
|
127 * @param aColumnIndex Text column index. |
|
128 * |
|
129 * @return Text. |
|
130 */ |
|
131 const TDesC& Text( TInt aColumnIndex ) const; |
|
132 |
|
133 /** |
|
134 * Sets the text for the specified column in core data row. Does not |
|
135 * change the position of the row in the tree. |
|
136 * |
|
137 * @param aText Text. |
|
138 * |
|
139 * @param aColumnIndex Text column index. |
|
140 * |
|
141 * @param aDrawNow @c ETrue to redraw the item after the text is changed. |
|
142 * |
|
143 * @leave KErrNoMemory Not enough memory. |
|
144 * |
|
145 * @leave KErrNotFound Specified column does not exist. |
|
146 */ |
|
147 void SetTextL( const TDesC& aText, TInt aColumnIndex, TBool aDrawNow ); |
|
148 |
|
149 /** |
|
150 * Checks whether core data row is emphasised. |
|
151 * |
|
152 * @return @c ETrue if row is emphasised, otherwise @c EFalse; |
|
153 */ |
|
154 TBool IsEmphasised() const; |
|
155 |
|
156 /** |
|
157 * Set emphasis for core data row. When the core data row is emphasised, |
|
158 * another layout that emphasises the text is used when drawing the item. |
|
159 * By default, each core data row is set emphasised. |
|
160 * |
|
161 * @param aEmphasis @c ETrue if item is to be emphasised. |
|
162 * |
|
163 * @param aDrawNow @c ETrue to redraw the item, otherwise @c EFalse. |
|
164 */ |
|
165 void SetEmphasis( TBool aEmphasis, TBool aDrawNow ); |
|
166 |
|
167 /** |
|
168 * Checks whether the third text column is enabled. |
|
169 * |
|
170 * @return @c ETrue when third text column is enabled. |
|
171 */ |
|
172 TBool IsThirdColumnEnabled() const; |
|
173 |
|
174 /** |
|
175 * Enables third text column to be used in landscape mode when list has |
|
176 * enough space for the third column. |
|
177 * |
|
178 * @param aEnable @c ETrue to enable third column, @c EFalse to disable it. |
|
179 * |
|
180 * @param aDrawNow @c ETrue to redraw the item, otherwise @c EFalse. |
|
181 */ |
|
182 void EnableThirdColumn( TBool aEnable, TBool aDrawNow ); |
|
183 |
|
184 /** |
|
185 * Returns the icon ID set for the specified icon type. |
|
186 * |
|
187 * @param aType Type of the icon. |
|
188 * |
|
189 * @return The icon ID for the icon of specified type. The value |
|
190 * @c AknTreeListIconID::KDefault is returned, if no icon for the |
|
191 * specified type is set. |
|
192 */ |
|
193 TInt Icon( TIconType aType ) const; |
|
194 |
|
195 /** |
|
196 * Sets an icon ID for a specified core data row icon type. The icon ID |
|
197 * indicates which icon from the tree is used when the icon of specified |
|
198 * type is drawn by the tree item. |
|
199 * |
|
200 * @param aType The icon type for which the icon ID is changed. The type |
|
201 * has to be one of the types defined in @c TIconType enumeration. |
|
202 * |
|
203 * @param aIconId The new icon ID for the specified icon type. The value |
|
204 * @c AknTreeListIconID::KDefault indicates that the default icon |
|
205 * for the type is to be used. |
|
206 * |
|
207 * @param aDrawNow @c ETrue to redraw the item after the icon is changed. |
|
208 */ |
|
209 void SetIcon( TIconType aType, TInt aIconId, TBool aDrawNow ); |
|
210 |
|
211 /** |
|
212 * Determines which icon ID is to be used when drawing the row. The used |
|
213 * icon depends on the value of @c aFocused parameter, and which icon IDs |
|
214 * have been set. |
|
215 * |
|
216 * @param aFocused @c ETrue, if icon ID for focused item is required. |
|
217 * |
|
218 * @return Icon ID. |
|
219 */ |
|
220 TInt IconId( TBool aFocused ) const; |
|
221 |
|
222 /** |
|
223 * Determines which icon ID is to be used for the specified optional icon. |
|
224 * |
|
225 * @param aIndex Index specifying the optional icon. |
|
226 * |
|
227 * @param aFocused @c ETrue, if icon ID for focused item is required. |
|
228 * |
|
229 * @return Icon ID for specified optional icon. |
|
230 */ |
|
231 TInt OptionalIconId( TInt aIndex, TBool aFocused ) const; |
|
232 |
|
233 /** |
|
234 * Determines which text layout variety should be used for the specified |
|
235 * text column. |
|
236 * |
|
237 * @param aColumnIndex Index specifying the text column. |
|
238 * |
|
239 * @param aOptIconId1 Icon ID for first optional icon. |
|
240 * |
|
241 * @param aOptIconId2 Icon ID for second optional icon. |
|
242 * |
|
243 * @param aThirdColumnEnabled |
|
244 * |
|
245 * @return Text variety for specified column, or @c KErrNotFound if |
|
246 * suitable variety is not found. |
|
247 */ |
|
248 TInt TextVariety( TInt aColumnIndex, TInt aOptIconId1, |
|
249 TInt aOptIconId2, TBool aThirdColumnEnabled ) const; |
|
250 |
|
251 // from base class CAknTreeItem |
|
252 |
|
253 /** |
|
254 * From CAknTreeItem. |
|
255 * Returns the type of the item. |
|
256 * |
|
257 * @return Item type. |
|
258 */ |
|
259 TInt Type() const; |
|
260 |
|
261 /** |
|
262 * From CAknTreeItem. |
|
263 * Returns the minimum size required to display the item completely in the |
|
264 * view with the current layout. |
|
265 * |
|
266 * @return Minimum size. |
|
267 */ |
|
268 TSize MinimumSize() const; |
|
269 |
|
270 /** |
|
271 * From CAknTreeItem. |
|
272 * Draws the core data row. |
|
273 * |
|
274 * @param aGc Graphic context. |
|
275 * |
|
276 * @param aItemRect A rectangle defining the size and position of the |
|
277 * core data row. |
|
278 * |
|
279 * @param aRect Rectangle that needs to be redrawn. |
|
280 * |
|
281 * @param aFocused @c ETrue, when the item is focused. |
|
282 */ |
|
283 void Draw( CWindowGc& aGc, const TRect& aItemRect, |
|
284 const TRect& aRect, TBool aFocused ) const; |
|
285 |
|
286 /** |
|
287 * From CAknTreeItem. |
|
288 * Handles pointer events. |
|
289 * |
|
290 * @param aPointerEvent Pointer event. |
|
291 * |
|
292 * @param aItemRect Item rectangle. |
|
293 */ |
|
294 void HandlePointerEventL( const TPointerEvent& aPointerEvent, |
|
295 const TRect& aItemRect ); |
|
296 |
|
297 private: |
|
298 |
|
299 /** |
|
300 * C++ constructor. |
|
301 * |
|
302 * @param aFlags Flags. |
|
303 */ |
|
304 CAknSingleColumnStyleCoreDataRow( TUint32 aFlags ); |
|
305 |
|
306 /** |
|
307 * Second phase constructor. |
|
308 * |
|
309 * @param aFirstColumn Text for the first text column. |
|
310 * |
|
311 * @param aSecondColumn Text for the second text column. |
|
312 */ |
|
313 void ConstructL( const TDesC& aFirstColumn, const TDesC& aSecondColumn ); |
|
314 |
|
315 /** |
|
316 * Second phase constructor. |
|
317 * |
|
318 * @param aFirstColumn Text for the first text column. |
|
319 * |
|
320 * @param aSecondColumn Text for the second text column. |
|
321 * |
|
322 * @param aThirdColumn Text for the third text column. |
|
323 */ |
|
324 void ConstructL( const TDesC& aFirstColumn, const TDesC& aSecondColumn, |
|
325 const TDesC& aThirdColumn ); |
|
326 |
|
327 private: // data |
|
328 |
|
329 /** |
|
330 * List item text for the first text column. |
|
331 * Own. |
|
332 */ |
|
333 HBufC* iFirstColumn; |
|
334 |
|
335 /** |
|
336 * List item text for the second text column. |
|
337 * Own. |
|
338 */ |
|
339 HBufC* iSecondColumn; |
|
340 |
|
341 /** |
|
342 * List item text for the third text column. |
|
343 * Own. |
|
344 */ |
|
345 HBufC* iThirdColumn; |
|
346 |
|
347 /** |
|
348 * Icon ID for main core data row icon. |
|
349 */ |
|
350 TInt iIcon; |
|
351 |
|
352 /** |
|
353 * Icon ID for first optional icon. |
|
354 */ |
|
355 TInt iOptIcon1; |
|
356 |
|
357 /** |
|
358 * Icon ID for second optional icon. |
|
359 */ |
|
360 TInt iOptIcon2; |
|
361 |
|
362 /** |
|
363 * Icon ID for highlighted main core data row icon. |
|
364 */ |
|
365 TInt iHighlightedIcon; |
|
366 |
|
367 /** |
|
368 * Icon ID for first highlighted optional icon. |
|
369 */ |
|
370 TInt iHighlightedOptIcon1; |
|
371 |
|
372 /** |
|
373 * Icon ID for second highlighted optional icon. |
|
374 */ |
|
375 TInt iHighlightedOptIcon2; |
|
376 |
|
377 }; |
|
378 |
|
379 |
|
380 #endif // C_AKNSINGLECOLUMNSTYLECOREDATAROW_H |