|
|
|
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.
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.
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.
Read more about screen layout in the UIQ Style Guide.
See UIQ API Reference for MQikViewContext and CQikViewBase.
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";
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.
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);