Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 04:41, 30 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Understanding the Symbian C++ Helloworld project

From Wiki
Jump to: navigation, search

This article provides an overview of the core files in a basic helloworld Symbian C++ application.

Article Metadata
Created: giridharn (28 May 2007)
Last edited: hamishwillee (30 May 2013)

Understanding the Simple Helloworld Symbian project

Go to HelloBasic/src and take a look at the files. HelloBasicApplication.cpp sets up the application UID, creates the document class, and provides the simple functions that the framework needs to start the application.

  • HelloBasicDocument.cppDocument class is where you would store a pointer to your engine, or that would store the state of the application into a file if you wanted to make it persistent between the times you call it. In this simple example it's empty, and just goes on to create the application ui. We pass a pointer to the document to the rest of the class in case they need access to it in a more complicated program.
  • HelloBasicAppUi.cpp Here you have the menu callbacks, and we create the last class of the framework, the application view.
  • HelloBasicAppView.cpp Application view contains the drawing functions of the application. Also, if you want to do keyboard-based interaction, the event handling happens here. In this simple case the Draw function merely clears the screen.

In the inc/ directory there's a *.h file for each of the four classes (application, document, appui, appview). There's also

  • HelloBasic.pan : creates one panic code for this applications (panics are used during development to show something went wrong, and why), and
  • HelloBasic.hrh : enumerates the user-commands for the menu (in this case only one, ECMD1).

In aif/ there is:

  • HelloBasicAif.rss an Application Information File which contains some obscure resource information, and

In data/ there is:

  • HelloBasic.rss the main resource source file, where the menu structure is described in an ASCII description, and which the Symbian framework reads and compiles to get the actual menu structure.

In the group/ directory you can find

  • bld.inf, a component definition file that lists the project files, such as HelloBasic.mmp which specifies the properties of a project in a platform and compiler independent way. There the project source and header files are listed, as well as where they can be found, similarly which libraries are needed to link the whole application, and so on.
  • Makefile This is not really part of the Symbian machinery, I just prefer typing make instead of several commands with many arguments.
  • ABLD.BAT This file actually is there only if you called bldmake bldfiles (or make).

Finally, there is one file in the sis/ directory,

  • HelloBasic.pkg This is the package file that is used to create the *.sis file that can be installed to the phone (take a look into Makefile to see how the *.sis file is created).

In order to learn a bit more, and see how the help works, let's study the drawing part, which is the Draw function in AppView. Peeking into inc/HelloBasicAppView.h we can find out the class CHelloBasicAppView derives from. In SDK Help, in the Index tab, type in the class name (CCoeControl). We'll learn in which header file it is declared (coecntrl.h), and which library is needed (cone.lib). There's also a very succinct class description. We're interested in the Draw method, find that in the list of members and click the link. In the description it mentions that a graphics context is needed for drawing, suggests using SystemGC(), which indeed is what the Draw() implementation in HelloBasicAppView.cpp does as the first thing. Find also the documentation for SystemGC() and Rect() (both are members of CCoeControl). One more hint about documentation: sometimes the header files (can be found in /epoc32/include, starting from the SDK root) contain some information or additional documentation that didn't make its way to the SDK Help.

This page was last modified on 30 May 2013, at 04:41.
61 page views in the last 30 days.