diff -r 48780e181b38 -r 578be2adaf3e Symbian3/PDK/Source/GUID-57CA8A13-05C6-4AFE-9804-E2EA2453143A.dita --- a/Symbian3/PDK/Source/GUID-57CA8A13-05C6-4AFE-9804-E2EA2453143A.dita Tue Jul 20 12:00:49 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-57CA8A13-05C6-4AFE-9804-E2EA2453143A.dita Fri Aug 13 16:47:46 2010 +0100 @@ -1,107 +1,107 @@ - - - - - -Compound -controls in the view architecture -

Compound controls are -controls that contain other controls. To create a compound control, you must -do the following:

- -

CCoeControl* CContainerContainer::ComponentControl(TInt aIndex) and CCoeControl::CountComponentControls() work in conjunction with each other. The Symbian platform can query the -control as to how many components it has and then request a pointer to each -of the component's controls. Controls can be added or removed at run time -using these two methods. The framework uses this information to draw the container.

-

The compound control usually owns the child controls and therefore it -is responsible of their construction and destruction. The compound control -should also set the positions and sizes of its child controls; it must ensure -that all child controls are inside the compound control rectangle and visible -child rectangles do not overlap each other.

+ + + + + +Compound +controls in the view architecture +

Compound controls are +controls that contain other controls. To create a compound control, you must +do the following:

+
    +
  • construct the control in the parent control (that owns the +window in which the child control appears). An example of an implementation +is as follows:

    + +void CMyViewContainer::ConstructL(const TRect& aRect) + { + CreateWindowL(); + + iLabel = new (ELeave) CEikLabel; + iLabel->SetContainerWindowL( *this ); + iLabel->SetTextL( _L("MyView 1\n\nSelect local view\nswitching from menu") ); + + SetRect(aRect); + ActivateL(); + } +

    , where

    +

    iLabel = new (ELeave) CEikLabel; creates a CEikLabel class +that supports the display of text in the parent window.

    +

    CCoeControl::SetContainerWindowL() assigns the non-window-owning +control to the window-owning control.

    +

    CEikLabel::SetTextL() sets a text for the label.

    +

    The other methods are the standard methods for creating a window for +the window-owning control.

    +
    +
  • +
  • add a method to the owning control that returns the number +of controls in the compound control. An example of an implementation is as +follows:

    + +TInt CMyViewAppContainer::CountComponentControls() const + { + return KNumberOfControls; // return nbr of controls inside this compound control + } +

    , where

    +

    CMyViewAppContainer::CountComponentControls() overrides CCoeControl::CountComponentControls() to +return the number of controls in the compound control.

    +

    KNumberOfControls is a TInt constant +for the number of controls in the application. Other approaches could be used.

    +
    +
  • +
  • Add a method to the owning control that returns each of the +controls by a zero-based index. An example of an implementation is as follows:

    + +CCoeControl* CContainerContainer::ComponentControl( + TInt aIndex) const + { + switch ( aIndex ) + { + case 0: + return iLabel; // return a pointer to the + //iLabel + default: + return NULL; + } + } + +

    , where

    +

    CCoeControl* CContainerContainer::ComponentControl(TInt aIndex) gets +an indexed component of a compound control. There are 2 ways to implement +a compound control:

    +
      +
    • override the function.

    • +
    +
      +
    • use the CCoeControlArray functionality +(see the CCoeControl::InitComponentArrayL() method).

      +
    • +
    + +

    Within a compound control, each component control is identified by +an index, where the index depends on the order the controls were added: the +first is given an index of 0, the next an index of 1, +and so on.

    +
    +

    All child controls should be accessible by CCoeControl::ComponentControl() at +any time, regardless of whether they are visible or not. The visibility of +a control should be adjusted using the CCoeControl::MakeVisible() method.

    +
    +
  • +
+

CCoeControl* CContainerContainer::ComponentControl(TInt aIndex) and CCoeControl::CountComponentControls() work in conjunction with each other. The Symbian platform can query the +control as to how many components it has and then request a pointer to each +of the component's controls. Controls can be added or removed at run time +using these two methods. The framework uses this information to draw the container.

+

The compound control usually owns the child controls and therefore it +is responsible of their construction and destruction. The compound control +should also set the positions and sizes of its child controls; it must ensure +that all child controls are inside the compound control rectangle and visible +child rectangles do not overlap each other.

\ No newline at end of file