Wt::WPaintedWidget

WPaintedWidget是一种向量绘图组件,它在浏览器端渲染并可根据浏览器类型自动选择渲染方式,如HtmlCanvas或InlineSVG。该组件需通过派生类实现paintEvent方法来绘制图形。
来自:http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WPaintedWidget.html#_details

Detailed Description

A widget that is painted using vector graphics.

WPaintedWidget的用途是作为一个widget,允许用户使用向量图在其上作画。

A painted widget is rendered from basic drawing primitives. Rendering is done not on the server but on the browser, using different rendering methods:

WPaintedWidget渲染自基本的绘图元素,渲染发生在浏览器端,而不是服务器端,可能采用以下渲染方法:

BrowserMethodsDefault method
Firefox 1.5+HtmlCanvas, InlineSVGHtmlCanvas
Internet Explorer 6.0+InlineVMLInlineVML
SafariHtmlCanvas, InlineSVGHtmlCanvas
OperaInlineSVG, HtmlCanvas*InlineSVG
other?HtmlCanvas

* HtmlCanvas occasionally suffers from rendering artefacts in Opera.

The different rendering methods correspond to different WPaintDevice implementations, from which this widget choses a suitable one depending on the browser capabilities and configuration.

不同的渲染方法对应不同的 WPaintDevice 实现,WPaintedWidget 会根据浏览器能力和配置自动选择适合的渲染方法。

If no JavaScript is available, the JavaScript-based HtmlCanvas will not be used, and InlineSVG will be used instead. The method used may be changed by using setPreferredMethod().

如果禁用 JavaScript, 那么基于 JavaScript 的 HtmlCanvas 将不会被采用,而使用 InlineSVG 代替。我们可以使用 setPreferredMethod() 方法改变渲染方法。

InlineSVG requires that the document is rendered as XHTML. This must be enabled in the configuration file using the <send-xhtml-mime-type> option. By default, this option is off.

InlineSVG 需要 文档作为 XHTML 渲染,这就要求配置文件中必须设置 <send-xhtml-mime-type> 选项,默认情况下,这个选项是被关闭的。

To use a WPaintedWidget, you must derive from it and reimplement paintEvent(WPaintDevice *paintDevice). To paint on a WPaintDevice, you will need to use a WPainter. Repainting is triggered by calling the update() method.

要想使用 WPaintedWidget,你必须定义继承于它的子类,并重新实现 paintEvent(WPaintDevice *paintDevice) 。要想在 WPaintDevice 作画,你需要使用  WPainter 。Repainting 是由 update()  引发的。

Usage example:【示例

class MyPaintedWidget : public Wt::WPaintedWidget
{
public:
MyPaintedWidget(Wt::WContainerWidget *parent = 0)
: Wt::WPaintedWidget(parent),
foo_(100)
{
resize(200, 200); // provide a default size
}

void setFoo(int foo) {
foo_ = foo;
update(); // trigger a repaint
}

protected:
void paintEvent(Wt::WPaintDevice *paintDevice) {
Wt::WPainter painter(paintDevice);
painter.drawLine(20, 20, foo_, foo_);
...
}

private:
int foo_;
};

CSS

Styling through CSS is not applicable.

Note:【注意
A WPaintedWidget requires that it is given a size using resize() or by a layout manager.
         【 WPaintedWidget 需要被指定尺寸,或指定布局管理器
See also:
WImage

类别: c++witty  查看评论

转载于:https://my.oschina.net/zhmsong/blog/5223

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值