Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Control contexts

Control contexts allow a group of controls to share graphics context settings for drawing. Each control can optionally use a control context, which is a class derived from MCoeControlContext. By using the same control context, a group of controls can share common settings. A typical use is for components of a compound control to use the same control context to ensure that they use the same background colour settings.

Functions defined by MCoeControlContext are called from within the control framework when a control is about to be drawn, and these functions can be implemented to initialise graphics settings to common values. By using the same control context, a group of controls can all be made to use the same graphics settings.

The context is set for all controls that wish to use it, by setting their iContext members, either directly or using CCoeControl::SetControlContext() or CCoeControl::CopyControlContextFrom(). Whenever a control is about to be drawn, the control framework checks if the control has its iContext member set, and if so, calls MCoeControlContext::ActivateContext(). This function has a default implementation that calls MCoeControlContext::PrepareContext(), which should be implemented to initialise the graphics settings.

The control framework provides one concrete control context class, CCoeBrushAndPenContext, which sets graphics context brush and pen settings. Applications may derive other control context classes if required.

The control framework automatically propagates a compound control’s context to all of its components, when the components set their container with CCoeControl::SetContainerWindowL().