This page was last modified 18:46, 24 June 2008.
S60 application views
From Forum Nokia Wiki
Introduction to S60 View Structure
View architecture is widely used in application development in the S60 platform. A GUI application can create several views and display different application data or UI controls in each view. Each view has its own control stack. Each view’s container and controls are created when it is called forward, and destroyed when another view of the same application is called forward. When activating a view, a message ID and a message can be passed. This provides a great deal of functionality that you can build and use in existing applications.
View Architecture Overview
In the AppUi class of a traditional Eikon GUI application, you create the container class, which creates all the controls. In a view architecture GUI application, you create a view class, derived from CAknView in the AppUi, which is derived from CAknViewAppUi. CAknViewAppUi adds view-handling methods to CAknAppUi. The activation and deactivation of a view are handled in the view class. This is done in the functions DoActivateL() and DoDeActivateL(). In these functions the container class is created and destroyed. The container class in turn creates and destroys the controls in the container.
Switching Views
To switch to a view within your application, you can use the AppUi class method ActivateLocalViewL(). The parameter for ActivateLocalViewL() is a TUid. The following is an example of view switching:
const TUid KDemo1ViewId = { 1 }; // UID of the first view
ActivateLocalViewL(KDemo1ViewId); // activate view 1
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. System dialogs automatically handle this. If you need to save data in your dialog when the dialog is open but the view is being shut down, you need to save the data when handling EAknSoftkeyCancel. In these cases Cancel/back route in the dialog is followed.
Sending Messages
ActivateLocalViewL() has been overloaded to include MessageUid and a message. MessageUid is a TUid and it is usually used for a specific dialog page in a view or to execute a certain functionality. Messages are in TDesC8 descriptors and can be used to pass data between the views. Here is an example: const TUid KViewUid= {1}; const TUid KCustomMessageUid= {2}; TBuf8<255> customMessage; customMessage.Copy(_L8("Some data here")); ActivateLocalViewL(KViewUid, KCustomMessageUid, customMessage);
DoActivateL and the Previous View ID
The purpose of DoActivateL() in the view class is to create the container and also to handle the messages that are passed. In addition to those described in the previous section, DoActivateL() gets the TVwsViewId for the previous view. This can be used to switch back to the original view with or without a message, which may be useful within your own application views. If your application is called by another application, and when the user exits your application, the previous view is automatically restored. Knowing the previous view can be useful if you want to specify which application to respond to.
DoDeActivateL
DoDeActivateL is called when another view has been activated and the previous active window needs to be shut down. This order makes view switching fast. In DoDeActivateL the view is removed from the stack and therefore the view’s container and its controls are destroyed.
Using Other Applications’ Views
To activate a view of an external application, use ActivateViewL() of the AppUi class. ActivateViewL() behaves in the same way as ActivateLocalViewL(). The only difference is that ActivateViewL() takes the TVwsViewId parameter type instead of TUid. TVwsViewId consists of the UID of the application and the UID of the view in that application. Here is an example:
const TUid KPhotoAlbumUid KGalleryUid = {0x101f8599 0x101F4CD1};
CCoeAppUi::ActivateViewL(TVwsViewId(KGalleryUidKPhotoAlbumUid,TUid::Uid(1)));
ActivateViewL() has been overloaded in the same way as ActivateLocalViewL()
To pass messages - here is an example:
const TUid KCustomMessageUid= {2};
TBuf8<255> customMessage;
customMessage.Copy(_L8("Some data here"));
const TUid KGalleryUid KPhotoAlbumUid={0x101f8599 0x101F4CD1};
CCoeAppUi::ActivateViewL(TVwsViewId(KGalleryUidKPhotoAlbumUid,
TUid::Uid(1)), KCustomMessageUid, customMessage);
When the user exits the launched application, the framework will automatically return the original view from where the ActivateViewL() was called.
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Switch views in Series80... | GeKI | Symbian User Interface | 2 | 2005-11-02 10:21 |
| pass data from one view to another view in multiviews | vrnreddy84 | General Symbian C++ | 17 | 2008-01-22 13:32 |
| using existing application | dotcdotc | General Symbian C++ | 2 | 2005-02-18 05:01 |
| Joystick events - where to handle? | Adriana_P | General Symbian C++ | 1 | 2008-04-11 10:18 |
| RWindow issues.. | mayankkedia | General Symbian C++ | 10 | 2007-06-28 10:51 |
