Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: coecntrl.h
Link against: cone.lib

Class CCoeControl

CCoeControl

Support

Supported from 5.0

Description

Control base class from which all other controls are derived.

Note:

Derivation

CBaseBase class for all classes to be instantiated on the heap
CCoeControlControl base class from which all other controls are derived

Defined in CCoeControl:
ActivateGc(), ActivateL(), BackedUpWindow(), CCoeControl(), CapturesPointer(), ClaimPointerGrab(), CloseWindow(), ComponentControl(), ConstructFromResourceL(), ControlContext(), ControlEnv(), CopyControlContextFrom(), CountComponentControls(), CreateBackedUpWindowL(), CreateWindowL(), DeactivateGc(), Draw(), DrawDeferred(), DrawNow(), DrawableWindow(), EnableDragEvents(), FocusChanged(), GetColor(), GetColorUseListL(), GetHelpContext(), GrabbingComponent(), HandleComponentControlsResourceChange(), HandlePointerBufferReadyL(), HandlePointerEventL(), HandleRedrawEvent(), HandleResourceChange(), HasBorder(), IgnoreEventsUntilNextPointerUp(), Index(), InputCapabilities(), IsActivated(), IsBackedUp(), IsBeingDestroyed(), IsBlank(), IsDimmed(), IsFocused(), IsNonFocusing(), IsReadyToDraw(), IsVisible(), MakeVisible(), MinimumSize(), Observer(), OfferKeyEventL(), OverrideColorL(), OwnsWindow(), Position(), PositionChanged(), PositionRelativeToScreen(), PrepareForFocusGainL(), PrepareForFocusLossL(), Rect(), RecursivelyMergedInputCapabilities(), ReportEventL(), ResetGc(), SetAdjacent(), SetAllowStrayPointers(), SetBlank(), SetCanDrawOutsideRect(), SetComponentsToInheritVisibility(), SetContainerWindow(), SetContainerWindowL(), SetControlContext(), SetCornerAndSize(), SetCornerAndSizeL(), SetDimmed(), SetExtent(), SetExtentL(), SetExtentToWholeScreen(), SetExtentToWholeScreenL(), SetFocus(), SetFocusing(), SetGloballyCapturing(), SetNeighbor(), SetNonFocusing(), SetObserver(), SetPointerCapture(), SetPosition(), SetRect(), SetRectL(), SetSize(), SetSizeL(), SetSizeWithoutNotification(), SetSizeWithoutNotificationL(), Size(), SizeChanged(), SizeChangedL(), SystemGc(), Window(), ~CCoeControl()

Inherited from CBase:
operator new()


Construction and destruction


CCoeControl()

CCoeControl();

Description

Default C++ constructor.

This function performs initialisation of the CCoeControl base class.

Note:


ConstructFromResourceL()

virtual void ConstructFromResourceL(TResourceReader& aReader);

Description

Constructs controls from a resource file.

This function has an empty default implementation. It should be implemented if the control is to be displayed within a dialog. It should initialise the control, reading in resource values from the resource file using aReader.

Note:

Parameters

TResourceReader& aReader

The resource reader with which to access the control's resource values.


IsBeingDestroyed()

TBool IsBeingDestroyed() const;

Support

Supported from 6.0

Description

Tests if the control is being destroyed.

Return value

TBool

ETrue if the control is being destroyed, otherwise EFalse.


~CCoeControl()

~CCoeControl();

Description

Destructor.

It destroys the window owned by the control, if it is a window-owning control.

From version 6.1, the destructor in debug builds checks if the control exists in the control stack and gives a CONE 44 panic if it is still there. An application must remove every control that it adds to the stack.

[Top]


Creating compound controls

Description

A compound control is one which contains one or more simple or compound controls. Compound controls are also known as container controls, and may be window-owning or non-window-owning.


CountComponentControls()

virtual TInt CountComponentControls() const;

Description

Gets the number of controls contained in a compound control.

This function should be implemented by all compound controls.

Note:

In 6.1 this was changed from protected to public.

Return value

TInt

The number of component controls contained by this control.


ComponentControl()

protected: virtual CCoeControl* ComponentControl(TInt aIndex) const;

Description

Gets the specified component of a compound control.

This function should be implemented by all compound controls.

Note:

Parameters

TInt aIndex

The index of the control to get.

Return value

CCoeControl*

The component control with an index of aIndex.


SetContainerWindow()

void SetContainerWindow(RWindow& aWindow);

Support

Withdrawn in 5.1

Description

Sets a component control's container window — if the container is a window-owning control.

This function sets the control's associated window to be the same as the container's associated window.

The function can only be called on non-window-owning controls.

Note:

Parameters

RWindow& aWindow

The window owned by the container control.

Panic codes

 

If called on a window-owning control.


SetContainerWindowL()

void SetContainerWindowL(RWindow& aWindow);

Support

Supported from 5.1

Description

Sets a component control's container window — if the container is a window-owning control.

This function sets the control's associated window to be the same as the container's associated window. The function can only be called on non-window-owning controls.

Note:

Parameters

RWindow& aWindow

The window owned by the container control.

Panic codes

 

If called on a window-owning control.


SetContainerWindow()

void SetContainerWindow(RBackedUpWindow& aWindow);

Support

Withdrawn in 5.1

Description

Sets a component control's container window — if the container is a backed up window owning control.

This function sets the control's associated window to be the same as the container's associated window.

The function can only be called on non-window-owning controls.

Note:

Parameters

RBackedUpWindow& aWindow

The backed up window owned by the control.

Panic codes

 

If called on a window-owning control.


SetContainerWindowL()

SetContainerWindowL(RBackedUpWindow& aWindow);

Description

Sets a component control's container window — if the container is a backed up window owning control.

Sets a component control's container as a. This function sets the control's associated window to be the same as the container's associated window.

The function can only be called on non-window-owning controls.

Note:

Parameters

RBackedUpWindow& aWindow

The backed up window owned by the control.

Panic codes

 

If called on a window-owning control.


SetContainerWindowL()

virtual void SetContainerWindowL(const CCoeControl& aContainer);

Description

Sets a component control's container — leaving.

It does this by setting the control's associated window to be the same as the container's associated window.

This function can only be called on non-window-owning controls.

Note:

Parameters

const CCoeControl& aContainer

The compound control that is to be the container for this control.

Panic codes

 

If called on a window-owning control.


Index()

TInt Index(const CCoeControl* aControl) const;

Description

Gets the index of a control that is a component of this control.

Parameters

const CCoeControl* aControl

The component control.

Return value

TInt

The index of the component control within the compound control. If aControl is not a component of this control, it returns KErrNotFound.


SetAdjacent()

virtual void SetAdjacent(TInt aAdjacent);

Description

Sets control's appearance when next to other controls.

Its intended use is to remove the double border that may occur if two controls, both with borders, are adjacent within a container control.

This function has an empty default implementation, and is not used within the UI control framework. However, it may be implemented and used by derived control classes: for example it is implemented and used by the standard GUI.

Parameters

TInt aAdjacent

Typically a value defined in TGulAdjacent.


SetNeighbor()

virtual void SetNeighbor(CCoeControl* aNeighbor);

Description

Sets associated control.

This can be used to establish co-ordinated groups of controls (e.g. in dialogs) without specific application co-operation.

This function has an empty default implementation, and is not used within the UI control framework. However, it may be implemented and used by derived control classes: for example it is implemented and used by the standard GUI.

Parameters

CCoeControl* aNeighbor

A control to be used by this function.


HasBorder()

virtual TBool HasBorder() const;

Description

Tests if a control has a border.

When component controls are arranged in a container, the container control may need to know whether or not the component have borders, as this may affect the way the components are laid out within the container.

The default implementation of this function always returns EFalse, but can be overridden to provide the required functionality. The GUI implements and uses this function in several of its concrete controls.

Return value

TBool

ETrue if the control has a border, EFalse if the control does not have a border. The default implementation of this function always returns EFalse.

[Top]


Creating window owning controls


CreateWindowL()

protected: void CreateWindowL();

Description

Creates a control's window. The created window is the child of the application's window group.

This function makes the specified control a window-owning control, and would typically be called in the control's ConstructL() function.

Note:


CreateWindowL()

protected: void CreateWindowL(const CCoeControl* aParent);

Description

Creates a control's window — specifying the parent control.

The control's window is created as a child of the parent control's window.

This function makes the specified control a window-owning control, and would typically be called in the control's ConstructL() function.

Note:

Parameters

const CCoeControl* aParent

The control to be the parent of this control.


CreateWindowL()

protected: void CreateWindowL(RWindowTreeNode& aParent);

Description

Creates a control's window — specifying its parent window.

This function makes the specified control a window-owning control, and would typically be called in the control's ConstructL() function.

Note:

Parameters

RWindowTreeNode& aParent

The window of the control to be the parent of this control.


CreateWindowL()

protected: void CreateWindowL(RWindowGroup* aParent);

Description

Creates a control's window — specifying its parent window group.

This function makes the specified control a window-owning control, and would typically be called in the control's ConstructL() function.

Note:

Parameters

RWindowGroup* aParent

The window group of the control to be the parent of this control


OwnsWindow()

TBool OwnsWindow() const;

Description

Tests if the control is window-owning.

Return value

TBool

ETrue if the control is window-owning. EFalse if the control is non-window-owning.


Window()

protected: RWindow& Window() const;

Description

Get control's associated window.

The control must be window owning, and the window must be of type RWindow. If you don't know whether the window is of type RWindow or RBackedUpWindow, you should use DrawableWindow().

Return value

RWindow&

The control's associated window, cast to an RWindow.


DrawableWindow()

RDrawableWindow* DrawableWindow() const;

Description

Get control's associated drawable window. The control must be a window-owning control.

This function should be called if it is not known whether the window is of type RWindow or RBackedUpWindow. RDrawableWindow is an abstract base class from which RWindow and RBackedUpWindow are derived.

Return value

RDrawableWindow*

The control's associated window.

See also:


CreateBackedUpWindowL()

protected: void CreateBackedUpWindowL(RWindowTreeNode& aParent);

Description

Create a control's window as a backed-up window.

The new window is the child of aParent and the display mode of the control becomes the same as that of aParent.

Parameters

RWindowTreeNode& aParent

The window to be the parent of this control's window. Does not have to be a backed-up window.


CreateBackedUpWindowL()

protected: void CreateBackedUpWindowL(RWindowTreeNode& aParent,TDisplayMode aDisplayMode);

Description

Create a control's window as a backed-up window, specifying the display mode.

The new window is the child of aParent and the display mode of the control is set to aDisplayMode.

Parameters

RWindowTreeNode& aParent

The window of the control to be the parent of this control. Does not have to be a backed-up window.

TDisplayMode aDisplayMode

The display mode of the backed-up window.


IsBackedUp()

TBool IsBackedUp() const;

Description

Tests if the window owned by the control is a backed-up window.

Return value

TBool

ETrue if the window owned by this control is a backed-up window. EFalse if the window is not a backed-up window.


BackedUpWindow()

protected: RBackedUpWindow& BackedUpWindow() const;

Description

Gets the backed-up window owned by control.

The window must be of type RBackedUpWindow. If you don't know whether the window is of type RWindow or RBackedUpWindow, you should use DrawableWindow().

Return value

RBackedUpWindow&

The control's associated window, cast to an RBackedUpWindow.


SetBlank()

protected: void SetBlank();

Description

Sets a flag to indicate the control is blank.

Once set, this flag cannot be unset for the lifetime of the control.

See also:


IsBlank()

protected: TBool IsBlank() const;

Description

Tests if the control is a blank.

This simply gets the value of the flag set by SetBlank().

Return value

TBool

ETrue if SetBlank() has been called on the control. EFalse if SetBank() has not been called on the control.


CloseWindow()

protected: void CloseWindow();

Description

Closes window owned by this control.

It is called from CCoeControl's destructor for window-owning controls.

[Top]


Setting and querying size, position and extent

Description

A control's origin is its top-left corner. The position of a control is specified relative to the origin of its associated window.


SetExtentL()

void SetExtentL(const TPoint& aPosition,const TSize& aSize);

Support

Withdrawn in 5.1

Description

Sets the control's extent — specifying size and position.

Note:

Parameters

const TPoint& aPosition

The position of the control, relative to its associated window.

const TSize& aSize

The size of the control, in pixels.


SetExtent()

void SetExtent(const TPoint& aPosition,const TSize& aSize);

Support

Supported from 5.1

Description

Sets the control's extent — specifying size and position.

Note:

Parameters

const TPoint& aPosition

The position of the control, relative to its associated window.

const TSize& aSize

The size of the control, in pixels.


SetRectL()

void SetRectL(const TRect& aRect);

Support

Withdrawn in 5.1

Description

Sets the control's extent — specifying a TRect.

Note:

Parameters

const TRect& aRect

The rectangle that defines the control's extent. The rectangle's origin is relative to the origin of its associated window.


SetRect()

void SetRect(const TRect& aRect);

Support

Supported from 5.1

Description

Sets the control's extent — specifying a TRect.

Note:

Parameters

const TRect& aRect

The rectangle that defines the control's extent. The rectangle's origin is relative to the origin of its associated window.


Rect()

TRect Rect() const;

Description

Gets the control's extent.

Return value

TRect

The control's extent.


SetSizeL()

void SetSizeL(const TSize& aSize);

Support

Withdrawn in 5.1

Description

Sets the control's size.

If the size, but not the position, of a control is set, then its position will default to TPoint(0,0).

Note:

Parameters

const TSize& aSize

The control's size, in pixels.


SetSize()

void SetSize(const TSize& aSize);

Support

Supported from 5.1

Description

Sets the control's size.

If the size, but not the position, of a control is set, then its position will default to TPoint(0,0).

Note:

Parameters

const TSize& aSize

The control's size, in pixels.


SetSizeWithoutNotificationL()

protected: void SetSizeWithoutNotificationL(const TSize& aSize);

Support

Withdrawn in 5.1

Description

Sets a control's size without calling SizeChangedL().

If the size, but not the position, of a control is set, then its position will default to TPoint(0,0).

Note:

Parameters

const TSize& aSize

The control's size, in pixels.

See also:


SetSizeWithoutNotification()

protected: void SetSizeWithoutNotification(const TSize& aSize);

Support

Supported from 5.1

Description

Sets a control's size without calling SizeChanged().

If the size, but not the position, of a control is set, then its position will default to TPoint(0,0).

Note:

Parameters

const TSize& aSize

The control's size, in pixels.

See also:


Size()

TSize Size() const;

Description

Gets the control's size.

Return value

TSize

The control's size, in pixels.


SetPosition()

void SetPosition(const TPoint& aPosition);

Description

Sets the control's position.

Parameters

const TPoint& aPosition

The position of the control, relative to its associated window.


Position()

TPoint Position() const;

Description

Gets the control's position.

Return value

TPoint

The position of the control, relative to its associated window.


PositionRelativeToScreen()

TPoint PositionRelativeToScreen() const;

Description

Gets the control's position relative to screen origin.

The screen origin is its top-left corner.

Return value

TPoint

The position of the control, measured in pixels, relative to the screen origin.


SetExtentToWholeScreenL()

void SetExtentToWholeScreenL();

Support

Withdrawn in 5.1

Description

Sets the control's extent to the whole screen.

Note:


SetExtentToWholeScreen()

void SetExtentToWholeScreen();

Support

Supported from 5.1

Description

Sets the control's extent to the whole screen.

Note:


SetCornerAndSizeL()

protected: void SetCornerAndSizeL(TCoeAlignment aCorner,const TSize& aSize);

Support

Withdrawn in 5.1

Description

Sets the control's position by setting its screen alignment and size.

The control's position is calculated, relative to the screen, according to the requested alignment.

Note:

Parameters

TCoeAlignment aCorner

The alignment of the control.

const TSize& aSize

The control's size.


SetCornerAndSize()

protected: void SetCornerAndSize(TCoeAlignment aCorner,const TSize& aSize);

Support

Supported from 5.1

Description

Sets the control's position by setting its screen alignment and size.

The control's position is calculated, relative to the screen, according to the requested alignment.

Note:

Parameters

TCoeAlignment aCorner

The alignment of the control.

const TSize& aSize

The control's size.


MinimumSize()

virtual TSize MinimumSize();

Description

Sets the control's minimum required size.

This function should be overridden by the concrete control class if the control is to be displayed inside a dialog. Standard GUI dialogs set the size and position of their components automatically, and use this function to inquire the minimum size that a control requires.

Other container controls that automatically calculate the layout of their components may also use this function.

Return value

TSize

The minimum size required by the control.


SizeChangedL()

protected: virtual void SizeChangedL();

Support

Withdrawn in 5.1

Description

Responds to size changes to sets the size and position of the contents of this control.

For a simple control this might include text or graphics. For a compound control this sets the size and position of the component. It has an empty default implementation and should be implemented by the CCoeControl-derived class.

The function is called whenever SetExtentL(), SetSizeL(), SetRectL(), SetCornerAndSizeL(), or SetExtentToWholeScreenL() are called on the control. Note that the window server does not generate size-changed events: SizeChangedL() gets called only as a result of calling the functions listed above. Therefore, if a resize of one control affects the size of other controls, it is up to the application to ensure that it handles the re-sizing of all affected controls.

Note:


SizeChanged()

protected: virtual void SizeChanged();

Support

Supported from 5.1

Description

Responds to size changes to sets the size and position of the contents of this control.

For a simple control this might include text or graphics. For a compound control this sets the size and position of the component. It has an empty default implementation and should be implemented by the CCoeControl-derived class.

The function is called whenever SetExtent(), SetSize(), SetRect(), SetCornerAndSize(), or SetExtentToWholeScreen() are called on the control. Note that the window server does not generate size-changed events: SizeChanged() gets called only as a result of calling the functions listed above. Therefore, if a resize of one control affects the size of other controls, it is up to the application to ensure that it handles the re-sizing of all affected controls.

Note:


PositionChanged()

protected: virtual void PositionChanged();

Description

Responds to changes in the position of a control.

It has an empty default implementation which may be overridden by the CCoeControl-derived class.

This function is called by whenever the application calls SetPosition() on the control.

[Top]


Activating a control


ActivateL()

virtual void ActivateL();

Description

Sets control as ready to be drawn.

The application should call this function on all controls that are not components in a compound control.

The purpose of this function is that controls are not always ready to draw as soon as they have been constructed. For example, it may not be possible to set the control's extent during construction, but its extent should always be set before it is drawn. Similarly, if a control is to be made invisible, this should be done before it is activated.

The default implementation sets a flag in the control to indicate it is ready to be drawn. If the control is a compound control, the default implementation also calls ActivateL() for all the control's components. To get the control's components it uses CountComponentControls() and ComponentControl(), which should be implemented by the compound control.

ActivateL() is typically called from the control's ConstructL() function .

Notes:


IsActivated()

protected: TBool IsActivated() const;

Description

Tests if the control has been activated.

A control is not ready to draw until it is activated.

Return value

TBool

ETrue if the control is activated, EFalse if it is not activated.


IsReadyToDraw()

protected: TBool IsReadyToDraw() const;

Description

Tests if the control is ready for drawing.

This returns true if the control has been activated and is visible.

Return value

TBool

ETrue if the control is ready for drawing, EFalse if it is not ready for drawing.

[Top]


Drawing


Draw()

private: virtual void Draw(const TRect& aRect) const;

Description

Draw a control — called by window server.

All controls, except blank controls, should implement this function. The default implementation draws a blank control.

This function is used for window server-initiated redrawing of controls, and for some application-initiated drawing. It should be implemented by each control, but is only called from within CCoeControl's member functions, and not from the derived class. For this reason it is a private member function of CCoeControl.

The rectangle aRect indicates the region of the control that needs to be redrawn. The implementation of Draw()must always draw to every pixel within this rectangle.

Notes:

Parameters

const TRect& aRect

The region of the control to be redrawn. Co-ordinates are relative to the control's origin (top left corner).


DrawNow()

void DrawNow() const;

Description

Draws a control — called by an application or other code.

The application should call this function when the control is first created and is ready for drawing, or if a change in application data or the control's internal state means that entire control's appearance is no longer up-to-date.

Partial redrawing of a control is sometimes more appropriate than drawing the entire control, and in this case DrawNow() should not be used.

DrawNow() is implemented by CCoeControl and MAY NOT be overridden. It calls Draw() on the control itself, and also on all its component controls, if it is a compound control. (To do this it uses CountComponentControls() and ComponentControl(), which should be implemented by the derived control class.) If the control is a window-owning control, it also calls Draw() for its child windows (if any).


DrawDeferred()

void DrawDeferred() const;

Description

Draws the control with low priority — called by application

This function causes the control area to be marked as invalid, which will eventually cause a redraw initiated by the window server. The control framework handles redraw events at a lower priority than user input events, which means that any pending user input events will be processed before the redraw event. DrawDeferred() therefore allows a control to do drawing at a lower priority than drawing performed by DrawNow().

An advantage of using DrawDeferred() is that if you make multiple calls to DrawDeferred() on the same area of a control, the window server will not generate a redraw event to do drawing that has already been superseded. If you make multiple calls to DrawNow(), however, all of them get processed, even if they have already been superseded by the time they are processed.


SetCanDrawOutsideRect()

protected: void SetCanDrawOutsideRect();

Description

Allows the control to draw outside its own extent.

When a compound control is drawn, all its component controls are also drawn. However, unless this flag is set, they are not drawn if the rectangle they inhabit on the screen doesn't intersect with the rectangle to be drawn.

Setting this flag has the effect of allowing a component control to draw outside its own extent. It should be used with caution! By default, this flag is not set.


GetColor()

TBool GetColor(TInt aLogicalColor,TRgb& aColor) const;

Description

Gets the over-ridden physical colour.

This is the colour which has been mapped to the logical colour specified by a call to OverrideColorL(). If the logical colour specified has not been overridden, the aColor value is not changed.

Parameters

TInt aLogicalColor

The logical colour for which the corresponding physical colour will be retrieved. The set of logical colours for a standard GUI application are defined in the TLogicalColor.

TRgb& aColor

On return, contains the physical colour which has been mapped to aLogicalColour by a call to OverrideColorL().

Return value

TBool

ETrue if aLogicalColour has been overridden, EFalse otherwise.


OverrideColorL()

void OverrideColorL(TInt aLogicalColor,TRgb aColor);

Description

Overrides the control's colour setting, as specified in the application's colour scheme.

This function does not change the application's colour scheme — it changes the colour mapping used in this control only.

Parameters

TInt aLogicalColor

The logical colour. Indicates which part of a control the physical colour maps to. The set of logical colours for a standard application are defined in TLogicalColor.

TRgb aColor

The new physical colour to which the logical colour should be mapped.

Leave codes

 

This function can only leave with KErrNoMemory.

See also:


GetColorUseListL()

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

Support

Supported from 5.1

Description

Gets the list of logical colours used to draw the control.

The list includes an explanation of how each colour is used. By default, this function has an empty implementation.

Parameters

CArrayFix<TCoeColorUse>& aColorUseList

The colour list.

[Top]


Graphics contexts


SystemGc()

protected: CWindowGc& SystemGc() const;

Description

Gets the standard graphics context for use when drawing controls.

All graphics functions are carried out through a graphics context.

Note:

Return value

CWindowGc&

The system graphics context.


ActivateGc()

protected: void ActivateGc() const;

Description

Activates the standard graphics context.

This is the graphics context owned by the control environment (CCoeEnv).

Applications should not normally need to call this function, as it is called within the control framework whenever it is about to call Draw().


ResetGc()

protected: void ResetGc() const;

Description

Resets the standard graphics context.

The function resets the graphics context owned by the control environment to its default settings.


DeactivateGc()

protected: void DeactivateGc() const;

Description

Deactivates the standard graphics context owned by the UI control framework.

Applications should not normally need to call this function, as it is called within control framework whenever it has called Draw() and drawing is completed.

[Top]


Control contexts

Description

Control contexts allow a group of controls to share a common set of graphics context settings, and hence a common appearance.


SetControlContext()

void SetControlContext(MCoeControlContext* aContext);

Description

Set the control context for this control.

Parameters

MCoeControlContext* aContext

The context for this control.


CopyControlContextFrom()

void CopyControlContextFrom(const CCoeControl* aControl);

Description

Sets the control's context from another control.

Parameters

const CCoeControl* aControl

The control whose context to copy.

[Top]


Making controls invisible


MakeVisible()

virtual void MakeVisible(TBool aVisible);

Description

Sets this control as visible or invisible.

This causes the control to disappear or reappear. When a control is created, it is made visible by default.

MakeVisible() can be called before of after the control is activated.

Note:

Parameters

TBool aVisible

ETrue to make the control visible, EFalse to make it invisible.


IsVisible()

TBool IsVisible() const;

Description

Tests if the control is visible.

Unless MakeVisible() has been called with argument EFalse, the control is visible.

Return value

TBool

ETrue if the control is visible, EFalse if it is invisible.


SetComponentsToInheritVisibility()

void SetComponentsToInheritVisibility(TBool aInherit=ETrue);

Description

Sets components to inherit visibility setting from their container control.

If set, when MakeVisible() is called on the compound control, the value for visibility is propagated to all its components.

Parameters

TBool aInherit=ETrue

ETrue to set that the control's components inherit its visibility setting, EFalse to set that they do not inherit its visibility setting.

[Top]


Making controls dimmed


SetDimmed()

virtual void SetDimmed(TBool aDimmed);

Description

Sets control dimmed.

This function sets a flag within the control which indicates whether or not the control is dimmed (greyed out). This is typically used to show that the action performed by the control is temporarily unavailable.

SetDimmed() does not initiate a redraw of the control. The application should call DrawNow() or DrawDeferred() if a redraw is required after calling SetDimmed(). The control's Draw() function should draw the control appropriately according to whether it is dimmed or not. (This can be inquired using IsDimmed().)

Parameters

TBool aDimmed

ETrue to dim the control, EFalse to set the control as not dimmed.


IsDimmed()

TBool IsDimmed() const;

Description

Tests if control is dimmed.

This function returns the value of a flag within the control which is set and unset using SetDimmed().

Return value

TBool

ETrue if the control is dimmed, EFalse if it is not dimmed.

[Top]


Keyboard focus


SetFocus()

void SetFocus(TBool aFocus,TDrawNow aDrawNow=ENoDrawNow);

Description

Sets that the control has keyboard focus.

The function sets the value of a focus flag within the control to the value given by aFocus. This flag indicates whether or not the control has keyboard focus, and its value can be inquired using IsFocused(). It then calls FocusChanged(), passing it the value given by aDrawNow, unless the control is invisible or not activated, in which case it passes ENoDrawNow.

Note that setting focus does not initiate a redraw. The control's implementation of FocusChanged() should do this if required. The control's Draw() function, or that of its container, should normally change the appearance of the control to indicate whether or not it currently has focus.

Parameters

TBool aFocus

ETrue sets the control as having keyboard focus, EFalse sets it as not having keyboard focus.

TDrawNow aDrawNow=ENoDrawNow

Flag to pass to FocusChanged().


PrepareForFocusLossL()

virtual void PrepareForFocusLossL();

Description

Prepare for focus loss.

A control which is displayed within a dialog should implement this function if it wishes to validate data entered into the control.

This function is called by the dialog framework immediately before it removes keyboard focus from a control within a dialog. It is intended to be used for validating the state of the control: for example, if the control allows the user to enter a date, PrepareForFocusLossL() would normally check to make sure the user did not enter an invalid date such as February 31st. If an invalid state is detected, PrepareForFocusLossL() should leave and issue a message to the user if appropriate. If it does leave, the framework does not perform the action that would have resulted in the control losing focus, and focus remains with the control to allow valid data to be entered.

In standard GUI dialogs, two actions result in a control losing focus: one is when the user presses the OK button or the Enter key, to close the dialog and enter the information, and the second is when the user presses the up or down arrow keys to change the keyboard focus within the dialog. All these actions result in PrepareForFocusLossL() being called on the control that currently has keyboard focus.

The default implementation of this function is empty, and it is not called from within the UI control framework. The function exists only to provide an interface to the control, for the GUI and any other UI library.


PrepareForFocusGainL()

virtual void PrepareForFocusGainL();

Support

Supported from 6.0

Description

Prepares the control for gaining focus.

Implementations may by taking any action required, such as updating control information. By default, the implementation is empty.


FocusChanged()

protected: virtual void FocusChanged(TDrawNow aDrawNow);

Description

Responds to focus changed.

This function is called whenever a control gains or loses focus — as a result of a call to SetFocus(). A typical use of FocusChanged() is to change the appearance of the control to indicate whether or not it has focus, for example by drawing a focus rectangle around it.

The default implementation is empty, and should be overridden by the CCoeControl-derived class.

Parameters

TDrawNow aDrawNow

Contains the value that was passed to it by SetFocus().


IsFocused()

TBool IsFocused() const;

Description

Tests if the control has focus.

Focus is set and unset using SetFocus().

Return value

TBool

ETrue if the control has focus, EFalse if it doesn't.


SetNonFocusing()

void SetNonFocusing();

Description

Deprecated. Use SetFocusing().

Sets the control as unable to receive keyboard focus. The function would typically be called during construction of the control.


SetFocusing()

void SetFocusing(TBool aFocusing);

Description

Sets the control as able to receive keyboard focus.

The function would typically be called after construction of the control.

Parameters

TBool aFocusing

ETrue if the control can have focus, EFalse if it cant.


IsNonFocusing()

TBool IsNonFocusing() const;

Description

Tests if the control can receive focus.

Return value

TBool

ETrue if the control cannot receive focus, EFalse if it can.

See also:

[Top]


Handling key and pointer events

Description

The functions grouped below handle key and pointer events and sending events to another control.


OfferKeyEventL()

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

Description

Handles key events.

If a control wishes to process key events, it should implement this function. The implementation must ensure that the function returns EKeyWasNotConsumed if it does not do anything in response to a key event — otherwise, other controls or dialogs may be prevented from receiving the key event. If it is able to process the event it should return EKeyWasConsumed.

When a key event occurs, the control framework calls this function for each control on the control stack, until one of them can process the key event (and returns EKeyWasConsumed).

Parameters

const TKeyEvent& aKeyEvent

The key event.

TEventCode aType

The type of key event: EEventKey, EEventKeyUp or EEventKeyDown.

Return value

TKeyResponse

Indicates whether or not the key event was used by this control.

Notes:


HandlePointerEventL()

protected: virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);

Description

Handles pointer events.

This function gets called whenever a pointer event occurs in the control, i.e. with the pointer within the control's extent, or when the control has grabbed the pointer. The control should implement this function to handle pointer events.

Note:

Parameters

const TPointerEvent& aPointerEvent

The pointer event.


SetAllowStrayPointers()

protected: void SetAllowStrayPointers();

Description

Set allow stray pointer events.

This function sets a flag that affects the way the control framework handles pointer events. By default, the flag is not set, and the control will ignore any pointer drag events and up events where the matching pointer down event occurred in a different control. This would happen if a user pressed the pointer down in a control, but then dragged the pointer into a different control before releasing it.

SetAllowStrayPointers() is typically used for menus, where stray pointer events are required because is it the pointer up event that is used to activate a menu option. This is in contrast to other components such as command buttons, where a pointer down event and up event in succession are required to activate the button.


EnableDragEvents()

protected: void EnableDragEvents();

Description

Requests pointer drag events.

This function should be called if a control is required to receive pointer drag and move events. The default behaviour for all controls is that pointer drag events and pointer move events are not delivered.

The control framework does not provide a function to disable drag events at a later time, but this can be done via the window server API, by calling Window()->PointerFilter().

Note:

See also:


HandlePointerBufferReadyL()

protected: virtual void HandlePointerBufferReadyL();

Description

Handle events in pointer buffer.

This function is called whenever the control receives an event of type EEventPointerBufferReady, unless one of its component controls has grabbed the pointer, in which case the function is called on that control. An event of type EEventPointerBufferReady will only be received if the pointer move buffer has been set up using window server functions.

The pointer move buffer is typically used when the application requires a continuous stream of pointer drag events, such as in a drawing application.

See also:


HandleRedrawEvent()

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

Description

Handles redraw event.

In normal circumstances this function should not be used or overridden by the derived control class.

Parameters

const TRect& aRect

The rectangle to be redrawn.


InputCapabilities()

TCoeInputCapabilities InputCapabilities() const;

Support

Supported from 5.1

Description

Gets the control's input capabilities.

Return value

TCoeInputCapabilities

The control's input capabilities.

Notes:


RecursivelyMergedInputCapabilities()

TCoeInputCapabilities RecursivelyMergedInputCapabilities() const;

Support

Supported from 6.0

Description

Gets the input capabilities of the control and all its components.

Return value

TCoeInputCapabilities

The input capabilities of the control.

[Top]


Handling changes to resources


HandleResourceChange()

virtual void HandleResourceChange(TInt aType);

Support

Supported from 5.1

Description

Handles a change to the control's resources.

The types of resources handled are those which are shared across the environment, e.g. colours or fonts.

Parameters

TInt aType

A message UID value. The most common is KEikMessageColorSchemeChange which controls get when the colour scheme is changed. Other examples include: KEikMessageFadeAllWindows, KEikMessageUnfadeWindows, KEikMessageZoomChange, KEikMessageVirtualCursorStateChange, KEikMessageCapsLock, KEikMessagePrepareForSave.

See also:


HandleComponentControlsResourceChange()

void HandleComponentControlsResourceChange(TInt aType);

Support

Supported from 5.1

Description

Handles a change to the resources in the components of a compound control.

Parameters

TInt aType

A message UID value. The most common is KEikMessageColorSchemeChange which controls get when the colour scheme is changed. Other examples include: KEikMessageFadeAllWindows, KEikMessageUnfadeWindows, KEikMessageZoomChange, KEikMessageVirtualCursorStateChange, KEikMessageCapsLock, KEikMessagePrepareForSave.

See also:

[Top]


Grabbing the pointer

Description

This is implemented within control framework and does not have to be implemented by the derived control class.

In the UI control framework, when a pointer event of type EButton1Down occurs in a control, the control grabs the pointer until the next event of type EButton1Up. This means, all pointer events are delivered to this control between (and inclusive of) the EButton1Down and EButton1Up events, regardless of which control the event occurs in. (If the control is invisible or dimmed, however, it does not grab the pointer.)


ClaimPointerGrab()

void ClaimPointerGrab(TBool aSendUpEvent=ETrue);

Description

Claims pointer grab from another control.

This ensures that all subsequent pointer events are delivered to it and not to the control that originally owned the grab.

The function allows a control to claim the pointer grab only if the pointer is already grabbed by another control.

Parameters

TBool aSendUpEvent=ETrue

Passed as the argument to RWindowBase::ClaimPointerGrab().

See also:


GrabbingComponent()

protected: CCoeControl* GrabbingComponent() const;

Description

Gets the component control which is grabbing the pointer.

Return value

CCoeControl*

The component control that is currently grabbing the pointer. If no component of this control is currently grabbing the pointer, or if the control is not a compound control, returns NULL.

[Top]


Capturing pointer events


SetPointerCapture()

void SetPointerCapture(TBool aCapture=ETrue);

Description

Set pointer capture.

Once set, pointer capture lasts until SetPointerCapture() is called on the control with aCapture=EFalse.

This function is typically used with dialogs, to throw away any pointer events that don't occur within the dialog, or with menus, to dismiss the menu if the user clicks outside it.

Parameters

TBool aCapture=ETrue

If ETrue, passes the following value as the argument to RWindowBase::SetPointerCapture():RWindowBase::TCaptureFlagAllGroups|RWindowBase::TCaptureFlagEnabled, if the control's global capture flag is set to ETrue (see SetGloballyCapturing()) or RWindowBase::TCaptureFlagEnabled if the control's global capture flag is set to EFalse. If EFalse, passes EFalse as the argument to RWindowBase::SetPointerCapture().

See also:


SetGloballyCapturing()

void SetGloballyCapturing(TBool aGlobal);

Description

Sets the global pointer capture flag.

This flag indicates whether or not pointer capture should be global.

The flag is used by SetPointerCapture() to determine what value to pass to RWindowBase::SetPointerCapture(). The default for the global capture flag, when a control is created, is EFalse.

Parameters

TBool aGlobal

Value for global capture flag.


CapturesPointer()

protected: TBool CapturesPointer() const;

Description

Tests if pointer capture is set for the control.

This returns true if SetPointerCapture() has been called with aCapture=ETrue.

Return value

TBool

ETrue if the control captures the pointer, EFalse if it doesn't.


IgnoreEventsUntilNextPointerUp()

void IgnoreEventsUntilNextPointerUp();

Description

Sets control to ignore pointer events until next pointer up.

This means that all events until and including the next pointer up event get thrown away and are not processed.

[Top]


Control observers — sending an event to another control

Description

MCoeControlObserver defines a protocol for passing events between controls: events are sent using CCoeControl::ReportEventL(), and handled by the observer control using MCoeControlObserver::HandleControlEventL(). MCoeControlObserver also defines a set of event types that can be passed between controls: these are not the same as the user input events that are generated by the window server.

A control can send events to another control by making that control its observer. To do this, the observer control must be derived from MCoeControlObserver, and must be set as the control's observer by calling SetObserver().


SetObserver()

void SetObserver(MCoeControlObserver* aObserver);

Description

Sets the control's observer.

Parameters

MCoeControlObserver* aObserver

The observer.


Observer()

MCoeControlObserver* Observer() const;

Description

Gets the control's observer.

Return value

MCoeControlObserver*

The control's observer.


ReportEventL()

protected: void ReportEventL(MCoeControlObserver::TCoeEvent aEvent);

Description

Sends an event to the control's observer.

Parameters

MCoeControlObserver::TCoeEvent aEvent

The event type.

[Top]


Control environment and contexts


ControlEnv()

CCoeEnv* ControlEnv() const;

Description

Gets the control environment object for this control.

Return value

CCoeEnv*

The control's control environment object.


GetHelpContext()

virtual void GetHelpContext(TCoeHelpContext& aContext) const;

Support

Supported from 5.1

Description

Gets the control's help context. Returns a NULL context by default.

The function must be implemented in derived classes to associate the control with a particular Help file and topic in a context sensitive application. The implementation should set the public data members of TCoeHelpContext to the required Help file UID and context descriptor — as created using the Context-Sensitive Help Compiler.

Parameters

TCoeHelpContext& aContext

The control's help context


ControlContext()

MCoeControlContext* ControlContext() const;

Support

Supported from 6.0

Description

Gets the control context being used by this control.

The function does not transfer ownership to the caller.

Return value

MCoeControlContext*

The control context.