#include <mw/coecontrolarray.h>
class CCoeControlArray : public CBase |
Public Member Enumerations | |
---|---|
enum | TEvent { EControlAdded, EControlRemoved } |
Public Member Functions | |
---|---|
~CCoeControlArray() | |
IMPORT_C TCursor | AppendLC(CCoeControl *, TInt) |
IMPORT_C TCoeControlWithId | At(TInt) |
IMPORT_C const TCoeControlWithId | At(TInt) |
IMPORT_C TCursor | Begin() |
T * | ControlById(TInt) |
const T * | ControlById(TInt) |
IMPORT_C TBool | ControlsOwnedExternally() |
IMPORT_C TInt | Count() |
IMPORT_C TCursor | End() |
IMPORT_C TCursor | Find(const CCoeControl *) |
IMPORT_C TCursor | Find(TInt) |
IMPORT_C TInt | Id(const CCoeControl &) |
IMPORT_C TCursor | InsertAfterLC(TInt, CCoeControl *, TInt) |
IMPORT_C TCursor | InsertLC(TCursor &, CCoeControl *, TInt) |
IMPORT_C TBool | IsArrayLocked() |
IMPORT_C CCoeControlArray * | NewL(CCoeControl &) |
IMPORT_C TInt | Remove(const CCoeControl *) |
IMPORT_C CCoeControl * | Remove(TCursor) |
IMPORT_C CCoeControl * | RemoveById(TInt) |
IMPORT_C TInt | Replace(CCoeControl *, CCoeControl *) |
IMPORT_C void | Reset() |
IMPORT_C void | ResetAndDestroy() |
IMPORT_C void | SetArrayLocked() |
IMPORT_C void | SetControlsOwnedExternally(TBool) |
IMPORT_C void | Sort(TLinearOrder< TCoeControlWithId >) |
IMPORT_C void | SortById() |
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.
Defines the possible events related to a change to the contents of the array.
Enumerator | Value | Description |
---|---|---|
EControlAdded |
A control has been added to the array | |
EControlRemoved |
A control has been removed from the array |
IMPORT_C | ~CCoeControlArray | ( | ) |
The destructor will delete the controls in the array only if the EControlsOwnedExternally flag is not set.
IMPORT_C TCursor | AppendLC | ( | CCoeControl * | aControl, |
TInt | aControlId = KCoeNoControlId | |||
) |
Appends a control at the end of the array.
Parameters | |
---|---|
aControl | The control to add |
aControlId | The id for the new control |
IMPORT_C TCoeControlWithId | At | ( | TInt | aIndex | ) |
Gets the element at the given index.
Parameters | |
---|---|
aIndex | The index of the control |
IMPORT_C const TCoeControlWithId | At | ( | TInt | aIndex | ) | const |
Gets the element at the given index.
Parameters | |
---|---|
aIndex | The index of the control |
T * | ControlById | ( | TInt | aControlId | ) |
Gets the control with the given id.
Parameters | |
---|---|
aControlId | The id of the desired control. |
const T * | ControlById | ( | TInt | aControlId | ) | const |
Gets the control with the given id.
Parameters | |
---|---|
aControlId | The id of the desired control. |
IMPORT_C TBool | ControlsOwnedExternally | ( | ) | 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.
IMPORT_C TInt | Count | ( | ) | const |
Gets the number of elements in the array.
IMPORT_C TCursor | End | ( | ) | 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.
IMPORT_C TCursor | Find | ( | 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 | |
---|---|
aControl | The control to find. |
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 | |
---|---|
aControlId | The id of the control to find. |
IMPORT_C TInt | Id | ( | const CCoeControl & | aControl | ) | const |
Gets the id of the control.
Parameters | |
---|---|
aControl | The control |
IMPORT_C TCursor | InsertAfterLC | ( | TInt | aInsertAfterId, |
CCoeControl * | aControl, | |||
TInt | aControlId = 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.
Parameters | |
---|---|
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. |
aControl | The new control we want to add. |
aControlId | The id of the new control. |
Leave Codes | |
---|---|
KErrLocked | if the array has been locked using the |
KErrNotFound | if the array doesn't contain a control identified by aInsertAfterId. |
IMPORT_C TCursor | InsertLC | ( | TCursor & | aInsertAt, |
CCoeControl * | aControl, | |||
TInt | aControlId = 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.
Parameters | |
---|---|
aInsertAt | The position at which we want to insert the new control. |
aControl | The new control we want to add. |
aControlId | The id of the new control. |
Leave Codes | |
---|---|
KErrLocked | if the array has been locked using the |
IMPORT_C TBool | IsArrayLocked | ( | ) | 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.
IMPORT_C CCoeControlArray * | NewL | ( | CCoeControl & | aOwner | ) | [static] |
Creates a new CCoeControlArray.
Parameters | |
---|---|
aOwner | The control that owns the new array |
IMPORT_C TInt | Remove | ( | 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 | |
---|---|
aControl | The control to remove |
IMPORT_C CCoeControl * | Remove | ( | TCursor | aRemoveAt | ) |
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 | |
---|---|
aRemoveAt | The position of the control to remove |
IMPORT_C CCoeControl * | RemoveById | ( | TInt | aControlId | ) |
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 | |
---|---|
aControlId | The id of the control to remove |
IMPORT_C TInt | Replace | ( | CCoeControl * | aOriginalControl, |
CCoeControl * | aNewControl | |||
) |
Replaces a control in the array with another control.
Parameters | |
---|---|
aOriginalControl | The control that must be replaced |
aNewControl | The new control |
IMPORT_C void | ResetAndDestroy | ( | ) |
Removes all the controls from the array and deletes them.
IMPORT_C void | SetArrayLocked | ( | ) |
Locks the array. If an array is locked any attempt to add or remove controls will fail with KErrLocked.
IMPORT_C void | SetControlsOwnedExternally | ( | TBool | aOwnedExternally | ) |
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 | |
---|---|
aOwnedExternally | ETrue if the controls are owned externally, EFalse if they are owned by the array. |
IMPORT_C void | Sort | ( | TLinearOrder< TCoeControlWithId > | aOrder | ) |
This function provides a pluggable implementation to sort the array of controls.
Parameters | |
---|---|
aOrder | The user defined static method which implements the algorithm for sorting. |