Wt: Wt::WPaintDevice Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
Wt::WPaintDevice Class Referenceabstract
Painting system

The abstract base class for a paint device. More...

`#include <Wt/WPaintDevice.h>`

Inheritance diagram for Wt::WPaintDevice:
[legend]

## Public Types
typedef PaintDeviceFeatureFlag | FeatureFlag
| Typedef for enum Wt::PaintDeviceFeatureFlag.

## Public Member Functions
virtual | ~WPaintDevice ()
| Destructor.
virtual WFlags< PaintDeviceFeatureFlag > | features () const =0
| Returns device features.
virtual WLength | width () const =0
| Returns the device width.
virtual WLength | height () const =0
| Returns the device height.
virtual void | setChanged (WFlags< PainterChangeFlag > flags)=0
| Indicates changes in painter state.
virtual void | drawArc (const WRectF &rect, double startAngle, double spanAngle)=0
| Draws an arc.
virtual void | drawImage (const WRectF &rect, const std::string &imageUri, int imgWidth, int imgHeight, const WRectF &sourceRect)=0
| Draws an image.
virtual void | drawLine (double x1, double y1, double x2, double y2)=0
| Draws a line.
virtual void | drawPath (const WPainterPath &path)=0
| Draws a path.
virtual void | drawRect (const WRectF &rectangle)=0
| Draws a rectangle.
virtual void | drawText (const WRectF &rect, WFlags< AlignmentFlag > alignmentFlags, TextFlag textFlag, const WString &text, const WPointF *clipPoint)=0
| Draws text.
virtual WTextItem | measureText (const WString &text, double maxWidth=-1, bool wordWrap=false)=0
| Measures rendered text size.
virtual WFontMetrics | fontMetrics ()=0
| Returns font metrics.
virtual void | init ()=0
| Initializes the device for painting.
virtual void | done ()=0
| Finishes painting on the device.
virtual bool | paintActive () const =0
| Returns whether painting is active.

## Protected Member Functions
virtual WPainter * | painter () const =0
| Returns the painter that is currently painting on the device.
virtual void | setPainter (WPainter *painter)=0
| Sets the painter.

## Detailed Description

The abstract base class for a paint device.

A WPaintDevice is a device on which may be painted using a WPainter. You should never paint directly on a paint device.

The device defines the size of the drawing area, using width() and height(). These dimensions must be defined in pixel units. In the future, additional information will be included to convert these pixel units to lengths (using DPI information).

You should reimplement this class if you wish to extend the Wt paint system to paint on other devices than the ones provided by the library.

Note: this interface is subject to changes to increase optimization possibilities for the painting using different devices.

See also
  WPainter

## Constructor & Destructor Documentation

## ◆ ~WPaintDevice()

virtual Wt::WPaintDevice::~WPaintDevice | ( |  | ) |
| virtual

Destructor.

Frees all resources associated with this device.

## Member Function Documentation

## ◆ done()

virtual void Wt::WPaintDevice::done | ( |  | ) |
| pure virtual

Finishes painting on the device.

This method is called when a WPainter stopped painting.

See also
  WPainter::end()

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ drawArc()

virtual void Wt::WPaintDevice::drawArc | ( | const WRectF & | rect,
|  | double | startAngle,
|  | double | spanAngle )
| pure virtual

Draws an arc.

The arc describes the segment of an ellipse enclosed by the rect. The segment starts at `startAngle`, and spans an angle given by `spanAngle`. These angles have as unit degree, and are measured counter-clockwise starting from the 3 o'clock position.

The arc must be stroked, filled, and transformed using the current painter settings.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ drawImage()

virtual void Wt::WPaintDevice::drawImage | ( | const WRectF & | rect,
|  | const std::string & | imageUri,
|  | int | imgWidth,
|  | int | imgHeight,
|  | const WRectF & | sourceRect )
| pure 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.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ drawLine()

virtual void Wt::WPaintDevice::drawLine | ( | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2 )
| pure virtual

Draws a line.

The line must be stroked and transformed using the current painter settings.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ drawPath()

virtual void Wt::WPaintDevice::drawPath | ( | const WPainterPath & | path | ) |
| pure virtual

Draws a path.

The path must be stroked, filled, and transformed using the current painter settings.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ drawRect()

virtual void Wt::WPaintDevice::drawRect | ( | const WRectF & | rectangle | ) |
| pure virtual

Draws a rectangle.

The rect must be stroked, filled, and transformed using the current painter settings.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ drawText()

virtual void Wt::WPaintDevice::drawText | ( | const WRectF & | rect,
|  | WFlags< AlignmentFlag > | alignmentFlags,
|  | TextFlag | textFlag,
|  | const WString & | text,
|  | const WPointF * | clipPoint )
| pure virtual

Draws text.

The text must be rendered, stroked and transformed using the current painter settings.

If clipPoint is not null, a check is performed whether the point is inside of the current clip area. If not, the text is not drawn.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ fontMetrics()

virtual WFontMetrics Wt::WPaintDevice::fontMetrics | ( |  | ) |
| pure 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.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ height()

virtual WLength Wt::WPaintDevice::height | ( |  | ) | const
| pure virtual

Returns the device height.

The device height, in pixels, establishes the height of the device coordinate system.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ init()

virtual void Wt::WPaintDevice::init | ( |  | ) |
| pure virtual

Initializes the device for painting.

This method is called when a WPainter starts painting.

See also
  WPainter::begin(WPaintDevice *), painter()

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ measureText()

virtual WTextItem Wt::WPaintDevice::measureText | ( | const WString & | text,
|  | double | maxWidth = -1,
|  | bool | wordWrap = false )
| pure 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.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ paintActive()

virtual bool Wt::WPaintDevice::paintActive | ( |  | ) | const
| pure virtual

Returns whether painting is active.

See also
  init(), painter()

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ painter()

virtual WPainter * Wt::WPaintDevice::painter | ( |  | ) | const
| protectedpure virtual

Returns the painter that is currently painting on the device.

See also
  init()

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ setChanged()

virtual void Wt::WPaintDevice::setChanged | ( | WFlags< PainterChangeFlag > | flags | ) |
| pure virtual

Indicates changes in painter state.

The `flags` argument is the logical OR of one or more change flags.

See also
  ChangeFlag

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.

## ◆ width()

virtual WLength Wt::WPaintDevice::width | ( |  | ) | const
| pure virtual

Returns the device width.

The device width, in pixels, establishes the width of the device coordinate system.

Implemented in Wt::WCanvasPaintDevice, Wt::WMeasurePaintDevice, Wt::WPdfImage, Wt::WRasterImage, Wt::WSvgImage, and Wt::WVmlImage.