Wt::WPaintedWidget

来自: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:html

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

Browser Methods Default method
Firefox 1.5+ HtmlCanvas, InlineSVG HtmlCanvas
Internet Explorer 6.0+ InlineVML InlineVML
Safari HtmlCanvas, InlineSVG HtmlCanvas
Opera InlineSVG, HtmlCanvas* InlineSVG
other ? HtmlCanvas

* HtmlCanvas occasionally suffers from rendering artefacts in Opera.web

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().app

若是禁用 JavaScript, 那么基于 JavaScript 的 HtmlCanvas 将不会被采用,而使用 InlineSVG 代替。咱们能够使用 setPreferredMethod() 方法改变渲染方法。ide

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> 选项,默认状况下,这个选项是被关闭的。ui

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.this

要想使用 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  查看评论
本站公众号
   欢迎关注本站公众号,获取更多信息