|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-89B12BB4-877E-4157-9BD1-81AD02EE3543" xml:lang="en"><title>Constructing |
|
13 the UI controller in the view architecture</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>The call on the first phase constructor method of the UI controller |
|
15 occurs in the <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknDocument.html" format="application/java-archive"><parmname>CAknDocument</parmname></xref>-derived |
|
16 class of application. For more information, see <xref href="GUID-07D2ED79-90B2-4ABC-A61F-108DAEE21955.dita">Implementing |
|
17 framework requirements</xref>.</p> |
|
18 <p>The methods you need to implement for your <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknViewAppUi.html" format="application/java-archive"><parmname>CAknViewAppUI</parmname></xref>-derived |
|
19 UI controller are as follows:</p> |
|
20 <ul> |
|
21 <li><p>C++ default constructor, which cannot contain any code that |
|
22 might leave. A common implementation is:</p> |
|
23 <itemgroup> |
|
24 <codeblock id="GUID-ED243BA0-4466-47F3-8F17-0A901EE29671" xml:space="preserve">CMyViewAppAppUi::CMyViewAppAppUi() |
|
25 { |
|
26 }</codeblock> |
|
27 <p>The class declaration for this constructor in the class header file |
|
28 needs to be public to support the construction method required.</p> |
|
29 </itemgroup> |
|
30 </li> |
|
31 <li><p>Symbian 2nd phase constructor with code that might leave. |
|
32 A common implementation is:</p> |
|
33 <itemgroup> |
|
34 <codeblock id="GUID-6665D735-D20A-4159-98B3-199BF15E7602" xml:space="preserve"> |
|
35 void CMyViewAppAppUi::ConstructL() |
|
36 { |
|
37 |
|
38 BaseConstructL(EAknEnableSkin); // Use EAknEnableSkin to make the application support themes. |
|
39 |
|
40 CMyViewAppView* view1 = CMyViewAppView::NewL(); |
|
41 |
|
42 AddViewL( view1 ); // transfer ownership to CAknViewAppAppUi |
|
43 iViewId1 = view1->Id(); // view id to get view from CAknViewAppAppUi |
|
44 |
|
45 |
|
46 CMyViewAppView2* view2 = CMyViewAppView2::NewL(); |
|
47 |
|
48 AddViewL( view2 ); // transfer ownership to CAknViewAppAppUi |
|
49 iViewId2 = view2->Id(); // view id to get view from CAknViewAppAppUi |
|
50 |
|
51 |
|
52 SetDefaultViewL( *view1 ); |
|
53 }</codeblock> |
|
54 <p><parmname>ConstructL</parmname> completes the construction of the object. |
|
55 It is a public constructor in the header file.</p> |
|
56 <p><xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknViewAppUi.html#ebd48f5819a517d45755391fd3497b3b" format="application/java-archive"><parmname>CAknViewAppUi::BaseConstructL</parmname></xref> initializes the application UI with necessary UI components |
|
57 , including status and control panes. <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknViewAppUi.html#ebd48f5819a517d45755391fd3497b3b" format="application/java-archive"><parmname>CAknViewAppUi::BaseConstructL</parmname></xref> can |
|
58 accept flags enumerated in <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/UIKON/CEikAppUiClass.html#%3a%3aCEikAppUi" format="application/java-archive"><parmname>CEikAppUi</parmname></xref> and <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknAppUi.html" format="application/java-archive"><parmname>CAknAppUi</parmname></xref>. |
|
59 In particular, the <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknAppUiBase.html#68986ab776eb5d6b5a809a1c005a73008d94047a388aa6a9fa6381f45d548ffe" format="application/java-archive"><parmname>CAknAppUi::EAknEnableSkin</parmname></xref> flag enables <xref href="GUID-A1DBE03F-728E-4F31-BE74-5BDA3906C8DD.dita">themes</xref> in |
|
60 the application.</p> |
|
61 <p><parmname>CMyViewAppView* view1 = CMyViewAppView::NewL()</parmname> is |
|
62 a two phase constructor for the <xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknView.html" format="application/java-archive"><parmname>CAknView</parmname></xref>-derived |
|
63 view controller.</p> |
|
64 <p><xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknViewAppUi.html#369fea4cfb57a7bf69ad843355a66d67" format="application/java-archive"><parmname>CAknViewAppUi::AddViewL</parmname></xref> registers and adds the view controller to the UI controller</p> |
|
65 <p><xref href="jar:GUID-759FBC7F-5384-4487-8457-A8D4B76F6AA6.jar!/html/classCAknView.html#71e3a172cd418a5d73071f598fe8d26d" format="application/java-archive"><parmname>iViewId1 |
|
66 = view1->Id()</parmname></xref> calls the view controller method that |
|
67 provides the UID of the view controller</p> |
|
68 <p><xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeAppUiClass.html#%3a%3aCCoeAppUi%3a%3aSetDefaultViewL%28const%20MCoeView%20%26amp%3b%29" format="application/java-archive"><parmname>CCoeAppUi::SetDefaultViewL</parmname></xref> registers a |
|
69 view as the default view of the application. The meaning of the default view |
|
70 varies depending on the UI. It is normally the view that is displayed when |
|
71 the application is launched. It may also be the view that is displayed when |
|
72 the application is brought to the foreground.</p> |
|
73 </itemgroup> |
|
74 </li> |
|
75 </ul> |
|
76 <p>You must implement other methods to support <xref href="GUID-E402616A-7ED8-45AC-B836-99C3A3760B33.dita">key |
|
77 event handling</xref>, <xref href="GUID-4941C035-C359-4968-9BD5-31F44EE5F810.dita">command |
|
78 handling</xref>, and other possible <xref href="GUID-EF7FF39E-929F-4767-B475-5D582D37BB32.dita">events</xref>, |
|
79 as well as overriding default <xref href="GUID-5918ED8A-B26B-41A0-94A6-AB6D51BF80A1.dita">control |
|
80 pane</xref> and status pane behavior.</p> |
|
81 <note> |
|
82 <p>Command, key event, and layout change support handling can take place |
|
83 at least partially in the view controller.</p> |
|
84 </note> |
|
85 <section id="GUID-4AA4BB6F-9331-4196-91F5-A3FF479667B2"><title>Scalability</title> |
|
86 <p>If you wish to support <xref href="GUID-B02C762B-C452-4184-ABEA-4753E6CD47D2.dita">scalability</xref> in |
|
87 your application, then you need to implement <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/UIKON/CEikAppUiClass.html#%3a%3aCEikAppUi%3a%3aHandleResourceChangeL%28%29" format="application/java-archive"><parmname>CEikAppUi::HandleResourceChangeL</parmname></xref> in the UI controller , and then a <parmname>HandleClientRectChangeL</parmname> method |
|
88 in the view controller.</p> |
|
89 <p> A common implementation is:</p> |
|
90 <codeblock id="GUID-ADB8DC30-EFF6-4F66-B418-78FD90A1B568" xml:space="preserve">void CMyViewAppAppUi::HandleResourceChangeL( TInt aType ) |
|
91 { |
|
92 CAknAppUi::HandleResourceChangeL( aType ); |
|
93 |
|
94 |
|
95 if ( aType==KEikDynamicLayoutVariantSwitch ) |
|
96 { |
|
97 ((CMyViewAppView*) View( iViewId1) )->HandleClientRectChange( ); |
|
98 ((CMyViewAppView2*) View( iViewId2) )->HandleClientRectChange( ); |
|
99 } |
|
100 |
|
101 } </codeblock> |
|
102 <p>, where</p> |
|
103 <p><xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/UIKON/CEikAppUiClass.html#%3a%3aCEikAppUi%3a%3aHandleResourceChangeL%28%29" format="application/java-archive"><parmname>CEikAppUi::HandleResourceChangeL</parmname></xref> is a <xref href="GUID-DD15F24B-0786-4531-A6C5-A5E70EBE2732.dita">layout change event method</xref>.</p> |
|
104 <p><parmname>HandleClientRectChangeL</parmname> is a method in the view |
|
105 controller for passing the change onto to the control</p> |
|
106 </section> |
|
107 </conbody></concept> |