Symbian_s60 Application Framework

Source: Internet
Author: User

UI/engine structure of Symbian
* Symbian applications can be divided:
-UI (view)
· Display application data on the screen to users
-Engine (model)
· Process application data

 

Different Application Structures
* Traditional symbianos
* Based on the dialog box
* Avkon-Based View

 

Traditional Structure Diagram

 

 

 

Application
* The first object to be created
* Rewrite required:
-Createdocumentl (): Creates a Document Object.
-Appdiiuid (): return the unique ID of the application (for example, uid3)
Class cmyappapp: Public caknapplication
{
PRIVATE:
... Functions from the base class
Capadocument * createdocumentl ();
Tuid appdiiuid () const;
};

Document Type
* Generally, the application data is stored in or loaded from a file.
-In many applications, this function is not required.
-In s60, this function is invalid by default.
* The constructor must pass the application object reference to cakndocument.
* Createappuil () must be rewritten to create the Appui.
Class cmyappdocument: Public cakndocument
{
Public:
Static cmyappdocument * newl (ceikapplication & AAPP );
Virtual ~ Cmyappdocument ();
PRIVATE:
Cmyappdocument (ceikapplication & AAPP );
Void constructl ();
Ceikappui * createappuil ();
};

Application UI
* Process commands (for menus) and events in the application (for buttons)
-Rewrite the virtual functions in the base class.
* Create and own a iner object
* Two-stage construction does not need to be completed through newl ().
Class cmyappappui: Public caknappui
{
Public:
Void constructl ();
~ Cmyappappui ();
Cmyappappui ();
PRIVATE:
Void dyninitmenupanel (iint aresourceid, ceikmenupane * amenupane );...... It is mainly about the dynamic display of menus: menu options can be dynamically adjusted along with the state of the program.
Void handlecommandl (tint acommand );
PRIVATE:
Cmyappcontainer * iappcontainer;
};

Container Type
* Create and own controls or containers
* Process Drawing operations related to commands and events
-Rewrite the virtual functions in the base class.
Class cmyappcontainer: Public ccoecontrol
{
Public:
Static cmyappcontainer * newl (const trect & arect );
~ Cmyappcontainer ();
PRIVATE:
Cmyappcontainer ();
Void constructl (const trect & arect );
PRIVATE:... functions from the base class
Void sizechanged ();
Tint countcomponentcontrols () const; number of reverse Components
Void draw (const trect & arect) const;
PRIVATE: ^ member variable
Ceiklabel * ilabel1;
Ceiklabel * ilabel2;
};

Advantages and disadvantages
* Advantages
-Flexible application UI Creation
-Developers can create and design their own UI structures.
* Disadvantages
-The View Management system provided by the system is not convenient for complicated application implementation.

 

 

Dialog Box-based structure


Dialog Box-based structure
* Use the dialog box as the main view (a special container)
* The multi-page dialog box can represent multiple views.
-Avkon provides automatic status space tag operations.
* Advantages
-You can modify the content and layout in the resource file without re-compiling the C ++ code.
* Disadvantages
-The nested dialog box occupies a large amount of stack space if the code is not carefully written.

 

Avkon View Structure


Avkon View Structure
* The view indicates the display page of the application.
-The application registers the "View" to the view server.
-The application activates/activates the view on the view Server Based on the event response.
-At a certain time point, only one view in the running program is active.
* Allows applications to send and receive requests to display a special view of data
* This structure can be considered as a message passing system.
* Navigation through the UI is based on ongoing tasks

Advantages
* Data and functions of views are compressed to view objects, and each view is activated/deactivated by itself.
* This structure is more object-oriented and more suitable for situations requiring modifications
* The external server management in the view means that the application must initiate a request to switch the view of other applications.
-Enhanced dependencies between applications sharing a function
-Reduced the complexity of a single application
-Make the application more efficient

Disadvantages
* The View Structure Framework is restricted.
* It cannot be used in all cases.
* Only applicable to applications that do not provide views to external applications or can handle external program interruptions

Appui class in avkon View
Caknviewappui
* All view-based applications must be inherited by this class.
* Create and manage application views inherited by caknappui
* Hand over plotting and screen-based interaction operations to the view
* Switch between views

Appui Class Example
* The view is created through constructl () of the aknviewappui derived class.
Void cmyappui: constructl ()
{
Baseconstrcutl ();

Cmyview1 * view1 = cmyview1: newlc ();... create view 1
Addview (view1);... transfer ownership to cmyappui
Cleanupstack: Pop ();

Cmyview2 * view2 = cmyview2: newlc ();
Addviewl (view2 );
Cleanupstack: Pop ();

... Set the default view to view 1
Activatelocalviewl (view1-> ID ())
}

Avkon View class
Caknview
* Process commands and events in the view
* Each view is equivalent to a small application UI.
* Create its own control class, inherited from ccoecontorl

Avkon View Class Example
* Caknview-Definition of a derived class:
Class cmyview1: Public caknview
{
Public:... constructor and destructor
Static cmyview1 * newl ();
Static cmyview1 * newlc ();
Virtual ~ Cmyview1 ();

Public:... from caknview
Tuid ID () const... returned view ID
Void doactivatel (const tvwsviewid & aprevviewid, tuid acustommessageid, const tdesc8 & acustommessage );
Void doactivete ();
Void handleforegroundeventl (tbool aforeground );
Void handlecommandl (tint acommand );
Void handlestatuspanesizechange ();

PRIVATE:
Cmyview1 ();... execute the first-stage constructor.
Void constructl ();... execute the second-stage Constructor

PRIVATE:... member variable
Cmycontainer1 * imycontainer1;
};

Avkon view Functions
* Construction
-Newl () and newlc () are constructed in two phases.
-Both call private constructl ()
Call caknview: baseconstructl () to pass the view resource ID
Void cmyview1: constructl ()
{
Baseconstructl (r_my_view_1 );
}
* Structure
-Complete the same functions as dodeactivate ().
* The unique construction/destructor code of the UI should be in doactiveatel () and dodeactive (), because only one view is active at a time.

* The caknview's
-ID ()
@ Return view unique ID; Type: tuid
@ This ID is defined by the developer in the header file of the view.
-Doacitvatel (..)
@ Called when the view is activated
@ As part of the request, the message parameters can be accepted
@ Create a View window and add it to the stack
@ Calls must be processed when the view is already activated
-Dodeactive ()
@ Called when activating a view (for example, when exiting an application or other view of the application is activated)
@ Remove the vision container and remove it from the application UI Stack
@ This function cannot be ignored
-Handleforegroudeventl (tbool aforeground)
@ Used to set focus or control screen updates
@ Called only when the view is activated
@ Called only when the foreground status changes
@ Aforeground
-Etrue: when moving to the foreground
-Efalse: When the foreground is removed
-Handlecommandl ()
@ Process menu/soft key commands
-Handalestatuspanesizechange ()
@ This parameter is called when the size of the client rectangle changes due to changes in the status space.

Avkon view resources
* Each view has associated resources so that the view can have its own menu and/or command button array (CBA)
* Avkon_view resource provision
-View with menu
-View with CBA
* Example
Resource avkon_view r_my_view_1
{
Menubar = r_my_menubar_1;
CBA = r_avkon_softkeys_options_back;
}

 

Switch View
* The caknviewappui processes the response based on the USER command.
* Local vision Switching
-Activate other views in the same application to activate the current view.
-Achieve this by specifying the UID of the target view
-Caknviewappui: activatelocalviewl (tuid aviewid)
* Remote view switching
-Activate the view of other applications
-You can specify the UID of the target application and the UID of the target view.
-Ccoeappui: activeviewl (const tvwsview & aviewid)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.