(Difference between revisions)

Drawing custom borders around a Symbian control

From Nokia Developer Wiki
Jump to: navigation, search
tapiolaitinen (Talk | contribs)
(New page: {{KBCS}} __NOTOC__ __NOEDITSECTION__ {|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" |- |'''ID''' ||   |'''Creation date''' || February 6, 2008...)
Forum Nokia KB (Talk | contribs)
Line 1: Line 1:

Revision as of 13:48, 8 February 2008

ID   Creation date February 6, 2008
Platform S60 3rd Edition
S60 3rd Edition, FP1
S60 3rd Edition, FP2
Tested on devices Nokia E90 Communicator
Nokia N95 8 GB
Category Symbian C++ Subcategory UI
APIs None Classes CWindowGc
Methods CCoeControl::Draw    


In this code snippet, a custom border is drawn around a GUI component.

This snippet can be self-signed.

Header file

Override CCoeControl::Draw method.

// From CCoeControl
// Draws the view.
void Draw(const TRect& aRect) const;

Source file

Define the color of the border:

#define KBorderColor    TRgb(180, 0, 0)

The drawing is implemented in CCoeControl::Draw method so that the border is drawn every time the view is drawn.

// Draws the view.
void CAppView::Draw(const TRect& aRect) const
CWindowGc& gc = SystemGc();
// Draw the border around the component (iComponent)
TRect rect = iComponent->Rect();
// Grow the border rectangle so that it becomes visible. Without this,
// the rect would only contain the innards of the component, which will
// be obscured by the component itself.
rect.Grow(3, 3);
73 page views in the last 30 days.