williamr@2: /* williamr@2: * Copyright (c) 2001-2006 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: Command button class interfaces. Contains a common base class williamr@2: * for command-generating buttons, plus several concrete, specialized classes williamr@2: * williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #if !defined(__EIKCMBUT_H__) williamr@2: #define __EIKCMBUT_H__ williamr@2: williamr@2: #if !defined(__EIKBUTB_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__COECCNTX_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__GULUTIL_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: class CEikLabel; williamr@2: class CEikImage; williamr@2: class CEikAlignedControl; williamr@2: class TResourceReader; williamr@2: class CEikCommandStack; williamr@2: williamr@2: /** williamr@2: * Base class for buttons that generate commands. williamr@2: * williamr@2: * MControlContext is mixed in. This class is used as the interface to the button member of williamr@2: * CEikLabeledButton, as well as being the base class for CEikCommandButton, CEikTextButton, and CEikBitmapButton williamr@2: * williamr@2: * @lib eikcoctl.dll williamr@2: * @since S60 1.0 williamr@2: */ williamr@2: class CEikCommandButtonBase : public CEikButtonBase, public MCoeControlContext williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Enumeration to tag the components of a command button (text or image) williamr@2: */ williamr@2: enum TWhichComponent williamr@2: { williamr@2: EFirst, williamr@2: ESecond williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Controls which of the components of the command button are shown. williamr@2: */ williamr@2: enum TDisplayContent williamr@2: { williamr@2: EFirstOnly =0x0100, williamr@2: ESecondOnly =0x0200, williamr@2: EBoth =0x0300 williamr@2: }; williamr@2: williamr@2: /* williamr@2: * Layout and font options for the components of the command button williamr@2: */ williamr@2: enum TLayout williamr@2: { williamr@2: EFirstRightSecondLeft=0x0000, williamr@2: EFirstBottomSecondTop=0x0001, williamr@2: EFirstTopSecondBottom=0x0002, williamr@2: EFirstLeftSecondRight=0x0003, williamr@2: EDenseFont =0x0008 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Options for where excess space between the two components of the command button is distrubuted williamr@2: */ williamr@2: enum TExcess williamr@2: { williamr@2: EShare =0x0000, williamr@2: EToFirst =0x0010, williamr@2: EToSecond =0x0020 williamr@2: }; williamr@2: williamr@2: public: // new functions williamr@2: williamr@2: /** williamr@2: * C++ destructor williamr@2: */ williamr@2: IMPORT_C ~CEikCommandButtonBase(); williamr@2: williamr@2: /** williamr@2: * Sets the layout of the button williamr@2: * @param aLayout Layout enumeration williamr@2: */ williamr@2: IMPORT_C void SetButtonLayout(TLayout aLayout); williamr@2: williamr@2: /** williamr@2: * Sets where excess space is to be put williamr@2: * @param aExcess Excess space enumeration williamr@2: */ williamr@2: IMPORT_C void SetExcessSpace(TExcess aExcess); williamr@2: williamr@2: /** williamr@2: * Sets the content of the button williamr@2: * williamr@2: * @param aContent williamr@2: */ williamr@2: IMPORT_C void SetDisplayContent(TDisplayContent aContent); williamr@2: williamr@2: /** williamr@2: * Causes the content to be (re-)laid out. williamr@2: */ williamr@2: IMPORT_C void LayoutComponents(); williamr@2: williamr@2: /** williamr@2: * Read preamble part of the resource. This call can be followed by calls to williamr@2: * ConstructLabelFromResourceL and/or ConstructImageFromResourceL to complete contruction. williamr@2: */ williamr@2: IMPORT_C void StartConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: /** williamr@2: * Constructs a label component for the button williamr@2: * williamr@2: * @aparam aWhich Which component to construct in this call williamr@2: */ williamr@2: IMPORT_C void ConstructLabelFromResourceL(TResourceReader& aReader,TWhichComponent aWhich); williamr@2: williamr@2: /** williamr@2: * Constructs an image component for the button williamr@2: * williamr@2: * @aparam aWhich Which component to construct in this call williamr@2: */ williamr@2: IMPORT_C void ConstructImageFromResourceL(TResourceReader& aReader,TWhichComponent aWhich); williamr@2: williamr@2: /** williamr@2: * Cause a recalculation of the components alignment williamr@2: */ williamr@2: IMPORT_C virtual void UpdateComponentAlignment(); williamr@2: williamr@2: /** williamr@2: * Sets this button to be the default. williamr@2: */ williamr@2: IMPORT_C void SetDefault(TBool aIsDefault); williamr@2: williamr@2: public: // from CCoeControl. See base class documentation williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Sets the button to be inactive. The button is drawn with a dimmed effect. williamr@2: * williamr@2: * @param aDimmed If not EFalse, set the state to dimmed. Otherwise set to non-dimmed williamr@2: */ williamr@2: IMPORT_C void SetDimmed(TBool aDimmed); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Reports to the caller the minimum size that the control can be, given its contents. williamr@2: * williamr@2: * @return The minimum size williamr@2: */ williamr@2: IMPORT_C TSize MinimumSize(); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Returns the number of component controls williamr@2: * williamr@2: * @return Number of component controls williamr@2: */ williamr@2: IMPORT_C TInt CountComponentControls() const; williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Return a pointer to the component control at the give index. williamr@2: * williamr@2: * @return Pointer to the conponent control. No ownership is transferred williamr@2: */ williamr@2: IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const; williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Make the control ready for display. williamr@2: */ williamr@2: IMPORT_C void ActivateL(); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Sets the control whose window is to be used as a container for this control williamr@2: * williamr@2: * @param aContainer control williamr@2: */ williamr@2: IMPORT_C void SetContainerWindowL(const CCoeControl& aContainer); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Called when the focus has changed williamr@2: * williamr@2: * @param aDrawNow Iff not EFalse, then the control is requested to redraw. williamr@2: */ williamr@2: IMPORT_C void FocusChanged(TDrawNow aDrawNow); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * CONE framework is requesting that the passed-in key be handled. williamr@2: * williamr@2: * @param aKeyEvent Wserv event type williamr@2: * @param aKeyCode Key code williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Obtain the list of colors to be used by this control williamr@2: * williamr@2: * @param aColorUseList williamr@2: */ williamr@2: IMPORT_C virtual void GetColorUseListL(CArrayFix& aColorUseList) const; williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * This is called when resource or layout or other display-affecting setting has changed. williamr@2: * Change the internals of the control so that it is ready for a subsequent SizeChanged call. williamr@2: * williamr@2: * @param aType Type of resource or setting that has changed williamr@2: */ williamr@2: IMPORT_C virtual void HandleResourceChange(TInt aType); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Handle a pointer event that has been routed to this control williamr@2: * williamr@2: * @param aPointerEvent Pointer event to handle williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: public: // but not exported williamr@2: /** williamr@2: * Access to the command stack williamr@2: * williamr@2: * @return pointer to the command stack williamr@2: */ williamr@2: CEikCommandStack* CommandStack() const; williamr@2: williamr@2: /** williamr@2: * Access to the button flags williamr@2: * williamr@2: * @return The button flag pattern williamr@2: */ williamr@2: TInt ButFlags() const; williamr@2: williamr@2: /** williamr@2: * Access to whether the button is default williamr@2: * williamr@2: * @return EFalse iff the button is not default. williamr@2: */ williamr@2: TBool IsDefault() const; williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * From CEikButtonBase williamr@2: * williamr@2: * Framework method called when the state changes williamr@2: */ williamr@2: IMPORT_C void StateChanged(); williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * Constructor williamr@2: */ williamr@2: IMPORT_C CEikCommandButtonBase(); williamr@2: williamr@2: /** williamr@2: * Sets the label text for the button. williamr@2: * williamr@2: * @param aText The text to set williamr@2: * @param aComponent The component for which the text is to be set. williamr@2: */ williamr@2: IMPORT_C void SetTextL(const TDesC& aText,CEikAlignedControl*& aComponent); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask for the button williamr@2: * williamr@2: * @param aMain The bitmap to use williamr@2: * @param aMask The mask. If null, then no mask will be used williamr@2: * @param aComponent The component for which the picture is to be set. williamr@2: */ williamr@2: IMPORT_C void SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask,CEikAlignedControl*& aComponent); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask from an mbm file. williamr@2: * williamr@2: * @param aFile Mbm filename williamr@2: * @param aMain Index of the bitmap to use williamr@2: * @param aMask Index of the mask. If -1, then a null mask will be used williamr@2: * @param aComponent The component for which the picture is to be set. williamr@2: */ williamr@2: IMPORT_C void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask,CEikAlignedControl*& aComponent); williamr@2: williamr@2: /** williamr@2: * Utility routine. Calling this without a leave will ensure the internal command stack is constructed. williamr@2: */ williamr@2: inline void CheckCreateCommandStackL(); williamr@2: williamr@2: protected: // from CCoeControl williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Request for the control to draw itself within the given rectangle williamr@2: * williamr@2: * @param aRect TRect to draw williamr@2: */ williamr@2: IMPORT_C void Draw(const TRect& aRect) const; williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Utility routine. Sets additional look and feel attributes for the image williamr@2: */ williamr@2: void SetImageAttributes(CEikImage* aImage); williamr@2: williamr@2: /** williamr@2: * Access the behaviour set into the button williamr@2: */ williamr@2: inline TInt Behavior() const; williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Serialize the state of the control williamr@2: * williamr@2: * @param aWriteStream Output stream for the serialization williamr@2: */ williamr@2: IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Framework method called when the size or layout changes williamr@2: */ williamr@2: IMPORT_C void SizeChanged(); williamr@2: IMPORT_C void Reserved_2(); williamr@2: williamr@2: private: // from CEikButtonBase williamr@2: IMPORT_C void Reserved_3(); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From MCoeControlContext williamr@2: * williamr@2: * Modify the passed-in graphics context ready for use in this control williamr@2: * williamr@2: * @param aGc Graphics context to set up williamr@2: */ williamr@2: IMPORT_C void PrepareContext(CWindowGc& aGc) const; williamr@2: williamr@2: private: williamr@2: IMPORT_C virtual void Reserved_4(); williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: // New methods williamr@2: private: williamr@2: void SetComponentExtents(const TRect& aRect); williamr@2: void SetNewComponentExtentL(); williamr@2: TBool LayoutIsVertical() const; williamr@2: protected: williamr@2: TMargins8 iMargins; williamr@2: /** williamr@2: * The components of the button: the image or the text (order determined by construction) williamr@2: */ williamr@2: CEikAlignedControl* iComponents[2]; williamr@2: TInt iCmdFlags; williamr@2: private: williamr@2: TInt iDrawOffset; williamr@2: /** williamr@2: * Owned williamr@2: */ williamr@2: CEikCommandStack* iCommandStack; williamr@2: TInt iDummy; williamr@2: TBool iDefault; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Command button with a text and/or an image williamr@2: * williamr@2: * This class in S60 does not function without derivation williamr@2: * This class does NOT implement S60 look-and-feel and is not skinned. williamr@2: * williamr@2: * @lib eikcoctl.dll williamr@2: * @since S60 1.0 williamr@2: */ williamr@2: class CEikCommandButton : public CEikCommandButtonBase williamr@2: { williamr@2: public: williamr@2: /** Layout options for a command button*/ williamr@2: enum TLayout williamr@2: { williamr@2: ETextRightPictureLeft=0x000, williamr@2: ETextBottomPictureTop=0x001, williamr@2: ETextTopPictureBottom=0x002, williamr@2: ETextLeftPictureRight=0x003 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Where to put excess space in the layout williamr@2: */ williamr@2: enum TExcess williamr@2: { williamr@2: EShare =0x0000, williamr@2: EToText =0x0010, williamr@2: EToPicture =0x0020 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Content to diplay for this button williamr@2: */ williamr@2: enum TDisplayContent williamr@2: { williamr@2: ETextOnly =0x0100, williamr@2: EPictureOnly =0x0200, williamr@2: ETextAndPicture =0x0300 williamr@2: }; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Constructor williamr@2: */ williamr@2: IMPORT_C CEikCommandButton(); williamr@2: williamr@2: /** williamr@2: * C++ destructor williamr@2: */ williamr@2: IMPORT_C ~CEikCommandButton(); williamr@2: williamr@2: /** williamr@2: * Sets the label text for the button. williamr@2: * williamr@2: * @param aText The text to set williamr@2: */ williamr@2: IMPORT_C void SetTextL(const TDesC& aText); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask for the button williamr@2: * williamr@2: * @param aMain The bitmap to use williamr@2: * @param aMask The mask. If null, then no mask will be used williamr@2: */ williamr@2: IMPORT_C void SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask=NULL); williamr@2: williamr@2: /** williamr@2: * Set bitmap and mask from file. williamr@2: */ williamr@2: IMPORT_C void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1); williamr@2: williamr@2: /** williamr@2: * Access the label control that implements the text label of the button. Ownership is not transferred. williamr@2: * williamr@2: * @return A pointer to the CEikLabel control used to implement the text display williamr@2: */ williamr@2: IMPORT_C CEikLabel* Label() const; williamr@2: williamr@2: /** williamr@2: * Access the CEikImage that implements the picture component of the button. Ownership is not transferred. williamr@2: * williamr@2: * @return A pointer to the CEikImage used to implement the image display. williamr@2: */ williamr@2: IMPORT_C CEikImage* Picture() const; williamr@2: williamr@2: /** williamr@2: * Set the layout of the button williamr@2: * williamr@2: * @param aLayout Layout to be used williamr@2: */ williamr@2: IMPORT_C void SetButtonLayout(TLayout aLayout); williamr@2: williamr@2: /** williamr@2: * Sets where the excess space in the layout is to be distributed williamr@2: * williamr@2: * @param aExcess Enum value to say where the excess space is to go williamr@2: */ williamr@2: IMPORT_C void SetExcessSpace(TExcess aExcess); williamr@2: williamr@2: /** williamr@2: * Set what content is to be displayed in the button williamr@2: * williamr@2: * @param aContent Enum value saying what content to display williamr@2: */ williamr@2: IMPORT_C void SetDisplayContent(TDisplayContent aContent); williamr@2: williamr@2: /** williamr@2: * Sets the command button's text, bitmap and bitmap mask. williamr@2: * williamr@2: * @param aCommandId Command ID to be generated by pressing this button williamr@2: * @param aText Text to display on the button williamr@2: * @param aBitmap Bitmap to display on the button williamr@2: * @param aMask Mask to use. May be Null williamr@2: */ williamr@2: IMPORT_C void SetCommandL(TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask); williamr@2: williamr@2: /** williamr@2: * Push a command ID + text + image binding onto the command stack. williamr@2: * williamr@2: * @param aCommandId Command ID to be generated by pressing this button williamr@2: * @param aText Text to display on the button williamr@2: * @param aBitmap Bitmap to display on the button williamr@2: * @param aMask Mask to use. May be Null williamr@2: */ williamr@2: IMPORT_C void AddCommandToStackL(TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask); williamr@2: williamr@2: /** williamr@2: * Find the stacked command with a given command ID and remove it from the stack williamr@2: * williamr@2: * @param aCommandId ID of the command to be removed williamr@2: * @return EFalse iff the comand is not found williamr@2: */ williamr@2: IMPORT_C TBool RemoveCommandFromStack(TInt aCommandId); williamr@2: williamr@2: /** williamr@2: * Remove the top (most recently added) command binding from the command stack williamr@2: * williamr@2: * @return the number of commands left on the stack. williamr@2: */ williamr@2: IMPORT_C TInt PopCommandFromStack(); williamr@2: williamr@2: public: // from CCoeControl williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Construct the object from resource williamr@2: * williamr@2: * @param aReader Fully constructed resource reader williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Handle a pointer event coming from the CONE framework williamr@2: * williamr@2: * @param aPointerEvent Event to handle williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: public: williamr@2: /** williamr@2: * From CEikCommandButtonBase williamr@2: * williamr@2: * Cause a recalculation of the components alignment williamr@2: */ williamr@2: IMPORT_C void UpdateComponentAlignment(); williamr@2: williamr@2: private: williamr@2: void UpdateLabelReserveLengthL(const TDesC* aText); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: williamr@2: TInt iDummy; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * The CEikTwoPictureCommandButton class is a command button which can hold two pictures as williamr@2: * well as label text. If a second picture is set for the button it is shown when the button williamr@2: * is pressed. williamr@2: * williamr@2: * @lib eikcoctl.dll williamr@2: * @since S60 1.0 williamr@2: */ williamr@2: class CEikTwoPictureCommandButton : public CEikCommandButtonBase williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Layout options for the Two Picture botton williamr@2: */ williamr@2: enum TLayout williamr@2: { williamr@2: ETextRightPictureLeft=0x000, williamr@2: ETextBottomPictureTop=0x001, williamr@2: ETextTopPictureBottom=0x002, williamr@2: ETextLeftPictureRight=0x003 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Where to put the excess space when laying out the bitmaps or text williamr@2: */ williamr@2: enum TExcess williamr@2: { williamr@2: EShare =0x0000, williamr@2: EToText =0x0010, williamr@2: EToPicture =0x0020 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Content to display for the text williamr@2: */ williamr@2: enum TDisplayContent williamr@2: { williamr@2: ETextOnly =0x0100, williamr@2: EPictureOnly =0x0200, williamr@2: ETextAndPicture =0x0300 williamr@2: }; williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Options for the type of button williamr@2: */ williamr@2: enum TPictureButtonType williamr@2: { williamr@2: EPictureButWithBorders =0x0000, williamr@2: EPictureButWithoutBorders =0x1000 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Sets the ownership of the pictures bitmap and mask objects. If owned externally, then no copy is made of the objects williamr@2: * in the setter functions. It must be, in this case, ensured by the client that that the button is destroyed before williamr@2: * deleting the externally-owned objects. williamr@2: */ williamr@2: enum TExternalPicture williamr@2: { williamr@2: EPictureNotOwnedExternally =0x00, williamr@2: EPictureOwnedExternally =0x01 williamr@2: }; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Two picture command button constructor williamr@2: */ williamr@2: IMPORT_C CEikTwoPictureCommandButton(); williamr@2: williamr@2: /** williamr@2: * Two picture command button C++ destructor williamr@2: */ williamr@2: IMPORT_C ~CEikTwoPictureCommandButton(); williamr@2: williamr@2: /** williamr@2: * Accesses ownership of the second picture' bitmap and mask (if present) williamr@2: * williamr@2: * @return EFalse iff and if the second picture is not owned externally williamr@2: */ williamr@2: IMPORT_C TBool IsSecondPictureOwnedExternally(); williamr@2: williamr@2: /** williamr@2: * Access the picture image. williamr@2: * williamr@2: * @return The picture as a CEikImage. No ownership transferred. williamr@2: */ williamr@2: IMPORT_C CEikImage* Picture() const; williamr@2: williamr@2: /** williamr@2: * Constructs the two images from resource williamr@2: * williamr@2: * @param aReader Constructed resource reader. williamr@2: * @param aWhich Which picture to be constructing williamr@2: */ williamr@2: IMPORT_C void ConstructImagesFromResourceL(TResourceReader& aReader,TWhichComponent aWhich); williamr@2: williamr@2: /** williamr@2: * Sets the label text on the button williamr@2: * williamr@2: * @param aText The text to set williamr@2: */ williamr@2: IMPORT_C void SetTextL(const TDesC& aText); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask for the button's two pictures. Optionally, only the first button's williamr@2: * picture may be set up. williamr@2: * williamr@2: * @param aMain The bitmap to use for the first picture williamr@2: * @param aMask The mask. If null, then no mask will be used williamr@2: * @param aSecondMain The bitmap to use for the second picture williamr@2: * @param aSecondMask The mask. If null, then no mask will be used williamr@2: */ williamr@2: IMPORT_C void SetTwoPicturesL(const CFbsBitmap* aMain,const CFbsBitmap* aMask=NULL,const CFbsBitmap* aSecondMain=NULL, const CFbsBitmap* aSecondMask=NULL); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask for the button's second picture williamr@2: * williamr@2: * @param aMain The bitmap to use williamr@2: * @param aMask The mask. If null, then no mask will be used williamr@2: */ williamr@2: IMPORT_C void SetSecondPicture(const CFbsBitmap* aSecondMain, const CFbsBitmap* aSecondMask=NULL); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask for the first picture from an mbm file. williamr@2: * williamr@2: * @param aFile Mbm filename williamr@2: * @param aMain Index of the bitmap to use williamr@2: * @param aMask Index of the mask. If -1, then a null mask will be used williamr@2: */ williamr@2: IMPORT_C void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask for the second picture from an mbm file. williamr@2: * williamr@2: * @param aFile Mbm filename williamr@2: * @param aMain Index of the bitmap to use williamr@2: * @param aMask Index of the mask. If -1, then a null mask will be used williamr@2: */ williamr@2: IMPORT_C void SetSecondPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1); williamr@2: williamr@2: /** williamr@2: * Sets the ownership of the second picture object williamr@2: * williamr@2: * @param aOwnership Set to EFalse if bitmaps associated with the object are owned by the button williamr@2: */ williamr@2: IMPORT_C void SetSecondPictureOwnedExternally(TBool aOwnership); williamr@2: williamr@2: public: // from CCoeControl. williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * @param aReader Fully constructed resource reader williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Make the control ready for display williamr@2: */ williamr@2: IMPORT_C void ActivateL(); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Handle a pointer event coming from the CONE framework williamr@2: * williamr@2: * @param aPointerEvent Event to handle williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Serialize the state of the control williamr@2: * williamr@2: * @param aWriteStream Output stream for the serialization williamr@2: */ williamr@2: IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: williamr@2: private: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Request for the control to draw itself within the given rectangle williamr@2: * williamr@2: * @param aRect TRect to draw williamr@2: */ williamr@2: IMPORT_C void Draw(const TRect& /*aRect*/) const; williamr@2: williamr@2: /** williamr@2: * From CEikButtonBase williamr@2: * williamr@2: * Framework method called when the state changes williamr@2: */ williamr@2: IMPORT_C void StateChanged(); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From MCoeControlContext williamr@2: * williamr@2: * Modify the passed-in graphics context ready for use in this control williamr@2: * williamr@2: * @param aGc Graphics context to set up williamr@2: */ williamr@2: IMPORT_C void PrepareContext(CWindowGc& aGc) const; williamr@2: williamr@2: private: williamr@2: void SwapPictures(CEikImage* aImage); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Ownership dependent on state of flags williamr@2: */ williamr@2: const CFbsBitmap* iSecondBitmap; williamr@2: /** williamr@2: * Ownership dependent on state of flags williamr@2: */ williamr@2: const CFbsBitmap* iSecondMaskBitmap; williamr@2: TInt iPictureFlags; williamr@2: TInt iDummy; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * The CEikInverterCommandButton class is a command button which swaps the foreground and background williamr@2: * colors used to draw the button contents when the button is pressed. williamr@2: * williamr@2: * @since S60 1.0 williamr@2: */ williamr@2: class CEikInverterCommandButton : public CEikCommandButton williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Constructor williamr@2: */ williamr@2: IMPORT_C CEikInverterCommandButton(); williamr@2: williamr@2: /** williamr@2: * C++ destructor williamr@2: */ williamr@2: IMPORT_C ~CEikInverterCommandButton(); williamr@2: williamr@2: public: // From CCoeControl williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Handle a pointer event coming from the CONE framework williamr@2: * williamr@2: * @param aPointerEvent Event to handle williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Serialize the state of the control williamr@2: * williamr@2: * @param aWriteStream Output stream for the serialization williamr@2: */ williamr@2: IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From MCoeControlContext williamr@2: * williamr@2: * Modify the passed-in graphics context ready for use in this control williamr@2: * williamr@2: * @param aGc Graphics context to set up williamr@2: */ williamr@2: IMPORT_C void PrepareContext(CWindowGc& aGc) const; williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: williamr@2: TInt iFlag; williamr@2: TInt iDummy; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * A command button with a text label williamr@2: * williamr@2: * This specialization of CEikCommandButtonBase supports a single text label. williamr@2: * williamr@2: * @lib eikcoctl.dll williamr@2: * @since S60 1.0 williamr@2: */ williamr@2: class CEikTextButton : public CEikCommandButtonBase williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Constructor williamr@2: */ williamr@2: IMPORT_C CEikTextButton(); williamr@2: williamr@2: /** williamr@2: * C++ destructor williamr@2: */ williamr@2: IMPORT_C ~CEikTextButton(); williamr@2: williamr@2: /** williamr@2: * Sets the label text for the button. williamr@2: * williamr@2: * @param aText The text to set williamr@2: * @param aWhich The component for which the text is to be set. williamr@2: */ williamr@2: IMPORT_C void SetTextL(const TDesC& aText,TWhichComponent aWhich=EFirst); williamr@2: williamr@2: /** williamr@2: * Access the label control that implements the text label of the button. Ownership is not transferred. williamr@2: * williamr@2: * @return A pointer to the CEikLabel control used to implement the text display williamr@2: */ williamr@2: IMPORT_C CEikLabel* Label(TWhichComponent aWhich=EFirst) const; williamr@2: williamr@2: // from CCoeControl williamr@2: public: williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Construct the object from resource williamr@2: * williamr@2: * @param aReader Fully constructed resource reader williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Handle a pointer event coming from the CONE framework williamr@2: * williamr@2: * @param aPointerEvent Event to handle williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: // From CAknControl williamr@2: private: williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: private: // data williamr@2: TInt iDummy; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * A command button with a single bitmap williamr@2: * williamr@2: * This specialization of CEikCommandButtonBase supports a single bitmap, optionally with a mask. williamr@2: * williamr@2: * @lib eikcoctl.dll williamr@2: * @since S60 1.0 williamr@2: */ williamr@2: class CEikBitmapButton : public CEikCommandButtonBase williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Constructor williamr@2: */ williamr@2: IMPORT_C CEikBitmapButton(); williamr@2: williamr@2: /** williamr@2: * C++ Destructor williamr@2: */ williamr@2: IMPORT_C ~CEikBitmapButton(); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask for the button williamr@2: * williamr@2: * @param aMain The bitmap to use williamr@2: * @param aMask The mask. If null, then no mask will be used williamr@2: * @param aWhich The component for which the picture is to be set. williamr@2: */ williamr@2: IMPORT_C void SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask=NULL,TWhichComponent aWhich=EFirst); williamr@2: williamr@2: /** williamr@2: * Sets the bitmap and optional mask from an mbm file. williamr@2: * williamr@2: * @param aFile Mbm filename williamr@2: * @param aMain Index of the bitmap to use williamr@2: * @param aMask Index of the mask. If -1, then a null mask will be used williamr@2: * @param aWhich The component for which the picture is to be set. williamr@2: */ williamr@2: IMPORT_C void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1,TWhichComponent aWhich=EFirst); williamr@2: williamr@2: /** williamr@2: * Access to the image williamr@2: * williamr@2: * @param aWhich Which picture to access williamr@2: * @return pointer to the image. No ownership is transferred williamr@2: */ williamr@2: IMPORT_C CEikImage* Picture(TWhichComponent aWhich=EFirst) const; williamr@2: williamr@2: // from CCoeControl williamr@2: public: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Construct the object from resource williamr@2: * williamr@2: * @param aReader Fully constructed resource reader williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: * williamr@2: * Handle a pointer event coming from the CONE framework williamr@2: * williamr@2: * @param aPointerEvent Event to handle williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: private: // data williamr@2: TInt iDummy; williamr@2: }; williamr@2: williamr@2: #endif // __EIKCMBUT_H__