|
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-FC63E2D1-697C-4890-9B70-0DC0AAE7597C" xml:lang="en"><title>Switching |
|
13 views in traditional architecture</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>If the application contains multiple views and they need to be switched, |
|
15 it can be done in various ways. One of the common ways is to delete the current |
|
16 view, create a new view, and add the new one to the control stack. Here, <parmname>CMyAppUi</parmname> has |
|
17 a custom method to change a view. Often a more generic approach should be |
|
18 favored, but for simplicity the basic idea could be as follows:</p> |
|
19 <codeblock id="GUID-CEEB1B52-944E-4C2D-A9A9-AB1D55559234" xml:space="preserve">void CMyAppUi::ChangeToView2L() |
|
20 { |
|
21 CCoeControl* newView = CMyAppView2::NewL(ClientRect()); |
|
22 if(iCurrentView) |
|
23 { |
|
24 RemoveFromStack(iCurrentView); |
|
25 delete iCurrentView; |
|
26 } |
|
27 iCurrentView = newView; |
|
28 AddToStackL(iCurrentView); |
|
29 } |
|
30 </codeblock> |
|
31 <p>Although this architecture provides the most flexible way of manipulating |
|
32 different views, the <xref href="GUID-68B999C2-0993-4804-9624-42C3D88BE5C7.dita">view |
|
33 architecture</xref> should be considered. Among other things, it provides |
|
34 a ready framework for doing the essentials in view switching.</p> |
|
35 </conbody></concept> |