epoc32/include/mw/aknsinglestyletreelist.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2 * Copyright (c) 2006, 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 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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  Single style hierarchical list.
    15 *
    16 */
    17 
    18 
    19 #ifndef C_AKNSINGLESTYLETREELIST_H
    20 #define C_AKNSINGLESTYLETREELIST_H
    21 
    22 
    23 #include <akntreelist.h>
    24 
    25 
    26 /**
    27  *  Single style hierarchical list.
    28  *
    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.
    34  *
    35  *  Here is an example of how an instance of window-owning single style
    36  *  hierarchical list can be constructed:
    37  *
    38  *  @code
    39  *  // Construct the list, set its size, and make it visible.
    40  *  CAknSingleStyleTreeList* list = CAknSingleStyleTreeList::NewL();
    41  *  list->SetRect( rect );
    42  *  list->MakeVisible( ETrue );
    43  *  @endcode
    44  *
    45  *  Adding items to the constructed list:
    46  *
    47  *  @code
    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,
    52  *      flags, EFalse );
    53  *
    54  *  // Add a leaf to the previously added node.
    55  *  _LIT( KLeafText, "Leaf" );
    56  *  TAknTreeItemID leaf = list->AddLeafL( node, KLeafText, flags, EFalse );
    57  *  @endcode
    58  *
    59  *  Changing icons for the list items:
    60  *
    61  *  @code
    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 );
    67  *  @endcode
    68  *
    69  *  @see CAknTreeList
    70  *
    71  *  @lib aknhlist.lib
    72  *  @since S60 v3.2
    73  */
    74 NONSHARABLE_CLASS( CAknSingleStyleTreeList ) : public CAknTreeList
    75     {
    76 
    77 public:
    78 
    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
    83         for the list item. */
    84     enum TIconType
    85         {
    86         /** Leaf icon. Only usable with tree leaves. */
    87         ELeaf                       = 0,
    88         /** Highlighted leaf icon. Only usable with tree leaves. */
    89         EHighlightedLeaf            = 1,
    90         /** Expanded node icon. Only usable with tree nodes. */
    91         EExpandedNode               = 2,
    92         /** Highlighted expanded node  icon. Only usable with tree nodes. */
    93         EHighlightedExpandedNode    = 3,
    94         /** Collapsed node icon. Only usable with tree nodes. */
    95         ECollapsedNode              = 4,
    96         /** Highlighted collapsed node icon. Only usable with tree nodes. */
    97         EHighlightedCollapsedNode   = 5,
    98         /** First optional icon. */
    99         EOptionalIcon1              = 6,
   100         /** First highlighted optional icon. */
   101         EHighlightedOptionalIcon1   = 7,
   102         /** Second optional icon. */
   103         EOptionalIcon2              = 8,
   104         /** Second highlighted optional icon. */
   105         EHighlightedOptionalIcon2   = 9
   106         };
   107 
   108     /** Single style hierarchical list ordering types. */
   109     enum TOrdering
   110         {
   111         /** Ascending alphabetical ordering based on item text fields. */
   112         EAscendingAlphabeticalOrdering,
   113         /** Descending alphabetical ordering based on item text fields. */
   114         EDescendingAlphabeticalOrdering
   115         };
   116 
   117     /** Flags usable with single style tree items. */
   118     enum TSingleStyleItemFlags
   119         {
   120         /** Item is persistent. */
   121         EPersistent = 0x01,
   122         /** Item is marked. */
   123         EMarked     = 0x02,
   124         /** Item is expanded. Applicable to nodes only. */
   125         EExpanded   = 0x04,
   126         /** Item appears non-empty. Applicable to nodes only. */
   127         ENonEmpty   = 0x08
   128         };
   129 
   130     /**
   131      * Two phased constructor. Creates a new single style hierarchical list
   132      * instance as window-owning control.
   133      *
   134      * @return Newly constructed object.
   135      *
   136      * @leave KErrNoMemory Not enough memory.
   137      */
   138     IMPORT_C static CAknSingleStyleTreeList* NewL();
   139 
   140     /**
   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.
   144      *
   145      * @param aContainer The compound control used as container for the list.
   146      *
   147      * @return Newly constructed object.
   148      *
   149      * @leave KErrNoMemory Not enough memory.
   150      */
   151     IMPORT_C static CAknSingleStyleTreeList* NewL(
   152         const CCoeControl& aContainer );
   153 
   154     /**
   155      * Otherwise identical to @c NewL(), but leaves the newly created object
   156      * in the cleanup stack.
   157      *
   158      * @copydoc CAknSingleStyleTreeList::NewL()
   159      *
   160      * @post Newly constructed object is left in cleanup stack.
   161      */
   162     IMPORT_C static CAknSingleStyleTreeList* NewLC();
   163 
   164     /**
   165      * Otherwise identical to @c NewL( const CCoeControl& ), but leaves the
   166      * newly created object in the cleanup stack.
   167      *
   168      * @copydoc CAknSingleStyleTreeList::NewL( const CCoeControl& )
   169      *
   170      * @post Newly constructed object is left in cleanup stack.
   171      */
   172     IMPORT_C static CAknSingleStyleTreeList* NewLC(
   173         const CCoeControl& aContainer );
   174 
   175     /**
   176      * Destructor.
   177      */
   178     virtual ~CAknSingleStyleTreeList();
   179 
   180     /**
   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.
   185      *
   186      * @param aParent The item ID of the parent node.
   187      *
   188      * @param aText Text for the added item.
   189      *
   190      * @param aFlags Flags for the added item.
   191      *
   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.
   194      *
   195      * @return The item ID for the added leaf.
   196      *
   197      * @leave KErrNoMemory Not enough memory.
   198      *
   199      * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
   200      *
   201      * @panic EAknHListPanicInvalidItemType Specified parent item is not a node.
   202      */
   203     IMPORT_C TAknTreeItemID AddLeafL( TAknTreeItemID aParent,
   204         const TDesC& aText, TUint32 aFlags, TBool aDrawNow );
   205 
   206     /**
   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.
   211      *
   212      * @param aParent The item ID of the parent node.
   213      *
   214      * @param aText Text for the added node.
   215      *
   216      * @param aFlags Flags for the added node.
   217      *
   218      * @param aDrawNow @c ETrue to redraw the list after the node has been
   219      *      added, otherwise @c EFalse.
   220      *
   221      * @return The Item ID for the added node.
   222      *
   223      * @leave KErrNoMemory Not enough memory.
   224      *
   225      * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
   226      *
   227      * @panic EAknHListPanicInvalidItemType Specified parent item is not a node.
   228      */
   229     IMPORT_C TAknTreeItemID AddNodeL( TAknTreeItemID aParent,
   230         const TDesC& aText, TUint32 aFlags, TBool aDrawNow );
   231 
   232     /**
   233      * Sorts the hierarchical list according to the given ordering.
   234      *
   235      * @param aOrdering Type of ordering.
   236      *
   237      * @param aDrawNow @c ETrue to redraw the list after it has been sorted
   238      *      according the new ordering, otherwise @c EFalse.
   239      *
   240      * @leave KErrNoMemory Not enough memory.
   241      */
   242     IMPORT_C void SortL( TOrdering aOrdering, TBool aDrawNow );
   243 
   244     /** 
   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.
   248      *
   249      * @param aItem Item ID of modified item.
   250      *
   251      * @param aText New text for the item.
   252      *
   253      * @param aDrawNow @c ETrue if the list is to be redrawn after the text
   254      *      has been changed.
   255      *
   256      * @leave KErrNoMemory Not enough memory for adding text.
   257      *
   258      * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
   259      *
   260      * @panic EAknHListPanicInvalidItemType Specified item has invalid type.
   261      */
   262     IMPORT_C void SetTextL( TAknTreeItemID aItem, const TDesC& aText,
   263         TBool aDrawNow );
   264 
   265     /**
   266      * Returns the text field of the specified item.
   267      *
   268      * @param aItem Item ID.
   269      *
   270      * @return Text of the specified item.
   271      *
   272      * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
   273      */ 
   274     IMPORT_C const TDesC& Text( TAknTreeItemID aItem ) const;
   275 
   276     /**
   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.
   284      *
   285      * @param aItem Item ID of the modified list item.
   286      *
   287      * @param aType The type of the icon to be added.
   288      *
   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.
   291      *
   292      * @param aDrawNow @c ETrue to redraw the list after the icon has been
   293      *      changed, othewise @c EFalse.
   294      *
   295      * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
   296      *
   297      * @panic EAknHListPanicInvalidItemType Specified icon is not applicable
   298      *      with the item type.
   299      */
   300     IMPORT_C void SetIcon( TAknTreeItemID aItem, TIconType aType,
   301         TInt aIconId, TBool aDrawNow );
   302 
   303     /**
   304      * Returns the icon ID set for the specified icon of a list item.
   305      *
   306      * @param aItem Item ID of a list item.
   307      *
   308      * @param aType Type defining the specific icon within list item.
   309      *
   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.
   313      *
   314      * @panic EAknHListPanicInvalidItemID Item with specified ID is not found.
   315      */
   316     IMPORT_C TInt Icon( TAknTreeItemID aItem, TIconType aType ) const;
   317 
   318 // from base class CAknTreeList
   319 
   320     /**
   321      * From CAknTreeList.
   322      * Sets the flags for the single style hierarchical list.
   323      *
   324      * @param aFlags Flags.
   325      */
   326     void SetFlags( TUint32 aFlags );
   327 
   328 private:
   329 
   330     /**
   331      * Default constructor.
   332      */
   333     CAknSingleStyleTreeList();
   334 
   335     /**
   336      * Second phase constructor.
   337      */
   338     void ConstructL();
   339 
   340     /**
   341      * Second phase constructor.
   342      *
   343      * @param aContainer Container for the list.
   344      */
   345     void ConstructL( const CCoeControl& aContainer );
   346 
   347     };
   348 
   349 
   350 #endif // C_AKNSINGLESTYLETREELIST_H