Wt: Wt::WPainter Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions
Wt::WPainter Class Reference
Painting system

Vector graphics painting class. More...

`#include <Wt/WPainter>`

List of all members.

## Classes
class | Image
| An image that can be rendered on a WPainter. More...
## Public Types
enum | RenderHint { Antialiasing = 1, LowQualityShadows = 2 }
| Enumeration for render hints. More...
## Public Member Functions
| WPainter ()
| Default constructor.
| WPainter (WPaintDevice *device)
| Creates a painter on a given paint device.
| ~WPainter ()
| Destructor.
bool | begin (WPaintDevice *device)
| Begins painting on a paint device.
bool | isActive () const
| Returns whether this painter is active on a paint device.
bool | end ()
| Ends painting.
WPaintDevice * | device () const
| Returns the device on which this painter is active (or 0 if not active).
void | setRenderHint (RenderHint hint, bool on=true)
| Sets a render hint.
int | renderHints () const
| Returns the current render hints.
void | drawArc (const WRectF &rectangle, int startAngle, int spanAngle)
| Draws an arc.
void | drawArc (double x, double y, double width, double height, int startAngle, int spanAngle)
| Draws an arc.
void | drawChord (const WRectF &rectangle, int startAngle, int spanAngle)
| Draws a chord.
void | drawChord (double x, double y, double width, double height, int startAngle, int spanAngle)
| Draws a chord.
void | drawEllipse (const WRectF &rectangle)
| Draws an ellipse.
void | drawEllipse (double x, double y, double width, double height)
| Draws an ellipse.
void | drawImage (const WPointF &point, const Image &image)
| Draws an image.
void | drawImage (const WPointF &point, const Image &image, const WRectF &sourceRect)
| Draws part of an image.
void | drawImage (const WRectF &rect, const Image &image)
| Draws an image inside a rectangle.
void | drawImage (const WRectF &rect, const Image &image, const WRectF &sourceRect)
| Draws part of an image inside a rectangle.
void | drawImage (double x, double y, const Image &image, double sx=0, double sy=0, double sw=-1, double sh=-1)
| Draws part of an image.
void | drawLine (const WLineF &line)
| Draws a line.
void | drawLine (const WPointF &p1, const WPointF &p2)
| Draws a line.
void | drawLine (double x1, double y1, double x2, double y2)
| Draws a line.
void | drawLines (const WLineF *lines, int lineCount)
| Draws an array of lines.
void | drawLines (const WPointF *pointPairs, int lineCount)
| Draws an array of lines.
void | drawLines (const std::vector< WLineF > &lines)
| Draws an array of lines.
void | drawLines (const std::vector< WPointF > &pointPairs)
| Draws an array of lines.
void | drawPath (const WPainterPath &path)
| Draws a (complex) path.
void | drawPie (const WRectF &rectangle, int startAngle, int spanAngle)
| Draws a pie.
void | drawPie (double x, double y, double width, double height, int startAngle, int spanAngle)
| Draws a pie.
void | drawPoint (const WPointF &position)
| Draws a point.
void | drawPoint (double x, double y)
| Draws a point.
void | drawPoints (const WPointF *points, int pointCount)
| Draws a number of points.
void | drawPolygon (const WPointF *points, int pointCount)
| Draws a polygon.
void | drawPolyline (const WPointF *points, int pointCount)
| Draws a polyline.
void | drawRect (const WRectF &rectangle)
| Draws a rectangle.
void | drawRect (double x, double y, double width, double height)
| Draws a rectangle.
void | drawRects (const WRectF *rectangles, int rectCount)
| Draws a number of rectangles.
void | drawRects (const std::vector< WRectF > &rectangles)
| Draws a number of rectangles.
void | drawText (const WRectF &rect, WFlags< AlignmentFlag > alignmentFlags, TextFlag textFlag, const WString &text)
| Draws text.
void | drawText (const WRectF &rectangle, WFlags< AlignmentFlag > flags, const WString &text)
| Draws text.
void | drawText (double x, double y, double width, double height, WFlags< AlignmentFlag > flags, const WString &text)
| Draws text.
void | drawText (double x, double y, double width, double height, WFlags< AlignmentFlag > alignmentFlags, TextFlag textFlag, const WString &text)
| Draws text.
void | fillPath (const WPainterPath &path, const WBrush &brush)
| Fills a (complex) path.
void | fillRect (const WRectF &rectangle, const WBrush &brush)
| Fills a rectangle.
void | fillRect (double x, double y, double width, double height, const WBrush &brush)
| Fills a rectangle.
void | strokePath (const WPainterPath &path, const WPen &pen)
| Strokes a path.
void | setShadow (const WShadow &shadow)
| Sets a shadow effect.
const WShadow & | shadow () const
| Returns the current shadow effect.
void | setBrush (const WBrush &brush)
| Sets the fill style.
void | setFont (const WFont &font)
| Sets the font.
void | setPen (const WPen &pen)
| Sets the pen.
const WBrush & | brush () const
| Returns the current brush.
const WFont & | font () const
| Returns the current font.
const WPen & | pen () const
| Returns the current pen.
void | setClipping (bool enable)
| Enables or disables clipping.
bool | hasClipping () const
| Returns whether clipping is enabled.
void | setClipPath (const WPainterPath &clipPath)
| Sets the clip path.
WPainterPath | clipPath () const
| Returns the clip path.
void | resetTransform ()
| Resets the current transformation.
void | rotate (double angle)
| Rotates the logical coordinate system.
void | scale (double sx, double sy)
| Scales the logical coordinate system.
void | translate (const WPointF &offset)
| Translates the origin of the logical coordinate system.
void | translate (double dx, double dy)
| Translates the origin of the logical coordinate system.
void | setWorldTransform (const WTransform &matrix, bool combine=false)
| Sets a transformation for the logical coordinate system.
const WTransform & | worldTransform () const
| Returns the current world transformation matrix.
void | save ()
| Saves the current state.
void | restore ()
| Returns the last save state.
void | setViewPort (const WRectF &viewPort)
| Sets the viewport.
void | setViewPort (double x, double y, double width, double height)
| Sets the viewport.
WRectF | viewPort () const
| Returns the viewport.
void | setWindow (const WRectF &window)
| Sets the window.
void | setWindow (double x, double y, double width, double height)
| Sets the window.
WRectF | window () const
| Returns the current window.
WTransform | combinedTransform () const
| Returns the combined transformation matrix.

## Detailed Description

Vector graphics painting class.

The painter class provides a vector graphics interface for painting. It needs to be used in conjunction with a WPaintDevice, onto which it paints. To start painting on a device, either pass the device through the constructor, or use begin().

A typical use is to instantiate a WPainter from within a specialized WPaintedWidget::paintEvent() implementation, to paint on the given paint device, but you can also use a painter to paint directly to a particular paint device of choice, for example to create SVG, PDF or PNG images (as resources).

The painter maintains state such as the current pen, brush, font, shadow, transformation and clipping settings (see setClipping() and setClipPath()). A particular state can be saved using save() and later restored using restore().

The painting system distinguishes between device coordinates, logical coordinates, and local coordinates. The device coordinate system ranges from (0, 0) in the top left corner of the device, to (device->width().toPixels(), device->height().toPixels()) for the bottom right corner. The logical coordinate system defines a coordinate system that may be chosen independent of the geometry of the device, which is convenient to make abstraction of the actual device size. Finally, the current local coordinate system may be different from the logical coordinate system because of a transformation set (using translate(), rotate(), and scale()). Initially, the local coordinate system coincides with the logical coordinate system, which coincides with the device coordinate system.

The device coordinates are defined in terms of pixels. Even though most underlying devices are actual vector graphics formats, when used in conjunction with a WPaintedWidget, these vector graphics are rendered by the browser onto a pixel-based canvas (like the rest of the user-interface). The coordinates are defined such that integer values correspond to an imaginary raster which separates the individual pixels, as in the figure below.

The device coordinate system for a 6x5 pixel device

As a consequence, to avoid anti-aliasing effects when drawing straight lines of width one pixel, you will need to use vertices that indicate the middle of a pixel to get a crisp one-pixel wide line, as in the example figure.

By setting a viewPort() and a window(), a viewPort transformation is defined which maps logical coordinates onto device coordinates. By changing the world transformation (using setWorldTransform(), or translate(), rotate(), scale() operations), it is defined how current local coordinates map onto logical coordinates.

The painter provides support for clipping using an arbitrary path, but not that the WVmlImage paint device only has limited support for clipping.

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_;
     };

See also:
  WPaintedWidget::paintEvent(WPaintDevice *)

## Member Enumeration Documentation

enum Wt::WPainter::RenderHint

Enumeration for render hints.

Enumerator:

  Antialiasing | Antialiasing.
  LowQualityShadows | Use low-quality shadows (applies only to VML)

## Constructor & Destructor Documentation

Wt::WPainter::WPainter | ( |  | ) |

Default constructor.

Before painting, you must invoke begin(WPaintDevice *) on a paint device.

See also:
  WPainter(WPaintDevice *)

## Member Function Documentation

bool Wt::WPainter::begin | ( | WPaintDevice * | device | ) |

Begins painting on a paint device.

See also:
  end(), isActive()

const WBrush& Wt::WPainter::brush | ( |  | ) | const

Returns the current brush.

Returns the brush style that is currently used for filling.

See also:
  setBrush(const WBrush&)

WPainterPath Wt::WPainter::clipPath | ( |  | ) | const

Returns the clip path.

The clip path is returned as it was defined: in the local coordinates at time of definition.

See also:
  setClipPath(const WPainterPath&)

WTransform Wt::WPainter::combinedTransform | ( |  | ) | const

Returns the combined transformation matrix.

Returns the transformation matrix that maps coordinates to device coordinates. It is the combination of the current world transformation (which defines the transformation within the logical coordinate system) and the window/viewport transformation (which transforms logical coordinates to device coordinates).

See also:
  setWorldTransform(), setViewPort(), setWindow()

WPaintDevice* Wt::WPainter::device | ( |  | ) | const

Returns the device on which this painter is active (or 0 if not active).

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

void Wt::WPainter::drawArc | ( | const WRectF & | rectangle,
|  | int | startAngle,
|  | int | spanAngle
| ) |  |

Draws an arc.

Draws an arc using the current pen, and fills using the current brush.

The arc is defined as a segment from an ellipse, which fits in the rectangle. The segment starts at `startAngle`, and spans an angle given by `spanAngle`. These angles have as unit 1/16th of a degree, and are measured counter-clockwise starting from the 3 o'clock position.

See also:
  drawEllipse(const WRectF&), drawChord(const WRectF&, int, int)
  drawArc(double, double, double, double, int, int)

void Wt::WPainter::drawArc | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | int | startAngle,
|  | int | spanAngle
| ) |  |

Draws an arc.

This is an overloaded method for convenience.

See also:
  drawArc(const WRectF&, int, int)

void Wt::WPainter::drawChord | ( | const WRectF & | rectangle,
|  | int | startAngle,
|  | int | spanAngle
| ) |  |

Draws a chord.

Draws an arc using the current pen, and connects start and end point with a line. The area is filled using the current brush.

The arc is defined as a segment from an ellipse, which fits in the rectangle. The segment starts at `startAngle`, and spans an angle given by `spanAngle`. These angles have as unit 1/16th of a degree, and are measured counter-clockwise starting at 3 o'clock.

See also:
  drawEllipse(const WRectF&), drawArc(const WRectF&, int, int)
  drawChord(double, double, double, double, int, int)

void Wt::WPainter::drawChord | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | int | startAngle,
|  | int | spanAngle
| ) |  |

Draws a chord.

This is an overloaded method for convenience.

See also:
  drawChord(const WRectF&, int, int)

void Wt::WPainter::drawEllipse | ( | const WRectF & | rectangle | ) |

Draws an ellipse.

Draws an ellipse using the current pen and fills it using the current brush.

The ellipse is defined as being bounded by the `rectangle`.

See also:
  drawArc(const WRectF&, int, int)
  drawEllipse(double, double, double, double)

void Wt::WPainter::drawEllipse | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Draws an ellipse.

This is an overloaded method for convenience.

See also:
  drawEllipse(const WRectF&)

void Wt::WPainter::drawImage | ( | const WPointF & | point,
|  | const Image & | image
| ) |  |

Draws an image.

Draws the `image` so that the top left corner corresponds to `point`.

This is an overloaded method provided for convenience.

void Wt::WPainter::drawImage | ( | const WPointF & | point,
|  | const Image & | image,
|  | const WRectF & | sourceRect
| ) |  |

Draws part of an image.

Draws the `sourceRect` rectangle from an image to the location `point`.

This is an overloaded method provided for convenience.

void Wt::WPainter::drawImage | ( | const WRectF & | rect,
|  | const Image & | image
| ) |  |

Draws an image inside a rectangle.

Draws the image inside `rect` (If necessary, the image is scaled to fit into the rectangle).

This is an overloaded method provided for convenience.

void Wt::WPainter::drawImage | ( | const WRectF & | rect,
|  | const Image & | image,
|  | const WRectF & | sourceRect
| ) |  |

Draws part of an image inside a rectangle.

Draws the `sourceRect` rectangle from an image inside `rect` (If necessary, the image is scaled to fit into the rectangle).

void Wt::WPainter::drawImage | ( | double | x,
|  | double | y,
|  | const Image & | image,
|  | double | sx = `0`,
|  | double | sy = `0`,
|  | double | sw = `-1`,
|  | double | sh = `-1`
| ) |  |

Draws part of an image.

Draws the `sourceRect` rectangle with top left corner (sx, sy) and size sw x `sh` from an image to the location (x, `y`).

void Wt::WPainter::drawLine | ( | const WLineF & | line | ) |

Draws a line.

Draws a line using the current pen.

See also:
  drawLine(const WPointF&, const WPointF&), drawLine(double, double, double, double)

void Wt::WPainter::drawLine | ( | const WPointF & | p1,
|  | const WPointF & | p2
| ) |  |

Draws a line.

Draws a line defined by two points.

See also:
  drawLine(const WLineF&), drawLine(double, double, double, double)

void Wt::WPainter::drawLine | ( | double | x1,
|  | double | y1,
|  | double | x2,
|  | double | y2
| ) |  |

Draws a line.

Draws a line defined by two points.

See also:
  drawLine(const WLineF&), drawLine(const WPointF&, const WPointF&)

void Wt::WPainter::drawLines | ( | const WLineF * | lines,
|  | int | lineCount
| ) |  |

Draws an array of lines.

Draws the `lineCount` first lines from the given array of lines.

void Wt::WPainter::drawLines | ( | const WPointF * | pointPairs,
|  | int | lineCount
| ) |  |

Draws an array of lines.

Draws `lineCount` lines, where each line is specified using a begin and end point that are read from an array. Thus, the pointPairs array must have at least 2*`lineCount` points.

void Wt::WPainter::drawLines | ( | const std::vector< WLineF > & | lines | ) |

Draws an array of lines.

Draws the lines given in the vector.

void Wt::WPainter::drawLines | ( | const std::vector< WPointF > & | pointPairs | ) |

Draws an array of lines.

Draws a number of lines that are specified by pairs of begin- and endpoints. The vector should hold a number of points that is a multiple of two.

void Wt::WPainter::drawPath | ( | const WPainterPath & | path | ) |

Draws a (complex) path.

Draws and fills the given path using the current pen and brush.

See also:
  strokePath(const WPainterPath&, const WPen&), fillPath(const WPainterPath&, const WBrush&)

void Wt::WPainter::drawPie | ( | const WRectF & | rectangle,
|  | int | startAngle,
|  | int | spanAngle
| ) |  |

Draws a pie.

Draws an arc using the current pen, and connects start and end point with the center of the corresponding ellipse. The area is filled using the current brush.

The arc is defined as a segment from an ellipse, which fits in the rectangle. The segment starts at `startAngle`, and spans an angle given by `spanAngle`. These angles have as unit 1/16th of a degree, and are measured counter-clockwise starting at 3 o'clock.

See also:
  drawEllipse(const WRectF&), drawArc(const WRectF&, int, int)
  drawPie(double, double, double, double, int, int)

void Wt::WPainter::drawPie | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | int | startAngle,
|  | int | spanAngle
| ) |  |

Draws a pie.

This is an overloaded method for convenience.

See also:
  drawPie(const WRectF&, int, int)

void Wt::WPainter::drawPoint | ( | const WPointF & | position | ) |

Draws a point.

Draws a single point using the current pen. This is implemented by drawing a very short line, centered around the given `position`. To get the result of a single point, you should use a pen with a Wt::SquareCap or Wt::RoundCap pen cap style.

See also:
  drawPoint(double, double)

void Wt::WPainter::drawPoint | ( | double | x,
|  | double | y
| ) |  |

Draws a point.

This is an overloaded method for convenience.

See also:
  drawPoint(const WPointF&)

void Wt::WPainter::drawPoints | ( | const WPointF * | points,
|  | int | pointCount
| ) |  |

Draws a number of points.

Draws the `pointCount` first points from the given array of points.

See also:
  drawPoint(const WPointF&)

void Wt::WPainter::drawPolygon | ( | const WPointF * | points,
|  | int | pointCount
| ) |  |

Draws a polygon.

Draws a polygon that is specified by a list of points, using the current pen. The polygon is closed by connecting the last point with the first point, and filled using the current brush.

See also:
  drawPath(const WPainterPath&), drawPolyline()

void Wt::WPainter::drawPolyline | ( | const WPointF * | points,
|  | int | pointCount
| ) |  |

Draws a polyline.

Draws a polyline that is specified by a list of points, using the current pen.

See also:
  drawPath(const WPainterPath&), drawPolygon()

void Wt::WPainter::drawRect | ( | const WRectF & | rectangle | ) |

Draws a rectangle.

Draws and fills a rectangle using the current pen and brush.

See also:
  drawRect(double, double, double, double)

void Wt::WPainter::drawRect | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Draws a rectangle.

This is an overloaded method for convenience.

See also:
  drawRect(const WRectF&)

void Wt::WPainter::drawRects | ( | const WRectF * | rectangles,
|  | int | rectCount
| ) |  |

Draws a number of rectangles.

Draws and fills the `rectCount` first rectangles from the given array, using the current pen and brush.

See also:
  drawRect(const WRectF&)

void Wt::WPainter::drawRects | ( | const std::vector< WRectF > & | rectangles | ) |

Draws a number of rectangles.

Draws and fills a list of rectangles using the current pen and brush.

See also:
  drawRect(const WRectF&)

void Wt::WPainter::drawText | ( | const WRectF & | rect,
|  | WFlags< AlignmentFlag > | alignmentFlags,
|  | TextFlag | textFlag,
|  | const WString & | text
| ) |  |

Draws text.

Draws text using inside the rectangle, using the current font. The text is aligned inside the rectangle following alignment indications given in `flags`. The text is drawn using the current transformation, pen color (pen()) and font settings (font()).

AlignmentFlags is the logical OR of a horizontal and vertical alignment. Horizontal alignment may be one of AlignLeft, AlignCenter, or AlignRight. Vertical alignment is one of AlignTop, AlignMiddle or AlignBottom.

TextFlag determines how the text is rendered in the rectangle. Text can be rendered on one line or by wrapping the words within the rectangle.

Note:
  HtmlCanvas: on older browsers implementing Html5 canvas, text will be rendered horizontally (unaffected by rotation and unaffected by the scaling component of the transformation matrix). In that case, text is overlayed on top of painted shapes (in DOM div's), and is not covered by shapes that are painted after the text. Use the SVG and VML renderers (WPaintedWidget::inlineSvgVml) for the most accurate font rendering. Native HTML5 text rendering is supported on Firefox3+, Chrome2+ and Safari4+.
  TextWordWrap: using the TextWordWrap TextFlag is currently only supported by the SVG backend. The code generated by the SVG backend uses features currently only supported by Inkscape. Inkscape currently supports only Top vertical alignments.

void Wt::WPainter::drawText | ( | const WRectF & | rectangle,
|  | WFlags< AlignmentFlag > | flags,
|  | const WString & | text
| ) |  |

Draws text.

This is an overloaded method for convenience, it will render text on a single line.

See also:
  drawText(const WRectF&, WFlags<AlignmentFlag>, TextFlag textFlag, const WString&)

void Wt::WPainter::drawText | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | WFlags< AlignmentFlag > | flags,
|  | const WString & | text
| ) |  |

Draws text.

This is an overloaded method for convenience.

See also:
  drawText(const WRectF&, WFlags<AlignmentFlag>, const WString&)

void Wt::WPainter::drawText | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | WFlags< AlignmentFlag > | alignmentFlags,
|  | TextFlag | textFlag,
|  | const WString & | text
| ) |  |

Draws text.

This is an overloaded method for convenience.

See also:
  drawText(const WRectF& rect, WFlags<AlignmentFlag> alignmentFlags, TextFlag textFlag, const WString& text)

bool Wt::WPainter::end | ( |  | ) |

Ends painting.

This method is called automatically from the destructor.

void Wt::WPainter::fillPath | ( | const WPainterPath & | path,
|  | const WBrush & | brush
| ) |  |

Fills a (complex) path.

Like drawPath(const WPainterPath&), but does not stroke the path, and fills the path with the given `brush`.

See also:
  drawPath(const WPainterPath&), strokePath(const WPainterPath&, const WPen&)

void Wt::WPainter::fillRect | ( | const WRectF & | rectangle,
|  | const WBrush & | brush
| ) |  |

Fills a rectangle.

Like drawRect(const WRectF&), but does not stroke the rect, and fills the rect with the given `brush`.

See also:
  drawRect(const WRectF&)

void Wt::WPainter::fillRect | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height,
|  | const WBrush & | brush
| ) |  |

Fills a rectangle.

This is an overloaded method for convenience.

See also:
  fillRect(const WRectF&, const WBrush&)

const WFont& Wt::WPainter::font | ( |  | ) | const

Returns the current font.

Returns the font that is currently used for rendering text. The default font is a 10pt sans serif font.

See also:
  setFont(const WFont&)

bool Wt::WPainter::hasClipping | ( |  | ) | const

Returns whether clipping is enabled.

Note:
  Clipping support is limited for the VML renderer.

See also:
  setClipping(bool), setClipPath(const WPainterPath&)

bool Wt::WPainter::isActive | ( |  | ) | const

Returns whether this painter is active on a paint device.

See also:
  begin(WPaintDevice *), end()

const WPen& Wt::WPainter::pen | ( |  | ) | const

Returns the current pen.

Returns the pen that is currently used for stroking.

See also:
  setPen(const WPen&)

int Wt::WPainter::renderHints | ( |  | ) | const

Returns the current render hints.

Returns the logical OR of render hints currently set.

See also:
  setRenderHint(RenderHint, bool).

void Wt::WPainter::resetTransform | ( |  | ) |

Resets the current transformation.

Resets the current transformation to the identity transformation matrix, so that the logical coordinate system coincides with the device coordinate system.

void Wt::WPainter::restore | ( |  | ) |

Returns the last save state.

Pops the last saved state from the state stack.

See also:
  save()

void Wt::WPainter::rotate | ( | double | angle | ) |

Rotates the logical coordinate system.

Rotates the logical coordinate system around its origin. The `angle` is specified in degrees, and positive values are clock-wise.

See also:
  scale(double, double), translate(double, double), resetTransform()

void Wt::WPainter::save | ( |  | ) |

Saves the current state.

A copy of the current state is saved on a stack. This state will may later be restored by popping this state from the stack using restore().

The state that is saved is the current pen, brush, font, shadow, transformation and clipping settings (see setClipping() and setClipPath()).

See also:
  restore()

void Wt::WPainter::scale | ( | double | sx,
|  | double | sy
| ) |  |

Scales the logical coordinate system.

Scales the logical coordinate system around its origin, by a factor in the X and Y directions.

See also:
  rotate(double), translate(double, double), resetTransform()

void Wt::WPainter::setBrush | ( | const WBrush & | brush | ) |

Sets the fill style.

Changes the fills style for subsequent draw operations.

See also:
  brush(), setPen(const WPen&)

void Wt::WPainter::setClipPath | ( | const WPainterPath & | clipPath | ) |

Sets the clip path.

Sets the path that is used for clipping subsequent drawing operations. The clip path is only used when clipping is enabled using setClipping(bool). The path is specified in local coordinates.

Note:
  Clipping support is limited for the VML renderer.

See also:
  clipPath(), setClipping(bool)

void Wt::WPainter::setClipping | ( | bool | enable | ) |

Enables or disables clipping.

Enables are disables clipping for subsequent operations using the current clip path set using setClipPath().

Note:
  Clipping support is limited for the VML renderer. Only clipping with a rectangle is supported for the VML renderer (see WPainterPath::addRect()). The rectangle must, after applying the combined transformation system, be aligned with the window.

See also:
  hasClipping(), setClipPath(const WPainterPath&)

void Wt::WPainter::setFont | ( | const WFont & | font | ) |

Sets the font.

Changes the font for subsequent text rendering. Note that only font sizes that are defined as an explicit size (see WFont::FixedSize) will render correctly in all devices (SVG, VML, and HtmlCanvas).

The list of fonts that will render correctly with VML (on IE<9) are limited to the following: http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html

Careful, for a font family that contains a space, you need to add quotes, to WFont::setFamily() e.g.

     WFont mono;
     mono.setFamily(WFont::Monospace, "'Courier New'");
     mono.setSize(18);

See also:
  font(), drawText()

void Wt::WPainter::setPen | ( | const WPen & | pen | ) |

Sets the pen.

Changes the pen used for stroking subsequent draw operations.

See also:
  pen(), setBrush(const WBrush&)

void Wt::WPainter::setRenderHint | ( | RenderHint | hint,
|  | bool | on = `true`
| ) |  |

Sets a render hint.

Renderers may ignore particular hints for which they have no support.

void Wt::WPainter::setShadow | ( | const WShadow & | shadow | ) |

Sets a shadow effect.

The shadow effect is applied to all things drawn (paths, text and images).

Note:
  With the VML backend (IE), the shadow is not applied to images, and the shadow color is always black; only the opacity (alpha) channel is taken into account.

See also:
  LowQualityShadows

void Wt::WPainter::setViewPort | ( | const WRectF & | viewPort | ) |

Sets the viewport.

Selects the part of the device that will correspond to the logical coordinate system.

By default, the viewport spans the entire device: it is the rectangle (0, 0) to (device->width(), device->height()). The window defines how the viewport is mapped to logical coordinates.

See also:
  viewPort(), setWindow(const WRectF&)

void Wt::WPainter::setViewPort | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Sets the viewport.

This is an overloaded method for convenience.

See also:
  setViewPort(const WRectF&)

void Wt::WPainter::setWindow | ( | const WRectF & | window | ) |

Sets the window.

Defines the viewport rectangle in logical coordinates, and thus how logical coordinates map onto the viewPort.

By default, is (0, 0) to (device->width(), device->height()). Thus, the default window and viewport leave logical coordinates identical to device coordinates.

See also:
  window(), setViewPort(const WRectF&)

void Wt::WPainter::setWindow | ( | double | x,
|  | double | y,
|  | double | width,
|  | double | height
| ) |  |

Sets the window.

This is an overloaded method for convenience.

See also:
  setWindow(const WRectF&)

void Wt::WPainter::setWorldTransform | ( | const WTransform & | matrix,
|  | bool | combine = `false`
| ) |  |

Sets a transformation for the logical coordinate system.

Sets a new transformation which transforms logical coordinates to device coordinates. When `combine` is `true`, the transformation is combined with the current world transformation matrix.

See also:
  worldTransform()
  rotate(double), scale(double, double), translate(double, double)
  resetTransform()

const WShadow& Wt::WPainter::shadow | ( |  | ) | const

Returns the current shadow effect.

See also:
  setShadow()

void Wt::WPainter::strokePath | ( | const WPainterPath & | path,
|  | const WPen & | pen
| ) |  |

Strokes a path.

Like drawPath(const WPainterPath&), but does not fill the path, and strokes the path with the given `pen`.

See also:
  drawPath(const WPainterPath&), fillPath(const WPainterPath&, const WBrush&)

void Wt::WPainter::translate | ( | const WPointF & | offset | ) |

Translates the origin of the logical coordinate system.

Translates the origin of the logical coordinate system to a new location relative to the current logical coordinate system.

See also:
  translate(double, double), rotate(double), scale(double, double), resetTransform()

void Wt::WPainter::translate | ( | double | dx,
|  | double | dy
| ) |  |

Translates the origin of the logical coordinate system.

Translates the origin of the logical coordinate system to a new location relative to the logical coordinate system.

See also:
  translate(const WPointF& offset), rotate(double), scale(double, double), resetTransform()

WRectF Wt::WPainter::viewPort | ( |  | ) | const

Returns the viewport.

See also:
  setViewPort(const WRectF&)

WRectF Wt::WPainter::window | ( |  | ) | const

Returns the current window.

See also:
  setViewPort(const WRectF&)

const WTransform& Wt::WPainter::worldTransform | ( |  | ) | const

Returns the current world transformation matrix.

See also:
  setWorldTransform()

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator