Symbian3/PDK/Source/GUID-BE871265-147B-45F3-8772-A4E091223EDB.dita
changeset 5 f345bda72bc4
parent 3 46218c8b8afa
child 9 59758314f811
equal deleted inserted replaced
4:4816d766a08a 5:f345bda72bc4
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    12 <concept id="GUID-BE871265-147B-45F3-8772-A4E091223EDB" xml:lang="en"><title>Constructing
    12 <concept id="GUID-BE871265-147B-45F3-8772-A4E091223EDB" xml:lang="en"><title>Constructing
    13 views in traditional architecture</title><prolog><metadata><keywords/></metadata></prolog><conbody>
    13 views in traditional architecture</title><prolog><metadata><keywords/></metadata></prolog><conbody>
    14 <p>The call on the first phase constructor method of the view occurs in <xref href="GUID-FD2CDEB8-0784-4BE5-A775-170F57D71BBC.dita">UI controller</xref>. The
    14 <p>The call on the first phase constructor method of the view occurs in <xref href="GUID-FD2CDEB8-0784-4BE5-A775-170F57D71BBC.dita">UI controller</xref>. The
    15 view serves as the top-level window under the UI controller.</p>
    15 view serves as the top-level window under the UI controller.</p>
    16 <p>The methods you need to implement for your <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html" format="application/java-archive"><parmname>CCoeControl</parmname></xref>-derived
    16 <p>The methods you need to implement for your <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita"><apiname>CCoeControl</apiname></xref>-derived
    17 view are as follows:</p>
    17 view are as follows:</p>
    18 <ul>
    18 <ul>
    19 <li><p>C++ default constructor, which cannot contain code that leaves.
    19 <li><p>C++ default constructor, which cannot contain code that leaves.
    20 A common implementation is:</p>
    20 A common implementation is:</p>
    21 <itemgroup>
    21 <itemgroup>
    44     CleanupStack::PushL( self );
    44     CleanupStack::PushL( self );
    45     self-&gt;ConstructL( aRect );
    45     self-&gt;ConstructL( aRect );
    46     return self;
    46     return self;
    47     }
    47     }
    48 </codeblock>
    48 </codeblock>
    49 <p>The declarations for <parmname>CMyAppView::NewL</parmname> and <parmname>CMyAppView::NewLC</parmname> in
    49 <p>The declarations for <parmname>CMyAppView::NewL()</parmname> and <parmname>CMyAppView::NewLC</parmname> in
    50 the class header file needs to be public to support the construction method
    50 the class header file needs to be public to support the construction method
    51 required. <parmname>CMyAppView</parmname> is the default constructor for the <parmname>CMyAppView</parmname> class
    51 required. <parmname>CMyAppView</parmname> is the default constructor for the <parmname>CMyAppView</parmname> class
    52 and it is private.</p>
    52 and it is private.</p>
    53 <p>In this approach, <parmname>CMyAppView::NewL</parmname> is called from
    53 <p>In this approach, <parmname>CMyAppView::NewL()</parmname> is called
    54 the UI controller. It creates a view object by calling <parmname>CMyAppView::NewLC</parmname>. <parmname>CMyAppView::NewLC</parmname> calls
    54 from the UI controller. It creates a view object by calling <parmname>CMyAppView::NewLC()</parmname>. <parmname>CMyAppView::NewLC()</parmname> calls
    55 new (<parmname>ELeave</parmname>) on the C++ default constructor <parmname>CMyAppView</parmname> to
    55 new (<parmname>ELeave</parmname>) on the C++ default constructor <parmname>CMyAppView</parmname> to
    56 create the object (and leave if it cannot), <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Kernel_Architecture_2/CCleanupClass.html#%3a%3aCCleanup%3a%3aPushL%28CBase%20%2a%29" format="application/java-archive">pushes</xref> a pointer to the clean-up stack in case the second phase construction method
    56 create the object (and leave if it cannot), <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Kernel_Architecture_2/CCleanupClass.html#%3a%3aCCleanup%3a%3aPushL%28CBase%20%2a%29" format="application/java-archive">pushes</xref> a pointer to the clean-up stack in case the second phase construction method
    57 leaves, and then calls the second phase construction method of the object.
    57 leaves, and then calls the second phase construction method of the object.
    58 When it returns to <parmname>CMyAppView::NewL</parmname>, the pointer pushed
    58 When it returns to <parmname>CMyAppView::NewL()</parmname>, the pointer pushed
    59 to the cleanup stack is <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Kernel_Architecture_2/CCleanupClass.html#%3a%3aCCleanup%3a%3aPop%28%29" format="application/java-archive">removed</xref>.</p>
    59 to the cleanup stack is <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Kernel_Architecture_2/CCleanupClass.html#%3a%3aCCleanup%3a%3aPop%28%29" format="application/java-archive">removed</xref>.</p>
    60 </itemgroup>
    60 </itemgroup>
    61 </li>
    61 </li>
    62 <li><p>Symbian 2nd phase constructor with code that might leave.
    62 <li><p>Symbian 2nd phase constructor with code that might leave.
    63 A common implementation is:</p>
    63 A common implementation is:</p>
    73     SetRect( aRect );
    73     SetRect( aRect );
    74 
    74 
    75     // Activate the window, which makes it ready to be drawn
    75     // Activate the window, which makes it ready to be drawn
    76     ActivateL();
    76     ActivateL();
    77     }</codeblock>
    77     }</codeblock>
    78 <p><parmname>CMyAppView::ConstructL</parmname> is a private class providing
    78 <p><parmname>CMyAppView::ConstructL()</parmname> is a private class providing
    79 the second phase construction that accepts the rectangle the view is drawn
    79 the second phase construction that accepts the rectangle the view is drawn
    80 to.</p>
    80 to.</p>
    81 <p><xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aCreateWindowL%28%29" format="application/java-archive"><parmname>CCoeControl::CreateWindowL</parmname></xref> creates a window
    81 <p><xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-03CC715F-11D8-39B1-875D-F4589BC9681E"><apiname>CCoeControl::CreateWindowL()</apiname></xref> creates a window for
    82 for the control. Note that this window is a child of the UI controller. This
    82 the control. Note that this window is a child of the UI controller. This method
    83 method makes the control a <xref href="GUID-352850A9-227F-45DB-8DCD-C6268954B4ED.dita">window-owning
    83 makes the control a <xref href="GUID-352850A9-227F-45DB-8DCD-C6268954B4ED.dita">window-owning
    84 control</xref>. While the use of window-owning controls is generally discouraged
    84 control</xref>. While the use of window-owning controls is generally discouraged
    85 to prevent the taxing of run-time resources, this is the top-level window
    85 to prevent the taxing of run-time resources, this is the top-level window
    86 for the UI controller.</p>
    86 for the UI controller.</p>
    87 <p>This is a simple control that does not contain other controls; other
    87 <p>This is a simple control that does not contain other controls; other
    88 controls could be added to the control between <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aCreateWindowL%28%29" format="application/java-archive"><parmname>CCoeControl::CreateWindowL</parmname></xref> and <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aSetRect%28const%20TRect%20%26amp%3b%29" format="application/java-archive"><parmname>CCoeControl::SetRect(aRect)</parmname></xref>. For more information,
    88 controls could be added to the control between <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-03CC715F-11D8-39B1-875D-F4589BC9681E"><apiname>CCoeControl::CreateWindowL()</apiname></xref> and <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-AC806401-86C7-308A-9D18-39085CB8D877"><apiname>CCoeControl::SetRect(aRect)</apiname></xref>.
    89 see <xref href="GUID-97486385-88F7-4AF1-B880-D9A8AA4D7094.dita">Compound
    89 For more information, see <xref href="GUID-97486385-88F7-4AF1-B880-D9A8AA4D7094.dita">Compound
    90 controls in traditional architecture</xref>.</p>
    90 controls in traditional architecture</xref>.</p>
    91 <p><xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aSetRect%28const%20TRect%20%26amp%3b%29" format="application/java-archive"><parmname>CCoeControl::SetRect(aRect)</parmname></xref> sets the window
    91 <p><xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-AC806401-86C7-308A-9D18-39085CB8D877"><apiname>CCoeControl::SetRect(aRect)</apiname></xref> sets the window size
    92 size according to the requirements of the mobile device. The top-level control
    92 according to the requirements of the mobile device. The top-level control
    93 rectangle is set to the area that the framework provides for the application.
    93 rectangle is set to the area that the framework provides for the application.
    94 Calling <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aSetRect%28const%20TRect%20%26amp%3b%29" format="application/java-archive"><parmname>CCoeControl::SetRect(aRect)</parmname></xref> calls the <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aSizeChanged%28%29" format="application/java-archive"><parmname>CCoeControl::SizeChanged</parmname></xref> method, where
    94 Calling <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-AC806401-86C7-308A-9D18-39085CB8D877"><apiname>CCoeControl::SetRect(aRect)</apiname></xref> calls the <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-9D6A2C52-DCE0-3490-BDA1-323406B7FBCF"><apiname>CCoeControl::SizeChanged()</apiname></xref> method,
    95 the control should set the position and size for any child controls and thus
    95 where the control should set the position and size for any child controls
    96 adjust the control layout to the UI.</p>
    96 and thus adjust the control layout to the UI.</p>
    97 <p><xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aActivateL%28%29" format="application/java-archive"><parmname>CCoeControl::ActivateL</parmname></xref> sets the control
    97 <p><xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-C79D0B6F-C2D7-3F22-A62B-88762092E869"><apiname>CCoeControl::ActivateL()</apiname></xref> sets the control as ready
    98 as ready to be drawn.</p>
    98 to be drawn.</p>
    99 </itemgroup>
    99 </itemgroup>
   100 </li>
   100 </li>
   101 </ul>
   101 </ul>
   102 <p>If required for your application, you may need to implement other methods
   102 <p>If required for your application, you may need to implement other methods
   103 for your control. For top-level windows, you would need to implement <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aSizeChanged%28%29" format="application/java-archive"><parmname>CCoeControl::SizeChanged</parmname></xref>  to respond to
   103 for your control. For top-level windows, you would need to implement <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-9D6A2C52-DCE0-3490-BDA1-323406B7FBCF"><apiname>CCoeControl::SizeChanged()</apiname></xref> 
   104 changes to the size and position of the contents of this control. This is
   104 to respond to changes to the size and position of the contents of this control.
   105 called by the platform when a change occurs. A typical implementation for
   105 This is called by the platform when a change occurs. A typical implementation
   106 a compound control is:</p>
   106 for a compound control is:</p>
   107 <codeblock id="GUID-A100010E-DF65-4EB7-AC5D-707604805976" xml:space="preserve">void CMyAppView::SizeChanged()
   107 <codeblock id="GUID-A100010E-DF65-4EB7-AC5D-707604805976" xml:space="preserve">void CMyAppView::SizeChanged()
   108     {
   108     {
   109     // Control resize code
   109     // Control resize code
   110     iControl-&gt;SetExtent( const TPoint &amp;aPosition, const TSize &amp;aSize);
   110     iControl-&gt;SetExtent( const TPoint &amp;aPosition, const TSize &amp;aSize);
   111     }</codeblock>
   111     }</codeblock>