Symbian3/SDK/Source/GUID-DFDDF0C5-0E66-4394-A746-7FE35EEA4E6A.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-DFDDF0C5-0E66-4394-A746-7FE35EEA4E6A" xml:lang="en"><title>Switching
views in the view architecture</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-5D19303A-8318-4F7B-84CF-FAAE630225FD"><title>Local switching</title>
<p>To switch between views within an application, you can use <xref href="GUID-26F8606A-0803-3693-A022-3BB620D64C0E.dita#GUID-26F8606A-0803-3693-A022-3BB620D64C0E/GUID-BA4DF836-625E-3AE6-8538-8B1C5A36900B"><apiname>CAknViewAppUI::ActivateLocalViewL()</apiname></xref>.</p>
<p>An example implementation of switching between views in an application
as a result of <xref href="GUID-4941C035-C359-4968-9BD5-31F44EE5F810.dita">command
handling</xref> is as follows:</p>
<codeblock id="GUID-4CC3D27C-CB0B-4BF2-AFEB-13CC054D509A" xml:space="preserve">case EMyViewAppCmdView1Cmd1:
            {
            // Switch to view 2            
            AppUi()-&gt;ActivateLocalViewL(KView2Id);
            break;</codeblock>
<p>, where <parmname>KView2Id</parmname> is the UID for view 2 in the application,
and is defined in another header filer in the application.</p>
<p>A new view is activated first and the previous view is deactivated after
that. This allows quick view switching to take place. When deactivating, all
controls, including menus and dialogs, are also closed down.</p>
<p>Each view may have its own menu system as defined in the <xref href="GUID-B238952B-1691-49F4-B8B9-9F755011A7DD.dita"><parmname>AVKON_VIEW</parmname> resource</xref> structure. However, if the menu system owned by the application
is to be used, its contents must be updated for the new view prior to switching.</p>
<p>An example implementation is as follows:</p>
<codeblock id="GUID-508F9B8E-7C24-4E8B-91FA-F0E596B91A29" xml:space="preserve">// Switch to a new menu system for the new view.
iEikonEnv-&gt;AppUiFactory()-&gt;MenuBar()-&gt;
    SetMenuTitleResourceId(R_MY_VIEW_ARCH_APP_VIEW2_MENU);
// Now switch the view to view 2
iAvkonViewAppUi-&gt;ActivateLocalViewL(TUid::KView2Id);
</codeblock>
</section>
<section id="GUID-A8098599-D103-4DB6-B7BE-1E01AF10B88A"><title>Remote switching</title>
<p>In remote view switching, an application initiates the remote target
application to change its view. If the application is not running, it is started.</p>
<p>In the application, call the <xref href="GUID-3AC2CDAC-0291-309F-A020-049BC9F2CF90.dita#GUID-3AC2CDAC-0291-309F-A020-049BC9F2CF90/GUID-013EC4FB-9B9D-352A-B3F5-9C37B4458032"><apiname>CCoeAppUi::ActivateViewL()</apiname></xref> function,
giving <xref href="GUID-3DEA9A17-CB50-3DCD-87AC-0E91B377FB0E.dita"><apiname>TVwsViewId</apiname></xref> containing the target application’s UID
and the target view UID. </p>
<p>Optionally, if the remote application view requires, give a message
ID and the descriptor data, which the view needs for its initialization. The
remote application view documentation publishes the required parameters.</p>
<p>Note that the calling and target application are independent of each
other. When the target application exits, it will not exit the calling application.
Also, when the calling client exits after switching the remote view of the
target application, it will not exit the target application.</p>
<p>Remote view switching is a one-way request through the application framework
from a calling application to a target application. The caller can send data,
but the target application cannot pass data back through the framework. Of
course, the calling application may pass a file path, which could be used
for data exchange.</p>
</section>
</conbody></concept>