Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: eikcmbut.h
Link against: eikcoctl.lib

Class CEikCommandButtonBase

CEikCommandButtonBase

Support

Supported from 6.0

Description

Base class for command buttons. A command button can be used to invoke a command in an application, or to toggle one of its states. It may display a text label, an image, or both.

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
CEikCommandButtonBaseBase class for command buttons
MCoeControlContextInterface to allow sharing of graphics settings between controls

Defined in CEikCommandButtonBase:
ActivateL(), Behavior(), CEikCommandButtonBase(), CheckCreateCommandStack(), ComponentControl(), ConstructImageFromResourceL(), ConstructLabelFromResourceL(), CountComponentControls(), Draw(), EBoth, EFirst, EFirstBottomSecondTop, EFirstLeftSecondRight, EFirstOnly, EFirstRightSecondLeft, EFirstTopSecondBottom, ESecond, ESecondOnly, EShare, EToFirst, EToSecond, FocusChanged(), GetColorUseListL(), HandleResourceChange(), LayoutComponents(), MinimumSize(), OfferKeyEventL(), SetButtonLayout(), SetContainerWindowL(), SetDefault(), SetDimmed(), SetDisplayContent(), SetExcessSpace(), SetPictureFromFileL(), SetPictureL(), SetTextL(), StartConstructFromResourceL(), StateChanged(), TDisplayContent, TExcess, TLayout, TWhichComponent, UpdateComponentAlignment(), iCmdFlags, iComponents[2], ~CEikCommandButtonBase()

Inherited from CBase:
operator new()

Inherited from CCoeControl:
ActivateGc(), BackedUpWindow(), CapturesPointer(), ClaimPointerGrab(), CloseWindow(), ConstructFromResourceL(), 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 MCoeControlContext:
ActivateContext(), PrepareContext(), ResetContext()


Construction and destruction


CEikCommandButtonBase()

protected: CEikCommandButtonBase();

Description

Constructor. Constructs a command button setting default button behaviour and layout.


StartConstructFromResourceL()

void StartConstructFromResourceL(TResourceReader& aReader);

Description

Begins construction of the button, setting default behaviour and layout. This function can be followed by ConstructImageFromResourceL() and ConstructLabelFromResourceL() to set up a button with an image and a label.

Parameters

TResourceReader& aReader

A resource file reader.


~CEikCommandButtonBase()

~CEikCommandButtonBase();

Description

Destructor. Removes all of the button’s components and the command stack.

[Top]


Container window


SetContainerWindowL()

void SetContainerWindowL(const CCoeControl& aContainer);

Description

Sets a command button’s container window.

Parameters

const CCoeControl& aContainer

The compound control that is to be the container for the command button.

[Top]


Layout, display and behaviour


SetButtonLayout()

void SetButtonLayout(TLayout aLayout);

Description

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

Parameters

TLayout aLayout

Relative positions of text and picture.


LayoutComponents()

void LayoutComponents();

Description

Responds to size and position changes to the button’s contents.


SetExcessSpace()

void SetExcessSpace(TExcess aExcess);

Description

Sets how excess horizontal space is shared between the two component controls of the command button.

Parameters

TExcess aExcess

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


UpdateComponentAlignment()

void UpdateComponentAlignment();

Description

Sets the alignment of button components according to layout flags.


Behavior()

protected: TInt Behavior() const;

Description

Gets the behaviour of a button. Button behaviour can be: stay set, stay clear or latching button.

Return value

TInt

The button’s behaviour.


MinimumSize()

TSize MinimumSize();

Description

Gets the minimum amount of space required to display the command button.

Return value

TSize

The minimum size required by the button.


ActivateL()

void ActivateL();

Description

Sets the button as ready to be drawn. An application should call this function on all command buttons that are not components in a compound control.


Draw()

protected: void Draw(const TRect& aRect) const;

Description

Draws the button.

Parameters

const TRect& aRect

Optional. The region of the button to be drawn. Coordinates are relative to the button's top left corner.

[Top]


Button contents and attributes

Description

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


SetTextL()

protected: 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.

CEikAlignedControl*& aComponent

The component for which the text is set.


SetPictureL()

protected: void SetPictureL(const CFbsBitmap* aMain,const CFbsBitmap* aMask,CEikAlignedControl*& aComponent);

Description

Sets the image to be displayed in the button, and an optional bitmask for the image.

Parameters

const CFbsBitmap* aMain

The bitmap to appear on the command button.

const CFbsBitmap* aMask

Specifies the bitmap mask to use with the bitmap aMain. This must be – 1 if you wish to use a null mask.

CEikAlignedControl*& aComponent

The component for which the image is set.

See also:


SetPictureFromFileL()

protected: void SetPictureFromFileL(const TDesC& aFilename,TInt aMain,TInt aMask,CEikAlignedControl*& aComponent);

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

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

CEikAlignedControl*& aComponent

The component for which the image is set.


SetDisplayContent()

void SetDisplayContent(TDisplayContent aContent);

Description

Specify whether component 1, component 2 or both are displayed.

Parameters

TDisplayContent aContent

The required content.


ConstructImageFromResourceL()

void ConstructImageFromResourceL(TResourceReader& aReader,TWhichComponent aWhich);

Description

Constructs an image from resource for the specified button component.

Parameters

TResourceReader& aReader

The resource reader to use.

TWhichComponent aWhich

The component for which the image will be constructed.


ConstructLabelFromResourceL()

void ConstructLabelFromResourceL(TResourceReader& aReader,TWhichComponent aWhich);

Description

Constructs a label from resource for the specified button component.

Parameters

TResourceReader& aReader

The resource reader to use.

TWhichComponent aWhich

The component for which the label will be constructed.


SetDimmed()

void SetDimmed(TBool aDimmed);

Description

Dims or undims the button. This is typically used to show that the action performed by the button is temporarily unavailable.

Parameters

TBool aDimmed

ETrue to dim the button, EFalse to set the button as not dimmed


GetColorUseListL()

void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const;

Description

Gets a list of logical colors used to draw the button, paired with an explanation of how they are used. Appends the list to aColorUseList.

Parameters

CArrayFix<TCoeColorUse>& aColorUseList

List of logical colours with an explanation of how they are used.

[Top]


Command button stacks


CheckCreateCommandStack()

protected: void CheckCreateCommandStack();

Description

Checks whether the command stack exists. If it does not exist one is created.


SetDefault()

void SetDefault(TBool aIsDefault);

Support

Supported from 6.1

Description

Sets the button to be the default.

Parameters

TBool aIsDefault

True to be default, false not to be default.

[Top]


Component controls


CountComponentControls()

TInt CountComponentControls() const;

Description

Gets the number of controls contained in a compound control.

Return value

TInt

The number of component controls contained by this control.


ComponentControl()

CCoeControl* ComponentControl(TInt aIndex) const;

Description

Gets the specified component of a compound control. Each component control is identified by an index, where the index depends on the order the controls were added: the first is given an index of 0, the next an index of 1.

Parameters

TInt aIndex

The index of the control to get.

Return value

CCoeControl*

The component control with an index of aIndex.

[Top]


Responding to events


FocusChanged()

void FocusChanged(TDrawNow aDrawNow);

Description

Responds to a change in focus. Whether the button is redrawn depends on aDrawNow. This function is called whenever a button gains or loses focus.

Parameters

TDrawNow aDrawNow

If EDrawNow the button is redrawn immediately. If ENoDrawNow the button is not redrawn.


HandleResourceChange()

void HandleResourceChange(TInt aType);

Description

Handles a change to the button's resources which are shared across the environment. For example, colors or fonts.

Parameters

TInt aType

A message UID value. The most common is KEikMessageColorSchemeChange which controls get when the colour scheme is changed.


OfferKeyEventL()

TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);

Description

Processes key events.

Parameters

const TKeyEvent& aKeyEvent

The key event.

TEventCode aType

The type of key event.

Return value

TKeyResponse

Indicates whether or not the key event was used by the button.


StateChanged()

protected: void StateChanged();

Description

Notifies the button that its draw state has changed.

[Top]


Enumeration constants


Enum TWhichComponent

TWhichComponent

Description

Identifies the command button’s components.

EFirst

First component.

ESecond

Second component.


Enum TDisplayContent

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.

EFirstOnly

Display only the first component.

ESecondOnly

Display only the second component.

EBoth

Display both components.


Enum TLayout

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.

EFirstRightSecondLeft

Components are positioned horizontally with the first component to the right of the second.

EFirstBottomSecondTop

Components are positioned vertically with the first component below the second.

EFirstTopSecondBottom

Components are positioned vertically with the first component above the second.

EFirstLeftSecondRight

Components are positioned horizontally with the first component to the left of the second.


Enum TExcess

TExcess

Description

Enumerates the possible ways of allocating excess horizontal space between the two component controls of the command button.

EShare

Excess space is shared equally.

EToFirst

Excess space is allocated to the first component only.

EToSecond

All excess space is allocated to the second component only.

[Top]


Protected data


iCmdFlags

TInt iCmdFlags

Description

Button command information such as the layout of the button, and whether the image is the first or second component.


iComponents[2]

CEikAlignedControl* iComponents[2]

Description

An array of two aligned controls.