CCoeControlArray Class Reference

class CCoeControlArray : public CBase

Class that represents an array of controls.

The CCoeControlArray class is used to store the child controls of a container control. The method CCoeControl::InitComponentArrayL() must be used to create the array and the method CCoeControlArray& CCoeControl::Components() can be used to get this array.

Inherits from

Nested Classes and Structures

Public Member Functions
~CCoeControlArray()
IMPORT_C TCursorAppendLC(CCoeControl *, TInt)
IMPORT_C TCoeControlWithIdAt(TInt)
IMPORT_C const TCoeControlWithIdAt(TInt)
IMPORT_C TCursorBegin()
T *ControlById(TInt)
const T *ControlById(TInt)
IMPORT_C TBoolControlsOwnedExternally()
IMPORT_C TIntCount()
IMPORT_C TCursorEnd()
IMPORT_C TCursorFind(const CCoeControl *)
IMPORT_C TCursorFind(TInt)
IMPORT_C TIntId(const CCoeControl &)
IMPORT_C TCursorInsertAfterLC(TInt, CCoeControl *, TInt)
IMPORT_C TCursorInsertLC(TCursor &, CCoeControl *, TInt)
IMPORT_C TBoolIsArrayLocked()
IMPORT_C CCoeControlArray *NewL(CCoeControl &)
IMPORT_C TIntRemove(const CCoeControl *)
IMPORT_C CCoeControl *Remove(TCursor)
IMPORT_C CCoeControl *RemoveById(TInt)
IMPORT_C TIntReplace(CCoeControl *, CCoeControl *)
IMPORT_C voidReset()
IMPORT_C voidResetAndDestroy()
IMPORT_C voidSetArrayLocked()
IMPORT_C voidSetControlsOwnedExternally(TBool)
IMPORT_C voidSort(TLinearOrder< TCoeControlWithId >)
IMPORT_C voidSortById()
Private Member Functions
CCoeControlArray(CCoeControl &)
IMPORT_C CCoeControl *CtrlById(TInt)
TInt IndexById(TInt)
Inherited Functions
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()
Public Member Enumerations
enumTEvent { EControlAdded, EControlRemoved }
Private Attributes
RArray< TCoeControlWithId >iControls
TInt iFlags
CCoeControl &iOwner

Constructor & Destructor Documentation

CCoeControlArray(CCoeControl &)

IMPORT_CCCoeControlArray(CCoeControl &aOwner)[private]

Constructor

Parameters

CCoeControl & aOwnerThe control that owns the new array

~CCoeControlArray()

IMPORT_C~CCoeControlArray()

The destructor will delete the controls in the array only if the EControlsOwnedExternally flag is not set.

Member Functions Documentation

AppendLC(CCoeControl *, TInt)

IMPORT_C TCursorAppendLC(CCoeControl *aControl,
TIntaControlId =  KCoeNoControlId
)

Appends a control at the end of the array.

Parameters

CCoeControl * aControlThe control to add
TInt aControlId =  KCoeNoControlId The id for the new control

At(TInt)

IMPORT_C TCoeControlWithIdAt(TIntaIndex)

Gets the element at the given index.

Parameters

TInt aIndexThe index of the control

At(TInt)

IMPORT_C const TCoeControlWithIdAt(TIntaIndex)const

Gets the element at the given index.

Parameters

TInt aIndexThe index of the control

Begin()

IMPORT_C TCursorBegin()const

Gets a cursor that points to the first element of the array. Note that if the array is empty this is actually equivalent to a call to End().

ControlById(TInt)

T *ControlById(TIntaControlId)

Gets the control with the given id.

Parameters

TInt aControlIdThe id of the desired control.

ControlById(TInt)

const T *ControlById(TIntaControlId)const

Gets the control with the given id.

Parameters

TInt aControlIdThe id of the desired control.

ControlsOwnedExternally()

IMPORT_C TBoolControlsOwnedExternally()const

This function checks if the controls are owned by the array or not. If the controls are owned by the array they will be deleted when the array is destroyed else they will not.

Count()

IMPORT_C TIntCount()const

Gets the number of elements in the array.

CtrlById(TInt)

IMPORT_C CCoeControl *CtrlById(TIntaControlId)const [private]

Gets the control with the given id or NULL if there is no control with the given id.

Parameters

TInt aControlIdThe id of the control

End()

IMPORT_C TCursorEnd()const

Gets a cursor to the position right after the last element in the array. To get the last element use Prev(). This cursor is useful as argument to the insertion function to add the new control at the end of the array.

Find(const CCoeControl *)

IMPORT_C TCursorFind(const CCoeControl *aControl)const

Gets a cursor to the control, if the control is found in the array. Use the TCursor::IsValid function to check that the search found something or not.

Parameters

const CCoeControl * aControlThe control to find.

Find(TInt)

IMPORT_C TCursorFind(TIntaControlId)const

Gets a cursor to the control, if the control with the given id is found in the array. Use the TCusror::IsValid function to check that the search found something or not.

Parameters

TInt aControlIdThe id of the control to find.

Id(const CCoeControl &)

IMPORT_C TIntId(const CCoeControl &aControl)const

Gets the id of the control.

Parameters

const CCoeControl & aControlThe control

IndexById(TInt)

TInt IndexById(TIntaControlId)const [private]

Gets the index of the control with the given id or KErrNotFound if there is no control that has that id.

Parameters

TInt aControlIdThe id of the control

InsertAfterLC(TInt, CCoeControl *, TInt)

IMPORT_C TCursorInsertAfterLC(TIntaInsertAfterId,
CCoeControl *aControl,
TIntaControlId =  KCoeNoControlId
)

Inserts a control after the control with the given id.

Each array has an owner (an instance of the CCoeControl class) which is the container of all the child controls. Each control has a parent and for the child controls this parent must be the container. This function will automatically update the parent of aControl.

The function will also result in the CCoeControl::HandleControlArrayEventL method being called on the owner of the array. The event being generated is EControlAdded.

leave
KErrLocked if the array has been locked using the CCoeControlArray::SetArrayLocked() function.
leave
KErrNotFound if the array doesn't contain a control identified by aInsertAfterId.

Parameters

TInt aInsertAfterIdThe id of the control after which we want to insert the new control. If a control with this id can't be found in the array the function will leave with KErrNotFound.
CCoeControl * aControlThe new control we want to add.
TInt aControlId =  KCoeNoControlId The id of the new control.

InsertLC(TCursor &, CCoeControl *, TInt)

IMPORT_C TCursorInsertLC(TCursor &aInsertAt,
CCoeControl *aControl,
TIntaControlId =  KCoeNoControlId
)

Inserts a control at the given position.

Each array has an owner (an instance of the CCoeControl class) which is the container of all the child controls. Each control has a parent and for the child controls this parent must be the container. This function will automatically update the parent of aControl.

The function will also result in the CCoeControl::HandleControlArrayEventL method being called on the owner of the array. The event being generated is EControlAdded.

leave
KErrLocked if the array has been locked using the CCoeControlArray::SetArrayLocked() function.

Parameters

TCursor & aInsertAtThe position at which we want to insert the new control.
CCoeControl * aControlThe new control we want to add.
TInt aControlId =  KCoeNoControlId The id of the new control.

IsArrayLocked()

IMPORT_C TBoolIsArrayLocked()const

Checks whether the array is locked or not. If an array is locked any attempt to add or remove controls will fail with KErrLocked.

NewL(CCoeControl &)

IMPORT_C CCoeControlArray *NewL(CCoeControl &aOwner)[static]

Creates a new CCoeControlArray.

Parameters

CCoeControl & aOwnerThe control that owns the new array

Remove(const CCoeControl *)

IMPORT_C TIntRemove(const CCoeControl *aControl)

Removes a control but does NOT delete the control itself. The ownership of the control is transferred to the caller.

The function will also result in the CCoeControl::HandleControlArrayEventL method being called on the owner of the array. The event being generated is EControlRemoved.

Parameters

const CCoeControl * aControlThe control to remove

Remove(TCursor)

IMPORT_C CCoeControl *Remove(TCursoraRemoveAt)

Removes a control but does NOT delete the control itself. The ownership of the control is transferred to the caller.

The function will also result in the CCoeControl::HandleControlArrayEventL method being called on the owner of the array. The event being generated is EControlRemoved.

Parameters

TCursor aRemoveAtThe position of the control to remove

RemoveById(TInt)

IMPORT_C CCoeControl *RemoveById(TIntaControlId)

Removes a control but does NOT delete the control itself. The ownership of the control is transferred to the caller.

The function will also result in the CCoeControl::HandleControlArrayEventL method being called on the owner of the array. The event being generated is EControlRemoved.

Parameters

TInt aControlIdThe id of the control to remove

Replace(CCoeControl *, CCoeControl *)

IMPORT_C TIntReplace(CCoeControl *aOriginalControl,
CCoeControl *aNewControl
)

Replaces a control in the array with another control.

Parameters

CCoeControl * aOriginalControlThe control that must be replaced
CCoeControl * aNewControlThe new control

Reset()

IMPORT_C voidReset()

Removes all the controls from the array but doesn't delete them.

ResetAndDestroy()

IMPORT_C voidResetAndDestroy()

Removes all the controls from the array and deletes them.

SetArrayLocked()

IMPORT_C voidSetArrayLocked()

Locks the array. If an array is locked any attempt to add or remove controls will fail with KErrLocked.

SetControlsOwnedExternally(TBool)

IMPORT_C voidSetControlsOwnedExternally(TBoolaOwnedExternally)

Is used to set whether the array owns the controls or not. If the controls are owned by the array they will be deleted when the array is destroyed else they will not.

Parameters

TBool aOwnedExternallyETrue if the controls are owned externally, EFalse if they are owned by the array.

Sort(TLinearOrder< TCoeControlWithId >)

IMPORT_C voidSort(TLinearOrder< TCoeControlWithId >aOrder)

This function provides a pluggable implementation to sort the array of controls.

Parameters

TLinearOrder< TCoeControlWithId > aOrderThe user defined static method which implements the algorithm for sorting.

SortById()

IMPORT_C voidSortById()

Sorts the controls using their index as the key.

Member Enumerations Documentation

Enum TEvent

Defines the possible events related to a change to the contents of the array.

Enumerators

EControlAdded

A control has been added to the array

EControlRemoved

A control has been removed from the array

Member Data Documentation

RArray< TCoeControlWithId > iControls

RArray< TCoeControlWithId >iControls[private]

TInt iFlags

TInt iFlags[private]

CCoeControl & iOwner

CCoeControl &iOwner[private]