×
Namespaces

Variants
Actions
(Difference between revisions)

Drawing custom borders around a Symbian control

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
lpvalente (Talk | contribs)
m (Lpvalente -)
Line 1: Line 1:
[[Category:Symbian C++]][[Category:UI]][[Category:Code Snippet]][[Category:Code Snippet]]
+
[[Category:Symbian C++]][[Category:UI]][[Category:Code Snippet]][[Category:Code Snippet]][[Category:S60 3rd Edition FP1]][[Category:S60 3rd Edition FP2]][[Category:S60 3rd Edition (initial release)]]
{{ArticleMetaData <!-- v1.2 -->
+
{{Archived|timestamp=20120803210705|user=[[User:Lpvalente|Lpvalente]]}}
 +
 
 +
 
 +
{{ArticleMetaData <!-- v1.2 -->
 
|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]]) -->
Line 27: Line 30:
 
==Overview==
 
==Overview==
  
This code snippet demonstrates how to draw a custom border around a GUI component.
+
{Abstract|{This code snippet demonstrates how to draw a custom border around a GUI component.}}
  
 
==Header file==
 
==Header file==
Line 33: Line 36:
 
Override the {{Icode|CCoeControl::Draw}} method.
 
Override the {{Icode|CCoeControl::Draw}} method.
  
<code>
+
<code cpp>
 
// From CCoeControl
 
// From CCoeControl
 
public:
 
public:

Revision as of 00:07, 4 August 2012

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The article is believed to be still valid for the original topic scope.


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: lpvalente (04 Aug 2012)

Overview

{Abstract|{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);
}
117 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.

×