williamr@2: /* williamr@2: * Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Button component. williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef __AKNBUTTON_H__ williamr@2: #define __AKNBUTTON_H__ williamr@2: williamr@2: // INCLUDES williamr@4: #include williamr@4: #include williamr@4: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CGulIcon; williamr@2: class CAknButton; williamr@2: class CAknButtonExtension; williamr@2: class CAknInfoPopupNoteController; williamr@2: class CAknButtonStateExtension; williamr@2: class CAknPictographInterface; williamr@2: class CAknsFrameBackgroundControlContext; williamr@2: class CAknResourceProvider; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Class which represents one of the button states. williamr@2: * williamr@2: * @lib eikcoctl.lib williamr@2: * @since Series 60 3.1 williamr@2: */ williamr@2: class CAknButtonState : public CBase williamr@2: { williamr@2: public: // Constructors and destructors williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CAknButtonState(); williamr@2: williamr@2: protected: // Constructors and destructors williamr@2: williamr@2: /** williamr@2: * Constructor. williamr@2: * williamr@2: * @param aFlags The flags for the button state williamr@2: */ williamr@2: IMPORT_C CAknButtonState( const TInt aFlags ); williamr@2: williamr@2: /** williamr@2: * Symbian 2nd phase constructor. williamr@2: * williamr@2: * @param aIcon The icon for the normal state. Takes ownership. williamr@2: * @param aDimmedIcon The icon for the dimmed state. Takes ownership. williamr@2: * @param aPressedIcon The icon for the pressed down. Takes ownership. williamr@2: * @param aHoverIcon The icon for the hover state. Takes ownership. williamr@2: * @param aText The text inside the button. williamr@2: * @param aHelpText The text for the tooltip. williamr@2: */ williamr@2: IMPORT_C void ConstructL( CGulIcon* aIcon, williamr@2: CGulIcon* aDimmedIcon, williamr@2: CGulIcon* aPressedIcon, williamr@2: CGulIcon* aHoverIcon, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText ); williamr@2: williamr@2: /** williamr@2: * Symbian 2nd phase constructor. williamr@2: * williamr@2: * @param aFilePath The path to the file which contains icons. williamr@2: * @param aBmpId The bitmap ID for the normal state icon. williamr@2: * @param aMaskId The mask ID for the normal state icon. williamr@2: * @param aDimmedBmpId The bitmap ID for the dimmed state icon. williamr@2: * @param aDimmedMaskId The mask ID for the dimmed state icon. williamr@2: * @param aPressedBmpId The bitmap ID for the pressed down state. williamr@2: * @param aPressedMaskId The mask ID for the pressed down state. williamr@2: * @param aHoverBmpId The bitmap ID for the hover state icon. williamr@2: * @param aHoverMaskId The mask ID for the hover state icon. williamr@2: * @param aText The text inside the button. williamr@2: * @param aHelpText The text for the tooltip. williamr@2: * @param aId Item ID of the masked bitmap to be created for skin williamr@2: * specific icon. williamr@2: * @param aDimmedId Item ID of the dimmed masked bitmap to be created williamr@2: * for skin specific icon. williamr@2: * @param aPressedId Item ID of the pressed masked bitmap to be created williamr@2: * for skin specific icon. williamr@2: * @param aHoverId Item ID of the masked hover bitmap to be created williamr@2: * for skin specific icon. williamr@2: */ williamr@2: IMPORT_C void ConstructL( const TDesC& aFilePath, williamr@2: const TInt aBmpId, williamr@2: const TInt aMaskId, williamr@2: const TInt aDimmedBmpId, williamr@2: const TInt aDimmedMaskId, williamr@2: const TInt aPressedBmpId, williamr@2: const TInt aPressedMaskId, williamr@2: const TInt aHoverBmpId, williamr@2: const TInt aHoverMaskId, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TAknsItemID& aId = KAknsIIDNone, williamr@2: const TAknsItemID& aDimmedId = KAknsIIDNone, williamr@2: const TAknsItemID& aPressedId = KAknsIIDNone, williamr@2: const TAknsItemID& aHoverId = KAknsIIDNone ); williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Provides the icon for the normal state. williamr@2: * williamr@2: * @return The icon for the normal state. williamr@2: */ williamr@2: IMPORT_C const CGulIcon* Icon() const; williamr@2: williamr@2: /** williamr@2: * Provides the icon for the dimmed state. williamr@2: * williamr@2: * @return The icon for the dimmed state. williamr@2: */ williamr@2: IMPORT_C const CGulIcon* DimmedIcon() const; williamr@2: williamr@2: /** williamr@2: * Provides the icon for the pressed down (not released) state. williamr@2: * williamr@2: * @return The icon for the pressed down (not released) state. williamr@2: */ williamr@2: IMPORT_C const CGulIcon* PressedIcon() const; williamr@2: williamr@2: /** williamr@2: * Provides the icon for the hover state. williamr@2: * williamr@2: * @return The icon for the hover state. williamr@2: */ williamr@2: IMPORT_C const CGulIcon* HoverIcon() const; williamr@2: williamr@2: /** williamr@2: * Provides the text inside the button. williamr@2: * williamr@2: * @return The button text. williamr@2: */ williamr@2: IMPORT_C const TDesC& Text() const; williamr@2: williamr@2: /** williamr@2: * Provides the text inside the help note. williamr@2: * williamr@2: * @return The tooltip text. williamr@2: */ williamr@2: IMPORT_C const TDesC& HelpText() const; williamr@2: williamr@2: /** williamr@2: * Provides the flags for the state. williamr@2: * williamr@2: * @return The state flags. williamr@2: */ williamr@2: IMPORT_C TInt Flags() const; williamr@2: williamr@2: /** williamr@2: * Sets the icon for the normal state. Takes ownership. williamr@2: * williamr@2: * @param aIcon The icon for the normal state. williamr@2: */ williamr@2: IMPORT_C void SetIcon( CGulIcon* aIcon ); williamr@2: williamr@2: /** williamr@2: * Sets the icon for the dimmed state. Takes ownership. williamr@2: * williamr@2: * @param aDimmedIcon The icon for the dimmed state. williamr@2: */ williamr@2: IMPORT_C void SetDimmedIcon( CGulIcon* aDimmedIcon ); williamr@2: williamr@2: /** williamr@2: * Sets the icon for the pressed down state. Takes ownership. williamr@2: * williamr@2: * @param aPressedIcon The icon for the pressed down state. williamr@2: */ williamr@2: IMPORT_C void SetPressedIcon( CGulIcon* aPressedIcon ); williamr@2: williamr@2: /** williamr@2: * Sets the icon for the hover state. Takes ownership. williamr@2: * williamr@2: * @param aHoverIcon The icon for the hover state. williamr@2: */ williamr@2: IMPORT_C void SetHoverIcon( CGulIcon* aHoverIcon ); williamr@2: williamr@2: /** williamr@2: * Sets the text inside the button. williamr@2: * williamr@2: * @param aText The text inside the button. williamr@2: */ williamr@2: IMPORT_C void SetTextL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Sets the text inside the help note. williamr@2: * williamr@2: * @param aHelpText The text inside the tooltip. williamr@2: */ williamr@2: IMPORT_C void SetHelpTextL( const TDesC& aHelpText ); williamr@2: williamr@2: /** williamr@2: * Sets the flags for the state. williamr@2: * williamr@2: * @param aFlags The flags for the state. williamr@2: */ williamr@2: IMPORT_C void SetFlags( const TInt aFlags ); williamr@2: williamr@2: /** williamr@2: * Sets the icon for the normal state williamr@2: * williamr@2: * @param aFlags The flags for the state. williamr@2: */ williamr@2: void UpdateIconL( const TDesC& aFilePath, williamr@2: const TInt aBmpId, williamr@2: const TInt aMaskId, williamr@2: const TInt aDimmedBmpId, williamr@2: const TInt aDimmedMaskId, williamr@2: const TInt aPressedBmpId, williamr@2: const TInt aPressedMaskId, williamr@2: const TInt aHoverBmpId, williamr@2: const TInt aHoverMaskId, williamr@2: const TAknsItemID& aId = KAknsIIDNone, williamr@2: const TAknsItemID& aDimmedId = KAknsIIDNone, williamr@2: const TAknsItemID& aPressedId = KAknsIIDNone, williamr@2: const TAknsItemID& aHoverId = KAknsIIDNone ); williamr@2: williamr@2: williamr@2: williamr@2: protected: // New functions williamr@2: williamr@2: /** williamr@2: * Constructs controls from a resource file. williamr@2: * @param aReader The resource reader with which to access the williamr@2: * control's resource values. williamr@2: */ williamr@2: IMPORT_C virtual void ConstructFromResourceL( TResourceReader& aReader ); williamr@2: williamr@2: /** williamr@2: * Updates the size of icons. Called from CAknButton::SizeChanged() williamr@2: * function. williamr@2: * williamr@2: * @param aRect The new rectangle for the icons. williamr@2: * @param aScaleMode The scale mode which was set for the button. williamr@2: */ williamr@2: IMPORT_C virtual void SizeChanged( const TRect& aRect, williamr@2: TScaleMode aScaleMode ); williamr@2: williamr@2: /** williamr@2: * @return ETrue if the button has valid text (not empty and not space). williamr@2: */ williamr@2: IMPORT_C TBool HasText() const; williamr@2: williamr@2: /** williamr@2: * @return ETrue if the button has valid tooltip text (not empty and williamr@2: * not space). williamr@2: */ williamr@2: IMPORT_C TBool HasHelp() const; williamr@2: williamr@2: /** williamr@2: * Handles changes in state's environment. williamr@2: * williamr@2: * @since S60 3.2. williamr@2: * @param aType Resource change's type. williamr@2: */ williamr@2: void HandleResourceChange( TInt aType ); williamr@2: williamr@2: /** williamr@2: * Sets default scaling mode. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aScaleMode Scaling mode. williamr@2: */ williamr@2: void SetIconScaleMode( const TScaleMode aScaleMode ); williamr@2: williamr@2: private: // new functions williamr@2: williamr@2: /** williamr@2: * Creates one icon based on the specified file path and IDs. williamr@2: * williamr@2: * @param aIcon The icon object which is created and returned. williamr@2: * Will be deleted if it is not NULL on entry. williamr@2: * @param aFilePath The path to the file which contains icons. williamr@2: * @param aBmpId The bitmap ID for the icon. williamr@2: * @param aMaskId The mask ID for the icon. williamr@2: * @param aId Item ID of the masked bitmap to be created for skin williamr@2: * specific icon. williamr@2: */ williamr@2: void CreateButtonIconL( CGulIcon*& aIcon, const TDesC& aFilePath, williamr@2: TInt aBmpId, TInt aMaskId, williamr@2: const TAknsItemID& aId = KAknsIIDNone ) const; williamr@2: williamr@2: /** williamr@2: * Loads one icon based on the specified file path and IDs. If the icon williamr@2: * is already loaded it is deleted and replaced with a reloaded copy. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aIcon The icon object which is created and returned. williamr@2: * Will be deleted if it is not NULL on entry. williamr@2: * @param aFilePath The path to the file which contains icons. williamr@2: * @param aBmpId The bitmap ID for the icon. williamr@2: * @param aMaskId The mask ID for the icon. williamr@2: * @param aId Item ID of the masked bitmap to be created for skin williamr@2: * specific icon. williamr@2: */ williamr@2: void LoadButtonIcon( CGulIcon*& aIcon ) const; williamr@2: williamr@2: /** williamr@2: * Replaces the given icon with a new one. If the original icon had its williamr@2: * size set then the new icon is scaled to that size. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: void ReplaceIcon( CGulIcon*& aIcon, CGulIcon* aNewIcon ); williamr@2: williamr@2: /** williamr@2: * Scales all icons. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aSize New icon size. williamr@2: * @param aScaleMode Scaling mode. williamr@2: * @return KErrNone or an error code. williamr@2: */ williamr@2: TInt ScaleIcons( const TSize& aSize, TScaleMode aScaleMode ); williamr@2: williamr@2: /** williamr@2: * @return The extension object. williamr@2: */ williamr@2: CAknButtonStateExtension* Extension() const; williamr@2: williamr@2: /** williamr@2: * @return The scalemode of the ButtonState williamr@2: */ williamr@2: TScaleMode ScaleMode() const; williamr@2: williamr@2: /** williamr@2: * @param aDimmedIconCreatedByButton ETrue, if the dimmed icon of the state is williamr@2: * created by owning Button williamr@2: */ williamr@2: void SetGeneratedDimmedIcon( TBool aDimmedIconCreatedByButton ); williamr@2: williamr@2: friend class CAknButton; williamr@2: williamr@2: protected: // data williamr@2: CGulIcon* iIcon; // bitmaps for normal state williamr@2: CGulIcon* iDimmedIcon; // bitmaps for dimmed icon williamr@2: CGulIcon* iPressedIcon; // bitmaps for pressed but not activated state williamr@2: CGulIcon* iHoverIcon; // bitmaps for hover icon williamr@2: HBufC* iText; // text for normal state williamr@2: HBufC* iHelpText; // text which is shown as a help williamr@2: TInt iFlags; // flags for the state williamr@2: CAknButtonStateExtension* iExtension; // for future extensions williamr@2: }; williamr@2: williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Generic button class. williamr@2: * williamr@2: * @lib eikcoctl.lib williamr@2: * @since Series 60 3.1 williamr@2: */ williamr@2: class CAknButton : public CAknControl williamr@2: { williamr@2: public: // Enumerations williamr@2: williamr@2: enum TAlignment williamr@2: { williamr@2: ECenter, /* align center vertically or horizontally */ williamr@2: ETop, /* align to top vertically */ williamr@2: EBottom, /* align to bottom vertically */ williamr@2: ERight, /* align to right horizontally */ williamr@2: ELeft /* align to left horixontally */ williamr@2: }; williamr@2: williamr@2: enum TTooltipPosition williamr@2: { williamr@2: EPositionTop = 1, /* Tool tip alignment vertically to top */ williamr@2: EPositionBottom, /* Tool tip alignment vertically to bottom */ williamr@2: EPositionLeft, /* Tool tip alignment horizontally to left */ williamr@2: EPositionRight /* Tool tip alignment horizontally to right */ williamr@2: }; williamr@2: williamr@2: enum TTextAndIconAlignment williamr@2: { williamr@2: EIconBeforeText, /* Icon and text side by side Icon first */ williamr@2: EIconAfterText, /* Icon and text side by side Text first */ williamr@2: EIconUnderText, /* Icon and text one upon the other Icon under the text */ williamr@2: EIconOverText, /* Icon and text one upon the other Icon over the text */ williamr@2: EOverlay /* Icon and text overlaid */ williamr@2: }; williamr@2: williamr@2: enum TButtonEvent williamr@2: { williamr@2: ELongPressEvent = 100, /* Observer event for long press event */ williamr@2: ELongPressEndedEvent /* Observer event for long press ended event */ williamr@2: }; williamr@2: williamr@2: public: // Constructors and destructors williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * Constructs an empty button. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewL(); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs an empty button. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewLC(); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs the button from resources. williamr@2: * williamr@2: * @param aReader is the resource reader with which to access williamr@2: * the control's resource values. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewL( TResourceReader& aReader ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs the button from resources. williamr@2: * williamr@2: * @param aReader is the resource reader with which to access williamr@2: * the control's resource values. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewLC( TResourceReader& aReader ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs the button from resources. williamr@2: * williamr@2: * @param aResourceId is the ID for this component's resource. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewL( const TInt aResourceId ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs the button from resources. williamr@2: * williamr@2: * @param aResourceId is the ID for this component's resource. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewLC( const TInt aResourceId ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs one state button. williamr@2: * williamr@2: * @param aIcon The icon for the normal state. Takes ownership. williamr@2: * @param aDimmedIcon The icon for the dimmed state. Takes ownership. williamr@2: * @param aPressedIcon The icon for the pressed down. Takes ownership. williamr@2: * @param aHoverIcon The icon for the hover state. Takes ownership. williamr@2: * @param aText The text inside the button. williamr@2: * @param aHelpText The text for the tooltip. williamr@2: * @param aButtonFlags The flags for the button. williamr@2: * @param aStateFlags The flags for the first state. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewL( CGulIcon* aIcon, williamr@2: CGulIcon* aDimmedIcon, williamr@2: CGulIcon* aPressedIcon, williamr@2: CGulIcon* aHoverIcon, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aButtonFlags, williamr@2: const TInt aStateFlags ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs one state button. williamr@2: * williamr@2: * @param aIcon The icon for the normal state. Takes ownership. williamr@2: * @param aDimmedIcon The icon for the dimmed state. Takes ownership. williamr@2: * @param aPressedIcon The icon for the pressed down. Takes ownership. williamr@2: * @param aHoverIcon The icon for the hover state. Takes ownership. williamr@2: * @param aText The text inside the button. williamr@2: * @param aHelpText The text for the tooltip. williamr@2: * @param aButtonFlags The flags for the button. williamr@2: * @param aStateFlags The flags for the first state. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewLC( CGulIcon* aIcon, williamr@2: CGulIcon* aDimmedIcon, williamr@2: CGulIcon* aPressedIcon, williamr@2: CGulIcon* aHoverIcon, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aFlags, williamr@2: const TInt aStateFlags ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs one state button. williamr@2: * williamr@2: * @param aFilePath The path to the file which contains icons. williamr@2: * @param aBmpId The bitmap ID for the normal state icon. williamr@2: * @param aMaskId The mask ID for the normal state icon. williamr@2: * @param aDimmedBmpId The bitmap ID for the dimmed state icon. williamr@2: * @param aDimmedMaskId The mask ID for the dimmed state icon. williamr@2: * @param aPressedBmpId The bitmap ID for the pressed down state. williamr@2: * @param aPressedMaskId The mask ID for the pressed down state. williamr@2: * @param aHoverBmpId The bitmap ID for the hover state. williamr@2: * @param aHoverMaskId The mask ID for the hover state. williamr@2: * @param aText The text inside the button. williamr@2: * @param aHelpText The text for the tooltip. williamr@2: * @param aButtonFlags The flags for the button. williamr@2: * @param aStateFlags The flags for the first state. williamr@2: * @param aId Item ID of the masked bitmap to be created for skin williamr@2: * specific icon. williamr@2: * @param aDimmedId Item ID of the dimmed masked bitmap to be created williamr@2: * for skin specific icon. williamr@2: * @param aPressedId Item ID of the pressed masked bitmap to be created williamr@2: * for skin specific icon. williamr@2: * @param aHoverId Item ID of the masked hover bitmap to be created williamr@2: * for skin specific icon. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewL( const TDesC& aFilePath, williamr@2: const TInt aBmpId, williamr@2: const TInt aMaskId, williamr@2: const TInt aDimmedBmpId, williamr@2: const TInt aDimmedMaskId, williamr@2: const TInt aPressedBmpId, williamr@2: const TInt aPressedMaskId, williamr@2: const TInt aHoverBmpId, williamr@2: const TInt aHoverMaskId, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aButtonFlags, williamr@2: const TInt aStateFlags, williamr@2: const TAknsItemID& aId = KAknsIIDNone, williamr@2: const TAknsItemID& aDimmedId = KAknsIIDNone, williamr@2: const TAknsItemID& aPressedId = KAknsIIDNone, williamr@2: const TAknsItemID& aHoverId = KAknsIIDNone ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. Constructs one state button. williamr@2: * williamr@2: * @param aFilePath The path to the file which contains icons. williamr@2: * @param aBmpId The bitmap ID for the normal state icon. williamr@2: * @param aMaskId The mask ID for the normal state icon. williamr@2: * @param aDimmedBmpId The bitmap ID for the dimmed state icon. williamr@2: * @param aDimmedMaskId The mask ID for the dimmed state icon. williamr@2: * @param aPressedBmpId The bitmap ID for the pressed down state. williamr@2: * @param aPressedMaskId The mask ID for the pressed down state. williamr@2: * @param aHoverBmpId The bitmap ID for the hover state. williamr@2: * @param aHoverMaskId The mask ID for the hover state. williamr@2: * @param aText The text inside the button. williamr@2: * @param aHelpText The text for the tooltip. williamr@2: * @param aButtonFlags The flags for the button. williamr@2: * @param aStateFlags The flags for the first state. williamr@2: * @param aId Item ID of the masked bitmap to be created for skin williamr@2: * specific icon. williamr@2: * @param aDimmedId Item ID of the dimmed masked bitmap to be created williamr@2: * for skin specific icon. williamr@2: * @param aPressedId Item ID of the pressed masked bitmap to be created williamr@2: * for skin specific icon. williamr@2: * @param aHoverId Item ID of the hover state masked bitmap to be williamr@2: * created for skin specific icon. williamr@2: */ williamr@2: IMPORT_C static CAknButton* NewLC( const TDesC& aFilePath, williamr@2: const TInt aBmpId, williamr@2: const TInt aMaskId, williamr@2: const TInt aDimmedBmpId, williamr@2: const TInt aDimmedMaskId, williamr@2: const TInt aPressedBmpId, williamr@2: const TInt aPressedMaskId, williamr@2: const TInt aHoverBmpId, williamr@2: const TInt aHoverMaskId, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aButtonFlags, williamr@2: const TInt aStateFlags, williamr@2: const TAknsItemID& aId = KAknsIIDNone, williamr@2: const TAknsItemID& aDimmedId = KAknsIIDNone, williamr@2: const TAknsItemID& aPressedId = KAknsIIDNone, williamr@2: const TAknsItemID& aHoverId = KAknsIIDNone ); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C virtual ~CAknButton(); williamr@2: williamr@2: public: // Functions from base class williamr@2: williamr@2: /** williamr@2: * Sets control as ready to be drawn. williamr@2: */ williamr@2: IMPORT_C void ActivateL(); williamr@2: williamr@2: /** williamr@2: * Constructs controls from a resource file. williamr@2: * williamr@2: * @param aReader The resource reader, with which to access the williamr@2: * control's resource values. williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL( TResourceReader& aReader ); williamr@2: williamr@2: /** williamr@2: * Handles a change to the control's resources. williamr@2: * williamr@2: * @param aType is a message UID value. williamr@2: */ williamr@2: IMPORT_C void HandleResourceChange( TInt aType ); williamr@2: williamr@2: /** williamr@2: * Returns the control's minimum required size. It does not include the williamr@2: * size of the highlight. However, it includes current margins. williamr@2: * Use HighlightRect() function to get highlight rectangle for the williamr@2: * focused button. williamr@2: * williamr@2: * @return The minimum size required by the control. williamr@2: */ williamr@2: IMPORT_C TSize MinimumSize(); williamr@2: williamr@2: /** williamr@2: * Sets button dimmed. Does not redraw the button. Note: This function williamr@2: * does not affect the flag set with function CCoeControl::SetDimmed(), williamr@2: * since button needs to get pointer events, even if it is dimmed. williamr@2: * The value of the flag can be enquired using CAknButotn::IsDimmed(). williamr@2: * williamr@2: * @param aDimmed is ETrue to dim the button, EFalse to set the button williamr@2: * as not dimmed. williamr@2: */ williamr@2: IMPORT_C void SetDimmed( TBool aDimmed ); williamr@2: williamr@2: /** williamr@2: * Handles key events. williamr@2: * williamr@2: * @param aKeyEvent The key event. williamr@2: * @param aType The type of key event: EEventKey, EEventKeyUp or williamr@2: * EEventKeyDown. williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, williamr@2: TEventCode aType ); williamr@2: williamr@2: /** williamr@2: * Sets this control as visible or invisible. williamr@2: * williamr@2: * @param aVisible ETrue to make the control visible, EFalse to make williamr@2: * it invisible. williamr@2: */ williamr@2: IMPORT_C void MakeVisible( TBool aVisible ); williamr@2: williamr@2: /** williamr@2: * This function is called by the dialog framework immediately before williamr@2: * it removes keyboard focus from a control within a dialog. williamr@2: * Currently has empty implementation. williamr@2: */ williamr@2: IMPORT_C void PrepareForFocusLossL(); williamr@2: williamr@2: /** williamr@2: * Prepares the control for gaining focus. williamr@2: * Must be used before calling SetFocus() function in case when help williamr@2: * note should be shown. williamr@2: */ williamr@2: IMPORT_C void PrepareForFocusGainL(); williamr@2: williamr@2: /** williamr@2: * Handles pointer events. williamr@2: * williamr@2: * @param aPointerEvent The pointer event. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent ); williamr@2: williamr@2: /** williamr@2: * Responds to changes in the position of a control. williamr@2: */ williamr@2: IMPORT_C virtual void PositionChanged(); williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Constructs controls from a resource file. williamr@2: * williamr@2: * @param aResourceId The ID for this component's resource. williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL( const TInt aResourceId ); williamr@2: williamr@2: /** williamr@2: * Sets button state. williamr@2: * williamr@2: * @param aStateIndex The index for the state, starts from 0. williamr@2: * @param aDrawNow ETrue to redraw the button. williamr@2: */ williamr@2: IMPORT_C virtual void SetCurrentState( const TInt aStateIndex, williamr@2: const TBool aDrawNow ); williamr@2: williamr@2: /** williamr@2: * Adds one more state for the button to the end of state array. williamr@2: * williamr@2: * @param aIcon The icon object containing a bitmap and a mask (if williamr@2: * there is one) for the button. williamr@2: * @param aDimmedIcon The icon object containing a bitmap and a mask williamr@2: * (if there is one) for the dimmed case. williamr@2: * @param aPressedIcon The icon object containing a bitmap and a mask williamr@2: * (if there is one) for the case when button is pressed. williamr@2: * @param aHoverIcon The icon object containingg a bitmap and a mask williamr@2: * for the case when the pointer is hovering over the button. williamr@2: * @param aText is the text. williamr@2: * @param aHelpText is the text for the tooltip. williamr@2: * @param aStateFlags The flags for the state. williamr@2: */ williamr@2: IMPORT_C virtual void AddStateL( CGulIcon* aIcon, williamr@2: CGulIcon* aDimmedIcon, williamr@2: CGulIcon* aPressedIcon, williamr@2: CGulIcon* aHoverIcon, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aStateFlags ); williamr@2: williamr@2: /** williamr@2: * Adds one more state for the button. williamr@2: * williamr@2: * @param aFilePath The path to the file which contains icons. williamr@2: * @param aBmpId The bitmap ID for the normal state icon. williamr@2: * @param aMaskId The mask ID for the normal state icon. williamr@2: * @param aDimmedBmpId The bitmap ID for the dimmed state icon. williamr@2: * @param aDimmedMaskId The mask ID for the dimmed state icon. williamr@2: * @param aPressedBmpId The bitmap ID for the pressed down state. williamr@2: * @param aPressedMaskId The mask ID for the pressed down state. williamr@2: * @param aHoverBmpId The bitmap ID for the hover state. williamr@2: * @param aHoverMaskId The mask ID for the hover state. williamr@2: * @param aHoverId Item ID of the hover state masked bitmap to be williamr@2: * created for skin specific icon. williamr@2: * @param aText is the text. williamr@2: * @param aHelpText is the text for the tooltip. williamr@2: * @param aStateFlags The flags for the state. williamr@2: * @param aId Item ID of the masked bitmap to be created for skin williamr@2: * specific icon. Use KAknsIIDNone when it is not needed. williamr@2: * @param aDimmedId Item ID of the dimmed masked bitmap to be created williamr@2: * for skin specific icon. Use KAknsIIDNone when it is not needed. williamr@2: * @param aPressedId Item ID of the pressed masked bitmap to be created williamr@2: * for skin specific icon. Use KAknsIIDNone when it is not needed. williamr@2: * @param aHoverId Item ID of the hover state masked bitmap to be williamr@2: * created for skin specific icon. williamr@2: */ williamr@2: IMPORT_C virtual void AddStateL( const TDesC& aFilePath, williamr@2: const TInt aBmpId, williamr@2: const TInt aMaskId, williamr@2: const TInt aDimmedBmpId, williamr@2: const TInt aDimmedMaskId, williamr@2: const TInt aPressedBmpId, williamr@2: const TInt aPressedMaskId, williamr@2: const TInt aHoverBmpId, williamr@2: const TInt aHoverMaskId, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aStateFlags, williamr@2: const TAknsItemID& aId, williamr@2: const TAknsItemID& aDimmedId, williamr@2: const TAknsItemID& aPressedId, williamr@2: const TAknsItemID& aHoverId ); williamr@2: williamr@2: /** williamr@2: * Adds one more state for the button to the end of state array. williamr@2: * williamr@2: * @param aIcon The icon object containing a bitmap and williamr@2: * a mask (if there is one) for the button. williamr@2: * @param aDimmedIcon The icon object containing a bitmap and a mask williamr@2: * (if there is one) for the dimmed case. williamr@2: * @param aPressedIcon The icon object containing a bitmap and a mask williamr@2: * (if there is one) for the case when williamr@2: * button is pressed. williamr@2: * @param aHoverIcon The icon object containingg a bitmap and williamr@2: * a mask for the case when the pointer is williamr@2: * hovering over the button. williamr@2: * @param aText is the text. williamr@2: * @param aHelpText is the text for the tooltip. williamr@2: * @param aStateFlags The flags for the state. williamr@2: * @param aCommandId Command to be attached with the state. williamr@2: */ williamr@2: void AddStateL( CGulIcon* aIcon, williamr@2: CGulIcon* aDimmedIcon, williamr@2: CGulIcon* aPressedIcon, williamr@2: CGulIcon* aHoverIcon, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aStateFlags, williamr@2: const TInt aCommandId ); williamr@2: williamr@2: /** williamr@2: * Sets the button flags. williamr@2: * williamr@2: * @param aFlags which can be combination of: KAknButtonTextLeft, williamr@2: * KAknButtonSizeFitText, KAknButtonNoFrame, KAknButtonKeyRepeat, williamr@2: * KAknButtonReportOnKeyDown, KAknButtonNoFramePressEvent, williamr@2: * KAknButtonRequestExitOnButtonUpEvent, KAknButtonReportOnLongPress. williamr@2: */ williamr@2: IMPORT_C void SetButtonFlags( const TInt aFlags ); williamr@2: williamr@2: /** williamr@2: * Sets specified frame IDs. Can be used when default frame is not williamr@2: * suitable. Use KAknsIIDNone value in case when some frame or center williamr@2: * drawing is not needed or KAknsIIDDefault when the default button williamr@2: * frame should be used. williamr@2: * williamr@2: * @param aFrameId The item ID of the entire frame. williamr@2: * @param aCenterId The item ID of the center part of the frame. williamr@2: * @param aLatchedFrameId The item ID of the entire frame for button williamr@2: * in latched state. williamr@2: * @param aLatchedCenterId The item ID of the center part of the williamr@2: * frame for button in latched state. williamr@2: * @param aDimmedFrameId The item ID of the entire frame for a button williamr@2: * in dimmed state. williamr@2: * @param aDimmedCenterId The item ID of the center part of the frame williamr@2: * for a button in dimmed state. williamr@2: * @param aPressedFrameId The item ID of the entire frame for a williamr@2: * button in pressed state. williamr@2: * @param aPressedCenterId is the item ID of the center part of the williamr@2: * frame for a button in pressed state. williamr@2: * @param aLatchedDimmedFrameId The item ID of the entire frame for williamr@2: * a button in latched and dimmed state. williamr@2: * @param aLatchedDimmedCenterId The item ID of the center part of williamr@2: * the frame for a button in latched and dimmed state. williamr@2: */ williamr@2: IMPORT_C void SetFrameAndCenterIds( const TAknsItemID& aFrameId, williamr@2: const TAknsItemID& aCenterId, williamr@2: const TAknsItemID& aLatchedFrameId, williamr@2: const TAknsItemID& aLatchedCenterId, williamr@2: const TAknsItemID& aDimmedFrameId, williamr@2: const TAknsItemID& aDimmedCenterId, williamr@2: const TAknsItemID& aPressedFrameId, williamr@2: const TAknsItemID& aPressedCenterId, williamr@2: const TAknsItemID& aLatchedDimmedFrameId, williamr@2: const TAknsItemID& aLatchedDimmedCenterId ); williamr@2: williamr@2: /** williamr@2: * Sets specified background IDs. Can be used when default frame is not williamr@2: * suitable and the backgound is composed of only single image instead williamr@2: * of frame and center. SetFrameAndCenterIds() function can also be used williamr@2: * for this purpose by giving the same backround ID for both frame and williamr@2: * center. This allows also some of the states to be composed of frames williamr@2: * and the others from single backgound images. Use KAknsIIDNone value williamr@2: * in case when some backgound drawing is not needed or KAknsIIDDefault williamr@2: * when the default button frame should be used. williamr@2: * williamr@2: * @param aBackgroundId The item ID of the entire frame. williamr@2: * @param aLatchedBackgroundId The item ID of the background for the williamr@2: * button in latched state. williamr@2: * @param aDimmedBackgroundId The item ID of the background for the williamr@2: * button in dimmed state. williamr@2: * @param aPressedBackgroundId The item ID of the background for the williamr@2: * button in pressed state. williamr@2: * @param aLatchedDimmedBackgroundId The item ID of the background for williamr@2: * the button in latched and dimmed state. williamr@2: */ williamr@2: IMPORT_C void SetBackgroundIds( const TAknsItemID& aBackgroundId, williamr@2: const TAknsItemID& aLatchedBackgroundId, williamr@2: const TAknsItemID& aDimmedBackgroundId, williamr@2: const TAknsItemID& aPressedBackgroundId, williamr@2: const TAknsItemID& aLatchedDimmedBackgroundId ); williamr@2: williamr@2: /** williamr@2: * Sets some specific text font. williamr@2: * williamr@2: * @param aFont The font, which should be used for the text inside the williamr@2: * text button. williamr@2: */ williamr@2: IMPORT_C void SetTextFont( const CFont* aFont ); williamr@2: williamr@2: /** williamr@2: * Sets the color table and color index for the button text. It will be williamr@2: * used on button drawing, if color of the text shouldn't be taken from williamr@2: * text layout. williamr@2: * williamr@2: * @param aTextColorTableId Id for the color table williamr@2: * @param aTextColorIndex Index of the color inside color table. williamr@2: */ williamr@2: IMPORT_C void SetTextColorIds( const TAknsItemID& aTextColorTableId, williamr@2: const TInt aTextColorIndex ); williamr@2: williamr@2: /** williamr@2: * Sets the horizontal alignment for the text inside the button. It williamr@2: * will be used, if alignment shouldn't be taken from text layout. By williamr@2: * default it will be centered. williamr@2: * williamr@2: * @param aHorizontalAlignment The horizontal alignment for the text. williamr@2: */ williamr@2: IMPORT_C void SetTextHorizontalAlignment( williamr@2: const CGraphicsContext::TTextAlign aHorizontalAlignment ); williamr@2: williamr@2: /** williamr@2: * Sets the vertical alignment for the text inside the button. It will williamr@2: * be used if alignment shouldn't be taken from text layout. By default williamr@2: * it will be centered. williamr@2: * williamr@2: * @param aVerticalAlignment The vertical alignment for the text. williamr@2: */ williamr@2: IMPORT_C void SetTextVerticalAlignment( williamr@2: const CAknButton::TAlignment aVerticalAlignment ); williamr@2: williamr@2: /** williamr@2: * Sets the icon and text alignment for a button having both williamr@2: * williamr@2: * @param aAlignment. TTextAndIconAlignment williamr@2: */ williamr@2: IMPORT_C void SetTextAndIconAlignment( williamr@2: const CAknButton::TTextAndIconAlignment aAlignment ); williamr@2: williamr@2: /** williamr@2: * Sets the text underline style for the text inside the button. By williamr@2: * default no underline is used. williamr@2: * williamr@2: * @param aUnderlineStyle The style of underline. williamr@2: */ williamr@2: IMPORT_C void SetTextUnderlineStyle( TFontUnderline aUnderlineStyle ); williamr@2: williamr@2: /** williamr@2: * Sets the scale mode for the icon inside the button. williamr@2: * The default is EAspectRatioNotPreserved. williamr@2: * williamr@2: * @param aScaleMode The scale mode. williamr@2: */ williamr@2: IMPORT_C void SetIconScaleMode( const TScaleMode aScaleMode ); williamr@2: williamr@2: /** williamr@2: * Sets the horizontal alignment for the icon inside the button. williamr@2: * By default it will be centered. williamr@2: * williamr@2: * @param aHorizontalAlignment The horizontal alignment for the icon. williamr@2: */ williamr@2: IMPORT_C void SetIconHorizontalAlignment( williamr@2: const CAknButton::TAlignment aHorizontalAlignment ); williamr@2: williamr@2: /** williamr@2: * Sets the vertical alignment for the icon inside the button. williamr@2: * By default it will be centered. williamr@2: * williamr@2: * @param aVerticalAlignment The vertical alignment for the icon. williamr@2: */ williamr@2: IMPORT_C void SetIconVerticalAlignment( williamr@2: const CAknButton::TAlignment aVerticalAlignment ); williamr@2: williamr@2: /** williamr@2: * Sets the delay before the help text is shown and also specifies the williamr@2: * time for how long help text is visible. williamr@2: * williamr@2: * @param aBeforeTimeout The delay in milliseconds before text help note williamr@2: * is shown. The default is 150 milliseconds. williamr@2: * @param aInViewTimeout The interval in milliseconds during which help williamr@2: * text note is shown. The default is 3000 milliseconds. williamr@2: */ williamr@2: IMPORT_C void SetHelpNoteTimeouts( const TInt aBeforeTimeout, williamr@2: const TInt aInViewTimeout ); williamr@2: williamr@2: /** williamr@2: * Sets the interval for key repeat. williamr@2: * williamr@2: * @param aKeyRepeatDelay The initial delay, after which the key repeat is williamr@2: started. The default is 500 milliseconds. williamr@2: * @param aKeyRepeatInterval The interval in milliseconds, in which key williamr@2: * repeat events should be reported. The default is 500 milliseconds. williamr@2: */ williamr@2: IMPORT_C void SetKeyRepeatInterval( const TInt aKeyRepeatDelay, williamr@2: const TInt aKeyRepeatInterval ); williamr@2: williamr@2: /** williamr@2: * Sets the interval for long press. When KAknButtonReportOnLongPress williamr@2: * flag is set for the button, button will notify observer with williamr@2: * KAknButtonLongPressEvent as the event type, after button has been williamr@2: * pressed for the specified time. williamr@2: * williamr@2: * @param aLongPressInterval The time interval in milliseconds, after williamr@2: * which the long press event should be reported. The default williamr@2: * value is 800 milliseconds. williamr@2: */ williamr@2: IMPORT_C void SetLongPressInterval( const TInt aLongPressInterval ); williamr@2: williamr@2: /** williamr@2: * Returns the index of the button state. williamr@2: */ williamr@2: IMPORT_C TInt StateIndex() const; williamr@2: williamr@2: /** williamr@2: * Enables pictograph drawing in the button text. williamr@2: * Only effective in Japanese variant. williamr@2: * By default, it is disabled. williamr@2: * williamr@2: * @param aInterface Used pictograph interface owned by the caller. williamr@2: */ williamr@2: IMPORT_C void EnablePictographsL( CAknPictographInterface& aInterface ); williamr@2: williamr@2: /** williamr@2: * Disables pictograph drawing in the button text. williamr@2: * Only effective in Japanese variant. williamr@2: * By default, it is disabled. williamr@2: */ williamr@2: IMPORT_C void DisablePictographs(); williamr@2: williamr@2: /** williamr@2: * It will change the default highlight rectangle around williamr@2: * the focused button. williamr@2: * williamr@2: * @param aRect The highlight rectangle. williamr@2: */ williamr@2: IMPORT_C void SetHighlightRect( const TRect& aRect ); williamr@2: williamr@2: /** williamr@2: * Gets the highlight rectangle around the button. williamr@2: * williamr@2: * @return The higlight rectangle around the button. williamr@2: */ williamr@2: IMPORT_C TRect HighlightRect() const; williamr@2: williamr@2: /** williamr@2: * Sets the tooltip position. williamr@2: * williamr@2: * @param aPosition The position of the tooltip. williamr@2: */ williamr@2: IMPORT_C void SetTooltipPosition( const TTooltipPosition aPosition ); williamr@2: williamr@2: /** williamr@2: * Sets whether button should send an EEventRequestExit event to command williamr@2: * observer on button up event. williamr@2: * williamr@2: * @param aRequestExit ETrue if button should request exit. williamr@2: */ williamr@2: IMPORT_C void SetRequestExit( const TBool aRequestExit ); williamr@2: williamr@2: /** williamr@2: * Tests if the control is dimmed. This function overrides the function williamr@2: * declared in CCoeControl, and returns the value which is set and unset williamr@2: * using CAknButton::SetDimmed(). williamr@2: * williamr@2: * @return ETrue if the control is dimmed, EFalse if it is not dimmed. williamr@2: */ williamr@2: IMPORT_C TBool IsDimmed() const; williamr@2: williamr@2: /** williamr@2: * Sets the help text for dimmed button. williamr@2: * williamr@2: * @param aHelpText The text inside the tooltip. williamr@2: */ williamr@2: IMPORT_C void SetDimmedHelpTextL( const TDesC& aHelpText ); williamr@2: williamr@2: /** williamr@2: * Check if point is within buttons visible area, when williamr@2: * KAknButtonHitTest flag is enabled williamr@2: * williamr@2: * @param aPoint Location to check. williamr@2: * @param aCheckHitArea if need to check the hit area for fixed williamr@2: * toolbar button williamr@2: */ williamr@2: TBool HitAreaContainsL( const TPoint& aPoint, TBool aCheckHitArea ) const; williamr@2: williamr@2: /** williamr@2: * Returns the current state of the button. williamr@2: * williamr@2: * @return the current state of the button williamr@2: */ williamr@2: IMPORT_C CAknButtonState* State() const; williamr@2: williamr@2: /** williamr@2: * Returns the state of the button under specified index. williamr@2: * williamr@2: * @param aStateIndex The index for the state. williamr@2: * @return the state of the button. williamr@2: */ williamr@2: IMPORT_C CAknButtonState* State( const TInt aStateIndex ) const; williamr@2: williamr@2: /** williamr@2: * Returns the flags of button. The flags are defined in eikon.hrh. williamr@2: * @return Button flags. williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: IMPORT_C TInt ButtonFlags() const; williamr@2: williamr@2: /** williamr@2: * Sets button's margins. These define the free area inside the button williamr@2: * where content is placed. Note that calling this function overrides williamr@2: * default margins that are scaled automatically depending on the williamr@2: * current screen layout. If this function is called then the caller williamr@2: * is responsible for updating margins whenever the layout changes. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aMargins New marginals. williamr@2: */ williamr@2: IMPORT_C void SetMargins( const TMargins8& aMargins ); williamr@2: williamr@2: /** williamr@2: * Sets icon size for the button. Calling this function overrides the williamr@2: * default size that is scaled automatically depending on the current williamr@2: * screen layout. If this function is called then the caller is williamr@2: * responsible for updating icon size whenever the layout changes. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aSize New icon size. williamr@2: * @return KErrNone if the operation succeeded, otherwise an error code. williamr@2: */ williamr@2: IMPORT_C TInt SetIconSize( const TSize& aSize ); williamr@2: williamr@2: /** williamr@2: * Checks if the button uses default margins. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * williamr@2: * @return ETrue if default margins are used. williamr@2: */ williamr@2: TBool UsesDefaultMargins() const; williamr@2: williamr@2: /** williamr@2: * Sets tooltip to hide or show itself when background faded. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: * @param aHide should be ETrue if hiding, EFalse if showing williamr@2: */ williamr@2: void HideTooltipWhenAppFaded( TBool aHide ); williamr@2: williamr@2: williamr@2: /** williamr@2: */ williamr@2: void CheckHitArea(); williamr@2: williamr@2: /** williamr@2: * Resets button to unpressed state. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: */ williamr@2: IMPORT_C void ResetState(); williamr@2: williamr@2: /** williamr@2: * Sets button to use additional masks during drawing. Calling this williamr@2: * method forces button to bypass the normal drawing routine i.e. williamr@2: * method DrawMaskedL is executed instead of Draw. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @param aMaskedDraw ETrue to use additional mask. williamr@2: */ williamr@2: void UseMaskedDraw( TBool aMaskedDraw ); williamr@2: williamr@2: /** williamr@2: * Registers resource provider. williamr@2: * @param aProvider New resource provider. williamr@2: */ williamr@2: void RegisterResourceProvider( CAknResourceProvider* aProvider ); williamr@2: williamr@2: /** williamr@2: * Unregisters resource provider. williamr@2: */ williamr@2: void UnregisterResourceProvider(); williamr@2: williamr@2: CAknsFrameBackgroundControlContext* BgContext(); williamr@2: williamr@2: /** williamr@2: * Removes the currently active state from the button, williamr@2: * and sets the current state to the previous one. williamr@2: */ williamr@2: void RemoveCurrentState(); williamr@2: williamr@2: /** williamr@2: * Returns the button touchable area. williamr@2: * williamr@2: * @since S60 5.0 williamr@2: * @return Button touch area williamr@2: */ williamr@2: TRect TouchArea() const; williamr@2: williamr@2: protected: // Constructors williamr@2: williamr@2: /** williamr@2: * C++ constructor for the one state button. williamr@2: * williamr@2: * @param aFlags The flags for the button williamr@2: */ williamr@2: IMPORT_C CAknButton( const TInt aFlags ); williamr@2: williamr@2: /** williamr@2: * Symbian 2nd phase constructor. williamr@2: */ williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: /** williamr@2: * Symbian 2nd phase constructor. williamr@2: * williamr@2: * @param aIcon The icon for the normal state. Takes ownership. williamr@2: * @param aDimmedIcon The icon for the dimmed state. Takes ownership. williamr@2: * @param aPressedIcon The icon for the pressed down. Takes ownership. williamr@2: * @param aHoverIcon The icon for the hover state. williamr@2: * @param aText The text inside the button. williamr@2: * @param aHelpText The text for the tooltip. williamr@2: * @param aStateFlags The flags for the first state. williamr@2: */ williamr@2: IMPORT_C void ConstructL( CGulIcon* aIcon, williamr@2: CGulIcon* aDimmedIcon, williamr@2: CGulIcon* aPressedIcon, williamr@2: CGulIcon* aHoverIcon, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aStateFlags ); williamr@2: williamr@2: /** williamr@2: * Symbian 2nd phase constructor. williamr@2: * williamr@2: * @param aFilePath The path to the file which contains icons. williamr@2: * @param aBmpId The bitmap ID for the normal state icon. williamr@2: * @param aMaskId The mask ID for the normal state icon. williamr@2: * @param aDimmedBmpId The bitmap ID for the dimmed state icon. williamr@2: * @param aDimmedMaskId The mask ID for the dimmed state icon. williamr@2: * @param aPressedBmpId The bitmap ID for the pressed down state. williamr@2: * @param aPressedMaskId The mask ID for the pressed down state. williamr@2: * @param aHoverBmpId The bitmap ID for the hover state icon. williamr@2: * @param aHoverMaskId The mask ID for the hover state icon. williamr@2: * @param aText The text inside the button. williamr@2: * @param aHelpText The text for the tooltip. williamr@2: * @param aStateFlags The flags for the first state. williamr@2: * @param aId Item ID of the masked bitmap to be created for skin williamr@2: * specific icon. williamr@2: * @param aDimmedId Item ID of the dimmed masked bitmap to be created williamr@2: * for skin specific icon. williamr@2: * @param aPressedId Item ID of the pressed masked bitmap to be created williamr@2: * for skin specific icon. williamr@2: * @param aHoverId Item ID of the masked hover bitmap to be created williamr@2: * for skin specific icon. williamr@2: */ williamr@2: IMPORT_C void ConstructL( const TDesC& aFilePath, williamr@2: const TInt aBmpId, williamr@2: const TInt aMaskId, williamr@2: const TInt aDimmedBmpId, williamr@2: const TInt aDimmedMaskId, williamr@2: const TInt aPressedBmpId, williamr@2: const TInt aPressedMaskId, williamr@2: const TInt aHoverBmpId, williamr@2: const TInt aHoverMaskId, williamr@2: const TDesC& aText, williamr@2: const TDesC& aHelpText, williamr@2: const TInt aStateFlags, williamr@2: const TAknsItemID& aId = KAknsIIDNone, williamr@2: const TAknsItemID& aDimmedId = KAknsIIDNone, williamr@2: const TAknsItemID& aPressedId = KAknsIIDNone, williamr@2: const TAknsItemID& aHoverId = KAknsIIDNone ); williamr@2: williamr@2: protected: // Functions from base class williamr@2: williamr@2: /** williamr@2: * Responds to size changes to sets the size and position of the williamr@2: * contents of this control. williamr@2: */ williamr@2: IMPORT_C void SizeChanged(); williamr@2: williamr@2: /** williamr@2: * This function is called whenever a control gains or loses focus. williamr@2: * williamr@2: * @param aDrawNow Contains the value that was passed to it by SetFocus(). williamr@2: */ williamr@2: IMPORT_C void FocusChanged( TDrawNow aDrawNow ); williamr@2: williamr@2: /** williamr@2: * For future extensions williamr@2: * williamr@2: * @param aInterface The ID for the extension interface. williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: protected: // New functions williamr@2: williamr@2: /** williamr@2: * Changes the state of the button to the next one. williamr@2: * williamr@2: * @return the current state index williamr@2: */ williamr@2: IMPORT_C TInt ChangeState( TBool aDrawNow ); williamr@2: williamr@2: /** williamr@2: * Returns the text, which will be displayed inside the button williamr@2: * for the current state. williamr@2: */ williamr@2: IMPORT_C const TDesC& GetCurrentText() const; williamr@2: williamr@2: /** williamr@2: * Returns icon for the current state. williamr@2: */ williamr@2: IMPORT_C const CGulIcon* GetCurrentIcon() const; williamr@2: williamr@2: /** williamr@2: * Shows help text for a certain period of time. williamr@2: */ williamr@2: IMPORT_C void ShowHelpL(); williamr@2: williamr@2: /** williamr@2: * Hides help text after certain interval. williamr@2: */ williamr@2: IMPORT_C void HideHelp(); williamr@2: williamr@2: williamr@2: private: // Functions from base class williamr@2: williamr@2: /** williamr@2: * From CCoeControl. Draws the control. Called by window server. williamr@2: */ williamr@2: IMPORT_C void Draw( const TRect& aRect ) const; williamr@2: williamr@2: private: // New functions williamr@2: williamr@2: /** williamr@2: * Continues drawing of the button which has only text. williamr@2: */ williamr@2: void DrawTextButton( CWindowGc& aGc ) const; williamr@2: williamr@2: /** williamr@2: * Continues drawing of the button which has only an icon in it. williamr@2: */ williamr@2: void DrawIconButton( CWindowGc& aGc ) const; williamr@2: williamr@2: /** williamr@2: * Continues drawing of the button which has both text and icon. williamr@2: */ williamr@2: void DrawTextAndIconButton( CWindowGc& aGc ) const; williamr@2: williamr@2: /** williamr@2: * Starts the long press timer. williamr@2: */ williamr@2: void StartLongPressTimerL(); williamr@2: williamr@2: /** williamr@2: * Stops the long press timer. williamr@2: */ williamr@2: void StopLongPressTimer(); williamr@2: williamr@2: /** williamr@2: * Starts the timer for the key repeat. williamr@2: */ williamr@2: void StartKeyRepeatTimerL(); williamr@2: williamr@2: /** williamr@2: * Stops the key repeat timer. williamr@2: */ williamr@2: void StopKeyRepeatTimer(); williamr@2: williamr@2: /** williamr@2: * Called after timeout is over. williamr@2: */ williamr@2: static TInt ReportKeyRepeatL( TAny* aThis ); williamr@2: williamr@2: /** williamr@2: * Asserts that extension class object exists. williamr@2: * williamr@2: * @return Extension object. williamr@2: */ williamr@2: CAknButtonExtension* Extension() const; williamr@2: williamr@2: /** williamr@2: * Updates tooltip position. williamr@2: */ williamr@2: void UpdateTooltipPosition(); williamr@2: williamr@2: /** williamr@2: * Checks whether toolbar should send an EEventRequestExit event to williamr@2: * command observe on button up event. williamr@2: * williamr@2: * @return ETrue if event should be sent, EFalse otherwise. williamr@2: */ williamr@2: TBool RequestExit() const; williamr@2: williamr@2: /** williamr@2: * Gets the rectangele reserved for button content excluding frame. williamr@2: * williamr@2: * @return Content rectangle. williamr@2: */ williamr@2: TRect ContentRect() const; williamr@2: williamr@2: /** williamr@2: * Checks whether button needs redrawing when it is pressed or released. williamr@2: * williamr@2: * @return ETrue, if redraw is needed, othewise EFalse. williamr@2: */ williamr@2: TBool NeedsRedrawWhenPressed() const; williamr@2: williamr@2: /** williamr@2: * Returns the ID of specified skin item. williamr@2: */ williamr@2: TAknsItemID SkinIID( const TInt aIndex ) const; williamr@2: williamr@2: /** williamr@2: * Calculates default margins. williamr@2: */ williamr@2: void CalculateDefaultMargins(); williamr@2: williamr@2: /** williamr@2: * Scales all icons. williamr@2: * williamr@2: * @return KErrNone or an error code. williamr@2: */ williamr@2: TInt ScaleIcons(); williamr@2: williamr@2: /** williamr@2: * Gets the correct text color. williamr@2: * williamr@2: * @return Text color. williamr@2: */ williamr@2: TRgb TextColor() const; williamr@2: williamr@2: /** williamr@2: * Generates the pressed down bitmaps williamr@2: * if flag KAknButtonPressedDownFrame is set and button has no frame williamr@2: */ williamr@2: void CreatePressedDownFrameL(); williamr@2: williamr@2: /** williamr@2: * Calculates color's luminance. williamr@2: */ williamr@2: TInt CalculateLuminance( const TRgb& aColor ) const; williamr@2: williamr@2: /** williamr@2: * Converts outline color, if fill color is too similar to outline color williamr@2: * williamr@2: * @aFillColor fill color williamr@2: * @aOutlineColor outline color williamr@2: */ williamr@2: void ConvertColorsForOutlineEffect( TRgb& aFillColor, TRgb& aOutlineColor ) const; williamr@2: williamr@2: /** williamr@2: * Gets text colors williamr@2: * williamr@2: * @aPenColor pen color williamr@2: * @aBrushColor brush color williamr@2: */ williamr@2: void GetTextColors( TRgb& aPenColor, TRgb& aBrushColor ) const; williamr@2: williamr@2: /** williamr@2: * Sets new state index williamr@2: * williamr@2: * @param aNewIndex New state index williamr@2: */ williamr@2: void SetStateIndexL( TInt aNewIndex ); williamr@2: williamr@2: protected: // Data williamr@2: williamr@2: // array to keep states williamr@2: CArrayPtrFlat* iStates; williamr@2: williamr@2: // button flags williamr@2: TInt iFlags; williamr@2: williamr@2: // current button state index williamr@2: TInt iStateIndex; williamr@2: williamr@2: // flag to define whether the button is pressed williamr@2: TBool iButtonPressed; williamr@2: williamr@2: // number of drag events, needed to distinguish when it is outside williamr@2: // the button. williamr@2: TInt iNumberOfDragEvents; williamr@2: williamr@2: // Flag which shows whether key down event was reported before key up williamr@2: // event was sent to the button, because some controls consume key down williamr@2: // but don't consume key up events which might cause of button state williamr@2: // when it is not expected williamr@2: TBool iKeyDownReported; williamr@2: williamr@2: // Background control context for button's frame williamr@2: CAknsFrameBackgroundControlContext* iBgContext; williamr@2: williamr@2: // Customized highlight rectangular around the button if the default one williamr@2: // won't be used williamr@2: TRect iHighlightRect; williamr@2: williamr@2: // text button specific data williamr@2: const CFont* iFont; // font for the text inside the button williamr@2: TAlignment iVerticalAlignment; // vertical alignment for the text. Centered by default williamr@2: CGraphicsContext::TTextAlign iHorizontalAlignment; // horizontal alignment for the text. Centered by default williamr@2: TAknsItemID iTextColorTableId; // id for the color table williamr@2: TInt iTextColorIndex; // index of the color in color table williamr@2: williamr@2: // icon button specific data williamr@2: TScaleMode iScaleMode; // scale mode for the icon, by default it is EAspectRatioNotPreserved williamr@2: williamr@2: // tooltip specific data williamr@2: TInt iHelpNoteWaitInterval; // interval in milliseconds between the time when the button got focused and the help text is shown williamr@2: TInt iHelpNoteInViewInterval; // interval during which help text is shown in milliseconds williamr@2: CAknInfoPopupNoteController* iHelpNote; // component to show help text williamr@2: HBufC* iDimmedHelpText; // help text in case if the button is dimmed, not used currently williamr@2: TBool iShowHelp; // flag which specifies whether help note should be shown williamr@2: williamr@2: // Key repeat handling williamr@2: CPeriodic* iKeyRepeatTimer; // timer to report key repeats williamr@2: TInt iKeyRepeatDelay; // initial delay for key repeats williamr@2: TInt iKeyRepeatInterval; // time interval for key repeats williamr@2: williamr@2: private: williamr@2: CAknButtonExtension* iExtension; williamr@2: williamr@2: }; williamr@2: williamr@2: williamr@2: #endif // __AKNBUTTON_H__ williamr@2: williamr@2: // End of File