Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: coecontrolarray.h
Link against: cone.lib

Class CCoeControlArray

class CCoeControlArray : public CBase;

Description

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.

Derivation

Members

Defined in CCoeControlArray:
AppendLC(), At(), At(), Begin(), ControlById(), ControlById(), ControlsOwnedExternally(), Count(), EControlAdded, EControlRemoved, End(), Find(), Find(), Id(), InsertAfterLC(), InsertLC(), IsArrayLocked(), NewL(), Remove(), Remove(), RemoveById(), Replace(), Reset(), ResetAndDestroy(), SetArrayLocked(), SetControlsOwnedExternally(), Sort(), SortById(), TCursor, TEvent, ~CCoeControlArray()

Inherited from CBase:
Delete(), Extension_(), operator new()


Construction and destruction


NewL()

static IMPORT_C CCoeControlArray *NewL(CCoeControl &aOwner);

Description

Creates a new CCoeControlArray.

Parameters

CCoeControl &aOwner

The control that owns the new array

Return value

CCoeControlArray *

A new CCoeControlArray instance


~CCoeControlArray()

IMPORT_C ~CCoeControlArray();

Description

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

[Top]


Member functions


Count()

IMPORT_C TInt Count() const;

Description

Gets the number of elements in the array.

Return value

TInt

The number of elements in the array


Reset()

IMPORT_C void Reset();

Description

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


ResetAndDestroy()

IMPORT_C void ResetAndDestroy();

Description

Removes all the controls from the array and deletes them.


SortById()

IMPORT_C void SortById();

Description

Sorts the controls using their index as the key.


ControlsOwnedExternally()

IMPORT_C TBool ControlsOwnedExternally() const;

Description

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.

Return value

TBool

ETrue if the array does NOT own the controls, EFalse if the array owns the controls.


SetControlsOwnedExternally()

IMPORT_C void SetControlsOwnedExternally(TBool aOwnedExternally);

Description

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 aOwnedExternally

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


IsArrayLocked()

IMPORT_C TBool IsArrayLocked() const;

Description

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

Return value

TBool

ETrue if the array is locked, EFalse otherwise


SetArrayLocked()

IMPORT_C void SetArrayLocked();

Description

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


ControlById()

T *ControlById(TInt aControlId);

Description

Gets the control with the given id.

Parameters

TInt aControlId

The id of the desired control.

Return value

T *

The control with the given id.


ControlById()

const T *ControlById(TInt aControlId) const;

Description

Gets the control with the given id.

Parameters

TInt aControlId

The id of the desired control.

Return value

const T *

The control with the given id.


Begin()

IMPORT_C TCursor Begin() const;

Description

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().

Return value

TCursor

A cursor that points to the first control in the array.


End()

IMPORT_C TCursor End() const;

Description

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.

Return value

TCursor

A cursor that points right after the last element


Find()

IMPORT_C TCursor Find(const CCoeControl *aControl) const;

Description

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 *aControl

The control to find.

Return value

TCursor

A cursor to the control. This may be an invalid cursor if we didn't find the requested control. Use TCursor::IsValid() to check if the cursor is valid.


Find()

IMPORT_C TCursor Find(TInt aControlId) const;

Description

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 aControlId

The id of the control to find.

Return value

TCursor

A cursor to the control. This may be an invalid cursor if we didn't find the requested control. Use TCursor::IsValid() to check if the cursor is valid.


AppendLC()

IMPORT_C TCursor AppendLC(CCoeControl *aControl, TInt aControlId=KCoeNoControlId);

Description

Appends a control at the end of the array.

Parameters

CCoeControl *aControl

The control to add

TInt aControlId

The id for the new control

Return value

TCursor

A cursor to the added control


InsertAfterLC()

IMPORT_C TCursor InsertAfterLC(TInt aInsertAfterId, CCoeControl *aControl, TInt aControlId=KCoeNoControlId);

Description

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.

Parameters

TInt aInsertAfterId

The 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 *aControl

The new control we want to add.

TInt aControlId

The id of the new control.

Return value

TCursor

A cursor to the added control

Leave codes

KErrLocked

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

KErrNotFound

if the array doesn't contain a control identified by aInsertAfterId.


InsertLC()

IMPORT_C TCursor InsertLC(TCursor &aInsertAt, CCoeControl *aControl, TInt aControlId=KCoeNoControlId);

Description

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.

Parameters

TCursor &aInsertAt

The position at which we want to insert the new control.

CCoeControl *aControl

The new control we want to add.

TInt aControlId

The id of the new control.

Return value

TCursor

A cursor to the added control

Leave codes

KErrLocked

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


Remove()

IMPORT_C TInt Remove(const CCoeControl *aControl);

Description

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 *aControl

The control to remove

Return value

TInt

KErrNone if the control was removed successfully, KErrNotFound if the control could not be found.


Remove()

IMPORT_C CCoeControl *Remove(TCursor aRemoveAt);

Description

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 aRemoveAt

The position of the control to remove

Return value

CCoeControl *

A pointer to the control that has been removed. This can be used by the caller to delete the control.


RemoveById()

IMPORT_C CCoeControl *RemoveById(TInt aControlId);

Description

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 aControlId

The id of the control to remove

Return value

CCoeControl *

A pointer to the control that has been removed. This can be used by the caller to delete the control. The function returns NULL if no control with the given aControlId has been found.


Replace()

IMPORT_C TInt Replace(CCoeControl *aOriginalControl, CCoeControl *aNewControl);

Description

Replaces a control in the array with another control.

Parameters

CCoeControl *aOriginalControl

The control that must be replaced

CCoeControl *aNewControl

The new control

Return value

TInt

A standard error code


At()

IMPORT_C TCoeControlWithId At(TInt aIndex);

Description

Gets the element at the given index.

Parameters

TInt aIndex

The index of the control

Return value

TCoeControlWithId

The control and its id


At()

IMPORT_C const TCoeControlWithId At(TInt aIndex) const;

Description

Gets the element at the given index.

Parameters

TInt aIndex

The index of the control

Return value

const TCoeControlWithId

The control and its id


Id()

IMPORT_C TInt Id(const CCoeControl &aControl) const;

Description

Gets the id of the control.

Parameters

const CCoeControl &aControl

The control

Return value

TInt

The id of the control or KErrNotFound if the control can't be found.


Sort()

IMPORT_C void Sort(TLinearOrder< TCoeControlWithId > aOrder);

Description

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

Parameters

TLinearOrder< TCoeControlWithId > aOrder

The user defined static method which implements the algorithm for sorting.

[Top]


Member classes


Class TCursor

class TCursor;

Description

This class is an iterator for the CCoeControlArray class.

Members

Defined in CCoeControlArray::TCursor:
Control(), Control(), IsValid(), Next(), Prev(), operator!=(), operator==()

Member functions


Control()

T *Control();

Description

Gets the control.

Return value

T *

The control at the current cursor position.


Control()

const T *Control() const;

Description

Gets the control.

Return value

const T *

The control at the current cursor position.


Prev()

IMPORT_C TBool Prev();

Description

Updates the cursor so that it points to the previous element in the array. If the current element is the first one then this function does nothing and returns EFalse.

Return value

TBool

EFalse if the current element was the first one in the array, ETrue if it wasn't and the function actually did something.


Next()

IMPORT_C TBool Next();

Description

Updates the cursor so that it points to the next element in the array. If the current element is the last one then this function returns EFalse.

Return value

TBool

EFalse if the current element was the last one in the array, ETrue otherwise


IsValid()

IMPORT_C TBool IsValid() const;

Description

Checks if the cursor is valid. Use this to replace the comparison with NULL that you would do with pointers. This function is typically used on the cursors returned by the find operations.

Return value

TBool

ETrue if the cursor points to a control, EFalse otherwise


operator==()

IMPORT_C TBool operator==(const TCursor &aCursor) const;

Description

Checks if the cursors are equal. Cursors are equal if they point to the same control in the same array else they are different.

Parameters

const TCursor &aCursor

The other cursor.

Return value

TBool

ETrue if the cursors point to the same position in the same array, EFalse otherwise.


operator!=()

IMPORT_C TBool operator!=(const TCursor &aCursor) const;

Description

Checks if the cursors are different. Cursors are equal if they point to the same control in the same array else they are different.

Parameters

const TCursor &aCursor

The other cursor.

Return value

TBool

EFalse if the cursors point to the same position in the same array, EFalse otherwise.

[Top]


Member enumerations


Enum TEvent

TEvent

Description

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

EControlAdded

A control has been added to the array

EControlRemoved

A control has been removed from the array