×
Namespaces

Variants
Actions

How to ensure that the scroll bar background is drawn properly in Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): All (S60)
Compatibility
Platform(s): S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition, FP2
S60 5th Edition
S60 5th Edition
S60 3rd Edition FP2
S60 3rd Edition FP1
S60 3rd Edition (initial release)
Article
Keywords: CAknsBasicBackgroundControlContext, MObjectProvider, MopSupplyObject, SetMopParent
Created: User:Technical writer 2 (February 8, 2007, updated February 24, 2009)
Last edited: hamishwillee (09 May 2013)

Description

When drawing a control (list box, grid, editor, etc.) that uses a scroll bar, the background of the scroll bar may remain white. This happens when a container does not pass the correct object (context-specific skin parameters) to its child controls. Proper skinning for child controls can be enabled by implementing the CCoeControl::MopSupplyObject() method for the container class, and making sure that the object provider chain between controls and their parents is set up correctly. For more information, see SDK documentation on MObjectProvider and CCoeControl::SetMopParent().

Solution

To correctly draw scroll bar backgrounds, first add the following member variable to the view class derived from CCoeControl:

  CAknsBasicBackgroundControlContext*   iSkinContext;

In the constructor (ConstructL) of that class:

  void CMyCustomGridAppView::ConstructL()
{
...
iSkinContext = CAknsBasicBackgroundControlContext::NewL(
KAknsIIDQsnBgAreaMainAppsGrid,
iAppUi->ApplicationRect(),
EFalse );
}

Note: When using KAknsIIDQsnBgAreaMainAppsGrid skin ID, provide the application (full screen) rect as above.

Then, implement MopSupplyObject() as follows:

  TTypeUid::Ptr CMyCustomGridAppView::MopSupplyObject( TTypeUid aId )
{
if( iSkinContext && aId.iUid == MAknsControlContext::ETypeId )
{
return MAknsControlContext::SupplyMopObject( aId, iSkinContext );
}
return CCoeControl::MopSupplyObject( aId );
}

To ensure UI scalability, remember to update also the background context's size in CCoeControl::SizeChanged().

  void CMyCustomGridAppView::SizeChanged()
{
TRect rect = Rect();
...
iEditor->UpdateScrollBarsL();
iSkinContext->SetRect(rect);
}

See also

This page was last modified on 9 May 2013, at 06:15.
35 page views in the last 30 days.