Nokia N97 SDK
Example Applications Guide

Progress Bar Control Example

1. About this Example
2. Architecture
3. Design and Implementation


1. About this Example

This tutorial explains how to use progress bars. Progress bars show the progress status of an operation.

The example application can do the following:

The following are examples of progress bars:

The following figure (UML diagram) shows key classes of the progress bar example application. This example uses the Timer class object to generate events. This should be replaced by the classes that issue events in actual applications.

classes.png

Note: The class indicated by a yellow color is the concrete class of the progress bar.


1.1 APIs demonstrated


1.2 Prerequisites

The example makes use of the standard Symbian OS application framework comprising the Application, Document, UI, and View classes. The reader should be aware of this architecture before attempting to understand this example.


1.3 Running this example

The initial view is shown immediately after the example application is launched. The bar as a whole shows total operation, and it is filled from left to right according to the progress status of the operation.

Initial view:

initial_view.jpg

The Options menu displays four choices, Change final values, Show info 1, Show info 2 and Exit.

The Options menu:

options_menu.jpg

Select Show info 1 from the Options menu.


2. Architecture

The example makes use of the standard Symbian OS application framework comprising the Application, Document, UI, and View classes. The reader should be aware of this architecture before attempting to understand this example.


3. Design and Implementation

3.1 Resource definition

PROGRESSINFO, defined in "eikon.rh" , contains all settings that can be used in the resource file. Following example illustrates how to use PROGRESSINFO resource:

 RESOURCE PROGRESSINFO r_my_progress_bar
    {
    text_type = 0;
    splits_in_block = 0;
    finalval = 15;
    width = 120;
    height = 10;
    }

Explanations of PROGRESSINFO resource initializers:

text_type Text type to display. (0: none, 1: percentage, 2:fraction)
splits_in_block Gap between the blocks
finalval Total number of blocks
width Width of the progress bar [in pixel]
height Height of the progress bar [in pixel]


3.2 Constructing the progress bar

The progress bar can be constructed according to two methods:

3.2.1 Construction with the resource file

The following figure shows how to construct the progress bar with the resource file. The function ConstructFromResourceL is called according to the resource data. Next, the progress bar is constructed.

construct_from_resource.gif

3.2.1 Construction with the resource file

The following figure shows how to construct the progress bar without the resource file. Whether or not there is a resource file, CEikProgressInfo::SInfo must be defined and passed to the constructor as a parameter. The second constructor must be called ConstructL.

construct_from_code.gif


3.3 Runtime operations

The function IncrementAndDraw steps the current position of the progress bar forward or backward along the bar.

The gauge value changes depend on the parameter value. For example, when 1 is set to the parameter, the gauge value increases 1 and when -1 is set to the parameter, the gauge value decreases 1. To move the gauge to the target position, use SetAndDraw function. For example, when the function SetAndDraw is invoked with the "0" parameter, the progress bar gauge is reset.

runtime_operations.gif

In this example the final value of progress bar could be changed. The final value is realised by calling IncrementAndDraw with parameter 1 from the CAknExPbarTimer::RunL.


3.4 Capabilities

The application does not require any capabilities. The program capabilities are defined in mmp-files as CAPABILITY NONE.

© Nokia 2009

Back to top