Derive a class from the MCoeView
class
and provide the definition for each of the following functions:
TVwsViewId ViewId() const
This function defines the unique identifier of the view within the given application.
void ViewActivatedL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId,const TDesC8& aCustomMessage)
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.
void ViewDeactivated()
This function is called by the operating system when a view is deactivated.
TVwsViewIdAndMessage ViewScreenDeviceChangedL()
This
function has a default implementation. It handles a change to the screen device
returning the value of the TVwsViewIdAndMessage
object. By
default, returns the ID of the active view.
Cone provides a default
screen device change handler CCoeScreenDeviceChangeDefaultHandler
. CCoeScreenDeviceChangeDefaultHandler
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 MCoeView::ViewScreenDeviceChangedL()
.
The following code snippet shows deriving a class from MCoeView
and
implementing the required functions:
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; };