Drawing custom borders around a Symbian control
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot update - Fix metadata etc) |
hamishwillee
(Talk | contribs) m (Hamishwillee - Adding missing translation link) |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | [[Category:Symbian C++]][[Category:UI]][[Category: | + | [[Category:Symbian C++]][[Category:UI]][[Category:S60 3rd Edition (initial release)]][[Category:S60 3rd Edition FP1]][[Category:S60 3rd Edition FP2]][[Category:S60 5th Edition]][[Category:Symbian^3]][[Category:Symbian Anna]][[Category:Nokia Belle]] |
| − | + | {{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]]) --> | ||
|devices= Nokia E90 Communicator<br/>Nokia N95 8GB | |devices= Nokia E90 Communicator<br/>Nokia N95 8GB | ||
|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]) --> | ||
| − | |platform= S60 3rd Edition | + | |platform= S60 3rd Edition and later |
|devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> | |devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> | ||
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | ||
| Line 27: | Line 27: | ||
==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 33: | ||
Override the {{Icode|CCoeControl::Draw}} method. | Override the {{Icode|CCoeControl::Draw}} method. | ||
| − | <code> | + | <code cpp> |
// From CCoeControl | // From CCoeControl | ||
public: | public: | ||
| Line 67: | Line 67: | ||
} | } | ||
</code> | </code> | ||
| + | |||
| + | {{VersionHint}} | ||
| + | <!-- Translation --> [[zh-hans:如何绘制自定义边框]] | ||
Latest revision as of 08:57, 18 September 2012
Article Metadata
Tested with
Devices(s): Nokia E90 Communicator
Nokia N95 8GB
Nokia N95 8GB
Compatibility
Platform(s): S60 3rd Edition and later
Platform Security
Signing Required: Self Signed
Article
Keywords: CWindowGc, CGraphicsContext, TRect, CCoeControl::Draw
Created: tapiolaitinen
(06 Feb 2008)
Last edited: hamishwillee
(18 Sep 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);
}

