|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE reference |
|
11 PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd"> |
|
12 <reference id="GUID-F64B88E0-49DA-5563-896E-29BAB8A244C9" xml:lang="en"><title>HelloWorld: |
|
13 A simple GUI application with a single view</title><shortdesc>This example demonstrates a simple application using a GUI with |
|
14 a single view. </shortdesc><prolog><metadata><keywords/></metadata></prolog><refbody> |
|
15 <section><title>Download</title> <p>Click on the following link to download |
|
16 the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-a2004cb9-da88-4ec7-a85e-dd648022f4f9.zip" scope="external">HelloWorldGUI.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-a2004cb9-da88-4ec7-a85e-dd648022f4f9.html" scope="peer">browse</xref> to view the example code. </p> </section> |
|
17 <section><title>Class Summary</title><p><xref href="GUID-E36E2F07-09E7-32BC-BB83-14DF9232E7D9.dita"><apiname>CEikApplication</apiname></xref></p><p><xref href="GUID-B33A8A56-D1BE-3E3D-B5AC-F644A5C764DB.dita"><apiname>CEikDocument</apiname></xref></p><p><xref href="GUID-1185F595-0488-3E93-8D60-6B3A1A3AC32E.dita"><apiname>CEikAppUi</apiname></xref></p><p><xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita"><apiname>CCoeControl</apiname></xref></p></section> |
|
18 <section><title>Design and implementation</title> <p>This application consists |
|
19 of 4 classes: </p> <ul> |
|
20 <li id="GUID-28A83A4A-D743-556B-88EB-D65AAFD29D19"><p>Application class derived |
|
21 from <xref href="GUID-E36E2F07-09E7-32BC-BB83-14DF9232E7D9.dita"><apiname>CEikApplication</apiname></xref>. </p> </li> |
|
22 <li id="GUID-EF3F2195-1D04-56A4-B439-C2B50F543F74"><p>Document class derived |
|
23 from <xref href="GUID-B33A8A56-D1BE-3E3D-B5AC-F644A5C764DB.dita"><apiname>CEikDocument</apiname></xref>. </p> </li> |
|
24 <li id="GUID-65ABFCB1-BC5A-5BCA-9F45-D5FF82AB1AE4"><p>AppUi class derived |
|
25 from <xref href="GUID-1185F595-0488-3E93-8D60-6B3A1A3AC32E.dita"><apiname>CEikAppUi</apiname></xref>. </p> </li> |
|
26 <li id="GUID-12BE51BC-0F68-5C5E-A279-4AE00E96FC7D"><p>AppView class derived |
|
27 from <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita"><apiname>CCoeControl</apiname></xref>. </p> </li> |
|
28 </ul> <p> <codeph>E32Main()</codeph> marks the entry point to the example. |
|
29 It calls <codeph>EikStart::RunApplication()</codeph> to create a new application |
|
30 instance. The UI framework then calls <codeph>CExampleApplication::AppDllUid()</codeph> to |
|
31 obtain the application's UID. The UID returned must match the second value |
|
32 defined in the project definition file. </p> <p>Once the application is created, |
|
33 the UI framework calls <codeph>CExampleApplication::CreateDocumentL()</codeph> to |
|
34 create an instance of the document class. <codeph>CreateDocumentL()</codeph> internally |
|
35 calls the constructor of the document class and passes the supplied reference |
|
36 to the constructor initialisation list. The document has no real work to do |
|
37 in this simple GUI application. </p> <p>As soon as the document has been created |
|
38 the UI framework creates an instance of the application UI (appUI). The appUI |
|
39 class is an instance of a <xref href="GUID-1185F595-0488-3E93-8D60-6B3A1A3AC32E.dita"><apiname>CEikAppUi</apiname></xref> -derived class and |
|
40 this class takes care of user interaction. </p> <p>AppUI creation uses two |
|
41 phase construction where first <codeph>CExampleDocument::CreateAppUiL()</codeph> is |
|
42 called and then the framework calls the second phase constructor of the appUI |
|
43 class. <codeph>CExampleAppUi::ConstructL()</codeph> creates and owns the view. |
|
44 User commands are handled by the <codeph>CExampleAppUi::HandleCommandL()</codeph> method. </p> <p>The |
|
45 app view class is used to draw the view. The view in this example consists |
|
46 of a simple outline rectangle with text drawn in the middle. </p> <p>The example |
|
47 contains a resource file <filepath>HelloWorld.rss</filepath> which defines |
|
48 resource information. This includes a menubar with four menu items, an icon |
|
49 and caption. </p> <p> <filepath>HelloWorld.hrh</filepath> defines the menu |
|
50 command IDs and <filepath>HelloWorld.pkg</filepath> file is the source file |
|
51 used for installation file (SIS file) generation. </p> </section> |
|
52 <section><title>Building and configuring</title> <p>Steps to build the example: </p> <ul> |
|
53 <li id="GUID-81019373-E4C4-545E-85B9-1C4810203D5D"><p>You can build the example |
|
54 from your IDE or the command line. </p> <p>If you use an IDE, import the <filepath>bld.inf</filepath> file |
|
55 of the example into your IDE, and use the build command of the IDE. </p> <p>If |
|
56 you use the command line, open a command prompt, and set the current directory |
|
57 to the source code directory of the example. You can then build the example |
|
58 with the SBSv1 build tools with the following commands: </p> <p><userinput>bldmake |
|
59 bldfiles</userinput> </p> <p><userinput>abld build</userinput> </p> <p><xref href="GUID-793A5EF9-CC16-5EEB-9011-6431EA76EB15.dita">How to use bldmake</xref> and <xref href="GUID-B6B54E07-3B34-5D5C-8815-93383FA8FB4B.dita">How to use abld</xref> describe |
|
60 how to use the SBSv1 build tools. </p> </li> |
|
61 <li id="GUID-83E08D73-33DB-520B-8606-6547796EDE28"><p>For the emulator, the |
|
62 example builds an executable called <filepath>helloworld.exe</filepath> in |
|
63 the <filepath>epoc32\release\winscw\<udeb or urel>\</filepath> folder. </p> </li> |
|
64 </ul> </section> |
|
65 </refbody></reference> |