×
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 - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData)
hamishwillee (Talk | contribs)
m (Hamishwillee - Minor tidy up)
Line 1: Line 1:
__NOTOC__
+
[[Category:Symbian C++]][[Category:UI]][[Category:Code Examples]][[Category:Code Snippet]]
__NOEDITSECTION__
+
__NOTOC__ __NOEDITSECTION__
 
{{KBCS}}
 
{{KBCS}}
 
{{ArticleMetaData
 
{{ArticleMetaData
Line 6: Line 6:
 
|platform=S60 3rd Edition<br/>S60 3rd Edition, FP1<br/>S60 3rd Edition, FP2  
 
|platform=S60 3rd Edition<br/>S60 3rd Edition, FP1<br/>S60 3rd Edition, FP2  
 
|devices=Nokia E90 Communicator<br/>Nokia N95 8GB
 
|devices=Nokia E90 Communicator<br/>Nokia N95 8GB
|category=Symbian C++
 
|subcategory=UI
 
 
|creationdate=February 15, 2008
 
|creationdate=February 15, 2008
 
|keywords=CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
 
|keywords=CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
Line 15: Line 13:
 
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|signing=Self Signed
 
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
 
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. -->)
 
|author=[[User:Tapiolaitinen]]
 
|author=[[User:Tapiolaitinen]]
Line 23: Line 21:
  
 
This code snippet demonstrates how to draw a custom border around a GUI component.
 
This code snippet demonstrates how to draw a custom border around a GUI component.
 
This snippet can be self-signed.
 
 
  
 
==Header file==
 
==Header file==
Line 43: Line 38:
 
Define the color of the border:
 
Define the color of the border:
  
<code>
+
<code cpp>
 
#define KBorderColor    TRgb(180, 0, 0)
 
#define KBorderColor    TRgb(180, 0, 0)
 
</code>
 
</code>
Line 49: Line 44:
 
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 <tt>CCoeControl::Draw</tt> method so that the border is drawn every time the view is drawn.
  
<code>
+
<code cpp>
 
// Draws the view.
 
// Draws the view.
 
void CAppView::Draw(const TRect& aRect) const
 
void CAppView::Draw(const TRect& aRect) const
Line 65: Line 60:
 
     }
 
     }
 
</code>
 
</code>
 
[[Category:Symbian C++]][[Category:UI]][[Category:Code Examples]][[Category:Code Snippet]]
 

Revision as of 07:13, 20 December 2011


Template:KBCS

Article Metadata
Tested with
Devices(s): Nokia E90 Communicator
Nokia N95 8GB
CompatibilityPlatform Security
Signing Required: Self Signed
Capabilities: )
Article
Keywords: CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
Created: tapiolaitinen (15 Feb 2008)
Last edited: hamishwillee (20 Dec 2011)

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