×
Namespaces

Variants
Actions
(Difference between revisions)

Drawing custom borders around a Symbian control

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Minor tidy up)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix metadata etc)
Line 1: Line 1:
[[Category:Symbian C++]][[Category:UI]][[Category:Code Examples]][[Category:Code Snippet]]
+
[[Category:Symbian C++]][[Category:UI]][[Category:Code Snippet]][[Category:Code Snippet]]
__NOTOC__ __NOEDITSECTION__
+
{{ArticleMetaData <!-- v1.2 -->
{{KBCS}}
+
{{ArticleMetaData
+
|id= CS000824
+
|platform=S60 3rd Edition<br/>S60 3rd Edition, FP1<br/>S60 3rd Edition, FP2
+
|devices=Nokia E90 Communicator<br/>Nokia N95 8GB
+
|creationdate=February 15, 2008
+
|keywords=CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
+
 
+
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
+
|devices= Nokia E90 Communicator<br/>Nokia N95 8GB
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
+
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
|signing=Self Signed
+
|platform= S60 3rd Edition<br/>S60 3rd Edition, FP1<br/>S60 3rd Edition, FP2
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
+
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|author=[[User:Tapiolaitinen]]
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= Self Signed
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080206
 +
|author= [[User:Tapiolaitinen]]
 +
<!-- The following are not in current metadata -->
 +
|id= CS000824
 
}}
 
}}
  
Line 24: Line 31:
 
==Header file==
 
==Header file==
  
Override the <tt>CCoeControl::Draw</tt> method.
+
Override the {{Icode|CCoeControl::Draw}} method.
  
 
<code>
 
<code>
Line 39: Line 46:
  
 
<code cpp>
 
<code cpp>
#define KBorderColor   TRgb(180, 0, 0)
+
#define KBorderColor TRgb(180, 0, 0)
 
</code>
 
</code>
  
The drawing is implemented in the <tt>CCoeControl::Draw</tt> method so that the border is drawn every time the view is drawn.
+
The drawing is implemented in the {{Icode|CCoeControl::Draw}} method so that the border is drawn every time the view is drawn.
  
 
<code cpp>
 
<code cpp>

Revision as of 08:23, 17 April 2012

Article Metadata
Tested with
Devices(s): Nokia E90 Communicator
Nokia N95 8GB
CompatibilityPlatform Security
Signing Required: Self Signed
Article
Keywords: CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
Created: tapiolaitinen (06 Feb 2008)
Last edited: hamishwillee (17 Apr 2012)

Overview

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

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);
}
115 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×