Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: eikcmbut.h
Link against: eikcoctl.lib

Class CEikCommandButton

CEikCommandButton

Support

Supported from 6.0

Description

Command button.

Command buttons may contain text, an image or both. A command button can be used to invoke a command in an application, or to toggle one of the application's states.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CCoeControlControl base class from which all other controls are derived
CEikBorderedControlA control which is drawn surrounded by a rectangular border
CEikButtonBaseThis is the base class from which concrete button controls (command buttons, option buttons and checkboxes) are derived
CEikCommandButtonCommand button
CEikCommandButtonBaseBase class for command buttons
MCoeControlContextInterface to allow sharing of graphics settings between controls

Defined in CEikCommandButton:
AddCommandToStackL(), CEikCommandButton(), ConstructFromResourceL(), EPictureOnly, EShare, ETextAndPicture, ETextBottomPictureTop, ETextLeftPictureRight, ETextOnly, ETextRightPictureLeft, ETextTopPictureBottom, EToPicture, EToText, Label(), Picture(), PopCommandFromStack(), RemoveCommandFromStack(), SetButtonLayout(), SetCommandL(), SetDisplayContent(), SetExcessSpace(), SetPictureFromFileL(), SetPictureL(), SetTextL(), TDisplayContent, TExcess, TLayout, UpdateComponentAlignment(), ~CEikCommandButton()

Inherited from CBase:
operator new()

Inherited from CCoeControl:
ActivateGc(), BackedUpWindow(), CapturesPointer(), ClaimPointerGrab(), CloseWindow(), ControlContext(), ControlEnv(), CopyControlContextFrom(), CreateBackedUpWindowL(), CreateWindowL(), DeactivateGc(), DrawDeferred(), DrawNow(), DrawableWindow(), EnableDragEvents(), GetColor(), GetHelpContext(), GrabbingComponent(), HandleComponentControlsResourceChange(), HandlePointerBufferReadyL(), HandleRedrawEvent(), IgnoreEventsUntilNextPointerUp(), Index(), IsActivated(), IsBackedUp(), IsBeingDestroyed(), IsBlank(), IsDimmed(), IsFocused(), IsNonFocusing(), IsReadyToDraw(), IsVisible(), MakeVisible(), Observer(), OverrideColorL(), OwnsWindow(), Position(), PositionChanged(), PositionRelativeToScreen(), PrepareForFocusGainL(), PrepareForFocusLossL(), Rect(), RecursivelyMergedInputCapabilities(), ReportEventL(), ResetGc(), SetAllowStrayPointers(), SetBlank(), SetCanDrawOutsideRect(), SetComponentsToInheritVisibility(), SetContainerWindow(), SetControlContext(), SetCornerAndSize(), SetCornerAndSizeL(), SetExtent(), SetExtentL(), SetExtentToWholeScreen(), SetExtentToWholeScreenL(), SetFocus(), SetFocusing(), SetGloballyCapturing(), SetNeighbor(), SetNonFocusing(), SetObserver(), SetPointerCapture(), SetPosition(), SetRect(), SetRectL(), SetSize(), SetSizeL(), SetSizeWithoutNotification(), SetSizeWithoutNotificationL(), Size(), SizeChanged(), SizeChangedL(), SystemGc(), Window()

Inherited from CEikBorderedControl:
Border(), HasBorder(), SetAdjacent(), SetBorder(), iBorder

Inherited from CEikButtonBase:
Animate(), CopyDrawStateTo(), DrawState(), EClear, EDrawClear, EDrawClearPressed, EDrawIndeterminate, EDrawIndeterminatePressed, EDrawSet, EDrawSetPressed, EEikButtonLatches, EEikButtonReportsOnPointerDown, EEikButtonStaysClear, EEikButtonStaysSet, EIndeterminate, ESet, HandlePointerEventL(), InputCapabilities(), IsPressed(), SetAllowTristate(), SetBehavior(), SetBubbleHelpTextL(), SetCoordinator(), SetIgnoreNextPointerUp(), SetReportOnPointerDown(), SetState(), State(), TButtonBehavior, TDrawState, TState, iButFlags

Inherited from CEikCommandButtonBase:
ActivateL(), Behavior(), CheckCreateCommandStack(), ComponentControl(), ConstructImageFromResourceL(), ConstructLabelFromResourceL(), CountComponentControls(), Draw(), EBoth, EFirst, EFirstBottomSecondTop, EFirstLeftSecondRight, EFirstOnly, EFirstRightSecondLeft, EFirstTopSecondBottom, ESecond, ESecondOnly, EToFirst, EToSecond, FocusChanged(), GetColorUseListL(), HandleResourceChange(), LayoutComponents(), MinimumSize(), OfferKeyEventL(), SetContainerWindowL(), SetDefault(), SetDimmed(), StartConstructFromResourceL(), StateChanged(), TWhichComponent, iCmdFlags, iComponents[2]

Inherited from MCoeControlContext:
ActivateContext(), PrepareContext(), ResetContext()


Construction and destruction


CEikCommandButton()

CEikCommandButton();

Description

Constructor.

Creates a CEikCommandButton. See also ConstructFromResourceL().


ConstructFromResourceL()

void ConstructFromResourceL(TResourceReader& aReader);

Description

Second-phase construction from a resource. Completes the construction of a command button from a CMBUT resource.

Parameters

TResourceReader& aResourceReader

A resource file reader set to read a CMBUT resource.


~CEikCommandButton()

~CEikCommandButton();

Description

Destructor.

[Top]


Layout and display content


SetButtonLayout()

void SetButtonLayout(TLayout aLayout);

Description

Sets the relative positions of the text and image on a command button.

Parameters

TLayout aLayout

Relative positions of text and picture.


UpdateComponentAlignment()

void UpdateComponentAlignment();

Description

Updates the alignment of the button's text and image components.


SetExcessSpace()

void SetExcessSpace(TExcess aExcess);

Description

Sets how excess horizontal space is shared between the command button's text and image.

Parameters

TExcess aExcess

Determines whether excess horizontal space is shared equally, allocated to the text only or allocated to the image only.

[Top]


Setting and getting button image and label

Description

The label text and the button image can alternatively be set during construction using a CMBUT resource.


SetTextL()

void SetTextL(const TDesC& aText,CEikAlignedControl*& aComponent);

Description

Sets the text that will appear on the command button.

Parameters

const TDesC& aText

The text to appear on the command button.


SetPictureL()

void SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask=NULL);

Description

Sets the bitmap image to be displayed in the button, and optionally a bitmap mask for the image.

Parameters

const CFbsBitmap* aMain

The bitmap to appear on the command button.

const CFbsBitmap* aMask=NULL

Specifies the bitmap mask to use with the bitmap aMain; default is none.

See also:


SetPictureFromFileL()

void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask=-1);

Description

Set the command button's image to a bitmap stored in a file.

A bitmap mask may optionally be set using aMask. If the image cannot be read from the file, the button is not updated.

Parameters

const TDesC& aFilename

The filename from which to read the bitmap.

TInt aMain

The index of the bitmap in the file.

TInt aMask=-1

The index of the bitmap mask in the file. If specified, this is used to create the bitmap mask for the image.


Label()

CEikLabel* Label() const;

Description

Gets the button's text label.

Return value

CEikLabel*

The command button's text label.


Picture()

CEikImage* Picture() const;

Description

Gets the button's image.

Return value

CEikImage*

The command button's image.

[Top]


Command stack


AddCommandToStackL()

void AddCommandToStackL(TInt aCommandId,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask);

Support

Supported from 6.1

Description

Adds the command button's command ID and text/bitmap to the top of the command stack.

These values can subsequently be restored from the command stack by a call to PopCommandFromStack().

Each command button can store a stack of IDs and text/bitmaps on a command stack. This allows an application to use different command buttons depending on which of its views is currently visible.

Parameters

TInt aCommandId

The button's command ID.

const TDesC* aText

The text in the command button.

const CFbsBitmap* aBitmap

The command button's bitmap.

const CFbsBitmap* aMask

The command button's bitmap mask.


PopCommandFromStack()

TInt PopCommandFromStack();

Support

Supported from 6.1

Description

Pops the uppermost command button from the command stack.

This restores the current command button's command ID, text and bitmap to the values they had before the last call to AddCommandToStackL().

Return value

TInt

The command button's new command ID.


RemoveCommandFromStack()

TBool RemoveCommandFromStack(TInt aCommandId);

Support

Supported from 6.1

Description

Removes the command button with the command ID specified from the command stack.

Parameters

TInt aCommandId

The command ID of the button to remove.

Return value

TBool

ETrue if a command with the command ID specified was found and removed, EFalse if not.


SetCommandL()

void SetCommandL(TInt /*aCommandId*/,const TDesC* aText,const CFbsBitmap* aBitmap,const CFbsBitmap* aMask);

Support

Supported from 6.1

Description

Sets the command button's text, bitmap and bitmap mask.

Parameters

TInt /*aCommandId*/

Not used.

const TDesC* aText

The text in the command button.

const CFbsBitmap* aBitmap

The command button's bitmap.

const CFbsBitmap* aMask

The command button's bitmap mask.

[Top]


Other member functions


SetDisplayContent()

void SetDisplayContent(TDisplayContent aContent);

Description

Specifies whether text, image or both are to be displayed.

Parameters

TDisplayContent aContent

The required content.

[Top]


Public member enumerations


Enum TLayout

enum TLayout

Description

Specifies the positions of text and image on the command button. This enum shadows the values defined in CEikCommandButtonBase::TLayout to provide more intuitive names for a command button.

ETextRightPictureLeft

Text and image are positioned horizontally with the text to the right of the image.

ETextBottomPictureTop

Text and image are positioned vertically with the text below the image.

ETextTopPictureBottom

Text and image are positioned vertically with the text above the image.

ETextLeftPictureRight

Text and image are positioned horizontally with the text to the left of the image.


Enum TDisplayContent

enum TDisplayContent;

Description

Specifies whether text, image or both are to be displayed. This enum shadows the values defined in CEikCommandButtonBase::TDisplayContent to provide more intuitive names for a command button.

ETextOnly

Display text only.

EPictureOnly

Display image only.

ETextAndPicture

Display text and image.


Enum TExcess

enum TExcess;

Description

Enumerates the possible ways of sharing excess horizontal space between the command button's text and image. See also: SetExcessSpace(TExcess).

EShare

Excess space is shared equally.

EToText

Excess space is allocated to the text only.

EToPicture

All excess space is allocated to the picture.