03.01.2013 Views

Chapter 1

Chapter 1

Chapter 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In addition to the four C++ classes, you have to define elements of your application's GUI –<br />

the menu, possibly some shortcut keys, and any string resources you might want to use<br />

when localizing the application – in a resource file. In this chapter we'll briefly describe the<br />

simple resource file used for hellogui: we'll take a closer look at resource files in <strong>Chapter</strong><br />

7.<br />

Note<br />

The stated design goal of Symbian OS is to make real, potentially large,<br />

programs easier to write and understand. Compared with this aim,<br />

programming a minimal application really isn't very important. As a<br />

consequence, the document class in nonfile-based applications doesn't do<br />

much, and the idea that the app UI is there to 'edit the document' is a bit<br />

overengineered.<br />

Let's have a look at how the classes in hellogui implement the requirements of APPARC,<br />

Uikon, and CONE, and how the resource file is used to define the main elements of the GUI.<br />

4.4 A Graphical Hello World<br />

4.4.1 The Program<br />

Our example program for this section is hellogui, a graphical version of 'Hello world!'. With<br />

the aid of this example, you'll learn how to build an application for the Uikon GUI. Since the<br />

application is intended to run on a P800 phone, I've used UIQ classes instead of Uikon ones,<br />

but I'll point out the differences as they arise.<br />

It will take more time to learn how a GUI program works and in this chapter we'll only briefly<br />

comment on the C++ code itself. There's nothing particularly difficult about it, but it will be<br />

easier to cover how such programs use C++ when we have seen more of how Symbian OS<br />

C++ works. It's still worth getting to grips with the tools and techniques though, because we'll<br />

be using GUI programs to show off some of the basics of Symbian OS in the next few<br />

chapters.<br />

Despite all the differences in the code, the build process is similar to that for hellotext: we<br />

start with a .mmp file, turn it into the relevant makefile or project file, open up the IDE, build<br />

the program for the emulator and check that it works. Then we rebuild for an ARM target,<br />

copy to the target machine and run it there instead. There are, however, some important<br />

differences:<br />

� GUI programs must be built in such a way that Symbian OS can recognize them and<br />

launch them. To ensure this, a program called hellogui must be built into a path such<br />

as \system\apps\hellogui\ hellogui.app.<br />

� GUI programs use the Symbian OS unique identifier (UID) scheme to verify that they<br />

are Symbian OS GUI applications, and also to associate them, if necessary, with file<br />

types identified by the same UID.<br />

� GUI programs consist not only of the executable .app file, but also GUI data in a<br />

resource file.<br />

In this example, we'll start by looking at the project file for hellogui.app. We'll do a<br />

command-line build for the emulator, to generate hellogui.app together with its resource<br />

file, hellogui.rsc. Then we'll show how you can build the project from the IDE. Finally,<br />

we'll build for an ARM target and transfer both files to a target machine using Symbian OS<br />

Connect.<br />

4.4.2 The Project Specification File

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!