UIQ Technology
Symbian OS Library

UIQ 3.1 SDK        UIQ developer portal

[Index] [Spacer] [Previous] [Next]



UIQ Controls - How to Add and Change Text in the View Context Bar


1. Introduction

This guide explains the process of adding and changing text in the view context bar control.

Adding text in the view context bar is quite simple because the functionality for this is gathered in just one class. The view class itself handles tabs.

The view context bar is owned by the view and is not shared with other views.

Location of the view context bar in a vi...

Location of the view context bar in a view


1.1 View Context Class

MQikViewContext is the interface the view class uses for adding, removing, and handling contexts in the view context bar. Through this interface, text and icons are added to the context bar.


1.2 View Base Class

All views are derived, directly or indirectly, from CQikViewBase.

The view context bar can contain different types of controls. Text and icons are handled through the MQikViewContext class and tabs are handled directly through the view class which is derived from CQikViewBase.


1.3 Further Reference

Read more about screen layout in the UIQ Style Guide.

See UIQ API Reference for MQikViewContext and CQikViewBase.

[Top]


2. Architecture

High-level architecture of classes used...

High-level architecture of classes used for the view context bar

[Top]


3 Using the View Context Bar Control


3.1 Includes

Use the following #include directive in your view class:

#include <QikViewBase.h>


3.2 Declarations

1) Declare an enumeration for the control to be used in the view in a .hrh file. These files are included in both resource files (.rss) and .cpp files:

/* Declare the control ID in a .hrh file for use in both .rss and .cpp files*/
enum TMyViewControls
 {
 EContextViewText
 };

2) Declare the text resources in your resource file (.rss).

RESOURCE TBUF r_viewcontext_string { buf = STRING_r_viewcontext_string; }
RESOURCE TBUF r_viewcontext_change_string { buf = STRING_r_viewcontext_change_string; }

3) Declare the text strings that the text resource uses in your localizable string file (.rls).

rls_string STRING_r_viewcontext_string "Context title";
rls_string STRING_r_viewcontext_change_string "Another title";


3.3 Add Text in the View Context Bar

These steps are only necessary the first time you add text to the context view bar. Once this is done, use the steps described in section 3.4 to update the text.

1) To be able to add text to the view context bar, an interface has to be retrieved through the view.

MQikViewContext* viewContext = ViewContext();

2) From here it is simply a matter of calling MQikViewContext::AddTextL().

HBufC* viewContextText = iEikonEnv->AllocReadResourceLC(R_VIEWCONTEXT_STRING);
viewContext->AddTextL(EContextViewText, viewContextText->Des(), EHLeftVCenter, TCoeFont::AnnotationFont());
CleanupStack::PopAndDestroy(viewContextText);

The first argument in AddTextL() is a control ID that represents the order in which icons are placed. The lowest number is placed furthest to the left. Do not use 0 and 1000. These numbers are reserved.


3.4 Change Text in the View Context Bar

These steps can only be used if you already have added text to the context view bar. See section 3.3 first.

1) To be able to change the text in the view context bar, an interface has to be retrieved through the view.

MQikViewContext* viewContext = ViewContext();

2) From here it is simply a matter of calling MQikViewContext::ChangeTextL().

HBufC* viewContextText = iEikonEnv->AllocReadResourceLC(R_VIEWCONTEXT_CHANGE_STRING);
viewContext->ChangeTextL(EContextViewText, viewContextText->Des());
CleanupStack::PopAndDestroy(viewContextText);