PainterBase Class Reference

#include <Pt/Gfx/PainterBase.h>

Base class for drawing commands and paint state. More...

Inherits NonCopyable.

Inherited by Painter, and Painter.

Public Member Functions

virtual ~PainterBase ()
 Destructor.
 
void finish ()
 Ends the current painting operation.
 
const ImageFormatformat () const
 Returns the pixel format of the current target.
 
const Scalingscaling () const
 Returns the logical-to-physical scaling of the target.
 
const CompositionModecompositionMode () const
 Returns the current composition mode.
 
void setCompositionMode (const CompositionMode &mode)
 Sets the composition mode.
 
const Penpen () const
 Returns the current pen.
 
void setPen (const Pen &pen)
 Sets the pen used to stroke lines.
 
const Brushbrush () const
 Returns the current brush.
 
void setBrush (const Brush &brush)
 Sets the brush used to fill areas.
 
const Fontfont () const
 Returns the current font.
 
void setFont (const Font &font)
 Sets the font used to draw text.
 
const Transformtransform () const
 Returns the user transform.
 
void setTransform (const Transform &tx)
 Sets the user transform.
 
void resetTransform ()
 Resets the user transform to identity.
 
const RectFclip () const
 Returns the current clip rectangle or null if clipping is disabled.
 
void setClip (const RectF &clip)
 Sets the clipping rect.
 
void resetClip ()
 Resets the clipping rect.
 
void drawLine (const PointF &from, const PointF &to)
 Draws a line between two points.
 
void drawPolyline (const PointF *points, const size_t pointCount)
 Draws a connected sequence of line segments.
 
void fillPolygon (const PointF *points, const size_t pointCount)
 Fills a polygon defined by the given points.
 
void drawRect (const RectF &rect)
 Draws the outline of a rectangle.
 
void fillRect (const RectF &rect)
 Fills a rectangular area.
 
void drawCircle (const PointF &topLeft, double diameter)
 Draws the outline of a circle.
 
void fillCircle (const PointF &topLeft, double diameter)
 Fills a circular area.
 
void drawEllipse (const PointF &topLeft, const SizeF &size)
 Draws the outline of an ellipse.
 
void fillEllipse (const PointF &topLeft, const SizeF &size)
 Fills an elliptical area.
 
void drawArc (const PointF &topLeft, const SizeF &size, float degBegin, float degEnd)
 Draws an arc on an ellipse.
 
void fillChord (const PointF &topLeft, const SizeF &size, float degBegin, float degEnd)
 Fills a chord on an ellipse.
 
void fillPie (const PointF &topLeft, const SizeF &size, float degBegin, float degEnd)
 Fills a pie segment on an ellipse.
 
const Gfx::Pathpath () const
 Returns the current path.
 
void setPath (const Path &path)
 Sets the current path.
 
void drawPath ()
 Draws the current path.
 
void fillPath ()
 Fills the current path.
 
void drawPath (const Path &path)
 Draws the given path.
 
void fillPath (const Path &path)
 Fills the given path.
 
const FontMetricsfontMetrics () const
 Returns the font metrics of the current font.
 
TextMetrics textMetrics (const Pt::String &text) const
 Measures a line of text using the current font.
 
void drawText (const PointF &to, const Pt::String &text)
 Draws a line of text at the given position.
 
void drawText (const PointF &to, const Pt::String &text, const Transform &t)
 Draws a line of text using an additional text transform.
 
void drawImage (const PointF &to, const Image &im)
 Draws an image.
 
void drawImage (const PointF &to, const Image &im, const RectF &rect)
 Draws a rectangular part of an image.
 
void drawBitmap (const PointF &to, const Bitmap &bm)
 Draws a bitmap.
 
void drawBitmap (const PointF &to, const Bitmap &bm, const RectF &rect)
 Draws a rectangular part of a bitmap.
 

Protected Member Functions

 PainterBase ()
 Default constructor.
 
void beginPaint (PaintSurface &surface)
 Begins painting to a paint surface.
 
void beginPaint (PaintContext &context)
 Begins painting to a paint context.
 
const Paintpaint () const
 Returns the current paint state.
 
Canvascanvas () const
 Returns the current canvas or null.
 
virtual void onDetachSurface (PaintSurface &surface)
 Called when the surface is detached.
 
virtual void onDetachContext (PaintContext &context)
 Called when the context is detached.
 

Detailed Description

PainterBase stores the state used by drawing operations and forwards the resulting commands to a Canvas supplied by a PaintSurface or PaintContext. It provides the common API for lines, filled shapes, paths, text and image rendering, while concrete painters only need to manage how painting begins.