×
Namespaces

Variants
Actions

如何绘制自定义边框

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

概述

这段代码演示了如何在一个GUI组件上绘制自定义边框。此代码通过自签名即可执行。

头文件

重载CCoeControl::Draw方法。.

// From CCoeControl
public:
// Draws the view.
void Draw(const TRect& aRect) const;


源文件

定义边框的颜色:

#define KBorderColor TRgb(180, 0, 0)

绘制将在CCoeControl::Draw完成,这样当view被绘制时边框也能显示了.

// 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 16 August 2012, at 09:42.
110 page views in the last 30 days.
×