Header Sep
Symbian OS Tips, Tricks & Code
我的评分 用户评价
登录票选本页

March 2005
Custom controls - extending your UIQ smartphone

[Back]

 

The Symbian OS UIQ 2.1 SDK has a large number of predefined controls that can be used when building applications. It's also possible to create new custom controls that can be used in an application in the same manner as predefined controls. The custom controls can, for example, be used in resource files to specify the contents of a dialog.

The downloadable example application shows how to create a simple custom control.

Download example application>>

The example application shows how to create a simple "compass" control that lets a user specify eight possible directions: N, NW, W, SW, S, SE, E, NE. The exact appearance of the control will depend on the context, but it will typically look like this:

To build this Compass example for the smartphone, use the following:

$ bldmake bldfiles
$ abld build thumb urel
$ makesis compass.pkg
 
When the example application is run, directions can be specified in a dialog box in the same way as, for example, strings and numbers are specified. See the below image.

    


Two classes are used to build the compound control. CCompass and CCompassContainer. They both inherit from CCoeControl:

class CCompass : public CCoeControl

class CCompassContainer : public CCoeControl,
     public MCoeControlObserver

Some virtual methods in CoeControl have been overridden to specify the exact behavior of the control, for example, HandlePointerEventL, FocusChanged and CountComponentControls.

The compass control is defined in the resource header file in order to let the user of the control specify a direction and a height:

STRUCT COMPASSCONTROL
{
 BYTE direction=ENorth;
 WORD height=25;
}

To specify the compass control in the resource file, the following is done:

DLG_LINE
{
 type=ECompassControl;
     prompt = "Direction A";   
 id=ECompassControlIdData;
 control=COMPASSCONTROL
 {
  direction=ENorth;        };
}

More information about Controls can be found in the UIQ 2.1 SDK at:
 » UIQ 2.1 SDK » Developer Library » API Reference » C++ API reference » UI Control Framework » About the UI Control Framework

 

我的评分 用户评价
登录票选本页