Symbian3/PDK/Source/GUID-97486385-88F7-4AF1-B880-D9A8AA4D7094.dita
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 14 578be2adaf3e
equal deleted inserted replaced
4:4816d766a08a 5:f345bda72bc4
    13 controls in traditional architecture</title><prolog><metadata><keywords/></metadata></prolog><conbody>
    13 controls in traditional architecture</title><prolog><metadata><keywords/></metadata></prolog><conbody>
    14 <p><xref href="GUID-352850A9-227F-45DB-8DCD-C6268954B4ED.dita">Compound controls</xref> are
    14 <p><xref href="GUID-352850A9-227F-45DB-8DCD-C6268954B4ED.dita">Compound controls</xref> are
    15 controls that contain other controls. To create a compound control, you must
    15 controls that contain other controls. To create a compound control, you must
    16 do the following:</p>
    16 do the following:</p>
    17 <ul>
    17 <ul>
    18 <li><p>construct the control in the parent control, which is the
    18 <li><p>construct the control in the parent control (main control
    19 control that owns the window in which the control appears. The control should
    19 that owns the window in which the child control appears). The control should
    20 be constructed in the constructor for the window. An example of an implementation
    20 be constructed in the constructor for the window. An example of an implementation
    21 is as follows:</p>
    21 is as follows:</p>
    22 <itemgroup>
    22 <itemgroup>
    23 <codeblock id="GUID-F5320B9F-2CC1-4190-B75A-AF303DC5EB8B" xml:space="preserve">void CMyViewContainer::ConstructL(const TRect&amp; aRect)
    23 <codeblock id="GUID-F5320B9F-2CC1-4190-B75A-AF303DC5EB8B" xml:space="preserve">void CMyViewContainer::ConstructL(const TRect&amp; aRect)
    24     {
    24     {
    30 
    30 
    31     SetRect(aRect);
    31     SetRect(aRect);
    32     ActivateL();
    32     ActivateL();
    33     }</codeblock>
    33     }</codeblock>
    34 <p>, where</p>
    34 <p>, where</p>
    35 <p><parmname>iLabel = new (ELeave) CEikLabel;</parmname> creates a <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCEikLabel.html" format="application/java-archive"><parmname>CEikLabel</parmname></xref> object,
    35 <p><parmname>iLabel = new (ELeave) CEikLabel;</parmname> creates a <xref href="GUID-086B6DC9-E348-39C8-A9CB-686383CEA6EF.dita"><apiname>CEikLabel</apiname></xref> object,
    36 which is a class that supports the display of text in the parent window.</p>
    36 which is a class that supports the display of text in the parent window.</p>
    37 <p><xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aSetContainerWindowL%28const%20CCoeControl%20%26amp%3b%29" format="application/java-archive"><parmname>CCoeControl::SetContainerWindowL</parmname></xref> makes
    37 <p><xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-A39BAD7E-BAF2-3A4B-BE4F-2A86718EB190"><apiname>CCoeControl::SetContainerWindowL()</apiname></xref> makes the <xref href="GUID-352850A9-227F-45DB-8DCD-C6268954B4ED.dita">non-window-owning control</xref> a
    38 the <xref href="GUID-352850A9-227F-45DB-8DCD-C6268954B4ED.dita">non-window-owning
    38 child of the window-owning control.</p>
    39 control</xref> a child of the window-owning control.</p>
    39 <p><xref href="GUID-086B6DC9-E348-39C8-A9CB-686383CEA6EF.dita#GUID-086B6DC9-E348-39C8-A9CB-686383CEA6EF/GUID-879C7EC4-EDE0-3E2E-A827-CEAFB84154F7"><apiname>CEikLabel::SetTextL()</apiname></xref> sets a text for the label</p>
    40 <p><xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCEikLabel.html#bcf1d51ebf4177465387f76584078f0c" format="application/java-archive"><parmname>CEikLabel::SetTextL</parmname></xref> sets a text for the label</p>
       
    41 <p>The other methods are the standard methods for creating a window for
    40 <p>The other methods are the standard methods for creating a window for
    42 the window-owning control.</p>
    41 the window-owning control.</p>
    43 </itemgroup>
    42 </itemgroup>
    44 </li>
    43 </li>
    45 <li><p>add a method to the owning control that returns the number
    44 <li><p>add a method to the owning control that returns the number
    49 <codeblock id="GUID-73DD2770-41FC-4B29-AA8A-4B9010654B64" xml:space="preserve">TInt CMyViewAppContainer::CountComponentControls() const
    48 <codeblock id="GUID-73DD2770-41FC-4B29-AA8A-4B9010654B64" xml:space="preserve">TInt CMyViewAppContainer::CountComponentControls() const
    50     {
    49     {
    51     return KNumberOfControls; // return nbr of controls inside this compound control
    50     return KNumberOfControls; // return nbr of controls inside this compound control
    52     }</codeblock>
    51     }</codeblock>
    53 <p>, where</p>
    52 <p>, where</p>
    54 <p><parmname>CMyViewAppContainer::CountComponentControls()</parmname> overrides <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aCountComponentControls%28%29const" format="application/java-archive"><parmname>CCoeControl::CountComponentControls</parmname></xref> to
    53 <p><parmname>CMyViewAppContainer::CountComponentControls()</parmname> overrides <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-6F8D41E5-9B2C-3CEB-9F2F-9E2567D5BE39"><apiname>CCoeControl::CountComponentControls()</apiname></xref> to
    55 return the number of controls in the compound control</p>
    54 return the number of controls in the compound control</p>
    56 <p><parmname>KNumberOfControls</parmname> is a <parmname>TInt</parmname> constant
    55 <p><parmname>KNumberOfControls</parmname> is a <parmname>TInt</parmname> constant
    57 for the number of controls in the application. Other approaches could be used.</p>
    56 for the number of controls in the application. Other approaches could be used.</p>
    58 </itemgroup>
    57 </itemgroup>
    59 </li>
    58 </li>
    75 </codeblock>
    74 </codeblock>
    76 <p>, where</p>
    75 <p>, where</p>
    77 <p><parmname>CCoeControl* CContainerContainer::ComponentControl(TInt aIndex)</parmname> gets
    76 <p><parmname>CCoeControl* CContainerContainer::ComponentControl(TInt aIndex)</parmname> gets
    78 an indexed component of a compound control.  There are two ways to implement
    77 an indexed component of a compound control.  There are two ways to implement
    79 a compound control. One way is to override this function. The other way is
    78 a compound control. One way is to override this function. The other way is
    80 to use the <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlArrayClass.html#_top%20title=" format="application/java-archive"><parmname>CCoeControlArray</parmname></xref> functionality (see the <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aInitComponentArrayL%28%29" format="application/java-archive"><parmname>CCoeControl::InitComponentArrayL</parmname></xref> method).
    79 to use the <xref href="GUID-2D8BFBA2-79AC-364D-875D-E863CD4A2FE1.dita"><apiname>CCoeControlArray</apiname></xref> functionality (see the <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-40A8481A-F12C-3A5A-B84A-710301940585"><apiname>CCoeControl::InitComponentArrayL()</apiname></xref> method).
    81  </p>
    80  </p>
    82 <note>
    81 <note>
    83 <p>Within a compound control, each component control is identified by an
    82 <p>Within a compound control, each component control is identified by an
    84 index. </p>
    83 index. </p>
    85 </note>
    84 </note>
    86 <p>All child controls should be accessible by <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aComponentControl%28TInt%29const" format="application/java-archive"><parmname>CCoeControl::ComponentControl</parmname></xref> at any time, regardless
    85 <p>All child controls should be accessible by <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-B727C7DA-6DEF-339D-A31E-A292BD800A3B"><apiname>CCoeControl::ComponentControl()</apiname></xref> at
    87 of whether they are visible or not. You can adjust the visibility of a control
    86 any time, regardless of whether they are visible or not. You can adjust the
    88 using the <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aMakeVisible%28TBool%29" format="application/java-archive"><parmname>CCoeControl::MakeVisible</parmname></xref> method.</p>
    87 visibility of a control using the <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-159A51CE-4AEF-367B-9182-F33489D08BE2"><apiname>CCoeControl::MakeVisible()</apiname></xref> method.</p>
    89 </itemgroup>
    88 </itemgroup>
    90 </li>
    89 </li>
    91 </ul>
    90 </ul>
    92 <p><parmname>CCoeControl* CContainerContainer::ComponentControl(TInt aIndex)</parmname> and <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aCountComponentControls%28%29const" format="application/java-archive"><parmname>CCoeControl::CountComponentControls</parmname></xref> work
    91 <p><parmname>CCoeControl* CContainerContainer::ComponentControl(TInt aIndex)</parmname> and <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-6F8D41E5-9B2C-3CEB-9F2F-9E2567D5BE39"><apiname>CCoeControl::CountComponentControls()</apiname></xref> work in conjunction with each other. The Symbian platform can query the
    93 in conjunction with each other. The Symbian platform can query the control
    92 control as to how many components it has and then request a pointer to each
    94 as to how many components it has and then request a pointer to each of the
    93 of the component's controls. Controls can be added or removed at run time
    95 component's controls. Controls can be added or removed at run time using these
    94 using these two methods. The framework uses this information to draw the container. </p>
    96 two methods. The framework uses this information to draw the container. </p>
       
    97 <p>The compound control usually owns the child controls and therefore it
    95 <p>The compound control usually owns the child controls and therefore it
    98 is responsible of their construction and destruction. The compound control
    96 is responsible of their construction and destruction. The compound control
    99 should also set the positions and sizes of its child controls; it must ensure
    97 should also set the positions and sizes of its child controls; it must ensure
   100 that all child controls are inside the compound control rectangle and visible
    98 that all child controls are inside the compound control rectangle and visible
   101 child rectangles do not overlap each other.</p>
    99 child rectangles do not overlap each other.</p>