Namespaces
Variants
Actions
(Difference between revisions)

Drawing custom borders around a Symbian control

Jump to: navigation, search
m (Hamishwillee - Fix platform versions supported)
m (Hamishwillee - Adding missing translation link)
 
Line 69: Line 69:
  
 
{{VersionHint}}
 
{{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

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);
}
This page was last modified on 18 September 2012, at 08:57.
120 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved