uifw/AvKon/aknhlist/inc/aknsinglecolumnstylesimpledatarow.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 simple data row.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_AKNSINGLECOLUMNSTYLESIMPLEDATAROW_H
       
    20 #define C_AKNSINGLECOLUMNSTYLESIMPLEDATAROW_H
       
    21 
       
    22 
       
    23 #include "akntreeleaf.h"
       
    24 
       
    25 
       
    26 /**
       
    27  *  Single column style simple data row.
       
    28  *
       
    29  *  Single column style simple data rows can contain single row of text,
       
    30  *  leaf icon, and two optional icons. Each of these icons can also have an
       
    31  *  alternate representation, which is used when the item is highlighted.
       
    32  *
       
    33  *  As simple data row is derived from @c CAknTreeLeaf class, other tree
       
    34  *  items cannot be added to it as its children.
       
    35  *
       
    36  *  @lib aknhlist.lib
       
    37  *  @since S60 v5.0
       
    38  */
       
    39 NONSHARABLE_CLASS( CAknSingleColumnStyleSimpleDataRow ) : public CAknTreeLeaf
       
    40     {
       
    41 
       
    42 public:
       
    43 
       
    44     /** Icon types for column style simple data row. */
       
    45     enum TIconType
       
    46         {
       
    47         /** Leaf icon. */
       
    48         EIcon,
       
    49         /** Optional icon. */
       
    50         EOptIcon,
       
    51         /** Highlighted leaf icon. */
       
    52         EHighlightedIcon,
       
    53         /** Highlighted optional icon. */
       
    54         EHighlightedOptIcon
       
    55         };
       
    56 
       
    57     /**
       
    58      * Two phased constructor. Creates an instance of single column style
       
    59      * simple data row and leaves the newly created object in the cleanup
       
    60      * stack.
       
    61      *
       
    62      * @param aText Text for the simple data row.
       
    63      *
       
    64      * @param aFlags Flags.
       
    65      *
       
    66      * @return Pointer to the newly created object.
       
    67      *
       
    68      * @post Pointer to the newly created object is left in cleanup stack.
       
    69      *
       
    70      * @leave KErrNoMemory Not enough memory.
       
    71      */
       
    72     static CAknSingleColumnStyleSimpleDataRow* NewLC( const TDesC& aText,
       
    73         TUint32 aFlags );
       
    74 
       
    75     /**
       
    76      * Destructor.
       
    77      */
       
    78     virtual ~CAknSingleColumnStyleSimpleDataRow();
       
    79 
       
    80     /**
       
    81      * Text on simple data row.
       
    82      *
       
    83      * @return Text.
       
    84      */
       
    85     const TDesC& Text( ) const;
       
    86 
       
    87     /**
       
    88      * Sets the text for the simple data row. Does not change the position of
       
    89      * the row in the tree.
       
    90      *
       
    91      * @param aText Text.
       
    92      *
       
    93      * @param aDrawNow @c ETrue to redraw the item after the text is changed.
       
    94      *
       
    95      * @leave KErrNoMemory Not enough memory.
       
    96      */
       
    97     void SetTextL( const TDesC& aText, TBool aDrawNow );
       
    98 
       
    99     /**
       
   100      * Returns the icon ID set for the specified icon type.
       
   101      *
       
   102      * @param aType Type of the icon.
       
   103      *
       
   104      * @return The icon ID for the icon of specified type. The value
       
   105      *      @c AknTreeListIconID::KDefault is returned, if no icon for the
       
   106      *      specified type is set.
       
   107      */
       
   108     TInt Icon( TIconType aType ) const;
       
   109 
       
   110     /**
       
   111      * Sets an icon ID for a specified simple data row icon type. The icon ID
       
   112      * indicates which icon from the tree is used when the icon of specified
       
   113      * type is drawn by the tree item.
       
   114      *
       
   115      * @param aType The icon type for which the icon ID is changed. The type
       
   116      *      has to be one of the types defined in @c TIconType enumeration.
       
   117      *
       
   118      * @param aIconId The new icon ID for the specified icon type. The value
       
   119      *      @c AknTreeListIconID::KDefault indicates that the default icon
       
   120      *      for the type is to be used.
       
   121      *
       
   122      * @param aDrawNow @c ETrue to redraw the item after the icon is changed.
       
   123      */
       
   124     void SetIcon( TIconType aType, TInt aIconId, TBool aDrawNow );
       
   125 
       
   126     /**
       
   127      * Determines which icon ID is to be used when drawing the simple data row.
       
   128      * The used icon depends on the value of @c aFocused parameter and which
       
   129      * icon IDs have been set.
       
   130      *
       
   131      * @param aFocused @c ETrue, if icon ID for focused item is required.
       
   132      *
       
   133      * @return Icon ID.
       
   134      */
       
   135     TInt IconId( TBool aFocused ) const;
       
   136 
       
   137     /**
       
   138      * Determines which icon ID is to be used for the optional icon when
       
   139      * drawing the simple data row. The used icon ID depends on the value of
       
   140      * @c aFocused parameter, whether item is marked, and which optional
       
   141      * icon IDs have been set.
       
   142      * 
       
   143      * @param aFocused @c ETrue, if icon ID for focused item is required.
       
   144      *
       
   145      * @return Icon ID for optional icon.
       
   146      */
       
   147     TInt OptionalIconId( TBool aFocused ) const;
       
   148 
       
   149 // from base class CAknTreeItem
       
   150 
       
   151     /**
       
   152      * From CAknTreeItem.
       
   153      * Returns the type of the item.
       
   154      *
       
   155      * @return Item type.
       
   156      */
       
   157     TInt Type() const;
       
   158 
       
   159     /**
       
   160      * From CAknTreeItem.
       
   161      * Draws the simple data row.
       
   162      *
       
   163      * @param aGc Graphic context.
       
   164      *
       
   165      * @param aItemRect A rectangle defining the size and position of the
       
   166      *      simple data row.
       
   167      *
       
   168      * @param aRect Rectangle that needs to be redrawn.
       
   169      *
       
   170      * @param aFocused @c ETrue, when the item is focused.
       
   171      */
       
   172     void Draw( CWindowGc& aGc, const TRect& aItemRect,
       
   173         const TRect& aRect, TBool aFocused ) const;
       
   174 
       
   175     /**
       
   176      * From CAknTreeItem.
       
   177      * Handles pointer events.
       
   178      *
       
   179      * @param aPointerEvent Pointer event.
       
   180      *
       
   181      * @param aItemRect Item rectangle.
       
   182      */
       
   183     void HandlePointerEventL( const TPointerEvent& aPointerEvent,
       
   184         const TRect& aItemRect );
       
   185 
       
   186 private:
       
   187 
       
   188     /**
       
   189      * C++ constructor.
       
   190      *
       
   191      * @param aFlags Flags.
       
   192      */
       
   193     CAknSingleColumnStyleSimpleDataRow( TUint32 aFlags );
       
   194 
       
   195     /**
       
   196      * Second phase constructor.
       
   197      *
       
   198      * @param aText Text for the simle data row.
       
   199      */
       
   200     void ConstructL( const TDesC& aText );
       
   201 
       
   202 private: // data
       
   203 
       
   204     /**
       
   205      * List item text.
       
   206      * Own.
       
   207      */
       
   208     HBufC* iText;
       
   209 
       
   210     /**
       
   211      * Icon ID for simple data row icon.
       
   212      */
       
   213     TInt iIcon;
       
   214 
       
   215     /**
       
   216      * Icon ID for optional simple data row icon.
       
   217      */ 
       
   218     TInt iOptIcon;
       
   219 
       
   220     /**
       
   221      * Icon ID for highlighted simple data row icon.
       
   222      */
       
   223     TInt iHighlightedIcon;
       
   224 
       
   225     /**
       
   226      * Icon ID for highlighted optional simple data row icon.
       
   227      */
       
   228     TInt iHighlightedOptIcon;
       
   229 
       
   230     };
       
   231 
       
   232 
       
   233 #endif // C_AKNSINGLECOLUMNSTYLESIMPLEDATAROW_H