Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
<?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 task
PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-A399508A-DE6A-490D-9BFB-4FCF56FF9D4C" xml:lang="en"><title>Derive
a class from the MCoeView class</title><prolog><metadata><keywords/></metadata></prolog><taskbody>
<context> <p>Derive a class from the <codeph>MCoeView</codeph> class
and provide the definition for each of the following functions:</p><ul>
<li><p><codeblock xml:space="preserve">TVwsViewId ViewId() const</codeblock></p><p>This function
defines the unique identifier of the view within the given application.</p></li>
</ul><ul>
<li><p><codeblock xml:space="preserve">void ViewActivatedL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage)</codeblock></p><p>This is the function is called by the operating system when a view is activated.
The call gets several arguments: the view ID of the previous view that was
displayed (in case a switch back to it is desired), and the identifier and
text of a message that comes from the process that is activating the view.
This message can convey specialized information, such as information on what
to display, from the activating process.</p></li>
</ul><ul>
<li><p><codeblock xml:space="preserve">void ViewDeactivated()</codeblock></p><p>This function is
called by the operating system when a view is deactivated. </p></li>
</ul><ul>
<li><p><codeblock xml:space="preserve">TVwsViewIdAndMessage ViewScreenDeviceChangedL()</codeblock></p><p>This
function has a default implementation. It handles a change to the screen device
returning the value of the <codeph>TVwsViewIdAndMessage</codeph> object. By
default, returns the ID of the active view.</p><p>Cone provides a default
screen device change handler <codeph>CCoeScreenDeviceChangeDefaultHandler</codeph>. <codeph>CCoeScreenDeviceChangeDefaultHandler</codeph> handles
any screen device changes that occur while a view is active. It is used to
activate a default view when a screen flip (changing the screen orientation,
for example, landscape to portrait) occurs, if the currently active view does
not implement <codeph>MCoeView::ViewScreenDeviceChangedL()</codeph>.</p></li>
</ul><p>The following code snippet shows deriving a class from <codeph>MCoeView</codeph> and
implementing the required functions:</p><codeblock xml:space="preserve">class CNewView : public MCoeView
{
public:
//construction
CNewView( const TVwsViewId& aViewId, CCoeAppUi& aAppUi );
void ConstructL();
~CNewView();
private:
// From MCoeView class
void ViewActivatedL( const TVwsViewId& aPrevViewId,
TUid aCustomMessageId,
const TDesC8& aCustomMessage );
void ViewDeactivated();
TVwsViewIdAndMessage ViewScreenDeviceChangedL();
void ViewConstructL();
private:
CCoeAppUi& iCCoeAppUi;
TVwsViewId& iViewId;
};
</codeblock></context>
</taskbody></task>