CAlfControl Class Reference

class CAlfControl : public CAlfPropertyOwner

CAlfControl provides a base class for gathering logical functionality in the UI.

For example a list control could gather and control all visuals that form a listbox UI element. A thumbnail view control could be used to control visuals that form a thumbnail view in an image gallery application.

Their main use is to handle interaction with the user by catching events through overloaded OfferEventL() - method.

Developers should derive their controls from this base class to implement the UI logic of their application. Developers should remember to pass a reference to the CAlfEnv - object to the CAlfControl - base class when derived class is constructed through the CAlfControl::ConstructL() - method. Failure to do this will result in KERN-EXEC 3 panic when CAlfControl - derived object is added to a CAlfControlGroup. Usually you would do this when ConstructL() - method of the derived class is called, like this:

Usage:
 class CMyControl : public CAlfControl
    {
  public:
     CMyControl( CAlfEnv& aEnv );
    ~CMyControl();
 
    //Handle interaction with the user by catching events
    virtual TBool OfferEventL(const TAlfEvent& aEvent);
    
    //Few other notofication methods, overloaded by this custom
    //control, to perform required action
    void NotifyControlVisibility( TBool aIsVisible, CAlfDisplay& aDisplay );
    void VisualLayoutUpdated( CAlfVisual& aVisual );
    void FocusChanged( CAlfDisplay& aDisplay, TBool aFocused );
    void HostChanging( CAlfControl* aNewHost );
    TBool Focusing()const;
   };
 
  void CMyControl::ConstructL(CAlfEnv& aEnv)
 	{
     CAlfControl::ConstructL(aEnv);
 	}
 
  //To show the control on display
  //Create a new control group
  CAlfControlGroup& group = iEnv->NewControlGroupL( KControlGroupIdDefault );
 
  //Create control instance and append it to group
  CMyControl* control = CMyControl::ConstructL(&iEnv);
  group.AppendL( control );
 
  //Show control group on display
  iDisplay->Roster().ShowL( group );
Controls are not visible by themselves, but controls create and manipulate visuals (CAlfVisual - derived objects). Controls set the target values for visual properties and/or schedule animation commands.

Controls are collected in groups represented by CAlfControlGroup - objects (e.g., one group per view). Even though controls are contained within control groups they do not have a hierarchical organization. Controls can be, however, connected to each other for collaboration. This can be done using AddConnectionL() - method.

Inherits from

Nested Classes and Structures

Public Member Functions
CAlfControl()
~CAlfControl()
IMPORT_C TBoolAcceptInput()
IMPORT_C voidAcquireFocus()
IMPORT_C voidAddConnectionL(CAlfControl *, TInt)
IMPORT_C TIntAppend(CAlfVisual *, CAlfLayout *)
IMPORT_C CAlfLayout *AppendLayoutL(TAlfLayoutType, CAlfLayout *, TInt)
IMPORT_C CAlfVisual *AppendVisualL(TAlfVisualType, CAlfLayout *, TInt)
IMPORT_C voidBindDisplay(CAlfDisplay &)
IMPORT_C TRectBounds()
IMPORT_C voidCancelAllCommands()
voidClearChanged()
IMPORT_C CAlfControl &Connection(TInt)
IMPORT_C CAlfControl &ConnectionByOrdinal(TInt)
IMPORT_C TIntConnectionCount()
IMPORT_C TIntConnectionOrdinal(TInt)
IMPORT_C TIntConnectionRole(TInt)
IMPORT_C voidConstructL(CAlfEnv &)
IMPORT_C CAlfLayout *ContainerLayout(const CAlfControl *)
IMPORT_C CAlfControlGroup *ControlGroup()
IMPORT_C CAlfDisplay *Display()
IMPORT_C TRectDisplayArea()
IMPORT_C TAlfRealPointDisplayCenter()
IMPORT_C TPointDisplayToHost(const TPoint &)
IMPORT_C CAlfEnv &Env()
IMPORT_C TIntFindConnection(const CAlfControl *)
IMPORT_C CAlfVisual *FindTag(const TDesC8 &)
IMPORT_C TBoolFocus()
voidFocusChainChanged(TBool)
IMPORT_C voidFocusChanged(CAlfDisplay &, TBool)
IMPORT_C CAlfControl *FocusedConnection()
voidHide(CAlfDisplay &)
IMPORT_C TBoolHitTest(const TPoint &)
IMPORT_C CAlfControl *Host()
IMPORT_C TIntHostId()
IMPORT_C TPointHostToDisplay(const TPoint &)
IMPORT_C TIntId()
IMPORT_C TIntIdentifier()
IMPORT_C TBoolIsFocusing()
IMPORT_C TBoolOfferEventL(const TAlfEvent &)
IMPORT_C voidRelinquishFocus()
IMPORT_C voidRemove(CAlfVisual *)
IMPORT_C voidRemoveConnection(CAlfControl *)
IMPORT_C TIntRole()
voidSetControlGroup(CAlfControlGroup &)
voidSetFocus(CAlfDisplay &, TBool)
voidSetFocusing(TBool)
IMPORT_C voidSetHost(CAlfControl *)
IMPORT_C voidSetHostId(TInt)
IMPORT_C voidSetId(TInt)
IMPORT_C voidSetRole(TInt)
IMPORT_C voidShowL(CAlfDisplay &)
IMPORT_C CAlfVisual &Visual(TInt)
IMPORT_C TIntVisualCount()
IMPORT_C voidVisualDestroyed(CAlfVisual &)
IMPORT_C voidVisualLayoutUpdated(CAlfVisual &)
IMPORT_C voidVisualPrepareDrawFailed(CAlfVisual &, TInt)
Protected Member Functions
IMPORT_C voidConnectionAddedL(CAlfControl *, TInt)
IMPORT_C voidConnectionRemoved(CAlfControl *, TInt)
IMPORT_C voidHostChangingL(CAlfControl *)
IMPORT_C voidNotifyControlVisibility(TBool, CAlfDisplay &)
IMPORT_C voidPropertyOwnerExtension(const TUid &, TAny **)
voidRemoveVisualsFromHostControl(CAlfControl &)
IMPORT_C voidVisualAddedL(CAlfVisual *)
IMPORT_C voidVisualRemoved(CAlfVisual *)
Inherited Functions
CAlfPropertyOwner::CAlfPropertyOwner()
CAlfPropertyOwner::CopyProperty(const CAlfPropertyOwner &,const TDesC8 &)
CAlfPropertyOwner::PropertyClear()
CAlfPropertyOwner::PropertyFindInteger(const TDesC8 &,TInt *)const
CAlfPropertyOwner::PropertyFindString(const TDesC8 &,TDesC **)const
CAlfPropertyOwner::PropertyRemove(const TDesC8 &)
CAlfPropertyOwner::PropertySetIntegerL(const TDesC8 &,TInt,TInt,TInt)
CAlfPropertyOwner::PropertySetStringL(const TDesC8 &,const TDesC &)
CAlfPropertyOwner::~CAlfPropertyOwner()
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Private Attributes
TPrivateData *iData

Constructor & Destructor Documentation

CAlfControl()

IMPORT_CCAlfControl()

Constructor.

~CAlfControl()

IMPORT_C~CAlfControl()

Destructor.

Member Functions Documentation

AcceptInput()

IMPORT_C TBoolAcceptInput()const

Determines whether the control accepts input events.

AcquireFocus()

IMPORT_C voidAcquireFocus()

Attempt to acquire focus for this control.

Actively attempt to acquire focus on all displays that contain visuals owned by this control. This will set the focused control in the rosters of these displays, and then, in most situations, call SetFocus with a value of ETrue on this control. The callback in CAlfControl::FocusChanged or its virtual override is then called. It is there that the control should perform whatever visual or functional changes that it performs upon change of focus.

If a display for this control is not currently focused (for example if another application is showing a popup or an element from another UI library, for instance an Avkon menu is displayed ) then calling this method will only set a latent focus in that display's roster. That is, the focused control will be changed in the roster, but not in the control itself. The control will not receive a FocusChanged callback. The call to this method "fails" only in the sense that there is no immediate setting of focus to the control by the environment.

When focus is restored to the display, then the latent focus held in the roster will then be used to set focus again to the control. Alf controls will thus experience loss and gain of focus when displays lose and gain focus, with the record of which control has the latent focus held in the roster.

AddConnectionL(CAlfControl *, TInt)

IMPORT_C voidAddConnectionL(CAlfControl *aConnectedControl,
TIntaRole
)[virtual]

Establishes a manual connection between this host control and another control.

If setting manually the connection, do not use the SetHostId() function from the child control!

Calls ConnectionAddedL when a connection has been created between the two controls

ConnectionAddedL

Parameters

CAlfControl * aConnectedControlControl to connect.
TInt aRoleRole of the control. Interpretation depends on the host.

Append(CAlfVisual *, CAlfLayout *)

IMPORT_C TIntAppend(CAlfVisual *aVisual,
CAlfLayout *aParentLayout = NULL
)

Appends a new visual to the list of visuals owned by the control.

CAlfVisual::Owner()

Parameters

CAlfVisual * aVisualVisual to be appended.
CAlfLayout * aParentLayout = NULLParent layout visual to which the visual will be appended to.

AppendLayoutL(TAlfLayoutType, CAlfLayout *, TInt)

IMPORT_C CAlfLayout *AppendLayoutL(TAlfLayoutTypeaLayoutType,
CAlfLayout *aParentLayout = NULL,
TIntaImplementationUid = 0
)

Creates a new layout using the visual factory and appends it.

Parameters

TAlfLayoutType aLayoutTypeType of the layout to create.
CAlfLayout * aParentLayout = NULL
TInt aImplementationUid = 0

AppendVisualL(TAlfVisualType, CAlfLayout *, TInt)

IMPORT_C CAlfVisual *AppendVisualL(TAlfVisualTypeaVisualType,
CAlfLayout *aParentLayout = 0,
TIntaImplementationUid = 0
)

Creates a new visual using the visual factory and appends it.

Parameters

TAlfVisualType aVisualTypeType of the visual to create.
CAlfLayout * aParentLayout = 0
TInt aImplementationUid = 0

BindDisplay(CAlfDisplay &)

IMPORT_C voidBindDisplay(CAlfDisplay &aDisplay)

Binds the control to a display. Called automatically by CAlfControl::ShowL().

Parameters

CAlfDisplay & aDisplay

Bounds()

IMPORT_C TRectBounds()const

Calculates the region of the screen where the control's visuals are.

CancelAllCommands()

IMPORT_C voidCancelAllCommands()

Cancel all scheduled commands related to this control and the control's visuals.

ClearChanged()

voidClearChanged()

Clears the change flags of the control.

Connection(TInt)

IMPORT_C CAlfControl &Connection(TIntaIndex)const

Returns a client control.

Parameters

TInt aIndexIndex of the client.

ConnectionAddedL(CAlfControl *, TInt)

IMPORT_C voidConnectionAddedL(CAlfControl *aConnectedControl,
TIntaRole
)[protected, virtual]

Called when a client control is added to the control.

Override this function to get the notification.

AddConnectionL

Parameters

CAlfControl * aConnectedControlConnected child control aRole Role of the child control.
TInt aRole

ConnectionByOrdinal(TInt)

IMPORT_C CAlfControl &ConnectionByOrdinal(TIntaOrdinal)const

Returns a client control.

Parameters

TInt aOrdinalRole or index.

ConnectionCount()

IMPORT_C TIntConnectionCount()const

Returns the number of clients.

ConnectionOrdinal(TInt)

IMPORT_C TIntConnectionOrdinal(TIntaIndex)const

Ordinal is the effective index. Role overrides index.

Parameters

TInt aIndex

ConnectionRemoved(CAlfControl *, TInt)

IMPORT_C voidConnectionRemoved(CAlfControl *aConnectedControl,
TIntaRole
)[protected, virtual]

Called when a client control is removed from the control.

Override this function to get the notification.

RemoveConnection

Parameters

CAlfControl * aConnectedControlRemoved child control aRole Role of the child control.
TInt aRole

ConnectionRole(TInt)

IMPORT_C TIntConnectionRole(TIntaIndex)const

Returns the role of a client control.

Parameters

TInt aIndexIndex of the client.

ConstructL(CAlfEnv &)

IMPORT_C voidConstructL(CAlfEnv &aEnv)

Second-phase constructor.

Parameters

CAlfEnv & aEnv

ContainerLayout(const CAlfControl *)

IMPORT_C CAlfLayout *ContainerLayout(const CAlfControl *aConnected)const [virtual]

Returns a container layout for the specified child control.

By default this function returns NULL. Override this function in your own control to select the container layout.

Parameters

const CAlfControl * aConnectedChild control, which is querying the layout.

ControlGroup()

IMPORT_C CAlfControlGroup *ControlGroup()const

Returns the control group of the visual's owner control.

Display()

IMPORT_C CAlfDisplay *Display()const

Returns the display this control is bound to, or NULL.

DisplayArea()

IMPORT_C TRectDisplayArea()const

Determines the display area.

DisplayCenter()

IMPORT_C TAlfRealPointDisplayCenter()const

Determines the coordinates of the center of the display.

DisplayToHost(const TPoint &)

IMPORT_C TPointDisplayToHost(const TPoint &aPoint)const

Coordinate conversion.

Parameters

const TPoint & aPoint

Env()

IMPORT_C CAlfEnv &Env()const

Returns the environment of the visual.

FindConnection(const CAlfControl *)

IMPORT_C TIntFindConnection(const CAlfControl *aConnected)const

Find a client's index number.

Parameters

const CAlfControl * aConnectedConnected control to find.

FindTag(const TDesC8 &)

IMPORT_C CAlfVisual *FindTag(const TDesC8 &aTag)const

Finds the visual that matches a tag. Only the visuals owned by this control are searched.

Parameters

const TDesC8 & aTagTag descriptor to match against.

Focus()

IMPORT_C TBoolFocus()const

Determines whether the control has input focus.

FocusChainChanged(TBool)

voidFocusChainChanged(TBoolaInFocusChain)

Called when this control is included/excluded from the focus chain.

Example: There are controls c1, c2 and c3. The c3 is a child connection of the c2 (i.e. c2 is a host of c3). When the c1 is focused, the c2 is not part of the focus chain. Now, when c3 receives focus, the c2 becomes part of the focus chain and this function will be called for c2. When the c3 loses focus (with RelinquishFocus() or back to c1), this function we be called again for c2 object.

This function calls PropertyOwnerExtension() with parameters: aExtensionUid KUidAlfPropOwnerExtControlFocusChainChanged aExtensionParams TBool** True if focus chain is gained.

Parameters

TBool aInFocusChain

FocusChanged(CAlfDisplay &, TBool)

IMPORT_C voidFocusChanged(CAlfDisplay &aDisplay,
TBoolaFocused
)[virtual]

Called when the control's focus state changes.

Parameters

CAlfDisplay & aDisplay
TBool aFocused

FocusedConnection()

IMPORT_C CAlfControl *FocusedConnection()const

Finds a child connection with focus or recursively one of its child connections have focus. Use Focus() to find out if the returned control instance has focus.

Hide(CAlfDisplay &)

voidHide(CAlfDisplay &aDisplay)

Hides those visuals that are displayed on the specified display. Other visuals are not affected.

Parameters

CAlfDisplay & aDisplayDisplay to remove visuals from.

HitTest(const TPoint &)

IMPORT_C TBoolHitTest(const TPoint &aPoint)const

Tests whether a point is inside the control.

Parameters

const TPoint & aPointPoint in display coordinates.

Host()

IMPORT_C CAlfControl *Host()const

Returns the visual host control.

HostChangingL(CAlfControl *)

IMPORT_C voidHostChangingL(CAlfControl *aNewHost)[protected, virtual]

The host control is about to be changed. The control needs to add its visuals to the container layout provided by the new host.

Override this function to get the notification. Base call is mandatory. If this function leaves, the connection will not be created.

Parameters

CAlfControl * aNewHostNew host control. If NULL, the host is removed.

HostId()

IMPORT_C TIntHostId()const

Returns the automatic visual host identification.

HostToDisplay(const TPoint &)

IMPORT_C TPointHostToDisplay(const TPoint &aPoint)const

Coordinate conversion.

Parameters

const TPoint & aPoint

Id()

IMPORT_C TIntId()const

Returns the id of this control. Zero (0) id the control has no id.

Identifier()

IMPORT_C TIntIdentifier()const

IsFocusing()

IMPORT_C TBoolIsFocusing()const [virtual]

Determines whether the control wants to receive focus.

NotifyControlVisibility(TBool, CAlfDisplay &)

IMPORT_C voidNotifyControlVisibility(TBoolaIsVisible,
CAlfDisplay &aDisplay
)[protected, virtual]

Notifies the control that its visible has been changed on a display. This is the earliest time when the control knows the dimensions of the display it is being shown on.

Parameters

TBool aIsVisibleETrue, if the control is now visible on the display. EFalse, if the control is about to the hidden on the display.
CAlfDisplay & aDisplayThe display on which the control's visibility is changing.

OfferEventL(const TAlfEvent &)

IMPORT_C TBoolOfferEventL(const TAlfEvent &aEvent)[virtual]

Called when an input event is being offered to the control.

Parameters

const TAlfEvent & aEventEvent to be handled.

PropertyOwnerExtension(const TUid &, TAny **)

IMPORT_C voidPropertyOwnerExtension(const TUid &aExtensionUid,
TAny **aExtensionParams
)[protected, virtual]

! future proofing

Parameters

const TUid & aExtensionUid
TAny ** aExtensionParams

RelinquishFocus()

IMPORT_C voidRelinquishFocus()

Attempt to give up focus.

Actively give up focus on all displays containing visuals for this control. Whether the focus is actually changed in the associated roster(s) depends upon the focus state of the related displays. CAlfControl::AcquireFocus
Note:

If this control has latent focus in a roster then it is still cleared (i.e. is no longer even latent).

If this control is not the currently focused control in a roster (either active or latent) then calling this method has no effect on the focus state of that roster.

Remove(CAlfVisual *)

IMPORT_C voidRemove(CAlfVisual *aVisual)

Removes a visual from the control. The caller also receives ownership of the visual.

Parameters

CAlfVisual * aVisualVisual to remove. Caller gets ownership.

RemoveConnection(CAlfControl *)

IMPORT_C voidRemoveConnection(CAlfControl *aConnectedControl)

Removes a client.

Calls ConnectionRemoved when a connection has been broken between the two controls

ConnectionRemoved

Parameters

CAlfControl * aConnectedControlConnected control to remove.

RemoveVisualsFromHostControl(CAlfControl &)

voidRemoveVisualsFromHostControl(CAlfControl &aHostControl)[protected]

Parameters

CAlfControl & aHostControl

Role()

IMPORT_C TIntRole()const

Returns the controls role.

SetControlGroup(CAlfControlGroup &)

voidSetControlGroup(CAlfControlGroup &aOwnerGroup)

Sets the group that owns the control. Called by the control group when the control is added to the group.

Parameters

CAlfControlGroup & aOwnerGroupOwner group.

SetFocus(CAlfDisplay &, TBool)

voidSetFocus(CAlfDisplay &aDisplay,
TBoolaHasFocus
)

Changes the control's focus state.

Parameters

CAlfDisplay & aDisplay
TBool aHasFocus

SetFocusing(TBool)

voidSetFocusing(TBoolaFocusing)

Sets the flag that tells whether the control wants to receive focus.

Parameters

TBool aFocusing

SetHost(CAlfControl *)

IMPORT_C voidSetHost(CAlfControl *aHost)

Parameters

CAlfControl * aHost

SetHostId(TInt)

IMPORT_C voidSetHostId(TIntaHostId)

Sets the automatic visual host identification. When the control is shown, the connection is created automatically betweem this control and the host determined by the paramter.

If the automatic ID is set, do not use the manual AddConnectionL function!

Parameters

TInt aHostIdIdentifier of the host control. Zero if not set,

SetId(TInt)

IMPORT_C voidSetId(TIntaId)

Set an id value for this control.

Parameters

TInt aId

SetRole(TInt)

IMPORT_C voidSetRole(TIntaRole)

Sets the controls role.

Parameters

TInt aRoleNew role.

ShowL(CAlfDisplay &)

IMPORT_C voidShowL(CAlfDisplay &aDisplay)

Shows all the unshown visuals of the control on the specified display. Visuals that are currently shown on another display are not affected.

CAlfControl::BindDisplay()

Parameters

CAlfDisplay & aDisplayDisplay to add visuals to.

Visual(TInt)

IMPORT_C CAlfVisual &Visual(TIntaIndex)const

Returns one of the visuals owned by the control.

Parameters

TInt aIndexIndex number of the visual to return.

VisualAddedL(CAlfVisual *)

IMPORT_C voidVisualAddedL(CAlfVisual *aVisual)[protected, virtual]

Called when a visual has been added to the control.

Parameters

CAlfVisual * aVisualVisual that was added.

VisualCount()

IMPORT_C TIntVisualCount()const

Determines the number of visuals owned by the control.

Note that in visual hierarchies, child visuals are not owned by their parent visuals, but a control. This means that a control that owns a tree of visuals will return the total number of visuals in the tree, and not just the number of root visuals.

VisualDestroyed(CAlfVisual &)

IMPORT_C voidVisualDestroyed(CAlfVisual &aVisual)[virtual]

Called when a visual owned by the control is being destroyed. Visual is removed from the control.

Parameters

CAlfVisual & aVisualVisual about to the destroyed.

VisualLayoutUpdated(CAlfVisual &)

IMPORT_C voidVisualLayoutUpdated(CAlfVisual &aVisual)[virtual]

Notifies the owner that the layout of a visual has been recalculated. Called only when the EAlfVisualFlagLayoutUpdateNotification flag has been set for the visual.

Parameters

CAlfVisual & aVisualVisual that has been laid out.

VisualPrepareDrawFailed(CAlfVisual &, TInt)

IMPORT_C voidVisualPrepareDrawFailed(CAlfVisual &aVisual,
TIntaErrorCode
)[virtual]

Notifies the visual owner if there was an error (a leave happened) when preparing the visual for drawing. Typically the resource alloc errors such as out of memory is escalated through this callback.

Parameters

CAlfVisual & aVisualVisual that caused the error.
TInt aErrorCodeSymbian KErr error code for the failure.

VisualRemoved(CAlfVisual *)

IMPORT_C voidVisualRemoved(CAlfVisual *aVisual)[protected, virtual]

Called when a visual has been removed from the control.

Parameters

CAlfVisual * aVisualVisual that was removed.

Member Data Documentation

TPrivateData * iData

TPrivateData *iData[private]