Wt
3.2.2
|
A paint device for rendering using the HTML 5 <canvas> element. More...
#include <Wt/WCanvasPaintDevice>
Public Member Functions | |
WCanvasPaintDevice (const WLength &width, const WLength &height, WObject *parent=0, bool paintUpdate=false) | |
Create a canvas paint device. | |
virtual WFlags< FeatureFlag > | features () const |
Returns device features. | |
virtual void | setChanged (WFlags< ChangeFlag > flags) |
Indicates changes in painter state. | |
virtual void | drawArc (const WRectF &rect, double startAngle, double spanAngle) |
Draws an arc. | |
virtual void | drawImage (const WRectF &rect, const std::string &imgUri, int imgWidth, int imgHeight, const WRectF &sourceRect) |
Draws an image. | |
virtual void | drawLine (double x1, double y1, double x2, double y2) |
Draws a line. | |
virtual void | drawPath (const WPainterPath &path) |
Draws a path. | |
virtual void | drawText (const WRectF &rect, WFlags< AlignmentFlag > alignmentFlags, TextFlag textFlag, const WString &text) |
Draws text. | |
virtual WTextItem | measureText (const WString &text, double maxWidth=-1, bool wordWrap=false) |
Measures rendered text size. | |
virtual WFontMetrics | fontMetrics () |
Returns font metrics. | |
virtual void | init () |
Initializes the device for painting. | |
virtual void | done () |
Finishes painting on the device. | |
virtual bool | paintActive () const |
Returns whether painting is active. | |
virtual WLength | width () const |
Returns the device width. | |
virtual WLength | height () const |
Returns the device height. | |
Protected Member Functions | |
virtual WPainter * | painter () const |
Returns the painter that is currently painting on the device. | |
virtual void | setPainter (WPainter *painter) |
Sets the painter. |
A paint device for rendering using the HTML 5 <canvas> element.
The WCanvasPaintDevice is used by WPaintedWidget to render to the browser using the HTML 5 <canvas> element. You usually will not use the device directly, but rather rely on WPaintedWidget to use this device when appropriate.
void Wt::WCanvasPaintDevice::done | ( | ) | [virtual] |
Finishes painting on the device.
This method is called when a WPainter stopped painting.
Implements Wt::WPaintDevice.
void Wt::WCanvasPaintDevice::drawArc | ( | const WRectF & | rect, |
double | startAngle, | ||
double | spanAngle | ||
) | [virtual] |
Draws an arc.
The arc is defined as in WPainter::drawArc(const WRectF& rectangle, int startAngle, int spanAngle)
The arc must be stroked, filled, and transformed using the current painter settings.
Implements Wt::WPaintDevice.
void Wt::WCanvasPaintDevice::drawImage | ( | const WRectF & | rect, |
const std::string & | imageUri, | ||
int | imgWidth, | ||
int | imgHeight, | ||
const WRectF & | sourceRect | ||
) | [virtual] |
Draws an image.
Draws sourceRect from the image with URL imageUri
and original dimensions imgWidth and imgHeight
to the location, into the rectangle defined by rect
.
The image is transformed using the current painter settings.
Implements Wt::WPaintDevice.
void Wt::WCanvasPaintDevice::drawLine | ( | double | x1, |
double | y1, | ||
double | x2, | ||
double | y2 | ||
) | [virtual] |
Draws a line.
The line must be stroked and transformed using the current painter settings.
Implements Wt::WPaintDevice.
void Wt::WCanvasPaintDevice::drawPath | ( | const WPainterPath & | path | ) | [virtual] |
Draws a path.
The path must be stroked, filled, and transformed using the current painter settings.
Implements Wt::WPaintDevice.
void Wt::WCanvasPaintDevice::drawText | ( | const WRectF & | rect, |
WFlags< AlignmentFlag > | alignmentFlags, | ||
TextFlag | textFlag, | ||
const WString & | text | ||
) | [virtual] |
Draws text.
The text must be rendered, stroked and transformed using the current painter settings.
Implements Wt::WPaintDevice.
WFontMetrics Wt::WCanvasPaintDevice::fontMetrics | ( | ) | [virtual] |
Returns font metrics.
This returns font metrics for the current font.
Throws a std::logic_error if the underlying device does not provide font metrics.
Implements Wt::WPaintDevice.
virtual WLength Wt::WCanvasPaintDevice::height | ( | ) | const [virtual] |
Returns the device height.
The device height, in pixels, establishes the height of the device coordinate system.
Implements Wt::WPaintDevice.
void Wt::WCanvasPaintDevice::init | ( | ) | [virtual] |
Initializes the device for painting.
This method is called when a WPainter starts painting.
Implements Wt::WPaintDevice.
WTextItem Wt::WCanvasPaintDevice::measureText | ( | const WString & | text, |
double | maxWidth = -1 , |
||
bool | wordWrap = false |
||
) | [virtual] |
Measures rendered text size.
Returns the bounding rect of the given text when rendered using the current font.
If maxWidth
!= -1, then the text is truncated to fit in the width.
If wordWrap
= true
then text is truncated only at word boundaries. Note that in this case the whitespace at the truncated position is included in the text but not accounted for by the returned width (since usually you will not render the whitespace at the end of a line).
Throws a std::logic_error if the underlying device does not provide font metrics.
Implements Wt::WPaintDevice.
virtual bool Wt::WCanvasPaintDevice::paintActive | ( | ) | const [virtual] |
virtual WPainter* Wt::WCanvasPaintDevice::painter | ( | ) | const [protected, virtual] |
Returns the painter that is currently painting on the device.
Implements Wt::WPaintDevice.
void Wt::WCanvasPaintDevice::setChanged | ( | WFlags< ChangeFlag > | flags | ) | [virtual] |
Indicates changes in painter state.
The flags
argument is the logical OR of one or more change flags.
Implements Wt::WPaintDevice.
virtual WLength Wt::WCanvasPaintDevice::width | ( | ) | const [virtual] |
Returns the device width.
The device width, in pixels, establishes the width of the device coordinate system.
Implements Wt::WPaintDevice.