2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Single style hierarchical column list.
19 #ifndef C_AKNSINGLECOLUMNSTYLETREELIST_H
20 #define C_AKNSINGLECOLUMNSTYLETREELIST_H
23 #include <akntreelist.h>
27 * Single style hierarchical column list.
29 * Single style hierarchical column list is hierarchical list type that
30 * can contain three types of items: Core data rows, simple data rows, and
33 * Core data row is a list item that consists of two text columns in
34 * portrait mode, and in addition to those, it can have an optional
35 * third text column in landscape mode. Core data row can contain one icon
36 * in front of text columns, and up to two optional indicator icons at the
37 * other end of the row.
39 * Simple data row is a list item that consists of single text column, and
40 * can have one leaf icon in front of the text, and one optional icon at
43 * Subtitle row is otherwise similar to simple data row, but as core data
44 * row and simple data row are tree leaves that cannot contain other list
45 * items as children, the subtitle row is a tree node that can be used in
46 * forming the hierarchy for the list. As a node, subtitle row has expand
47 * and collapse functionality, and it can group other tree items, including
48 * other subtitle rows. However, since hierarchical column list does not
49 * support indention of tree items or drawing of tree structure lines,
50 * the hierarchy should be limited to two levels for clarity.
52 * The @c CAknSingleColumnStyleTreeList class contains only methods for
53 * constructing the list, constructing and adding the list type specific
54 * items to the list, and setting and getting item type specific properties.
55 * Other methods for list usage can be found from its parent class.
59 * Here is an example of how an instance of window-owning single style
60 * hierarchical column list can be constructed:
63 * // Construct the list, set its size, and make it visible.
64 * CAknSingleColumnStyleTreeList* list
65 * = CAknSingleColumnStyleTreeList::NewL();
66 * list->SetRect( rect );
67 * list->MakeVisible( ETrue );
70 * Adding items to the constructed list:
73 * TUint32 flags = CAknSingleColumnStyleTreeList::EPersistent;
74 * TBool drawNow = EFalse;
76 * // Add simple data row to the top-most level of the tree.
77 * _LIT( KSimpleDataRowText, "Simple data row" );
78 * TAknTreeItemID simpleItem = list->AddSimpleDataRowL( KAknTreeIIDRoot,
79 * KSimpleDataRowText, flags, drawNow );
81 * // Add subtitle row to the to the top-most level of the tree.
82 * _LIT( KSubtitleRowText, "Subtitle row" );
83 * TAknTreeItemID subtitle = list->AddSubtitleRowL( KAknTreeIIDRoot,
84 * KSubtitleRowText, flags, drawNow );
86 * // Add core data row to the previously added subtitle row.
87 * _LIT( KCoreDataRowText, "Core data row" );
88 * TAknTreeItemID coreItem = list->AddCoreDataRowL( subtitle,
89 * KCoreDataRowText, KNulDesC, flags, drawNow );
95 NONSHARABLE_CLASS( CAknSingleColumnStyleTreeList ) : public CAknTreeList
100 /** Item types used in single style hierarchical column list. The type
101 of each item can be get with @c ItemType() method. */
104 /** No item type. Associated with constant @c KAknTreeIIDNone. */
106 /** Tree root. Associated with constant @c KAknTreeIIDRoot. */
108 /** Simple data row. */
110 /** Core data row. */
116 /** Flags usable with single column style tree items. These flags can
117 be given, when adding new items to the list. */
120 /** Item is persistent. */
122 /** Item is marked. */
124 /** Item is expanded. Applicable to subtitle rows only. */
126 /** Item appears non-empty. Applicable to subtitle rows only. */
128 /** Emphasis. Applicable to core data rows only. */
130 /** Item is not markable. */
131 EMarkingDisabled = 0x20
134 /** Icon types usable with single column style hierarchical list.
135 Highlighted icons are used when item is focused, and normal icons are
136 used when item is not focused, or corresponding highlighted icon is
137 not specified for the item. */
141 Only usable with core data rows and simple data rows. */
143 /** Highlighted leaf icon.
144 Only usable with core data rows and simple data rows. */
145 EHighlightedLeaf = 1,
146 /** Expanded node icon. Only usable with subtitle rows. */
148 /** Highlighted expanded node icon. Only usable with subtitle rows. */
149 EHighlightedExpandedNode = 3,
150 /** Collapsed node icon. Only usable with subtitle rows. */
152 /** Highlighted collapsed node icon. Only usable with subtitle rows. */
153 EHighlightedCollapsedNode = 5,
154 /** First optional icon. */
156 /** First highlighted optional icon. */
157 EHighlightedOptionalIcon1 = 7,
158 /** Second optional icon. Only usable with core data rows. */
160 /** Second highlighted optional icon.
161 Only usable with core data rows. */
162 EHighlightedOptionalIcon2 = 9
166 * Two phased constructor. Creates a new single style hierarchical column
167 * list instance as window-owning control.
169 * @return Newly constructed object.
171 * @leave KErrNoMemory Not enough memory.
173 IMPORT_C static CAknSingleColumnStyleTreeList* NewL();
176 * Two phased constructor. Creates a new single style hierarchical column
177 * list instance as non-window-owning component control to the compound
178 * control given as parameter.
180 * @param aContainer The compound control used as container for the list.
182 * @return Newly constructed object.
184 * @leave KErrNoMemory Not enough memory.
186 IMPORT_C static CAknSingleColumnStyleTreeList* NewL(
187 const CCoeControl& aContainer );
190 * Otherwise identical to @c NewL(), but leaves the newly created object
191 * in the cleanup stack.
193 * @copydoc CAknSingleColumnStyleTreeList::NewL()
195 * @post Newly constructed object is left in cleanup stack.
197 IMPORT_C static CAknSingleColumnStyleTreeList* NewLC();
200 * Otherwise identical to @c NewL( const CCoeControl& ), but leaves the
201 * newly created object in the cleanup stack.
203 * @copydoc CAknSingleColumnStyleTreeList::NewL( const CCoeControl& )
205 * @post Newly constructed object is left in cleanup stack.
207 IMPORT_C static CAknSingleColumnStyleTreeList* NewLC(
208 const CCoeControl& aContainer );
213 virtual ~CAknSingleColumnStyleTreeList();
216 * Adds new simple data row to single style hierarchical column list. New
217 * simple data row with the specified content is constructed and added to
218 * the specified parent node. Constant @c KAknTreeIIDRoot can be used as
219 * parent node, if the new item is to be added to the top-most level of
222 * @param aParent The item ID of the parent node.
224 * @param aText Text for simple data row.
226 * @param aFlags Flags for simple data row. Possible flags are defined
227 * in @c CAknSingleColumnStyleTreeList::TItemFlags enumeration.
229 * @param aDrawNow @c ETrue, if the list is to be redrawn after the item
230 * has been added to the list, otherwise @c EFalse.
232 * @return The Item ID for the added node.
234 * @leave KErrNoMemory Not enough memory.
236 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
238 * @panic EAknHListPanicInvalidItemType Specified parent item is not a node.
240 IMPORT_C TAknTreeItemID AddSimpleDataRowL( TAknTreeItemID aParent,
241 const TDesC& aText, TUint32 aFlags, TBool aDrawNow );
244 * Adds new core data row to single style hierarchical column list. New
245 * core data row containing specified two text columns is constructed and
246 * added to the specified parent node. Constant @c KAknTreeIIDRoot can be
247 * used as parent node, if the new item is to be added to the top-most
248 * level of the hierarchy. By default, the core data row created with this
249 * method has its third text column disabled, but it can later be enabled
250 * with @c EnableThirdColumn() method.
252 * @param aParent The item ID of the parent node.
254 * @param aFirstColumn Text for first column of core data row.
256 * @param aSecondColumn Text for second column of core data row.
258 * @param aFlags Flags for core data row. Possible flags are defined
259 * in @c CAknSingleColumnStyleTreeList::TItemFlags enumeration.
261 * @param aDrawNow @c ETrue, if the list is to be redrawn after the item
262 * has been added to the list, otherwise @c EFalse.
264 * @return The Item ID for the added node.
266 * @leave KErrNoMemory Not enough memory.
268 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
270 * @panic EAknHListPanicInvalidItemType Specified parent item is not a node.
272 IMPORT_C TAknTreeItemID AddCoreDataRowL( TAknTreeItemID aParent,
273 const TDesC& aFirstColumn, const TDesC& aSecondColumn, TUint32 aFlags,
277 * Adds new core data row to single style hierarchical column list. New
278 * core data row containing the specified three text columns is constructed
279 * and added to the specified parent node. Constant @c KAknTreeIIDRoot can
280 * be used as parent node, if the new item is to be added to the top-most
281 * level of the hierarchy. By default, the core data row created with this
282 * method has its third text column enabled, but it can later be disabled
283 * with @c EnableThirdColumn() method.
285 * @param aParent The item ID of the parent node.
287 * @param aFirstColumn Text for first column of core data row.
289 * @param aSecondColumn Text for second column of core data row.
291 * @param aThirdColumn Text for third column of core data row. The third
292 * column is visible only in landscape mode.
294 * @param aFlags Flags for core data row. Possible flags are defined
295 * in @c CAknSingleColumnStyleTreeList::TItemFlags enumeration.
297 * @param aDrawNow @c ETrue, if the list is to be redrawn after the item
298 * has been added to the list, otherwise @c EFalse.
300 * @leave KErrNoMemory Not enough memory.
302 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
304 * @panic EAknHListPanicInvalidItemType Specified parent item is not a node.
306 IMPORT_C TAknTreeItemID AddCoreDataRowL( TAknTreeItemID aParent,
307 const TDesC& aFirstColumnd, const TDesC& aSecondColumn,
308 const TDesC& aThirdColumn, TUint32 aFlags, TBool aDrawNow );
311 * Adds new subtitle row to single style hierarchical column list. New row
312 * with the given content is constructed and added to the specified parent
313 * node. Constant @c KAknTreeIIDRoot can be used as parent node, if the new
314 * item is to be added to the top-most level of hierarchy.
316 * @param aParent The item ID of the parent node.
318 * @param aText Text for subtitle row.
320 * @param aFlags Flags for subtitle row. Possible flags are defined
321 * in @c CAknSingleColumnStyleTreeList::TItemFlags enumeration.
323 * @param aDrawNow @c ETrue, if the list is to be redrawn after the item
324 * has been added to the list, otherwise @c EFalse.
326 * @leave KErrNoMemory Not enough memory.
328 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
330 * @panic EAknHListPanicInvalidItemType Specified parent item is not a node.
332 IMPORT_C TAknTreeItemID AddSubtitleRowL( TAknTreeItemID aParent,
333 const TDesC& aText, TUint32 aFlags, TBool aDrawNow );
336 * Returns the text field of the specified list item.
338 * @param aItem Item ID.
340 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
342 IMPORT_C const TDesC& Text( TAknTreeItemID aItem ) const;
345 * Returns the specified text column of specified list item. If the text
346 * for specified column is not set, or the specified column does not
347 * exist, empty descriptor is returned.
349 * @param aItem Item ID.
351 * @param aColumnIndex Column index.
353 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
355 IMPORT_C const TDesC& Text( TAknTreeItemID aItem, TInt aColumnIndex ) const;
358 * Sets the text for specified hierarchical column list item.
360 * @param aItem Item ID.
362 * @param aText Text for specified list item.
364 * @param aDrawNow @c ETrue, if the list is to be redrawn after the text
365 * has been set, otherwise @c EFalse.
367 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
369 IMPORT_C void SetTextL( TAknTreeItemID aItem, const TDesC& aText,
373 * Sets the text for specified column of specified hierarchical column
374 * list item. Non-zero value for column list can only be used with core
375 * data row, as the other row types contain only one text column.
377 * @param aItem Item ID.
379 * @param aText Text for specified list item.
381 * @param aColumnIndex Index specifying the text column.
383 * @param aDrawNow @c ETrue, if the list is to be redrawn after the text
384 * has been set, otherwise @c EFalse.
386 * @leave KErrNotFound Specified column does not exist.
388 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
390 * @panic EAknHListPanicInvalidItemType Invalid item type.
392 IMPORT_C void SetTextL( TAknTreeItemID aItem, const TDesC& aText,
393 TInt aColumnIndex, TBool aDrawNow );
396 * Checks whether the specified core data row is emphasised. When core
397 * data row is emphasized, it uses different text layout for emphasising
400 * @param aItem Item ID for core data row.
402 * @return @c ETrue if item is emphasised, otherwise @c EFalse.
404 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
406 IMPORT_C TBool IsEmphasised( TAknTreeItemID aItem ) const;
409 * Sets the emphasis for specified core data row.
411 * @param aItem Item ID of core data row.
413 * @param aEmphasis @c ETrue to set emphasis on, @c EFalse to set it off.
415 * @param aDrawNow @c ETrue to redraw the list, otherwise @c EFalse.
417 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
419 * @panic EAknHListPanicInvalidItemType Invalid item type.
421 IMPORT_C void SetEmphasis( TAknTreeItemID aItem, TBool aEmphasis,
425 * Checks whether the third text column is enabled for specified core
426 * data row. If third text column is enabled, it is shown for the item
427 * in landscape mode, when list has enough space for the third column.
429 * @param aItem Item ID of core data row.
431 * @return @c ETrue if third column is enabled, otherwise @c EFalse.
433 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
435 IMPORT_C TBool IsThirdColumnEnabled( TAknTreeItemID aItem ) const;
438 * Enables or disables third text column usage in landscape mode for
439 * specified core data row.
441 * @param aItem Item ID or core data row.
443 * @param aEnable @c ETrue to enable third text column usage, @c EFalse
446 * @param aDrawNow @c ETrue to redraw the list, otherwise @c EFalse.
448 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
450 * @panic EAknHListPanicInvalidItemType Invalid item type.
452 IMPORT_C void EnableThirdColumn( TAknTreeItemID aItem, TBool aEnable,
456 * Returns the icon ID set for the specified icon of a list item.
458 * @param aItem Item ID of a list item.
460 * @param aType Type defining the specific icon within list item.
462 * @return Icon ID. The value @c AknTreeListIconID::KDefault is returned,
463 * if no icon has been set. Value @c KErrNotFound is returned, if the
464 * item does not contain icon of specified type.
466 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
468 IMPORT_C TInt Icon( TAknTreeItemID aItem, TIconType aType ) const;
471 * Sets an icon for a list item. Every list item may have several icons,
472 * so the correct icon has to be specified with the icon type. Note that
473 * the type has to be applicable to the specified list item. Pre-defined
474 * icon IDs can be found within @c AknTreeListIconID namespace. Constant
475 * @c AknTreeListIconID::KDefault can be used to indicate that default
476 * icon is to be used, and constant @c AknTreeListIconID::KNone to
477 * indicate that no icon is to be used.
479 * @param aItem Item ID of the modified list item.
481 * @param aType The type of the icon to be added.
483 * @param aIconId Icon ID. Icon ID is one of the pre-defined icon IDs, or
484 * an integer value returned by @c AddIconL() or @c AddColorIconL()
485 * methods when new icon was added to the list.
487 * @param aDrawNow @c ETrue to redraw the list after the icon has been
488 * changed, otherwise @c EFalse.
490 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
492 * @panic EAknHListPanicInvalidItemType Specified icon is not applicable
493 * with the item type.
495 IMPORT_C void SetIcon( TAknTreeItemID aItem, TIconType aType,
496 TInt aIconId, TBool aDrawNow );
499 * Checks the type of the specified list item.
501 * @param aItem Item ID specifying the list item.
503 * @return Type of the item.
505 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
507 IMPORT_C TItemType ItemType( TAknTreeItemID aItem ) const;
509 // from base class CAknTreeList
513 * Sets the flags for the single style hierarchical column list.
515 * @param aFlags Flags.
517 void SetFlags( TUint32 aFlags );
521 * Handles resource changes.
525 void HandleResourceChange( TInt aType );
530 * Default constructor.
532 CAknSingleColumnStyleTreeList();
535 * Second phase constructor.
540 * Second phase constructor.
542 * @param aContainer Container for the list.
544 void ConstructL( const CCoeControl& aContainer );
549 void UpdateIndention();
556 #endif // C_AKNSINGLECOLUMNSTYLETREELIST_H