×
Namespaces

Variants
Actions
(Difference between revisions)

Drawing custom borders around a Symbian control

From Nokia Developer Wiki
Jump to: navigation, search
Forum Nokia KB (Talk | contribs)
extkbeditor1 (Talk | contribs)
m
Line 2: Line 2:
 
__NOEDITSECTION__
 
__NOEDITSECTION__
 
{{KBCS}}
 
{{KBCS}}
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
+
{{CodeSnippet
|-
+
|id= CS000824
|'''ID''' || CS000824
+
|platform=S60 3rd Edition<br/>S60 3rd Edition, FP1<br/>S60 3rd Edition, FP2  
|'''Creation date''' || February 15, 2008
+
|devices=Nokia E90 Communicator<br/>Nokia N95 8GB
|-
+
|category=Symbian C++
|'''Platform''' || S60 3rd Edition<br>S60 3rd Edition, FP1<br>S60 3rd Edition, FP2  
+
|subcategory=UI
|'''Tested on devices''' || Nokia E90 Communicator<br>Nokia N95 8GB
+
|creationdate=February 15, 2008
|-
+
|keywords=CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
|'''Category''' || Symbian C++
+
}}
|'''Subcategory''' || UI  
+
|-
+
|'''APIs''' || None
+
|'''Classes''' || CWindowGc<br>CGraphicsContext<br>TRect
+
|-
+
|'''Methods''' || CCoeControl::Draw
+
|&nbsp; ||&nbsp;
+
|}
+
  
 
==Overview==
 
==Overview==

Revision as of 14:18, 8 October 2008


Template:KBCS

Article Metadata
Tested with
Devices(s): Nokia E90 Communicator
Nokia N95 8GB
CompatibilityArticle
Keywords: CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
Created: (15 Feb 2008)
Last edited: extkbeditor1 (08 Oct 2008)

Overview

This code snippet demonstrates how to draw a custom border around a GUI component.

This snippet can be self-signed.


Header file

Override the CCoeControl::Draw method.

// From CCoeControl
public:
// 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 the 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)
gc.SetBrushColor(KBorderColor);
TRect rect = iComponent->Rect();
// Enlarge 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);
gc.DrawRect(rect);
}
128 page views in the last 30 days.
×