2 * Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Single style hierarchical list.
19 #ifndef C_AKNSINGLESTYLETREELIST_H
20 #define C_AKNSINGLESTYLETREELIST_H
23 #include <akntreelist.h>
27 * Single style hierarchical list.
29 * Single style hierarchical list is a hierarchical list specialisation for
30 * a list type with simple list items, which contain only a folder or file
31 * icon, single line of text and some optional icons. This class provides
32 * only the specialisation specific APIs for the list usage. The common
33 * hierarchical list APIs are located in its base class.
35 * Here is an example of how an instance of window-owning single style
36 * hierarchical list can be constructed:
39 * // Construct the list, set its size, and make it visible.
40 * CAknSingleStyleTreeList* list = CAknSingleStyleTreeList::NewL();
41 * list->SetRect( rect );
42 * list->MakeVisible( ETrue );
45 * Adding items to the constructed list:
48 * // Add a node to the top-most level of the tree.
49 * _LIT( KNodeText, "Node" );
50 * TUint32 flags = CAknSingleStyleTreeList::EPersistent;
51 * TAknTreeItemID node = list->AddNodeL( KAknTreeIIDRoot, KNodeText,
54 * // Add a leaf to the previously added node.
55 * _LIT( KLeafText, "Leaf" );
56 * TAknTreeItemID leaf = list->AddLeafL( node, KLeafText, flags, EFalse );
59 * Changing icons for the list items:
62 * // Add icon to the list and set it to existing list item.
63 * TInt iconId = list->AddIconL( KAknsIIDQgnPropBtCarkit,
64 * AknIconUtils::AvkonIconFileName(), EMbmAvkonQgn_prop_bt_carkit,
65 * EMbmAvkonQgn_prop_bt_carkit_mask, EAspectRatioPreserved );
66 * list->SetIcon( leaf, CAknSingleStyleTreeList::ELeaf, iconId, ETrue );
74 NONSHARABLE_CLASS( CAknSingleStyleTreeList ) : public CAknTreeList
79 /** Icon types usable with single style hierarchical list. Normal icons
80 are used when the list item is not focused, and highlighted icons are
81 used when list item is focused. Normal icons are used also when list
82 item is focused, if corresponding highlighted icon is not specified
86 /** Leaf icon. Only usable with tree leaves. */
88 /** Highlighted leaf icon. Only usable with tree leaves. */
90 /** Expanded node icon. Only usable with tree nodes. */
92 /** Highlighted expanded node icon. Only usable with tree nodes. */
93 EHighlightedExpandedNode = 3,
94 /** Collapsed node icon. Only usable with tree nodes. */
96 /** Highlighted collapsed node icon. Only usable with tree nodes. */
97 EHighlightedCollapsedNode = 5,
98 /** First optional icon. */
100 /** First highlighted optional icon. */
101 EHighlightedOptionalIcon1 = 7,
102 /** Second optional icon. */
104 /** Second highlighted optional icon. */
105 EHighlightedOptionalIcon2 = 9
108 /** Single style hierarchical list ordering types. */
111 /** Ascending alphabetical ordering based on item text fields. */
112 EAscendingAlphabeticalOrdering,
113 /** Descending alphabetical ordering based on item text fields. */
114 EDescendingAlphabeticalOrdering
117 /** Flags usable with single style tree items. */
118 enum TSingleStyleItemFlags
120 /** Item is persistent. */
122 /** Item is marked. */
124 /** Item is expanded. Applicable to nodes only. */
126 /** Item appears non-empty. Applicable to nodes only. */
131 * Two phased constructor. Creates a new single style hierarchical list
132 * instance as window-owning control.
134 * @return Newly constructed object.
136 * @leave KErrNoMemory Not enough memory.
138 IMPORT_C static CAknSingleStyleTreeList* NewL();
141 * Two phased constructor. Creates a new single style hierarchical list
142 * instance as non-window-owning component control to the compound control
143 * given as parameter.
145 * @param aContainer The compound control used as container for the list.
147 * @return Newly constructed object.
149 * @leave KErrNoMemory Not enough memory.
151 IMPORT_C static CAknSingleStyleTreeList* NewL(
152 const CCoeControl& aContainer );
155 * Otherwise identical to @c NewL(), but leaves the newly created object
156 * in the cleanup stack.
158 * @copydoc CAknSingleStyleTreeList::NewL()
160 * @post Newly constructed object is left in cleanup stack.
162 IMPORT_C static CAknSingleStyleTreeList* NewLC();
165 * Otherwise identical to @c NewL( const CCoeControl& ), but leaves the
166 * newly created object in the cleanup stack.
168 * @copydoc CAknSingleStyleTreeList::NewL( const CCoeControl& )
170 * @post Newly constructed object is left in cleanup stack.
172 IMPORT_C static CAknSingleStyleTreeList* NewLC(
173 const CCoeControl& aContainer );
178 virtual ~CAknSingleStyleTreeList();
181 * Adds new leaf (file) to single style hierarchical list. New leaf with
182 * the specified content is created and added to the specified parent node.
183 * Constant @c KAknTreeIIDRoot can be used, if the new item is to be added
184 * to the top-most level of the hierarchical list.
186 * @param aParent The item ID of the parent node.
188 * @param aText Text for the added item.
190 * @param aFlags Flags for the added item.
192 * @param aDrawNow @c ETrue, if the list is to be redrawn after the item
193 * has been added to the list, otherwise @c EFalse.
195 * @return The item ID for the added leaf.
197 * @leave KErrNoMemory Not enough memory.
199 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
201 * @panic EAknHListPanicInvalidItemType Specified parent item is not a node.
203 IMPORT_C TAknTreeItemID AddLeafL( TAknTreeItemID aParent,
204 const TDesC& aText, TUint32 aFlags, TBool aDrawNow );
207 * Adds new node (folder) to single style hierarchical list. New node with
208 * the specified content is created and added to the specified parent node.
209 * Constant @c KAknTreeIIDRoot can be used, if the new item is to be added
210 * to the top-most level of the hierarchical list.
212 * @param aParent The item ID of the parent node.
214 * @param aText Text for the added node.
216 * @param aFlags Flags for the added node.
218 * @param aDrawNow @c ETrue to redraw the list after the node has been
219 * added, otherwise @c EFalse.
221 * @return The Item ID for the added node.
223 * @leave KErrNoMemory Not enough memory.
225 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
227 * @panic EAknHListPanicInvalidItemType Specified parent item is not a node.
229 IMPORT_C TAknTreeItemID AddNodeL( TAknTreeItemID aParent,
230 const TDesC& aText, TUint32 aFlags, TBool aDrawNow );
233 * Sorts the hierarchical list according to the given ordering.
235 * @param aOrdering Type of ordering.
237 * @param aDrawNow @c ETrue to redraw the list after it has been sorted
238 * according the new ordering, otherwise @c EFalse.
240 * @leave KErrNoMemory Not enough memory.
242 IMPORT_C void SortL( TOrdering aOrdering, TBool aDrawNow );
245 * Changes the text of the specified item. Note that the change of text
246 * might also affect the item's position in the list, when the items are
247 * ordered based on their text fields.
249 * @param aItem Item ID of modified item.
251 * @param aText New text for the item.
253 * @param aDrawNow @c ETrue if the list is to be redrawn after the text
256 * @leave KErrNoMemory Not enough memory for adding text.
258 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
260 * @panic EAknHListPanicInvalidItemType Specified item has invalid type.
262 IMPORT_C void SetTextL( TAknTreeItemID aItem, const TDesC& aText,
266 * Returns the text field of the specified item.
268 * @param aItem Item ID.
270 * @return Text of the specified item.
272 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
274 IMPORT_C const TDesC& Text( TAknTreeItemID aItem ) const;
277 * Sets an icon for a list item. Every list item may have several icons,
278 * so the correct icon has to be specified with the icon type. Note that
279 * the type has to be applicable to the specified list item. Pre-defined
280 * icon IDs can be found within @c AknTreeListIconID namespace. Constant
281 * @c AknTreeListIconID::KDefault can be used to indicate that default
282 * icon is to be used, and constant @c AknTreeListIconID::KNone to
283 * indicate that no icon is to be used.
285 * @param aItem Item ID of the modified list item.
287 * @param aType The type of the icon to be added.
289 * @param aIconId Icon ID. Icon ID is the integer value returned by the
290 * @c AddIconL() method when the icon was added to the list.
292 * @param aDrawNow @c ETrue to redraw the list after the icon has been
293 * changed, othewise @c EFalse.
295 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
297 * @panic EAknHListPanicInvalidItemType Specified icon is not applicable
298 * with the item type.
300 IMPORT_C void SetIcon( TAknTreeItemID aItem, TIconType aType,
301 TInt aIconId, TBool aDrawNow );
304 * Returns the icon ID set for the specified icon of a list item.
306 * @param aItem Item ID of a list item.
308 * @param aType Type defining the specific icon within list item.
310 * @return Icon ID. The value @c AknTreeListIconID::KDefault is returned,
311 * if no icon has been set. Value @c KErrNotFound is returned, if the
312 * item does not contain icon of specified type.
314 * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
316 IMPORT_C TInt Icon( TAknTreeItemID aItem, TIconType aType ) const;
318 // from base class CAknTreeList
322 * Sets the flags for the single style hierarchical list.
324 * @param aFlags Flags.
326 void SetFlags( TUint32 aFlags );
331 * Default constructor.
333 CAknSingleStyleTreeList();
336 * Second phase constructor.
341 * Second phase constructor.
343 * @param aContainer Container for the list.
345 void ConstructL( const CCoeControl& aContainer );
350 #endif // C_AKNSINGLESTYLETREELIST_H