Dialog-Based Architecture - free Symbian OS tutorials
Dialog-Based Architecture - free Symbian OS tutorials
Dialog-Based Architecture - free Symbian OS tutorials
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Symbian</strong> <strong>OS</strong><br />
GUI <strong>Architecture</strong>s<br />
1 Andreas Jakl, 2008<br />
v2.0b – 22 May 2008
Disclaimer<br />
● These slides are provided <strong>free</strong> of charge at http://www.symbianresources.com and are used<br />
during <strong>Symbian</strong> <strong>OS</strong> courses at the University of Applied Sciences in Hagenberg, Austria<br />
( http://www.fh-hagenberg.at/ )<br />
● Respecting the copyright laws, you are allowed to use them:<br />
for your own, personal, non-commercial use<br />
in the academic environment<br />
● In all other cases (e.g. for commercial training), please contact andreas.jakl@fh-hagenberg.at<br />
● The correctness of the contents of these materials cannot be guaranteed. Andreas Jakl is not<br />
liable for incorrect information or damage that may arise from using the materials.<br />
● Parts of these materials are based on information from <strong>Symbian</strong> Press-books published by John<br />
Wiley & Sons, Ltd. This document contains copyright materials which are proprietary to <strong>Symbian</strong>,<br />
UIQ, Nokia and SonyEricsson. “S60” is a trademark of Nokia. “UIQ” is a trademark of UIQ<br />
Technology. Pictures of mobile phones or applications are copyright their respective<br />
manufacturers / developers. “<strong>Symbian</strong> ”, “<strong>Symbian</strong> <strong>OS</strong> ” and all other <strong>Symbian</strong>-based marks<br />
and logos are trademarks of <strong>Symbian</strong> Software Limited and are used under license. © <strong>Symbian</strong><br />
Software Limited 2006.<br />
2<br />
Andreas Jakl, 2008
Contents<br />
● GUI Frameworks<br />
● Structure of a GUI application<br />
● <strong>Architecture</strong>s<br />
Views, Controls, <strong>Dialog</strong><br />
● Seperating UI and engine<br />
3<br />
MVC<br />
ECom<br />
Andreas Jakl, 2008
4<br />
<strong>Symbian</strong> <strong>OS</strong> – UI Framework<br />
UI Toolkit<br />
UI Framework<br />
Application Services<br />
Messaging, Browsing, PIM, App. Framework, Data Sync, …<br />
Generic <strong>OS</strong><br />
Services<br />
Telephony<br />
Services<br />
Licensee Platforms<br />
S60 Avkon UIQ Qikon<br />
** FEP = Front End Processor:<br />
Input of characters not directly<br />
supported by hardware keys.<br />
UI Application Framework<br />
Uikon UI LAF* Cone FEP Base**<br />
Comms Services<br />
Serial Comm &<br />
Short Link<br />
Services<br />
Base Services<br />
Networking<br />
Services<br />
Kernel Services & Hardware Abstraction<br />
Andreas Jakl, 2008<br />
Multimedia<br />
& Graphics<br />
Services<br />
JavaME<br />
Connectivity<br />
Services<br />
* LAF = Look & Feel. Allows changing<br />
appearance of Uikon controls without<br />
modifying Uikon-code itslef
5<br />
S60 (previously: Series 60)<br />
Nokia N96<br />
● Owner: Nokia<br />
● Licensed to: Samsung, LG,<br />
Panasonic, Lenovo<br />
● Designed for:<br />
Andreas Jakl, 2008<br />
One-handed use<br />
No touch screen, however:<br />
– 2 softkeys, 5-way navigation<br />
(4 directions + center), number-keys,<br />
special keys (menu)<br />
Portrait and landscape<br />
● Touch-Screen support starting<br />
with S60 5.0
6<br />
Series 80<br />
Andreas Jakl, 2008<br />
● Owner: Nokia<br />
● Designed for:<br />
Interaction through full<br />
QWERTY-keyboard, joystick<br />
and 4 softkeys<br />
● Has been superseded by<br />
S60 (Device: E90)
UIQ<br />
● UIQ Technology:<br />
Owned by SonyEricsson and Motorola<br />
● Designed for (since UIQ 3)<br />
Supported (in all combinations):<br />
– Portrait<br />
– Landscape<br />
– Pen-Input (Touchscreen)<br />
– Softkey-Input<br />
Applications not closed by users<br />
● Licensed to: SonyEricsson, Motorola,<br />
(BenQ, Arima)<br />
7<br />
Andreas Jakl, 2008<br />
SonyEricsson P1i
UIQ 3<br />
● Since UIQ3 support for multiple UI configurations, e.g.:<br />
8<br />
Pen-Style<br />
Andreas Jakl, 2008<br />
Softkey-Style
FOMA<br />
● Phones for NTT DoCoMo, FOMA = Freedom of<br />
Mobile Access ( 3G services)<br />
● Different manufacturers: Mitsubishi, Fujitsu,<br />
SonyEricsson, Sharp, ...<br />
● Japanese Market<br />
● Closed feature phones, no Smartphones!<br />
● Different to European market: Aromas,<br />
mobile credit cards, waterproof, capturing<br />
promotional data from coupons, fingerprint<br />
sensor, GPS not unusual, ...<br />
9<br />
Andreas Jakl, 2008
Structure of the UI framework<br />
<strong>Architecture</strong><br />
10<br />
Andreas Jakl, 2008
Application <strong>Architecture</strong><br />
● Applications typically divided into<br />
UI (View)<br />
– Presents data to the user<br />
Engine<br />
– Manipulates the data<br />
● <strong>Symbian</strong> <strong>OS</strong> application architectures are built based on<br />
a clear separation<br />
11<br />
Andreas Jakl, 2008
Structure<br />
Custom application<br />
implementation<br />
S60 (Avkon) / UIQ (Qikon)specific<br />
implementation<br />
Common <strong>Symbian</strong> <strong>OS</strong><br />
implementation, shared<br />
for specific UI Platforms<br />
Many abstract classes,<br />
define interface for<br />
UI framework APIs<br />
12<br />
Andreas Jakl, 2008<br />
Manages access to<br />
screen and input devices
Window Server (WServ)<br />
● Centralised access to the screen and user input devices<br />
● Tasks:<br />
Handles draw-operations for windows and controls<br />
Manages which view(s) belongs to which app<br />
Forward key/pointer/redraw-events to apps.<br />
● WServ does not define look & feel!<br />
● Communication with WServ through CONE using<br />
Client/Server-Communication<br />
13<br />
Andreas Jakl, 2008<br />
Application<br />
xkon<br />
Uikon<br />
AppArc CONE WServ
AppArc / CONE<br />
● AppArc = „Application <strong>Architecture</strong>“<br />
Basic application structure<br />
Mechanism for sending system information to the<br />
application and for saving data (through the file server)<br />
● CONE = „Control Environment“<br />
14<br />
Framework for creating UI-controls<br />
Framework for handling user interface events<br />
Interaction mainly with the Window Server<br />
Andreas Jakl, 2008<br />
Application<br />
xkon<br />
Uikon<br />
AppArc CONE WServ
Uikon<br />
● Uikon: Basic UI library<br />
15<br />
All UI applications are based on Uikon<br />
Generic, device-independent implementation<br />
Can either be used directly – or UI specific controls are<br />
available (adapted to the platform: S60, UIQ)<br />
Controls called Eikon-controls<br />
(e.g. CEikLabel and CEikImage of the Quickstart module)<br />
Andreas Jakl, 2008<br />
Application<br />
xkon<br />
Uikon<br />
AppArc CONE WServ
xxkon<br />
● Avkon / Qikon<br />
16<br />
S60 / UIQ-specific UI functionality (menu, …)<br />
Additional controls and adapted / extended versions of<br />
Uikon-controls<br />
Andreas Jakl, 2008<br />
Application<br />
xkon<br />
Uikon<br />
AppArc CONE WServ
Common<br />
Elements of a GUI-Application<br />
17<br />
Andreas Jakl, 2008
Elements of a GUI-App.<br />
● Common required functionality:<br />
18<br />
UI for displaying information + interaction<br />
React to user-initiated events (e.g. select a<br />
menu item)<br />
React to system events (e.g. redraw)<br />
Save / load application data<br />
Unique identification to the framework<br />
Provide information for the framework<br />
(Capabilities, …)<br />
Andreas Jakl, 2008<br />
View<br />
AppUi / View<br />
AppUi<br />
Document<br />
Application<br />
Application
<strong>Architecture</strong> – Overview<br />
● Traditional (Control-<strong>Based</strong>) S60 application:<br />
Application<br />
Avkon<br />
19<br />
CMyApplication<br />
Andreas Jakl, 2008<br />
Cone<br />
CAknApplication CAknDocument CAknAppUi CCoeControl<br />
Stores<br />
application<br />
properties<br />
Engine<br />
can be owned by the Document, AppUi or Container<br />
CMyDocument CMyAppUi CMyContainer<br />
Manages<br />
persistent data<br />
storage<br />
Direct events to<br />
the correct<br />
control<br />
(e.g. key input)<br />
Many pre-defined<br />
controls available<br />
(dialogs, forms, lists, ...)<br />
Compound<br />
control that can<br />
contain one or<br />
more controls<br />
= view
Framework<br />
20<br />
Initialisation<br />
(1) E32Main()<br />
(2) NewApplication()<br />
(3) <br />
(4) AppDllUid()<br />
(5) CApaDocument*<br />
CreateDocumentL() (6) NewL()<br />
(7) CEikAppUi* CreateAppUi()<br />
CMyApplication CMyDocument CMyAppUi<br />
Andreas Jakl, 2008<br />
(8) AppUi Constructor()
Start<br />
● E32Main()<br />
Entry point for the .exe-file<br />
Creates Active Scheduler, connection to File- and<br />
Window-Server. Loads libraries and resource files<br />
Parameter: Function-pointer to the factory function:<br />
● NewApplication()<br />
21<br />
GLDEF_C TInt E32Main() {<br />
return EikStart::RunApplication( NewApplication );<br />
}<br />
LOCAL_C CApaApplication* NewApplication() {<br />
return new CMyApplication;<br />
}<br />
Creates and returns Application-class<br />
The cleanup stack doesn’t exist<br />
yet, therefore there’s no (ELeave)<br />
when creating the object!<br />
Andreas Jakl, 2008
Application<br />
● Sends UID3 to the framework<br />
Has to be identical to UID defined in the .mmp-file<br />
● Creates Document<br />
● Functionality of AppUi base classes:<br />
22<br />
Framework can query Capabilities, App.-name<br />
class CMyApplication : public CAknApplication {<br />
public:<br />
TUid AppDllUid() const;<br />
protected:<br />
CApaDocument* CreateDocumentL();<br />
};<br />
Andreas Jakl, 2008<br />
Application
Document<br />
● Represents persistent Data of the application<br />
Functions to load and save data in file stores<br />
Not used by default in S60<br />
● Creates instance of AppUi<br />
23<br />
class CMyDocument : public CAknDocument {<br />
public:<br />
static CMyDocument* NewL( CEikApplication& aApp );<br />
virtual ~CMyDocument();<br />
// Called by the application framework to create AppUi-Object<br />
CEikAppUi* CreateAppUiL();<br />
private:<br />
void ConstructL();<br />
CMyDocument( CEikApplication& aApp );<br />
};<br />
Andreas Jakl, 2008<br />
Document
AppUi<br />
● Creates default view<br />
● Logic for handling events<br />
● No direct graphical<br />
representation<br />
24<br />
… but owner of<br />
Softkey/Title/…-Bar and<br />
Views<br />
Andreas Jakl, 2008<br />
CMyAppUi<br />
Application specific features<br />
Event handling, View construction, …<br />
CAppUi<br />
Features common across all apps, eg.:<br />
Title bars, Scroll bars, Start up & shut<br />
down, Standard soft keys, …<br />
CEikAppUi<br />
Document handling,<br />
Menus & Pop-ups,<br />
Screen Area,<br />
Resource File<br />
CCoeAppUi<br />
Control stack,<br />
view management,<br />
event handling<br />
AppUi
AppUi<br />
● Most important functions:<br />
Function Description<br />
HandleCommandL() Called when the user issues commands (menu command events).<br />
May be the only event-handling function that is implemented.<br />
25<br />
Andreas Jakl, 2008<br />
AppUi<br />
HandleKeyEvent() Handling user key presses, when no other control on the control stack has<br />
already handled it.<br />
HandleForegroundEventL() Called when application switches to or from the foreground.<br />
(Default: Keyboard-focus)<br />
DynInitMenuPaneL() Called right before the application menu is displayed. Allows the<br />
application to modify the contents of the menu on the fly, e.g. by hiding<br />
currently unnecessary options – not used anymore in UIQ 3.
View / Container<br />
● View defined as generic concept for displaying data on the<br />
screen<br />
● S60<br />
● UIQ<br />
26<br />
Three architectures:<br />
– Control-<strong>Based</strong> <strong>Architecture</strong><br />
The view is a control itself<br />
– <strong>Dialog</strong>-<strong>Based</strong> <strong>Architecture</strong><br />
– Avkon View-Switching <strong>Architecture</strong><br />
View = additional layer in between AppUi and Controls<br />
Recommended: view based<br />
Andreas Jakl, 2008<br />
View
RunApplication<br />
Avkon<br />
Uikon<br />
AppArc<br />
27<br />
App Startup (S60 Views)<br />
CMyApplication CMyDocument CMyAppUi CMyView1 CMyContainer1<br />
CAknApplication CAknDocument<br />
CEikApplication<br />
CreateDocumentL() CreateAppUiL() ConstructL() DoActivateL()<br />
Avkon View Switching Application<br />
CEikDocument<br />
CAknViewAppUi<br />
Cone<br />
CAknAppUi<br />
CAknAppUiBase<br />
CEikAppUi<br />
Andreas Jakl, 2008<br />
CAknView<br />
CApaApplication CApaDocument CCoeAppUi<br />
CCoeControl
Build the User Interface using<br />
Controls<br />
28<br />
Andreas Jakl, 2008
Control<br />
● Control = “Empty Canvas”<br />
Rectangular area of a window<br />
Can react to user input<br />
e.g. views, buttons, menus, nearly all UI controls, …<br />
● Two types:<br />
29<br />
Simple Control: Does not contain other controls<br />
Container/Compound Control: Contains and owns other<br />
controls<br />
Andreas Jakl, 2008<br />
CCoeControl
Compound Controls<br />
● Parent control contains<br />
child controls, e.g.:<br />
30<br />
main & window-owning<br />
control contains application<br />
content (label controls,<br />
image controls, ...)<br />
complex control made out<br />
of sub-controls (custom<br />
menu made out of multiple<br />
labels)<br />
Andreas Jakl, 2008
Compound Controls<br />
● Old way (pre-<strong>Symbian</strong> <strong>OS</strong> 9.1)<br />
31<br />
Compound control (=parent) saves<br />
component controls (=children) as instance variables<br />
Compound Control has to override two functions:<br />
– TInt CCoeControl::CountComponentControls()<br />
Returns the number of contained component controls<br />
– CCoeControl* CCoeControl::ComponentControl(TInt aIndex)<br />
Returns the component control with the specified index<br />
Andreas Jakl, 2008
32<br />
Old Way – Example<br />
TInt CMyContainer::CountComponentControls() const<br />
{<br />
// Return the number of controls this compound control (container) contains<br />
return 2;<br />
}<br />
CCoeControl* CMyContainer::ComponentControl( TInt aIndex ) const<br />
{<br />
// Return the component control with the specified index<br />
switch ( aIndex )<br />
{<br />
case 0:<br />
return iLabel;<br />
case 1:<br />
return iImage;<br />
}<br />
return NULL;<br />
}<br />
Andreas Jakl, 2008
Compound Controls – New!<br />
● Simplified control handling – base class does the<br />
counting and cleanup work!<br />
● Available since <strong>Symbian</strong> <strong>OS</strong> 9.1<br />
void CMyContainer::ConstructL()<br />
{<br />
// Initialize the component array, which is defined by the CCoeControl base class<br />
InitComponentArrayL();<br />
}<br />
// Construct all the new component controls and add them to the component array<br />
CComponent* myComponent = new (ELeave) CComponent();<br />
Components().AppendLC( myComponent ); // or InsertLC or InsertAfterLC(). Places item on cleanup stack.<br />
myComponent->ConstructL();<br />
// [Initialize the control...]<br />
CleanupStack::Pop( myComponent );<br />
33<br />
Andreas Jakl, 2008
Control<br />
● Window-Owning<br />
View of the application is windowowning<br />
(CreateWindowL() is called in ConstructL())<br />
Window has 1..1-Relationship<br />
to window-owning control<br />
e.g. dialogs, menus, toolbars,<br />
top-level controls<br />
● Non-Window-Owning (or “lodger” controls)<br />
34<br />
Use window owned by the parent control<br />
(SetContainerWindowL() is called in ConstructL())<br />
Controls may not overlap<br />
More efficient: less Client/Server-traffic to the Window Server<br />
e.g. command buttons, text boxes, labels<br />
Andreas Jakl, 2008<br />
Window = area<br />
of the screen,<br />
owned by the<br />
Window Server<br />
CCoeControl<br />
void CHourPowerAppView::ConstructL(<br />
const TRect& aRect )<br />
{<br />
// Create a window for this application view<br />
CreateWindowL();<br />
// Set the windows size<br />
SetRect( aRect );<br />
// Activate the window, which makes it<br />
// ready to be drawn<br />
ActivateL();<br />
}
Control Stack<br />
● Control Stack (owned by AppUi) contains list of all<br />
controls that would like to receive keyboard events<br />
● Adding a control to the stack:<br />
CCoeAppUi::AddToStackL()<br />
● Order of controls on the stack depends on:<br />
35<br />
Priority<br />
Same priority: order of putting on the stack<br />
Andreas Jakl, 2008<br />
CCoeControl
36<br />
Control Stack – Example<br />
void CMyAppUi::ConstructL()<br />
{<br />
// Initialize the AppUi with standard values (-> Resource file)<br />
BaseConstructL( EAknEnableSkin );<br />
// Create the main compound control that will own the window<br />
iMyContainer = CMyContainer::NewL( ClientRect(), NULL, this );<br />
// Define that the parant of the control is the AppUi<br />
iMyContainer->SetMopParent( this );<br />
// Add the control to the AppUi’s Control Stack<br />
AddToStackL( iMyContainer );<br />
}<br />
CMyAppUi::~CMyAppUi()<br />
{<br />
if ( iMyContainer != NULL )<br />
{<br />
// Remove the control from the Control Stack<br />
RemoveFromStack( iMyContainer );<br />
delete iMyContainer;<br />
iMyContainer = NULL;<br />
}<br />
}<br />
Andreas Jakl, 2008
Control Stack<br />
● Starting at stack pos. 0,<br />
events are offered to<br />
each control until they<br />
are consumed by a<br />
control<br />
● Most of the time App.<br />
view or dialogs are<br />
Compound Controls<br />
37<br />
Distribute key press<br />
events depending on<br />
keyboard focus<br />
Events<br />
Andreas Jakl, 2008<br />
ECoeStackPriorityDefault (=0)<br />
ECoeStackPriorityMenu (=10)<br />
ECoeStackPriority<strong>Dialog</strong> (=50)<br />
ECoeStackPriority<strong>Dialog</strong> (=50)<br />
CCoeControl<br />
Control X<br />
Control Y<br />
Keyboard Focus<br />
Control Z<br />
Stack position 0<br />
Controls put on the stack in the order: A, B, C, D
Handling Key Events<br />
TKeyResponse CMyContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)<br />
{<br />
// Default: We did not consume the key, framework will forward the events to other controls<br />
TKeyResponse ret = EKeyWasNotConsumed;<br />
}<br />
if (aType == EEventKey)<br />
{<br />
switch (aEventKey.iCode)<br />
{<br />
case EKeyLeftArrow:<br />
// Handle the key event...<br />
// We have handled the event, make sure it is not handled by multiple controls!<br />
ret = EKeyWasConsumed;<br />
break;<br />
//...<br />
}<br />
}<br />
return ret;<br />
38<br />
Andreas Jakl, 2008
The traditional <strong>Symbian</strong> <strong>OS</strong>-way<br />
Control-<strong>Based</strong> <strong>Architecture</strong><br />
39<br />
Andreas Jakl, 2008
● AppUi<br />
Control-<strong>Based</strong> <strong>Architecture</strong><br />
Direct owner of view-controls<br />
(those are derived from CCoeControl)<br />
Control has its own class (called Container or View),<br />
it can contain additional controls (= Compound Control)<br />
AppUi is responsible for changing displayed content<br />
((de)activate container)<br />
● Child-Parent-Relationship defined through<br />
Container::SetMopParent()<br />
● Self-made view-switching possible: through AddToStack()<br />
and RemoveFromStack()<br />
40<br />
Andreas Jakl, 2008
Avkon<br />
Uikon<br />
AppArc<br />
41<br />
Control-<strong>Based</strong> <strong>Architecture</strong><br />
Control-<strong>Based</strong> Application <strong>Architecture</strong><br />
CMyApplication CMyDocument CMyAppUi CMyContainer1<br />
CMyContainer1<br />
CAknApplication CAknDocument CAknAppUi<br />
CEikApplication<br />
CEikDocument<br />
CAknAppUiBase<br />
Cone<br />
CEikAppUi<br />
CApaApplication CApaDocument CCoeAppUi<br />
CCoeControl<br />
Andreas Jakl, 2008
Predefined controls<br />
<strong>Dialog</strong>-<strong>Based</strong> <strong>Architecture</strong><br />
42<br />
Andreas Jakl, 2008
<strong>Dialog</strong>s<br />
● <strong>Dialog</strong> = Control(s) with predefined framework for layout,<br />
command handling, etc.<br />
● Can be defined through resource files (instead of in the<br />
source code)<br />
● Examples:<br />
43<br />
Note Query <strong>Dialog</strong> List <strong>Dialog</strong> Form<br />
Andreas Jakl, 2008
<strong>Dialog</strong>-<strong>Based</strong> <strong>Architecture</strong><br />
● Predefined dialogs for common use cases:<br />
Data display<br />
-entry<br />
-editing<br />
● Less development work than when directly using<br />
controls<br />
<strong>Dialog</strong> automatically manages its child controls<br />
● Multipage dialogs possible (e.g. with tabs)<br />
● Example: settings application<br />
44<br />
Andreas Jakl, 2008
<strong>Dialog</strong>s<br />
● Most important properties:<br />
45<br />
Modal: Prevents interaction with the rest of the app as<br />
long as it is active (e.g. note)<br />
Modeless: Interaction with other parts of the UI is<br />
possible (e.g. main view in a dialog based architecture)<br />
Waiting: App. is paused as long as the dialog is displayed<br />
(e.g. simple text query dialog)<br />
Nonwaiting: App. continues while dialog is shown (e.g.<br />
progress note)<br />
Andreas Jakl, 2008
Avkon<br />
Uikon<br />
AppArc<br />
46<br />
<strong>Dialog</strong>-<strong>Based</strong> <strong>Architecture</strong><br />
<strong>Dialog</strong>-<strong>Based</strong> Application <strong>Architecture</strong><br />
CMyApplication CMyDocument CMyAppUi<br />
CAknApplication CAknDocument CAknAppUi<br />
CEikApplication<br />
CEikDocument<br />
CAknAppUiBase<br />
Cone<br />
CEikAppUi<br />
CApaApplication CApaDocument CCoeAppUi CCoeControl<br />
Andreas Jakl, 2008<br />
CMy<strong>Dialog</strong><br />
CAkn<strong>Dialog</strong><br />
CEik<strong>Dialog</strong><br />
CEikBordererd<br />
Control
The most flexible solution<br />
Avkon View-Switching <strong>Architecture</strong><br />
47<br />
Andreas Jakl, 2008
48<br />
Using Views<br />
Menu View Game View<br />
Andreas Jakl, 2008
Avkon View-Switching Archit.<br />
● Views represent different pages of the application<br />
Application registers views with the view server<br />
View Server takes responsibility for managing views<br />
from the AppUi<br />
Application can activate / deactivate views through the<br />
view server<br />
Only one view can be active at the same time<br />
● Allows different data representation based on the<br />
current task of the user<br />
49<br />
Andreas Jakl, 2008
Why Views?<br />
● Each view is an own object<br />
Encapsulates data and functions<br />
Own activation / deactivation functions<br />
● Views = modules: Application can easily be adapted for<br />
future modifications<br />
● Views from external applications<br />
50<br />
Allows access to views of other applications<br />
(e.g. contact list, video playback, ...)<br />
Reduces complexity of individual applications<br />
Andreas Jakl, 2008
Avkon View-Switching Archit.<br />
● Differences to Control-<strong>Based</strong> <strong>Architecture</strong>:<br />
Avkon-View <strong>Based</strong><br />
CAknViewAppUi<br />
51<br />
Additional class in-between AppUi and Container: CAknView<br />
� Each view handles its own events (like small AppUi)<br />
AppUi derived from CAknViewAppUi (instead of CAknAppUi)<br />
� manages views, delegates drawing and interaction<br />
View Server<br />
CAknView<br />
CAknView<br />
Andreas Jakl, 2008<br />
Container<br />
(Compound<br />
Control)<br />
Container<br />
(Control)<br />
Control<br />
Control
Example<br />
● Creating two views, setting the first as default<br />
52<br />
void CViewTestAppUi::ConstructL()<br />
{<br />
// Initialize the AppUi with standard values<br />
BaseConstructL( EAknEnableSkin );<br />
}<br />
// Construct the first view<br />
iViewTestContainerView = CViewTestContainerView::NewL();<br />
// Registers the view and adds it to the AppUi<br />
AddViewL( iViewTestContainerView );<br />
// Set the first view as the initial view<br />
SetDefaultViewL( *iViewTestContainerView );<br />
// Construct and register the second view<br />
iViewTestFormView = CViewTestFormView::NewL();<br />
AddViewL( iViewTestFormView );<br />
Andreas Jakl, 2008
Switching Views<br />
● Handled by the AppUi<br />
● Local view switching<br />
Activates another view of the same application,<br />
deactivates the current view<br />
Specify the new view through its UID<br />
CAknViewAppUi::ActivateLocalViewL(TUid aViewId)<br />
● Remote view switching<br />
53<br />
Activate a view in another application<br />
Specify the UID of target application and target view<br />
CCoeAppUi::ActivateViewL(const TVwsViewId& aViewId)<br />
Andreas Jakl, 2008
View<br />
● Most important functions:<br />
Function Description<br />
Construction ConstructL() – passes the view ID to the base class.<br />
Destruction Same functionality as DoDeactivate()<br />
DoActivateL() Called on view activation. Creates view’s containers and adds it to the<br />
AppUi’s stack.<br />
DoDeactivate() Called on view deactivation: When the application exits or another view is<br />
activated (only one view can be active at a time). Deletes the view’s<br />
container, removes it from the AppUi’s stack. Must not leave!<br />
Id() Returns the unique ID of the view (defined in its header-file)<br />
HandleForegroundEventL<br />
(TBool aForeground)<br />
54<br />
Parameter: ETrue when the application moves to the foreground.<br />
HandleCommandL(...) Handle commands from menus / soft keys<br />
Andreas Jakl, 2008<br />
View
View - Menu<br />
● Each view has associated resource<br />
Defines menu<br />
and/or Command Button Array (CBA)<br />
● Commands are passed in this order:<br />
1. HandleCommandL() of the active view<br />
2. AppUi::HandleCommandL()<br />
55<br />
.rss<br />
RESOURCE AVKON_VIEW r_my_view<br />
{<br />
cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;<br />
menubar = r_my_options_menu;<br />
}<br />
Andreas Jakl, 2008
Avkon<br />
Uikon<br />
AppArc<br />
56<br />
Architechture – S60 Views<br />
Avkon View Switching Application<br />
CMyApplication CMyDocument CMyAppUi CMyView1 CMyContainer1<br />
CAknApplication CAknDocument<br />
CEikApplication<br />
CEikDocument<br />
CAknViewAppUi<br />
Cone<br />
CAknAppUi<br />
CAknAppUiBase<br />
CEikAppUi<br />
Andreas Jakl, 2008<br />
CAknView<br />
Container(s)<br />
contain visible<br />
content<br />
CApaApplication CApaDocument CCoeAppUi<br />
CCoeControl
When to use which architecture?<br />
Choosing the optimal architecture<br />
57<br />
Andreas Jakl, 2008
Control <strong>Based</strong><br />
AppUi<br />
<strong>Dialog</strong> <strong>Based</strong><br />
AppUi<br />
Avkon-View <strong>Based</strong><br />
AppUi<br />
58<br />
<strong>Architecture</strong>s – Overview<br />
View Server<br />
Compound<br />
Control<br />
Control<br />
<strong>Dialog</strong><br />
<strong>Dialog</strong><br />
View<br />
View<br />
…<br />
Andreas Jakl, 2008<br />
Control<br />
Control<br />
Control<br />
Control<br />
Container<br />
(Compound<br />
Control)<br />
Container<br />
(Control)<br />
Control<br />
Control
● Use if:<br />
59<br />
Control <strong>Based</strong>?<br />
Application only needs one view<br />
Unlikely that other apps will want to access your view<br />
Porting from other <strong>Symbian</strong> <strong>OS</strong> platforms that do not<br />
use the view concept<br />
Andreas Jakl, 2008
● Use if:<br />
<strong>Dialog</strong> <strong>Based</strong>?<br />
(Nearly) all screens of the app.<br />
are dialogs (e.g. lists are dialogs<br />
as well!)<br />
● No cyclic navigation paths<br />
allowed!<br />
● Disadvantage: <strong>Dialog</strong>s not so<br />
good for communication with<br />
AppUi<br />
60<br />
Most of the time a dialog is a<br />
self-contained system, returns<br />
after dialog is dismissed<br />
Andreas Jakl, 2008<br />
Multipage-<strong>Dialog</strong><br />
1a 1b<br />
2<br />
3 4<br />
Navigation 1a 2 1b 1a<br />
not allowed! <strong>Dialog</strong> 1a would be<br />
instantiated twice.<br />
Rule: After navigating downwards<br />
in the hierarchy, return through the<br />
same path when navigating upwards.
Avkon View-Switching?<br />
● Allows access to views of other applications<br />
● Use if:<br />
61<br />
e.g. user gets an email, wants to save address of sender<br />
messaging-app. calls view of the contacts-app.<br />
Other programs should be able to access your views<br />
(if more complex interactions are required: views not<br />
enough, Client/Server should be used)<br />
If there are no good reasons for using other<br />
architectures<br />
Andreas Jakl, 2008
Mixing <strong>Architecture</strong>s<br />
● In many cases this is the optimal solution<br />
62<br />
e.g. combine <strong>Dialog</strong>-based architecture with others<br />
<strong>Dialog</strong>s are used for general navigation or simpler<br />
screens, custom views implemented with Viewarchitecture<br />
Andreas Jakl, 2008
Qikon<br />
Uikon<br />
AppArc<br />
<strong>Architecture</strong> – UIQ 3<br />
● ... more about UIQ in an individual module!<br />
UIQ Application<br />
CMyApplication CMyDocument CMyAppUi CMyView<br />
CQikApplication CQikDocument CQikAppUi CQikViewBase<br />
CEikApplication<br />
63<br />
CEikDocument<br />
Cone<br />
CEikAppUi<br />
CApaApplication CApaDocument CCoeAppUi CCoeControl<br />
Andreas Jakl, 2008<br />
(…)
Code structure<br />
UI and Engine<br />
64<br />
Andreas Jakl, 2008
Model View Controller Pattern<br />
● Model: Contains and manipulates data in the app.<br />
● View: Defines representation of data. Forwards events to<br />
the controller.<br />
● Controller: Defines how the UI should react to commands<br />
and requests<br />
65<br />
View<br />
Controller<br />
Andreas Jakl, 2008<br />
Model
Model<br />
● Out-source data and algorithms to the model (engine)<br />
● MVC-Pattern: AppUi = Controller<br />
Application<br />
1<br />
Document<br />
1<br />
1<br />
AppUi<br />
1<br />
View<br />
● Additional Controller (e.g. when the engine has its own<br />
asynchronous services)<br />
66<br />
Model<br />
Application<br />
1<br />
Document<br />
1<br />
AppUi<br />
1<br />
View<br />
1<br />
1<br />
Model<br />
Andreas Jakl, 2008<br />
Controller
● Engine:<br />
● UI:<br />
67<br />
Seperating UI / Engine<br />
Algorithms for managing and processing data<br />
Routines for loading and saving<br />
e.g. Chess: status of the board, rules for movement, AI<br />
Displays data for the user<br />
Transfers user-requests to the engine<br />
e.g. Chess: representation of the game status, user<br />
interaction<br />
Andreas Jakl, 2008
Seperating UI / Engine<br />
● Advantages:<br />
Prevent unnecessary dependencies<br />
Maximise code reuse<br />
Parallel development of UI and engine<br />
Good application structure<br />
● Implementation:<br />
68<br />
Put engine in its own dll or .exe-server<br />
or: ECom-Plugin<br />
Andreas Jakl, 2008
ECom (Short Overview)<br />
● Shared DLLs<br />
Platform Security – Data Caging: Access not so easy<br />
● ECom (Epoc Component Object Model)<br />
Generic framework, manages plug-ins<br />
Built using Client/Server architecture<br />
1. Plug-in registers itself at ECom<br />
69<br />
Your code is in a dll<br />
Data (name, ID, …) and connection<br />
interface/implementation defined through resource file<br />
Andreas Jakl, 2008
ECom<br />
2. Client requests implementation of an interface<br />
70<br />
Through UID or text (name of the implementation)<br />
ECom searches through its saved meta-information<br />
database, returns best results („resolution“)<br />
ECom instantiates desired object through its factory<br />
function, loads object in the process of the client<br />
ECom uses reference counting for resource<br />
management<br />
Andreas Jakl, 2008
71<br />
Basic ECom <strong>Architecture</strong><br />
Client<br />
instantiates<br />
Andreas Jakl, 2008<br />
<br />
InterfaceDefinition<br />
NewL()<br />
~InterfaceDefinition()<br />
Implementation 1 ECom
… any questions?<br />
Quiz<br />
72<br />
Andreas Jakl, 2008
Quiz I<br />
● What about those UI components:<br />
73<br />
Options menu<br />
Window-Owning<br />
Container in Avkon View-<strong>Architecture</strong><br />
Window-Owning Compound Control<br />
Label-Control<br />
Window-Owning Compound Control<br />
Andreas Jakl, 2008
Quiz I – Solution<br />
● What about those UI components:<br />
74<br />
Options menu<br />
Window-Owning<br />
Container in Avkon View-<strong>Architecture</strong><br />
Window-Owning Compound Control<br />
Label-Control<br />
Window-Owning Compound Control<br />
Andreas Jakl, 2008
Quiz II<br />
● Which application architectures are created through<br />
the following Carbide.c++ wizards?<br />
S60 3.x GUI Application<br />
75<br />
Control-based <strong>Dialog</strong>-based Avkon-Views<br />
S60 nth Ed. GUI App. with UI Designer (+ Support view switching)<br />
Control-based <strong>Dialog</strong>-based Avkon-Views<br />
Andreas Jakl, 2008
Quiz II – Solution<br />
● Which application architectures are created through<br />
the following Carbide.c++ wizards?<br />
S60 3.x GUI Application<br />
76<br />
Control-based <strong>Dialog</strong>-based Avkon-Views<br />
S60 nth Ed. GUI App. with UI Designer (+ Support view switching)<br />
Control-based <strong>Dialog</strong>-based Avkon-Views<br />
Andreas Jakl, 2008
Quiz III<br />
● … these dialogs are:<br />
77<br />
Modal Modeless<br />
Waiting Nonwaiting<br />
Modal Modeless<br />
Waiting Nonwaiting<br />
Andreas Jakl, 2008
Quiz III – Solution<br />
● … these dialogs are:<br />
78<br />
Modal Modeless<br />
Waiting Nonwaiting<br />
Modal Modeless<br />
Waiting Nonwaiting<br />
Andreas Jakl, 2008
Try it for your own<br />
… let’s move to the Challenges!<br />
79<br />
Andreas Jakl, 2008