Beruflich Dokumente
Kultur Dokumente
Quick Start
will get a compilation error when using a workspace with a path that
contains spaces).
After selecting a workspace, you will see the main window of Car-
bide.c++ (Figure 2.2), which is also known as a ‘perspective’. This book
does not explain the user interface of Carbide.c++. Please refer to Car-
bide.c++ Help to learn about it, or refer to the Symbian Press booklet at
developer.symbian.com/carbide booklet wikipage.
1. From the Carbide.c++ main window, select the File | New | Symbian
OS C++ Project menu.
2. On the New Symbian OS C++ Project dialog, select Quick Recipes
on Symbian OS > Hello World (see Figure 2.3).
Figure 2.3 Create a New Project Using the Hello World Project Template
3. Click Next and enter the project name (see Figure 2.4). Note that the
project name should not contain any spaces. For this example, let’s
use ‘HelloWorld’ as the project name.
4. Click Next and select the SDK where you want to build the project
(see Figure 2.5). Note that this template is compatible with S60 3rd
Edition (all Feature Packs) and UIQ 3 (UIQ 3.0 and 3.1). You can
choose S60 3rd Edition or UIQ 3.x or both of them.
5. Click Next to enter the basic properties of the project (see Figure 2.6).
The most important field on this dialog is the Application UID. It is a
unique identifier for your application.
You can apply for UIDs for your applications on the Symbian Signed
website (www.symbiansigned.com). For now, for development and
BUILDING THE HELLO WORLD PROJECT 13
Figure 2.7 The Folders Created for a Standard Symbian C++ Project
(If you have the RVCT compiler installed, you may have additional
build configurations available for smartphone builds. For the discussion
in this chapter, we will be concentrating on WINSCW and GCCE build
configurations only, but more information about the differences between
the GCC-E and RVCT compilers can be found in Chapter 6, Section 6.1.3.)
Tip: At the time of writing this book, most SDKs do not support
Windows Vista. There is a workaround available from the Forum
Nokia wiki (see links section at the end of this chapter) to make an
SDK work on Windows Vista.
The application also contains a single menu item that can be selected
either via the Option softkey on S60 or by a mouse click on the ‘Hel-
loWorld’ title on UIQ (that area is called the title bar). Selecting the
Command1 menu item displays a notification dialog.
Figure 2.10 Hello World Application Running on the S60 3rd Edition Emulator in Land-
scape Mode
16 QUICK START
Figure 2.11 shows the same Hello World application running on the
UIQ 3 emulator in softkey mode. Notice that now the application has a
‘More’ softkey label at the bottom right of the screen. Pressing the right
softkey on the emulator will bring up the menu.
Figure 2.11 Hello World Application Running on the UIQ Emulator in Softkey Mode
These additional lines add a new menu item with the command
identifier EHelloWorldSelectMe and the text string_r_
helloworld_selectme. We will be defining the identifier and
the string later.
2. Open \data\uiq3\HelloWorld.rss and do the same thing for
the resource definition for UIQ.
stateFlags = EQikCmdFlagDebugOnly;
text = string_r_helloworld_close_debug;
},
QIK_COMMAND
{
id = EHelloWorldSelectMe;
type = EQikCommandTypeScreen;
text = string_r_helloworld_selectme;
},
QIK_COMMAND
{
id = EHelloWorldCommand1;
type = EQikCommandTypeScreen;
text = string_r_helloworld_command1;
}
};
}
enum THelloWorldCommand
{
EHelloWorldCommand1 = 0x1000,
EHelloWorldSelectMe
};
At this point, if you build and run the application, you should see a
new item (see Figure 2.13). This menu item does not do anything yet. The
next section discusses how to handle the menu event from this new item.
The two lines above added two strings to the localization file for UK
English language. The first string is used as the title for the notification
dialog and the second one is used as the content.
2. Open \data\HelloWorld_string.rss to add resources that
point to the two strings above.
The lines above added two string resources with the maximum length
of 256 characters.
3. Open \src\HelloWorldAppUi.cpp. This file contains the defini-
tion of CHelloWorldAppUi class, which handles various aspects
of the application’s user interface, including the menu bar.
Every GUI application should have its own AppUi class derived
from CEikAppUi or one of its derivative classes. For example, S60
applications usually use CAknAppUi and UIQ applications usually
use CQikAppUi.
One of the main roles of the AppUi class is to handle commands from
the UI in its HandleCommandL() method. Add the code written
in bold below in CHelloWorldAppUi::HandleCommandL() to
handle the menu event from our new menu item.
{
Exit();
break;
}
case EHelloWorldCommand1:
{
iEikonEnv->InfoWinL(R_HELLOWORLD_CAPTION,
R_HELLOWORLD_CAPTION);
break;
}
case EHelloWorldSelectMe:
{
iEikonEnv->InfoWinL(R_HELLOWORLD_TITLE,
R_HELLOWORLD_DESCRIPTION);
break;
}
default:
// Do nothing
break;
}
}
Figure 2.14 shows the notification dialog that is shown when the user
selects our new item on S60 and UIQ devices.
Figure 2.14 Displaying the Notification Dialog on the Hello World Application
You may prefer not to read this section now, but to continue to the
next chapter and come back later as needed.
(a) An MMP file in the GUI editor (b) An MMP file in the text editor
PRJ_MMPFILES
HelloWorld.mmp
#ifndef UIQ_UMTS_AVAILABLE
gnumakefile icons_scalable_dc.mk
#endif
As you can see, the bld.inf above contains one MMP file, which is
HelloWorld.mmp. It also includes a GNU makefile, icons_scalable
_dc.mk, which is invoked if the macro UIQ_UMTS_AVAILABLE is not
defined. This macro is defined on the UIQ SDK only. In other words, the
ADVANCED TOPICS ON CARBIDE.c++ 23
GNU makefile will be used if the project is compiled using S60 SDK. This
particular makefile will build a scalable icon to be used to represent the
application in the main menu of the smartphone.
An MMP file specifies the properties of a project in a platform- and
compiler-independent way. During the build process, Symbian OS build
tools convert the MMP file into makefiles for particular platforms.
The following code shows the first couple of lines of HelloWorld.
mmp:
TARGET HelloWorld.exe
TARGETTYPE EXE
UID 0x100039CE 0xEF1D5F42
CAPABILITY None
LANG SC
...
When do you need to modify the project files? One case that you will
find very often in the following chapters is adding libraries. The Hello
World project includes some general libraries (see Figure 2.16). In order
to use some specific APIs, such as multimedia or telephony, you would
need to add additional libraries. To add libraries, click Add and select
the libraries you want to add.
Another case that you will also find quite often is adding platform
security capabilities (they are described in Chapter 3). The Hello World
project does not include any capabilities, as you can see in Figure 2.17.
Many APIs discussed in this book require additional capabilities. For
example, the telephony API requires NetworkServices. Click Choose
to add more capabilities to the project file, as shown in Figure 2.17.
24 QUICK START
4. Click Next and select the SDK. The dialog is similar to the one when
creating a new project (shown in Figure 2.5).
5. Click Next to select the MMP files to be imported (see Figure 2.20).
Since most examples contain only one MMP file, you can just press
Next again.
6. The next dialog asks for project name and location (see Figure 2.21).
You can usually just use the default values and click Finish.
2.9 Links
• Code samples for Symbian Press books, including this one:
developer.symbian.com/quickrecipesbook.
• Forum Nokia wiki – Moving to Windows Vista: wiki.forum.nokia.
com/index.php/Moving to Windows Vista.
LINKS 27