#include <coecontrolarray.h>
Link against:
cone.lib
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
CBase
-
Base class for all classes to be instantiated on the heap.
CCoeControlArray
- Class that represents an array of controls.
Members
Defined in CCoeControlArray
:
Inherited from CBase
:
Construction and destruction
IMPORT_C static CCoeControlArray* NewL(CCoeControl &aOwner);
Description
Creates a new CCoeControlArray.
Parameters
CCoeControl &aOwner |
The control that owns the new array
|
|
Return value
IMPORT_C ~CCoeControlArray();
Description
The destructor will delete the controls in the array only if the EControlsOwnedExternally flag is not set.
IMPORT_C TInt Count() const;
Description
Gets the number of elements in the array.
Return value
TInt
|
The number of elements in the array
|
|
IMPORT_C void Reset();
Description
Removes all the controls from the array but doesn't delete them.
IMPORT_C void ResetAndDestroy();
Description
Removes all the controls from the array and deletes them.
IMPORT_C void SortById();
Description
Sorts the controls using their index as the key.
ControlsOwnedExternally()const
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(TBool)
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.
|
|
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
|
|
IMPORT_C void SetArrayLocked();
Description
Locks the array. If an array is locked any attempt to add or remove controls will fail with KErrLocked.
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.
|
|
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.
|
|
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 CCoeControlArray::End()const
.
Return value
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
Find(const CCoeControl *)const
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 CCoeControlArray::TCursor::IsValid()const
function to check that the search found something or not.
Parameters
Return value
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
AppendLC(CCoeControl *,TInt)
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
InsertAfterLC(TInt,CCoeControl *,TInt)
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(CCoeControlArray::TEvent,const CCoeControlArray *,CCoeControl *,TInt)
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
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(TCursor &,CCoeControl *,TInt)
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(CCoeControlArray::TEvent,const CCoeControlArray *,CCoeControl *,TInt)
method being called on the owner of the array. The event being generated is EControlAdded.
Parameters
Return value
Leave codes
KErrLocked |
if the array has been locked using the CCoeControlArray::SetArrayLocked() function.
|
|
Remove(const CCoeControl *)
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(CCoeControlArray::TEvent,const CCoeControlArray *,CCoeControl *,TInt)
method being called on the owner of the array. The event being generated is EControlRemoved.
Parameters
Return value
TInt
|
KErrNone if the control was removed successfully, KErrNotFound if the control could not be found.
|
|
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(CCoeControlArray::TEvent,const CCoeControlArray *,CCoeControl *,TInt)
method being called on the owner of the array. The event being generated is EControlRemoved.
Parameters
Return value
CCoeControl *
|
A pointer to the control that has been removed. This can be used by the caller to delete the control.
|
|
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(CCoeControlArray::TEvent,const CCoeControlArray *,CCoeControl *,TInt)
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(CCoeControl *,CCoeControl *)
IMPORT_C TInt Replace(CCoeControl *aOriginalControl, CCoeControl *aNewControl);
Description
Replaces a control in the array with another control.
Parameters
Return value
TInt
|
A standard error code
|
|
IMPORT_C TCoeControlWithId At(TInt aIndex);
Description
Gets the element at the given index.
Parameters
TInt aIndex |
The index of the control
|
|
Return value
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
Id(const CCoeControl &)const
IMPORT_C TInt Id(const CCoeControl &aControl) const;
Description
Gets the id of the control.
Parameters
Return value
TInt
|
The id of the control or KErrNotFound if the control can't be found.
|
|
Sort(TLinearOrder< TCoeControlWithId >)
IMPORT_C void Sort(TLinearOrder< TCoeControlWithId > aOrder);
Description
This function provides a pluggable implementation to sort the array of controls.
Parameters
class TCursor;
Description
This class is an iterator for the CCoeControlArray
class.
Members
Defined in CCoeControlArray::TCursor
:
Control()
Gets the control.
Control()const
Gets the control.
IsValid()const
Checks if the cursor is valid. Use this to replace the comparison with NULL that...
Next()
Updates the cursor so that it points to the next element in the array. If the cu...
Prev()
Updates the cursor so that it points to the previous element in the array. If th...
operator!=(const TCursor &)const
Checks if the cursors are different. Cursors are equal if they point to the same...
operator==(const TCursor &)const
Checks if the cursors are equal. Cursors are equal if they point to the same con...
Member functions
Control()
T* Control();
Description
Gets the control.
Return value
T * |
The control at the current cursor position.
|
|
Control()const
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()const
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==(const TCursor &)const
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
Return value
TBool
|
ETrue if the cursors point to the same position in the same array, EFalse otherwise.
|
|
operator!=(const TCursor &)const
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
Return value
TBool
|
EFalse if the cursors point to the same position in the same array, EFalse otherwise.
|
|
TEvent
Description
Defines the possible events related to a change to the contents of the array.