classicui_pub/generic_button_api/inc/AknButton.h
changeset 0 2f259fa3e83a
child 5 aabf2c525e0f
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2005-2008 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:  Button component.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __AKNBUTTON_H__
       
    21 #define __AKNBUTTON_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <AknControl.h>
       
    25 #include <AknIconUtils.h>
       
    26 #include <AknUtils.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CGulIcon;
       
    30 class CAknButton;
       
    31 class CAknButtonExtension; 
       
    32 class CAknInfoPopupNoteController;
       
    33 class CAknButtonStateExtension;
       
    34 class CAknPictographInterface;
       
    35 class CAknsFrameBackgroundControlContext;
       
    36 class CAknResourceProvider;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 *  Class which represents one of the button states. 
       
    42 *
       
    43 *  @lib eikcoctl.lib
       
    44 *  @since Series 60 3.1
       
    45 */
       
    46 class CAknButtonState : public CBase
       
    47     {           
       
    48     public: // Constructors and destructors
       
    49 
       
    50         /**
       
    51          * Destructor.
       
    52          */
       
    53         IMPORT_C ~CAknButtonState();
       
    54 
       
    55     protected: // Constructors and destructors
       
    56 
       
    57         /**
       
    58          * Constructor.
       
    59          *
       
    60          * @param aFlags The flags for the button state
       
    61          */
       
    62         IMPORT_C CAknButtonState( const TInt aFlags );
       
    63 
       
    64         /**
       
    65          * Symbian 2nd phase constructor.
       
    66          *
       
    67          * @param aIcon The icon for the normal state. Takes ownership.
       
    68          * @param aDimmedIcon The icon for the dimmed state. Takes ownership.
       
    69          * @param aPressedIcon The icon for the pressed down. Takes ownership.
       
    70          * @param aHoverIcon The icon for the hover state. Takes ownership.
       
    71          * @param aText The text inside the button.
       
    72          * @param aHelpText The text for the tooltip.
       
    73          */
       
    74         IMPORT_C void ConstructL( CGulIcon* aIcon,
       
    75                                   CGulIcon* aDimmedIcon, 
       
    76                                   CGulIcon* aPressedIcon,
       
    77                                   CGulIcon* aHoverIcon,
       
    78                                   const TDesC& aText, 
       
    79                                   const TDesC& aHelpText );
       
    80 
       
    81         /**
       
    82          * Symbian 2nd phase constructor.
       
    83          *
       
    84          * @param aFilePath The path to the file which contains icons.
       
    85          * @param aBmpId The bitmap ID for the normal state icon.
       
    86          * @param aMaskId The mask ID for the normal state icon.
       
    87          * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
       
    88          * @param aDimmedMaskId The mask ID for the dimmed state icon.
       
    89          * @param aPressedBmpId The bitmap ID for the pressed down state.
       
    90          * @param aPressedMaskId The mask ID for the pressed down state.
       
    91          * @param aHoverBmpId The bitmap ID for the hover state icon.
       
    92          * @param aHoverMaskId The mask ID for the hover state icon.
       
    93          * @param aText The text inside the button.
       
    94          * @param aHelpText The text for the tooltip.
       
    95          * @param aId Item ID of the masked bitmap to be created for skin 
       
    96          *          specific icon.
       
    97          * @param aDimmedId Item ID of the dimmed masked bitmap to be created
       
    98          *          for skin specific icon.
       
    99          * @param aPressedId Item ID of the pressed masked bitmap to be created
       
   100          *          for skin specific icon.
       
   101          * @param aHoverId Item ID of the masked hover bitmap to be created
       
   102          *          for skin specific icon.
       
   103          */
       
   104         IMPORT_C void ConstructL( const TDesC& aFilePath, 
       
   105                                   const TInt aBmpId, 
       
   106                                   const TInt aMaskId,
       
   107                                   const TInt aDimmedBmpId, 
       
   108                                   const TInt aDimmedMaskId,
       
   109                                   const TInt aPressedBmpId, 
       
   110                                   const TInt aPressedMaskId,
       
   111                                   const TInt aHoverBmpId,
       
   112                                   const TInt aHoverMaskId,
       
   113                                   const TDesC& aText, 
       
   114                                   const TDesC& aHelpText,
       
   115                                   const TAknsItemID& aId = KAknsIIDNone, 
       
   116                                   const TAknsItemID& aDimmedId = KAknsIIDNone, 
       
   117                                   const TAknsItemID& aPressedId = KAknsIIDNone,
       
   118                                   const TAknsItemID& aHoverId = KAknsIIDNone );
       
   119 
       
   120     public: // New functions
       
   121 
       
   122         /**
       
   123          * Provides the icon for the normal state.
       
   124          *
       
   125          * @return The icon for the normal state.
       
   126          */
       
   127         IMPORT_C const CGulIcon* Icon() const;
       
   128 
       
   129         /**
       
   130          * Provides the icon for the dimmed state.
       
   131          *
       
   132          * @return The icon for the dimmed state.
       
   133          */
       
   134         IMPORT_C const CGulIcon* DimmedIcon() const;
       
   135 
       
   136         /**
       
   137          * Provides the icon for the pressed down (not released) state.
       
   138          *
       
   139          * @return The icon for the pressed down (not released) state.
       
   140          */
       
   141         IMPORT_C const CGulIcon* PressedIcon() const;
       
   142         
       
   143         /**
       
   144          * Provides the icon for the hover state.
       
   145          *
       
   146          * @return The icon for the hover state.
       
   147          */
       
   148         IMPORT_C const CGulIcon* HoverIcon() const;
       
   149 
       
   150         /**
       
   151          * Provides the text inside the button.
       
   152          *
       
   153          * @return The button text.
       
   154          */
       
   155         IMPORT_C const TDesC& Text() const;
       
   156 
       
   157         /**
       
   158          * Provides the text inside the help note.
       
   159          *
       
   160          * @return The tooltip text.
       
   161          */
       
   162         IMPORT_C const TDesC& HelpText() const;
       
   163 
       
   164         /**
       
   165          * Provides the flags for the state.
       
   166          *
       
   167          * @return The state flags.
       
   168          */
       
   169         IMPORT_C TInt Flags() const;
       
   170 
       
   171         /**
       
   172          * Sets the icon for the normal state. Takes ownership.
       
   173          *
       
   174          * @param aIcon The icon for the normal state.
       
   175          */
       
   176         IMPORT_C void SetIcon( CGulIcon* aIcon );
       
   177 
       
   178         /**
       
   179          * Sets the icon for the dimmed state. Takes ownership.
       
   180          *
       
   181          * @param aDimmedIcon The icon for the dimmed state.
       
   182          */
       
   183         IMPORT_C void SetDimmedIcon( CGulIcon* aDimmedIcon );
       
   184 
       
   185         /**
       
   186          * Sets the icon for the pressed down state. Takes ownership.
       
   187          *
       
   188          * @param aPressedIcon The icon for the pressed down state.
       
   189          */
       
   190         IMPORT_C void SetPressedIcon( CGulIcon* aPressedIcon );
       
   191 
       
   192         /**
       
   193          * Sets the icon for the hover state. Takes ownership.
       
   194          *
       
   195          * @param aHoverIcon The icon for the hover state.
       
   196          */
       
   197         IMPORT_C void SetHoverIcon( CGulIcon* aHoverIcon );
       
   198 
       
   199         /**
       
   200          * Sets the text inside the button.
       
   201          *
       
   202          * @param aText The text inside the button.
       
   203          */
       
   204         IMPORT_C void SetTextL( const TDesC& aText );
       
   205 
       
   206         /**
       
   207          * Sets the text inside the help note.
       
   208          *
       
   209          * @param aHelpText The text inside the tooltip.
       
   210          */
       
   211         IMPORT_C void SetHelpTextL( const TDesC& aHelpText );
       
   212 
       
   213         /**
       
   214          * Sets the flags for the state.
       
   215          *
       
   216          * @param aFlags The flags for the state.
       
   217          */
       
   218         IMPORT_C void SetFlags( const TInt aFlags );
       
   219         
       
   220         /**
       
   221          * Sets the icon for the normal state
       
   222          *
       
   223          * @param aFlags The flags for the state.
       
   224          */
       
   225         void UpdateIconL( const TDesC& aFilePath, 
       
   226                           const TInt aBmpId, 
       
   227                           const TInt aMaskId,
       
   228                           const TInt aDimmedBmpId, 
       
   229                           const TInt aDimmedMaskId,
       
   230                           const TInt aPressedBmpId, 
       
   231                           const TInt aPressedMaskId,
       
   232                           const TInt aHoverBmpId,
       
   233                           const TInt aHoverMaskId,
       
   234                           const TAknsItemID& aId = KAknsIIDNone, 
       
   235                           const TAknsItemID& aDimmedId = KAknsIIDNone, 
       
   236                           const TAknsItemID& aPressedId = KAknsIIDNone,
       
   237                           const TAknsItemID& aHoverId = KAknsIIDNone );
       
   238         
       
   239         
       
   240         
       
   241     protected: // New functions
       
   242 
       
   243         /**
       
   244          * Constructs controls from a resource file.
       
   245          * @param aReader The resource reader with which to access the
       
   246          *          control's resource values.
       
   247          */
       
   248         IMPORT_C virtual void ConstructFromResourceL( TResourceReader& aReader );
       
   249 
       
   250         /**
       
   251          * Updates the size of icons. Called from CAknButton::SizeChanged() 
       
   252          * function.
       
   253          *
       
   254          * @param aRect The new rectangle for the icons.
       
   255          * @param aScaleMode The scale mode which was set for the button.
       
   256          */
       
   257         IMPORT_C virtual void SizeChanged( const TRect& aRect, 
       
   258                                            TScaleMode aScaleMode );
       
   259 
       
   260         /**
       
   261          * @return ETrue if the button has valid text (not empty and not space).
       
   262          */
       
   263         IMPORT_C TBool HasText() const;
       
   264 
       
   265         /**
       
   266          * @return ETrue if the button has valid tooltip text (not empty and 
       
   267          *          not space).
       
   268          */
       
   269         IMPORT_C TBool HasHelp() const;
       
   270         
       
   271         /**
       
   272         * Handles changes in state's environment.
       
   273         *
       
   274         * @since S60 3.2.
       
   275         * @param aType Resource change's type.
       
   276         */
       
   277         void HandleResourceChange( TInt aType );
       
   278         
       
   279         /**
       
   280         * Sets default scaling mode.
       
   281         *
       
   282         * @since S60 3.2
       
   283         * @param aScaleMode Scaling mode.
       
   284         */
       
   285         void SetIconScaleMode( const TScaleMode aScaleMode );
       
   286 
       
   287     private: // new functions
       
   288 
       
   289         /**
       
   290          * Creates one icon based on the specified file path and IDs.
       
   291          *
       
   292          * @param aIcon The icon object which is created and returned. 
       
   293          *      Will be deleted if it is not NULL on entry.
       
   294          * @param aFilePath The path to the file which contains icons.
       
   295          * @param aBmpId The bitmap ID for the icon.
       
   296          * @param aMaskId The mask ID for the icon.
       
   297          * @param aId Item ID of the masked bitmap to be created for skin 
       
   298          *      specific icon.
       
   299          */
       
   300         void CreateButtonIconL( CGulIcon*& aIcon, const TDesC& aFilePath, 
       
   301                                 TInt aBmpId, TInt aMaskId, 
       
   302                                 const TAknsItemID& aId = KAknsIIDNone ) const;
       
   303                                 
       
   304         /**
       
   305          * Loads one icon based on the specified file path and IDs. If the icon
       
   306          * is already loaded it is deleted and replaced with a reloaded copy.
       
   307          *
       
   308          * @since S60 3.2
       
   309          * @param aIcon The icon object which is created and returned. 
       
   310          *      Will be deleted if it is not NULL on entry.
       
   311          * @param aFilePath The path to the file which contains icons.
       
   312          * @param aBmpId The bitmap ID for the icon.
       
   313          * @param aMaskId The mask ID for the icon.
       
   314          * @param aId Item ID of the masked bitmap to be created for skin 
       
   315          *      specific icon.
       
   316          */
       
   317         void LoadButtonIcon( CGulIcon*& aIcon ) const;
       
   318                                 
       
   319         /**
       
   320          * Replaces the given icon with a new one. If the original icon had its
       
   321          * size set then the new icon is scaled to that size.
       
   322          *
       
   323          * @since S60 3.2
       
   324          */
       
   325         void ReplaceIcon( CGulIcon*& aIcon, CGulIcon* aNewIcon );
       
   326                           
       
   327         /**
       
   328         * Scales all icons.
       
   329         *
       
   330         * @since S60 3.2
       
   331         * @param aSize New icon size.
       
   332         * @param aScaleMode Scaling mode.
       
   333         * @return KErrNone or an error code.
       
   334         */
       
   335         TInt ScaleIcons( const TSize& aSize, TScaleMode aScaleMode );
       
   336 
       
   337         /**
       
   338          * @return The extension object.
       
   339          */
       
   340         CAknButtonStateExtension* Extension() const;
       
   341 
       
   342         /**
       
   343          * @return The scalemode of the ButtonState
       
   344          */
       
   345         TScaleMode ScaleMode() const;
       
   346         
       
   347         /**
       
   348          * @param aDimmedIconCreatedByButton ETrue, if the dimmed icon of the state is 
       
   349          * created by owning Button
       
   350          */
       
   351         void SetGeneratedDimmedIcon( TBool aDimmedIconCreatedByButton );
       
   352 
       
   353         friend class CAknButton;
       
   354 
       
   355     protected: // data
       
   356         CGulIcon*   iIcon;                      // bitmaps for normal state
       
   357         CGulIcon*   iDimmedIcon;                // bitmaps for dimmed icon
       
   358         CGulIcon*   iPressedIcon;               // bitmaps for pressed but not activated state
       
   359         CGulIcon*   iHoverIcon;                 // bitmaps for hover icon
       
   360         HBufC*      iText;                      // text for normal state
       
   361         HBufC*      iHelpText;                  // text which is shown as a help
       
   362         TInt        iFlags;                     // flags for the state
       
   363         CAknButtonStateExtension* iExtension;   // for future extensions
       
   364     };
       
   365 
       
   366 
       
   367 // CLASS DECLARATION
       
   368 
       
   369 /**
       
   370 *  Generic button class.
       
   371 *
       
   372 *  @lib eikcoctl.lib
       
   373 *  @since Series 60 3.1
       
   374 */
       
   375 class CAknButton : public CAknControl
       
   376     {
       
   377     public: // Enumerations
       
   378 
       
   379         enum TAlignment
       
   380             {
       
   381             ECenter, /* align center vertically or horizontally */
       
   382             ETop, /* align to top vertically */
       
   383             EBottom, /* align to bottom vertically */
       
   384             ERight, /* align to right horizontally */
       
   385             ELeft /* align to left horixontally */
       
   386             };
       
   387 
       
   388         enum TTooltipPosition
       
   389             {
       
   390             EPositionTop = 1, /* Tool tip alignment vertically to top */
       
   391             EPositionBottom, /* Tool tip alignment vertically to bottom */
       
   392             EPositionLeft, /* Tool tip alignment horizontally to left */
       
   393             EPositionRight /* Tool tip alignment horizontally to right */
       
   394             };
       
   395             
       
   396         enum TTextAndIconAlignment
       
   397             {
       
   398             EIconBeforeText, /* Icon and text side by side Icon first */
       
   399             EIconAfterText,  /* Icon and text side by side Text first */
       
   400             EIconUnderText,  /* Icon and text one upon the other Icon under the text */
       
   401             EIconOverText,   /* Icon and text one upon the other Icon over the text */
       
   402             EOverlay         /* Icon and text overlaid */
       
   403             };            
       
   404 
       
   405         enum TButtonEvent
       
   406             {
       
   407             ELongPressEvent = 100, /* Observer event for long press event */
       
   408             ELongPressEndedEvent   /* Observer event for long press ended event */
       
   409             };
       
   410 
       
   411     public: // Constructors and destructors
       
   412     
       
   413         /**
       
   414          * Two-phased constructor.
       
   415          * Constructs an empty button.
       
   416          */
       
   417         IMPORT_C static CAknButton* NewL();
       
   418         
       
   419         /**
       
   420          * Two-phased constructor. Constructs an empty button.
       
   421          */
       
   422         IMPORT_C static CAknButton* NewLC();
       
   423         
       
   424         /**
       
   425          * Two-phased constructor. Constructs the button from resources.
       
   426          *
       
   427          * @param aReader is the resource reader with which to access 
       
   428          *      the control's resource values.
       
   429          */
       
   430         IMPORT_C static CAknButton* NewL( TResourceReader& aReader );
       
   431         
       
   432         /**
       
   433          * Two-phased constructor. Constructs the button from resources.
       
   434          *
       
   435          * @param aReader is the resource reader with which to access 
       
   436          *      the control's resource values. 
       
   437          */
       
   438         IMPORT_C static CAknButton* NewLC( TResourceReader& aReader ); 
       
   439         
       
   440         /**
       
   441          * Two-phased constructor. Constructs the button from resources.
       
   442          * 
       
   443          * @param aResourceId is the ID for this component's resource.
       
   444          */
       
   445         IMPORT_C static CAknButton* NewL( const TInt aResourceId );
       
   446         
       
   447         /**
       
   448          * Two-phased constructor. Constructs the button from resources. 
       
   449          * 
       
   450          * @param aResourceId is the ID for this component's resource.
       
   451          */
       
   452         IMPORT_C static CAknButton* NewLC( const TInt aResourceId );
       
   453 
       
   454         /**
       
   455          * Two-phased constructor. Constructs one state button.
       
   456          *
       
   457          * @param aIcon The icon for the normal state. Takes ownership.
       
   458          * @param aDimmedIcon The icon for the dimmed state. Takes ownership.
       
   459          * @param aPressedIcon The icon for the pressed down. Takes ownership.
       
   460          * @param aHoverIcon The icon for the hover state. Takes ownership.
       
   461          * @param aText The text inside the button.
       
   462          * @param aHelpText The text for the tooltip.
       
   463          * @param aButtonFlags The flags for the button.
       
   464          * @param aStateFlags The flags for the first state.
       
   465          */
       
   466         IMPORT_C static CAknButton* NewL( CGulIcon* aIcon, 
       
   467                                           CGulIcon* aDimmedIcon,
       
   468                                           CGulIcon* aPressedIcon,
       
   469                                           CGulIcon* aHoverIcon,
       
   470                                           const TDesC& aText, 
       
   471                                           const TDesC& aHelpText, 
       
   472                                           const TInt aButtonFlags,
       
   473                                           const TInt aStateFlags );
       
   474 
       
   475         /**
       
   476          * Two-phased constructor. Constructs one state button.
       
   477          *
       
   478          * @param aIcon The icon for the normal state. Takes ownership.
       
   479          * @param aDimmedIcon The icon for the dimmed state. Takes ownership.
       
   480          * @param aPressedIcon The icon for the pressed down. Takes ownership.
       
   481          * @param aHoverIcon The icon for the hover state. Takes ownership.
       
   482          * @param aText The text inside the button.
       
   483          * @param aHelpText The text for the tooltip.
       
   484          * @param aButtonFlags The flags for the button.
       
   485          * @param aStateFlags The flags for the first state.
       
   486          */
       
   487         IMPORT_C static CAknButton* NewLC( CGulIcon* aIcon, 
       
   488                                            CGulIcon* aDimmedIcon,
       
   489                                            CGulIcon* aPressedIcon,
       
   490                                            CGulIcon* aHoverIcon,
       
   491                                            const TDesC& aText, 
       
   492                                            const TDesC& aHelpText, 
       
   493                                            const TInt aFlags,
       
   494                                            const TInt aStateFlags );
       
   495 
       
   496         /**
       
   497          * Two-phased constructor. Constructs one state button.
       
   498          *
       
   499          * @param aFilePath The path to the file which contains icons.
       
   500          * @param aBmpId The bitmap ID for the normal state icon.
       
   501          * @param aMaskId The mask ID for the normal state icon.
       
   502          * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
       
   503          * @param aDimmedMaskId The mask ID for the dimmed state icon.
       
   504          * @param aPressedBmpId The bitmap ID for the pressed down state.
       
   505          * @param aPressedMaskId The mask ID for the pressed down state.
       
   506          * @param aHoverBmpId The bitmap ID for the hover state.
       
   507          * @param aHoverMaskId The mask ID for the hover state.
       
   508          * @param aText The text inside the button.
       
   509          * @param aHelpText The text for the tooltip.
       
   510          * @param aButtonFlags The flags for the button.
       
   511          * @param aStateFlags The flags for the first state.
       
   512          * @param aId Item ID of the masked bitmap to be created for skin 
       
   513          *      specific icon.
       
   514          * @param aDimmedId Item ID of the dimmed masked bitmap to be created 
       
   515          *      for skin specific icon.
       
   516          * @param aPressedId Item ID of the pressed masked bitmap to be created 
       
   517          *      for skin specific icon.
       
   518          * @param aHoverId Item ID of the masked hover bitmap to be created
       
   519          *      for skin specific icon.
       
   520          */
       
   521         IMPORT_C static CAknButton* NewL( const TDesC& aFilePath, 
       
   522                                           const TInt aBmpId, 
       
   523                                           const TInt aMaskId,
       
   524                                           const TInt aDimmedBmpId, 
       
   525                                           const TInt aDimmedMaskId,
       
   526                                           const TInt aPressedBmpId, 
       
   527                                           const TInt aPressedMaskId,
       
   528                                           const TInt aHoverBmpId,
       
   529                                           const TInt aHoverMaskId,
       
   530                                           const TDesC& aText, 
       
   531                                           const TDesC& aHelpText, 
       
   532                                           const TInt aButtonFlags, 
       
   533                                           const TInt aStateFlags,
       
   534                                           const TAknsItemID& aId = KAknsIIDNone, 
       
   535                                           const TAknsItemID& aDimmedId = KAknsIIDNone, 
       
   536                                           const TAknsItemID& aPressedId = KAknsIIDNone,
       
   537                                           const TAknsItemID& aHoverId = KAknsIIDNone );
       
   538 
       
   539         /**
       
   540          * Two-phased constructor. Constructs one state button.
       
   541          *
       
   542          * @param aFilePath The path to the file which contains icons.
       
   543          * @param aBmpId The bitmap ID for the normal state icon.
       
   544          * @param aMaskId The mask ID for the normal state icon.
       
   545          * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
       
   546          * @param aDimmedMaskId The mask ID for the dimmed state icon.
       
   547          * @param aPressedBmpId The bitmap ID for the pressed down state.
       
   548          * @param aPressedMaskId The mask ID for the pressed down state.
       
   549          * @param aHoverBmpId The bitmap ID for the hover state.
       
   550          * @param aHoverMaskId The mask ID for the hover state.
       
   551          * @param aText The text inside the button.
       
   552          * @param aHelpText The text for the tooltip.
       
   553          * @param aButtonFlags The flags for the button.
       
   554          * @param aStateFlags The flags for the first state.
       
   555          * @param aId Item ID of the masked bitmap to be created for skin 
       
   556          *      specific icon.
       
   557          * @param aDimmedId Item ID of the dimmed masked bitmap to be created 
       
   558          *      for skin specific icon.
       
   559          * @param aPressedId Item ID of the pressed masked bitmap to be created 
       
   560          *      for skin specific icon.
       
   561          * @param aHoverId Item ID of the hover state masked bitmap to be
       
   562          *      created for skin specific icon.
       
   563          */
       
   564         IMPORT_C static CAknButton* NewLC( const TDesC& aFilePath, 
       
   565                                            const TInt aBmpId, 
       
   566                                            const TInt aMaskId,
       
   567                                            const TInt aDimmedBmpId, 
       
   568                                            const TInt aDimmedMaskId,
       
   569                                            const TInt aPressedBmpId, 
       
   570                                            const TInt aPressedMaskId, 
       
   571                                            const TInt aHoverBmpId,
       
   572                                            const TInt aHoverMaskId,
       
   573                                            const TDesC& aText, 
       
   574                                            const TDesC& aHelpText, 
       
   575                                            const TInt aButtonFlags, 
       
   576                                            const TInt aStateFlags,
       
   577                                            const TAknsItemID& aId = KAknsIIDNone, 
       
   578                                            const TAknsItemID& aDimmedId = KAknsIIDNone, 
       
   579                                            const TAknsItemID& aPressedId = KAknsIIDNone,
       
   580                                            const TAknsItemID& aHoverId = KAknsIIDNone );
       
   581 
       
   582         /**
       
   583          * Destructor.
       
   584          */
       
   585         IMPORT_C virtual ~CAknButton();
       
   586 
       
   587     public: // Functions from base class
       
   588 
       
   589         /**
       
   590          * Sets control as ready to be drawn.
       
   591          */
       
   592         IMPORT_C void ActivateL();
       
   593 
       
   594         /**
       
   595          * Constructs controls from a resource file.
       
   596          *
       
   597          * @param aReader The resource reader, with which to access the 
       
   598          *      control's resource values.
       
   599          */
       
   600         IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
       
   601 
       
   602         /**
       
   603          * Handles a change to the control's resources.
       
   604          *
       
   605          * @param aType is a message UID value.
       
   606          */
       
   607         IMPORT_C void HandleResourceChange( TInt aType );
       
   608 
       
   609         /**
       
   610          * Returns the control's minimum required size. It does not include the
       
   611          * size of the highlight. However, it includes current margins.
       
   612          * Use HighlightRect() function to get highlight rectangle for the 
       
   613          * focused button.
       
   614          *
       
   615          * @return The minimum size required by the control.
       
   616          */
       
   617         IMPORT_C TSize MinimumSize();
       
   618 
       
   619         /**
       
   620          * Sets button dimmed. Does not redraw the button. Note: This function
       
   621          * does not affect the flag set with function CCoeControl::SetDimmed(),
       
   622          * since button needs to get pointer events, even if it is dimmed.
       
   623          * The value of the flag can be enquired using CAknButotn::IsDimmed().
       
   624          *
       
   625          * @param aDimmed is ETrue to dim the button, EFalse to set the button 
       
   626          *      as not dimmed.
       
   627          */
       
   628         IMPORT_C void SetDimmed( TBool aDimmed );
       
   629 
       
   630         /**
       
   631          * Handles key events.
       
   632          *
       
   633          * @param aKeyEvent The key event.
       
   634          * @param aType The type of key event: EEventKey, EEventKeyUp or 
       
   635          *      EEventKeyDown.
       
   636          */
       
   637         IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   638                                               TEventCode aType );
       
   639         
       
   640         /**
       
   641          * Sets this control as visible or invisible.
       
   642          *
       
   643          * @param aVisible ETrue to make the control visible, EFalse to make 
       
   644          *      it invisible.
       
   645          */
       
   646         IMPORT_C void MakeVisible( TBool aVisible );
       
   647 
       
   648         /**
       
   649          * This function is called by the dialog framework immediately before 
       
   650          * it removes keyboard focus from a control within a dialog.
       
   651          * Currently has empty implementation.
       
   652          */
       
   653         IMPORT_C void PrepareForFocusLossL();
       
   654 
       
   655         /**
       
   656          * Prepares the control for gaining focus.
       
   657          * Must be used before calling SetFocus() function in case when help 
       
   658          * note should be shown.
       
   659          */
       
   660         IMPORT_C void PrepareForFocusGainL(); 
       
   661 
       
   662         /**
       
   663          * Handles pointer events.
       
   664          *
       
   665          * @param aPointerEvent The pointer event.
       
   666          */
       
   667         IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   668 
       
   669         /**
       
   670          * Responds to changes in the position of a control.
       
   671          */
       
   672         IMPORT_C virtual void PositionChanged();  
       
   673 
       
   674     public: // New functions
       
   675 
       
   676         /**
       
   677          * Constructs controls from a resource file.
       
   678          *
       
   679          * @param aResourceId The ID for this component's resource.
       
   680          */
       
   681         IMPORT_C void ConstructFromResourceL( const TInt aResourceId );
       
   682 
       
   683         /**
       
   684          * Sets button state.
       
   685          *
       
   686          * @param aStateIndex The index for the state, starts from 0.
       
   687          * @param aDrawNow ETrue to redraw the button.
       
   688          */
       
   689         IMPORT_C virtual void SetCurrentState( const TInt aStateIndex, 
       
   690                                                const TBool aDrawNow );
       
   691 
       
   692         /**
       
   693          * Adds one more state for the button to the end of state array.
       
   694          *
       
   695          * @param aIcon The icon object containing a bitmap and a mask (if 
       
   696          *      there is one) for the button.
       
   697          * @param aDimmedIcon The icon object containing a bitmap and a mask 
       
   698          *      (if there is one) for the dimmed case.
       
   699          * @param aPressedIcon The icon object containing a bitmap and a mask
       
   700          *      (if there is one) for the case when button is pressed.
       
   701          * @param aHoverIcon The icon object containingg a bitmap and a mask
       
   702          *      for the case when the pointer is hovering over the button.
       
   703          * @param aText is the text.
       
   704          * @param aHelpText is the text for the tooltip.
       
   705          * @param aStateFlags The flags for the state.
       
   706          */
       
   707         IMPORT_C virtual void AddStateL( CGulIcon* aIcon, 
       
   708                                          CGulIcon* aDimmedIcon, 
       
   709                                          CGulIcon* aPressedIcon,
       
   710                                          CGulIcon* aHoverIcon,
       
   711                                          const TDesC& aText, 
       
   712                                          const TDesC& aHelpText, 
       
   713                                          const TInt aStateFlags );
       
   714 
       
   715         /**
       
   716          * Adds one more state for the button.
       
   717          *
       
   718          * @param aFilePath The path to the file which contains icons.
       
   719          * @param aBmpId The bitmap ID for the normal state icon.
       
   720          * @param aMaskId The mask ID for the normal state icon.
       
   721          * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
       
   722          * @param aDimmedMaskId The mask ID for the dimmed state icon.
       
   723          * @param aPressedBmpId The bitmap ID for the pressed down state.
       
   724          * @param aPressedMaskId The mask ID for the pressed down state.
       
   725          * @param aHoverBmpId The bitmap ID for the hover state.
       
   726          * @param aHoverMaskId The mask ID for the hover state.
       
   727          * @param aHoverId Item ID of the hover state masked bitmap to be
       
   728          *      created for skin specific icon.
       
   729          * @param aText is the text.
       
   730          * @param aHelpText is the text for the tooltip.
       
   731          * @param aStateFlags The flags for the state.
       
   732          * @param aId Item ID of the masked bitmap to be created for skin 
       
   733          *      specific icon. Use KAknsIIDNone when it is not needed.
       
   734          * @param aDimmedId Item ID of the dimmed masked bitmap to be created 
       
   735          *      for skin specific icon. Use KAknsIIDNone when it is not needed.
       
   736          * @param aPressedId Item ID of the pressed masked bitmap to be created 
       
   737          *      for skin specific icon. Use KAknsIIDNone when it is not needed.
       
   738          * @param aHoverId Item ID of the hover state masked bitmap to be
       
   739          *      created for skin specific icon.
       
   740          */
       
   741         IMPORT_C virtual void AddStateL( const TDesC& aFilePath, 
       
   742                                          const TInt aBmpId, 
       
   743                                          const TInt aMaskId,
       
   744                                          const TInt aDimmedBmpId, 
       
   745                                          const TInt aDimmedMaskId,
       
   746                                          const TInt aPressedBmpId, 
       
   747                                          const TInt aPressedMaskId, 
       
   748                                          const TInt aHoverBmpId,
       
   749                                          const TInt aHoverMaskId,
       
   750                                          const TDesC& aText,
       
   751                                          const TDesC& aHelpText,
       
   752                                          const TInt aStateFlags,
       
   753                                          const TAknsItemID& aId, 
       
   754                                          const TAknsItemID& aDimmedId, 
       
   755                                          const TAknsItemID& aPressedId,
       
   756                                          const TAknsItemID& aHoverId );
       
   757         
       
   758         /**
       
   759          * Adds one more state for the button to the end of state array.
       
   760          *
       
   761          * @param  aIcon         The icon object containing a bitmap and
       
   762          *                       a mask (if there is one) for the button.
       
   763          * @param  aDimmedIcon   The icon object containing a bitmap and a mask 
       
   764          *                       (if there is one) for the dimmed case.
       
   765          * @param  aPressedIcon  The icon object containing a bitmap and a mask
       
   766          *                       (if there is one) for the case when
       
   767          *                       button is pressed.
       
   768          * @param  aHoverIcon    The icon object containingg a bitmap and
       
   769          *                       a mask for the case when the pointer is
       
   770          *                       hovering over the button.
       
   771          * @param  aText         is the text.
       
   772          * @param  aHelpText     is the text for the tooltip.
       
   773          * @param  aStateFlags   The flags for the state.
       
   774          * @param  aCommandId    Command to be attached with the state.
       
   775          */
       
   776         void AddStateL( CGulIcon* aIcon, 
       
   777                         CGulIcon* aDimmedIcon, 
       
   778                         CGulIcon* aPressedIcon,
       
   779                         CGulIcon* aHoverIcon,
       
   780                         const TDesC& aText, 
       
   781                         const TDesC& aHelpText, 
       
   782                         const TInt aStateFlags,
       
   783                         const TInt aCommandId );
       
   784 
       
   785         /**
       
   786          * Sets the button flags.
       
   787          *
       
   788          * @param aFlags which can be combination of: KAknButtonTextLeft, 
       
   789          *      KAknButtonSizeFitText, KAknButtonNoFrame, KAknButtonKeyRepeat,
       
   790          *      KAknButtonReportOnKeyDown, KAknButtonNoFramePressEvent,
       
   791          *      KAknButtonRequestExitOnButtonUpEvent, KAknButtonReportOnLongPress.
       
   792          */
       
   793         IMPORT_C void SetButtonFlags( const TInt aFlags );
       
   794 
       
   795         /** 
       
   796          * Sets specified frame IDs. Can be used when default frame is not 
       
   797          * suitable. Use KAknsIIDNone value in case when some frame or center
       
   798          * drawing is not needed or KAknsIIDDefault when the default button
       
   799          * frame should be used.
       
   800          *
       
   801          * @param aFrameId The item ID of the entire frame.
       
   802          * @param aCenterId The item ID of the center part of the frame.
       
   803          * @param aLatchedFrameId The item ID of the entire frame for button 
       
   804          *      in latched state.
       
   805          * @param aLatchedCenterId The item ID of the center part of the 
       
   806          *      frame for button in latched state.
       
   807          * @param aDimmedFrameId The item ID of the entire frame for a button
       
   808          *      in dimmed state.
       
   809          * @param aDimmedCenterId The item ID of the center part of the frame
       
   810          *      for a button in dimmed state.
       
   811          * @param aPressedFrameId The item ID of the entire frame for a 
       
   812          *      button in pressed state.
       
   813          * @param aPressedCenterId is the item ID of the center part of the 
       
   814          *      frame for a button in pressed state.
       
   815          * @param aLatchedDimmedFrameId The item ID of the entire frame for 
       
   816          *      a button in latched and dimmed state.
       
   817          * @param aLatchedDimmedCenterId The item ID of the center part of 
       
   818          *      the frame for a button in latched and dimmed state.
       
   819          */
       
   820         IMPORT_C void SetFrameAndCenterIds( const TAknsItemID& aFrameId, 
       
   821                                             const TAknsItemID& aCenterId,
       
   822                                             const TAknsItemID& aLatchedFrameId, 
       
   823                                             const TAknsItemID& aLatchedCenterId,
       
   824                                             const TAknsItemID& aDimmedFrameId, 
       
   825                                             const TAknsItemID& aDimmedCenterId,
       
   826                                             const TAknsItemID& aPressedFrameId, 
       
   827                                             const TAknsItemID& aPressedCenterId,
       
   828                                             const TAknsItemID& aLatchedDimmedFrameId, 
       
   829                                             const TAknsItemID& aLatchedDimmedCenterId );
       
   830 
       
   831         /** 
       
   832          * Sets specified background IDs. Can be used when default frame is not
       
   833          * suitable and the backgound is composed of only single image instead
       
   834          * of frame and center. SetFrameAndCenterIds() function can also be used
       
   835          * for this purpose by giving the same backround ID for both frame and
       
   836          * center. This allows also some of the states to be composed of frames
       
   837          * and the others from single backgound images. Use KAknsIIDNone value
       
   838          * in case when some backgound drawing is not needed or KAknsIIDDefault
       
   839          * when the default button frame should be used.
       
   840          *
       
   841          * @param aBackgroundId The item ID of the entire frame.
       
   842          * @param aLatchedBackgroundId The item ID of the background for the
       
   843          *      button in latched state.
       
   844          * @param aDimmedBackgroundId The item ID of the background for the
       
   845          *      button in dimmed state.
       
   846          * @param aPressedBackgroundId The item ID of the background for the 
       
   847          *      button in pressed state.
       
   848          * @param aLatchedDimmedBackgroundId The item ID of the background for 
       
   849          *      the button in latched and dimmed state.
       
   850          */
       
   851         IMPORT_C void SetBackgroundIds( const TAknsItemID& aBackgroundId, 
       
   852                                         const TAknsItemID& aLatchedBackgroundId, 
       
   853                                         const TAknsItemID& aDimmedBackgroundId, 
       
   854                                         const TAknsItemID& aPressedBackgroundId, 
       
   855                                         const TAknsItemID& aLatchedDimmedBackgroundId );
       
   856 
       
   857         /**
       
   858          * Sets some specific text font.
       
   859          *
       
   860          * @param aFont The font, which should be used for the text inside the 
       
   861          *      text button.
       
   862          */
       
   863         IMPORT_C void SetTextFont( const CFont* aFont );
       
   864 
       
   865         /**
       
   866          * Sets the color table and color index for the button text. It will be
       
   867          * used on button drawing, if color of the text shouldn't be taken from
       
   868          * text layout.
       
   869          *
       
   870          * @param aTextColorTableId Id for the color table 
       
   871          * @param aTextColorIndex Index of the color inside color table.
       
   872          */
       
   873         IMPORT_C void SetTextColorIds( const TAknsItemID& aTextColorTableId, 
       
   874                                        const TInt aTextColorIndex );
       
   875 
       
   876         /**
       
   877          * Sets the horizontal alignment for the text inside the button. It
       
   878          * will be used, if alignment shouldn't be taken from text layout. By
       
   879          * default it will be centered.
       
   880          *
       
   881          * @param aHorizontalAlignment The horizontal alignment for the text.
       
   882          */
       
   883         IMPORT_C void SetTextHorizontalAlignment( 
       
   884             const CGraphicsContext::TTextAlign aHorizontalAlignment );
       
   885 
       
   886         /**
       
   887          * Sets the vertical alignment for the text inside the button. It will 
       
   888          * be used if alignment shouldn't be taken from text layout. By default 
       
   889          * it will be centered.
       
   890          *
       
   891          * @param aVerticalAlignment The vertical alignment for the text.
       
   892          */
       
   893         IMPORT_C void SetTextVerticalAlignment( 
       
   894             const CAknButton::TAlignment aVerticalAlignment );
       
   895 
       
   896         /**
       
   897          * Sets the icon and text alignment for a button having both
       
   898          *
       
   899          * @param aAlignment. TTextAndIconAlignment
       
   900          */
       
   901         IMPORT_C void SetTextAndIconAlignment( 
       
   902             const CAknButton::TTextAndIconAlignment aAlignment );
       
   903 
       
   904         /**
       
   905          * Sets the text underline style for the text inside the button. By
       
   906          * default no underline is used.
       
   907          *
       
   908          * @param aUnderlineStyle The style of underline.
       
   909          */
       
   910         IMPORT_C void SetTextUnderlineStyle( TFontUnderline aUnderlineStyle );
       
   911 
       
   912         /**
       
   913          * Sets the scale mode for the icon inside the button. 
       
   914          * The default is EAspectRatioNotPreserved.
       
   915          *
       
   916          * @param aScaleMode The scale mode.
       
   917          */
       
   918         IMPORT_C void SetIconScaleMode( const TScaleMode aScaleMode );
       
   919 
       
   920         /**
       
   921          * Sets the horizontal alignment for the icon inside the button.
       
   922          * By default it will be centered.
       
   923          *
       
   924          * @param aHorizontalAlignment The horizontal alignment for the icon.
       
   925          */
       
   926         IMPORT_C void SetIconHorizontalAlignment( 
       
   927             const CAknButton::TAlignment aHorizontalAlignment );
       
   928 
       
   929         /**
       
   930          * Sets the vertical alignment for the icon inside the button.
       
   931          * By default it will be centered.
       
   932          *
       
   933          * @param aVerticalAlignment The vertical alignment for the icon.
       
   934          */
       
   935         IMPORT_C void SetIconVerticalAlignment( 
       
   936             const CAknButton::TAlignment aVerticalAlignment );
       
   937             
       
   938         /**
       
   939          * Sets the delay before the help text is shown and also specifies the 
       
   940          * time for how long help text is visible.
       
   941          *
       
   942          * @param aBeforeTimeout The delay in milliseconds before text help note 
       
   943          *      is shown. The default is 150 milliseconds.
       
   944          * @param aInViewTimeout The interval in milliseconds during which help 
       
   945          *      text note is shown. The default is 3000 milliseconds.
       
   946          */
       
   947         IMPORT_C void SetHelpNoteTimeouts( const TInt aBeforeTimeout, 
       
   948                                            const TInt aInViewTimeout );
       
   949 
       
   950         /**
       
   951          * Sets the interval for key repeat.
       
   952          *
       
   953          * @param aKeyRepeatDelay The initial delay, after which the key repeat is
       
   954                 started. The default is 500 milliseconds.
       
   955          * @param aKeyRepeatInterval The interval in milliseconds, in which key
       
   956          *      repeat events should be reported. The default is 500 milliseconds.
       
   957          */
       
   958         IMPORT_C void SetKeyRepeatInterval( const TInt aKeyRepeatDelay, 
       
   959                                             const TInt aKeyRepeatInterval );
       
   960         
       
   961         /**
       
   962          * Sets the interval for long press. When KAknButtonReportOnLongPress
       
   963          * flag is set for the button, button will notify observer with 
       
   964          * KAknButtonLongPressEvent as the event type, after button has been
       
   965          * pressed for the specified time.
       
   966          * 
       
   967          * @param aLongPressInterval The time interval in milliseconds, after
       
   968          *      which the long press event should be reported. The default
       
   969          *      value is 800 milliseconds.
       
   970          */
       
   971         IMPORT_C void SetLongPressInterval( const TInt aLongPressInterval );
       
   972 
       
   973         /**
       
   974          * Returns the index of the button state.
       
   975          */
       
   976         IMPORT_C TInt StateIndex() const;
       
   977 
       
   978         /**
       
   979          * Enables pictograph drawing in the button text.
       
   980          * Only effective in Japanese variant.
       
   981          * By default, it is disabled.
       
   982          *
       
   983          * @param aInterface Used pictograph interface owned by the caller.
       
   984          */
       
   985         IMPORT_C void EnablePictographsL( CAknPictographInterface& aInterface );
       
   986 
       
   987         /**
       
   988          * Disables pictograph drawing in the button text.
       
   989          * Only effective in Japanese variant.
       
   990          * By default, it is disabled.
       
   991          */
       
   992         IMPORT_C void DisablePictographs();
       
   993 
       
   994         /**
       
   995          * It will change the default highlight rectangle around 
       
   996          * the focused button.
       
   997          *
       
   998          * @param aRect The highlight rectangle.
       
   999          */
       
  1000         IMPORT_C void SetHighlightRect( const TRect& aRect );
       
  1001 
       
  1002         /**
       
  1003          * Gets the highlight rectangle around the button.
       
  1004          *
       
  1005          * @return The higlight rectangle around the button.
       
  1006          */
       
  1007         IMPORT_C TRect HighlightRect() const;
       
  1008 
       
  1009         /**
       
  1010          * Sets the tooltip position.
       
  1011          *
       
  1012          * @param aPosition The position of the tooltip.
       
  1013          */
       
  1014         IMPORT_C void SetTooltipPosition( const TTooltipPosition aPosition );
       
  1015 
       
  1016         /**
       
  1017          * Sets whether button should send an EEventRequestExit event to command
       
  1018          * observer on button up event.
       
  1019          *
       
  1020          * @param aRequestExit ETrue if button should request exit.
       
  1021          */
       
  1022         IMPORT_C void SetRequestExit( const TBool aRequestExit );
       
  1023 
       
  1024         /**
       
  1025          * Tests if the control is dimmed. This function overrides the function
       
  1026          * declared in CCoeControl, and returns the value which is set and unset
       
  1027          * using CAknButton::SetDimmed().
       
  1028          *
       
  1029          * @return ETrue if the control is dimmed, EFalse if it is not dimmed.
       
  1030          */
       
  1031         IMPORT_C TBool IsDimmed() const;
       
  1032 
       
  1033         /**
       
  1034          * Sets the help text for dimmed button.
       
  1035          *
       
  1036          * @param aHelpText The text inside the tooltip.
       
  1037          */
       
  1038         IMPORT_C void SetDimmedHelpTextL( const TDesC& aHelpText );
       
  1039 
       
  1040         /**
       
  1041          * Check if point is within buttons visible area, when
       
  1042          * KAknButtonHitTest flag is enabled
       
  1043          *
       
  1044          * @param aPoint Location to check.
       
  1045          * @param aCheckHitArea if need to check the hit area for fixed 
       
  1046          *        toolbar button
       
  1047          */
       
  1048         TBool HitAreaContainsL( const TPoint& aPoint, TBool aCheckHitArea ) const; 
       
  1049         
       
  1050         /**
       
  1051          * Returns the current state of the button.
       
  1052          *
       
  1053          * @return the current state of the button
       
  1054          */
       
  1055         IMPORT_C CAknButtonState* State() const;
       
  1056 
       
  1057         /**
       
  1058          * Returns the state of the button under specified index.
       
  1059          *
       
  1060          * @param aStateIndex The index for the state.
       
  1061          * @return the state of the button.
       
  1062          */
       
  1063         IMPORT_C CAknButtonState* State( const TInt aStateIndex ) const;
       
  1064 
       
  1065         /**
       
  1066          * Returns the flags of button. The flags are defined in eikon.hrh.
       
  1067          * @return Button flags.
       
  1068          * @since S60 3.2
       
  1069          */
       
  1070         IMPORT_C TInt ButtonFlags() const;
       
  1071 
       
  1072         /**
       
  1073         * Sets button's margins. These define the free area inside the button
       
  1074         * where content is placed. Note that calling this function overrides
       
  1075         * default margins that are scaled automatically depending on the 
       
  1076         * current screen layout. If this function is called then the caller
       
  1077         * is responsible for updating margins whenever the layout changes.
       
  1078         *
       
  1079         * @since S60 3.2
       
  1080         * @param aMargins New marginals.
       
  1081         */
       
  1082         IMPORT_C void SetMargins( const TMargins8& aMargins );
       
  1083         
       
  1084         /**
       
  1085         * Sets icon size for the button. Calling this function overrides the
       
  1086         * default size that is scaled automatically depending on the current
       
  1087         * screen layout. If this function is called then the caller is
       
  1088         * responsible for updating icon size whenever the layout changes.
       
  1089         *
       
  1090         * @since S60 3.2
       
  1091         * @param aSize New icon size.
       
  1092         * @return KErrNone if the operation succeeded, otherwise an error code.
       
  1093         */
       
  1094         IMPORT_C TInt SetIconSize( const TSize& aSize );
       
  1095 
       
  1096         /**
       
  1097         * Checks if the button uses default margins.
       
  1098         *
       
  1099         * @since S60 3.2
       
  1100         *
       
  1101         * @return ETrue if default margins are used.
       
  1102         */
       
  1103         TBool UsesDefaultMargins() const;  
       
  1104 
       
  1105         /**
       
  1106          * Sets tooltip to hide or show itself when background faded.
       
  1107          *
       
  1108          * @since S60 3.2
       
  1109          * @param aHide should be ETrue if hiding, EFalse if showing
       
  1110          */
       
  1111         void HideTooltipWhenAppFaded( TBool aHide ); 
       
  1112 
       
  1113 
       
  1114         /**
       
  1115          */
       
  1116         void CheckHitArea();
       
  1117         
       
  1118         /**
       
  1119          * Resets button to unpressed state.
       
  1120          *
       
  1121          * @since S60 5.0
       
  1122          */
       
  1123         IMPORT_C void ResetState();
       
  1124         
       
  1125         /**
       
  1126         * Sets button to use additional masks during drawing. Calling this
       
  1127         * method forces button to bypass the normal drawing routine i.e. 
       
  1128         * method DrawMaskedL is executed instead of Draw.
       
  1129         *
       
  1130         * @since S60 5.0
       
  1131         * @param aMaskedDraw ETrue to use additional mask.
       
  1132         */
       
  1133         void UseMaskedDraw( TBool aMaskedDraw );
       
  1134 
       
  1135         /**
       
  1136         * Registers resource provider.
       
  1137         * @param aProvider New resource provider.
       
  1138         */
       
  1139         void RegisterResourceProvider( CAknResourceProvider* aProvider );
       
  1140 
       
  1141         /**
       
  1142         * Unregisters resource provider.
       
  1143         */
       
  1144         void UnregisterResourceProvider();
       
  1145         
       
  1146         CAknsFrameBackgroundControlContext* BgContext();
       
  1147         
       
  1148         /**
       
  1149         * Removes the currently active state from the button,
       
  1150         * and sets the current state to the previous one.
       
  1151         */
       
  1152         void RemoveCurrentState();
       
  1153 
       
  1154         /**
       
  1155         * Returns the button touchable area.
       
  1156         *
       
  1157         * @since S60 5.0
       
  1158         * @return Button touch area
       
  1159         */
       
  1160         TRect TouchArea() const;
       
  1161 
       
  1162     protected: // Constructors
       
  1163 
       
  1164         /**
       
  1165          * C++ constructor for the one state button.
       
  1166          *
       
  1167          * @param aFlags The flags for the button
       
  1168          */
       
  1169         IMPORT_C CAknButton( const TInt aFlags );
       
  1170 
       
  1171         /**
       
  1172          * Symbian 2nd phase constructor.
       
  1173          */
       
  1174         IMPORT_C void ConstructL();
       
  1175 
       
  1176         /**
       
  1177          * Symbian 2nd phase constructor.
       
  1178          *
       
  1179          * @param aIcon The icon for the normal state. Takes ownership.
       
  1180          * @param aDimmedIcon The icon for the dimmed state. Takes ownership.
       
  1181          * @param aPressedIcon The icon for the pressed down. Takes ownership.
       
  1182          * @param aHoverIcon The icon for the hover state.
       
  1183          * @param aText The text inside the button.
       
  1184          * @param aHelpText The text for the tooltip.
       
  1185          * @param aStateFlags The flags for the first state.
       
  1186          */
       
  1187         IMPORT_C void ConstructL( CGulIcon* aIcon, 
       
  1188                                   CGulIcon* aDimmedIcon, 
       
  1189                                   CGulIcon* aPressedIcon,
       
  1190                                   CGulIcon* aHoverIcon,
       
  1191                                   const TDesC& aText, 
       
  1192                                   const TDesC& aHelpText, 
       
  1193                                   const TInt aStateFlags );
       
  1194 
       
  1195         /**
       
  1196          * Symbian 2nd phase constructor.
       
  1197          *
       
  1198          * @param aFilePath The path to the file which contains icons.
       
  1199          * @param aBmpId The bitmap ID for the normal state icon.
       
  1200          * @param aMaskId The mask ID for the normal state icon.
       
  1201          * @param aDimmedBmpId The bitmap ID for the dimmed state icon.
       
  1202          * @param aDimmedMaskId The mask ID for the dimmed state icon.
       
  1203          * @param aPressedBmpId The bitmap ID for the pressed down state.
       
  1204          * @param aPressedMaskId The mask ID for the pressed down state.
       
  1205          * @param aHoverBmpId The bitmap ID for the hover state icon.
       
  1206          * @param aHoverMaskId The mask ID for the hover state icon.
       
  1207          * @param aText The text inside the button.
       
  1208          * @param aHelpText The text for the tooltip.
       
  1209          * @param aStateFlags The flags for the first state.
       
  1210          * @param aId Item ID of the masked bitmap to be created for skin 
       
  1211          *      specific icon.
       
  1212          * @param aDimmedId Item ID of the dimmed masked bitmap to be created 
       
  1213          *      for skin specific icon.
       
  1214          * @param aPressedId Item ID of the pressed masked bitmap to be created 
       
  1215          *      for skin specific icon.
       
  1216          * @param aHoverId Item ID of the masked hover bitmap to be created
       
  1217          *      for skin specific icon.
       
  1218          */
       
  1219         IMPORT_C void ConstructL( const TDesC& aFilePath, 
       
  1220                                   const TInt aBmpId, 
       
  1221                                   const TInt aMaskId,
       
  1222                                   const TInt aDimmedBmpId, 
       
  1223                                   const TInt aDimmedMaskId,
       
  1224                                   const TInt aPressedBmpId, 
       
  1225                                   const TInt aPressedMaskId, 
       
  1226                                   const TInt aHoverBmpId,
       
  1227                                   const TInt aHoverMaskId,
       
  1228                                   const TDesC& aText, 
       
  1229                                   const TDesC& aHelpText, 
       
  1230                                   const TInt aStateFlags,
       
  1231                                   const TAknsItemID& aId = KAknsIIDNone, 
       
  1232                                   const TAknsItemID& aDimmedId = KAknsIIDNone, 
       
  1233                                   const TAknsItemID& aPressedId = KAknsIIDNone,
       
  1234                                   const TAknsItemID& aHoverId = KAknsIIDNone );
       
  1235 
       
  1236     protected: // Functions from base class
       
  1237 
       
  1238         /**
       
  1239          * Responds to size changes to sets the size and position of the 
       
  1240          * contents of this control.
       
  1241          */
       
  1242         IMPORT_C void SizeChanged();
       
  1243 
       
  1244         /**
       
  1245          * This function is called whenever a control gains or loses focus.
       
  1246          *
       
  1247          * @param aDrawNow Contains the value that was passed to it by SetFocus().
       
  1248          */
       
  1249         IMPORT_C void FocusChanged( TDrawNow aDrawNow );
       
  1250 
       
  1251         /**
       
  1252          * For future extensions
       
  1253          * 
       
  1254          * @param aInterface The ID for the extension interface.
       
  1255          */
       
  1256         IMPORT_C void* ExtensionInterface( TUid aInterface );
       
  1257 
       
  1258     protected: // New functions
       
  1259 
       
  1260         /**
       
  1261          * Changes the state of the button to the next one.
       
  1262          *
       
  1263          * @return the current state index
       
  1264          */
       
  1265         IMPORT_C TInt ChangeState( TBool aDrawNow );
       
  1266 
       
  1267         /**
       
  1268          * Returns the text, which will be displayed inside the button 
       
  1269          * for the current state.
       
  1270          */
       
  1271         IMPORT_C const TDesC&  GetCurrentText() const;
       
  1272 
       
  1273         /**
       
  1274          * Returns icon for the current state.
       
  1275          */
       
  1276         IMPORT_C const CGulIcon* GetCurrentIcon() const;
       
  1277 
       
  1278         /**
       
  1279          * Shows help text for a certain period of time.
       
  1280          */
       
  1281         IMPORT_C void ShowHelpL();
       
  1282 
       
  1283         /**
       
  1284          * Hides help text after certain interval.
       
  1285          */
       
  1286         IMPORT_C void HideHelp();
       
  1287 
       
  1288 
       
  1289    private: // Functions from base class
       
  1290 
       
  1291         /**
       
  1292          * From CCoeControl. Draws the control. Called by window server.
       
  1293          */
       
  1294         IMPORT_C void Draw( const TRect& aRect ) const;  
       
  1295 
       
  1296     private: // New functions
       
  1297 
       
  1298         /**
       
  1299          * Continues drawing of the button which has only text.
       
  1300          */
       
  1301         void DrawTextButton( CWindowGc& aGc ) const;
       
  1302 
       
  1303         /**
       
  1304          * Continues drawing of the button which has only an icon in it.
       
  1305          */
       
  1306         void DrawIconButton( CWindowGc& aGc ) const;
       
  1307 
       
  1308         /**
       
  1309          * Continues drawing of the button which has both text and icon.
       
  1310          */
       
  1311         void DrawTextAndIconButton( CWindowGc& aGc ) const;
       
  1312         
       
  1313         /**
       
  1314          * Starts the long press timer.
       
  1315          */
       
  1316         void StartLongPressTimerL();
       
  1317 
       
  1318         /**
       
  1319          * Stops the long press timer.
       
  1320          */
       
  1321         void StopLongPressTimer();
       
  1322 
       
  1323         /**
       
  1324          * Starts the timer for the key repeat.
       
  1325          */
       
  1326         void StartKeyRepeatTimerL();
       
  1327 
       
  1328         /**
       
  1329          * Stops the key repeat timer.
       
  1330          */
       
  1331         void StopKeyRepeatTimer();
       
  1332 
       
  1333         /**
       
  1334          * Called after timeout is over.
       
  1335          */
       
  1336         static TInt ReportKeyRepeatL( TAny* aThis );
       
  1337 
       
  1338         /**
       
  1339          * Asserts that extension class object exists.
       
  1340          *
       
  1341          * @return Extension object.
       
  1342          */
       
  1343         CAknButtonExtension* Extension() const;
       
  1344 
       
  1345         /**
       
  1346          * Updates tooltip position.
       
  1347          */
       
  1348         void UpdateTooltipPosition();
       
  1349 
       
  1350         /**
       
  1351          * Checks whether toolbar should send an EEventRequestExit event to
       
  1352          * command observe on button up event.
       
  1353          *
       
  1354          * @return ETrue if event should be sent, EFalse otherwise.
       
  1355          */
       
  1356         TBool RequestExit() const;
       
  1357 
       
  1358         /**
       
  1359          * Gets the rectangele reserved for button content excluding frame.
       
  1360          *
       
  1361          * @return Content rectangle.
       
  1362          */
       
  1363         TRect ContentRect() const;
       
  1364 
       
  1365         /**
       
  1366          * Checks whether button needs redrawing when it is pressed or released.
       
  1367          *
       
  1368          * @return ETrue, if redraw is needed, othewise EFalse.
       
  1369          */
       
  1370         TBool NeedsRedrawWhenPressed() const;
       
  1371 
       
  1372         /**
       
  1373          * Returns the ID of specified skin item.
       
  1374          */
       
  1375         TAknsItemID SkinIID( const TInt aIndex ) const;
       
  1376         
       
  1377         /**
       
  1378         * Calculates default margins.
       
  1379         */
       
  1380         void CalculateDefaultMargins();
       
  1381         
       
  1382         /**
       
  1383         * Scales all icons.
       
  1384         *
       
  1385         * @return KErrNone or an error code.
       
  1386         */
       
  1387         TInt ScaleIcons();
       
  1388         
       
  1389         /**
       
  1390         * Gets the correct text color.
       
  1391         *
       
  1392         * @return Text color.
       
  1393         */
       
  1394         TRgb TextColor() const;
       
  1395 
       
  1396         /**
       
  1397         * Generates the pressed down bitmaps
       
  1398         * if flag KAknButtonPressedDownFrame is set and button has no frame
       
  1399         */
       
  1400         void CreatePressedDownFrameL();
       
  1401         
       
  1402         /**
       
  1403          * Calculates color's luminance. 
       
  1404          */
       
  1405         TInt CalculateLuminance( const TRgb& aColor ) const; 
       
  1406 
       
  1407         /**
       
  1408          * Converts outline color, if fill color is too similar to outline color
       
  1409          * 
       
  1410          * @aFillColor fill color
       
  1411          * @aOutlineColor outline color
       
  1412          */
       
  1413         void ConvertColorsForOutlineEffect( TRgb& aFillColor, TRgb& aOutlineColor ) const; 
       
  1414 
       
  1415         /**
       
  1416          * Gets text colors 
       
  1417          * 
       
  1418          * @aPenColor pen color
       
  1419          * @aBrushColor brush color 
       
  1420          */
       
  1421         void GetTextColors( TRgb& aPenColor, TRgb& aBrushColor ) const; 
       
  1422         
       
  1423         /**
       
  1424          * Sets new state index 
       
  1425          * 
       
  1426          * @param aNewIndex New state index
       
  1427          */
       
  1428         void SetStateIndexL( TInt aNewIndex );
       
  1429 
       
  1430     protected: // Data
       
  1431 
       
  1432         // array to keep states
       
  1433         CArrayPtrFlat<CAknButtonState>* iStates;
       
  1434 
       
  1435         // button flags
       
  1436         TInt iFlags;
       
  1437 
       
  1438         // current button state index
       
  1439         TInt iStateIndex;
       
  1440 
       
  1441         // flag to define whether the button is pressed
       
  1442         TBool iButtonPressed;
       
  1443 
       
  1444         // number of drag events, needed to distinguish when it is outside 
       
  1445         // the button.
       
  1446         TInt iNumberOfDragEvents; 
       
  1447 
       
  1448         // Flag which shows whether key down event was reported before key up 
       
  1449         // event was sent to the button, because some controls consume key down 
       
  1450         // but don't consume key up events which might cause of button state 
       
  1451         // when it is not expected
       
  1452         TBool iKeyDownReported;
       
  1453 
       
  1454         // Background control context for button's frame
       
  1455         CAknsFrameBackgroundControlContext* iBgContext;
       
  1456 
       
  1457         // Customized highlight rectangular around the button if the default one
       
  1458         // won't be used
       
  1459         TRect iHighlightRect;
       
  1460 
       
  1461         // text button specific data  
       
  1462         const CFont*                    iFont;                // font for the text inside the button
       
  1463         TAlignment                      iVerticalAlignment;   // vertical alignment for the text. Centered by default
       
  1464         CGraphicsContext::TTextAlign    iHorizontalAlignment; // horizontal alignment for the text. Centered by default
       
  1465         TAknsItemID                     iTextColorTableId;    // id for the color table 
       
  1466         TInt                            iTextColorIndex;      // index of the color in color table
       
  1467 
       
  1468         // icon button specific data
       
  1469         TScaleMode  iScaleMode; // scale mode for the icon, by default it is EAspectRatioNotPreserved
       
  1470 
       
  1471         // tooltip specific data
       
  1472         TInt        iHelpNoteWaitInterval;         // interval in milliseconds between the time when the button got focused and the help text is shown
       
  1473         TInt        iHelpNoteInViewInterval;       // interval during which help text is shown in milliseconds
       
  1474         CAknInfoPopupNoteController* iHelpNote;    // component to show help text
       
  1475         HBufC*      iDimmedHelpText;               // help text in case if the button is dimmed, not used currently
       
  1476         TBool       iShowHelp;                     // flag which specifies whether help note should be shown 
       
  1477 
       
  1478         // Key repeat handling
       
  1479         CPeriodic* iKeyRepeatTimer; // timer to report key repeats
       
  1480         TInt iKeyRepeatDelay;       // initial delay for key repeats
       
  1481         TInt iKeyRepeatInterval;    // time interval for key repeats
       
  1482     
       
  1483     private:
       
  1484         CAknButtonExtension* iExtension;
       
  1485 
       
  1486     };
       
  1487 
       
  1488 
       
  1489 #endif // __AKNBUTTON_H__
       
  1490 
       
  1491 // End of File