29 #ifndef PT_GFX_CANVAS_H
30 #define PT_GFX_CANVAS_H
32 #include <Pt/Gfx/Api.h>
33 #include <Pt/Gfx/Size.h>
34 #include <Pt/Gfx/Point.h>
35 #include <Pt/Gfx/Rect.h>
36 #include <Pt/Gfx/Scaling.h>
37 #include <Pt/Gfx/Pen.h>
38 #include <Pt/Gfx/Brush.h>
39 #include <Pt/Gfx/Font.h>
40 #include <Pt/Gfx/CompositionMode.h>
41 #include <Pt/Gfx/FontMetrics.h>
42 #include <Pt/Gfx/TextMetrics.h>
43 #include <Pt/Gfx/Transform.h>
44 #include <Pt/Gfx/Path.h>
46 #include <Pt/String.h>
72 enum DirtyFlags :
unsigned
74 DirtyTransform = 0x01,
75 DirtyComposition = 0x02,
240 virtual void onBeginPaint(
const Gfx::Paint& paint) = 0;
242 virtual void onFinishPaint() = 0;
247 virtual void onApplyTransform() = 0;
251 virtual void onApplyCompositionMode() = 0;
253 virtual void onSetPen(
const Pen& pen) = 0;
255 virtual void onApplyPen() = 0;
257 virtual void onSetBrush(
const Brush& pen) = 0;
259 virtual void onApplyBrush() = 0;
261 virtual void onSetFont(
const Gfx::Font& font) = 0;
263 virtual void onApplyFont() = 0;
265 virtual void onSetClip(
const Gfx::RectF* clip) = 0;
267 virtual void onApplyClip() = 0;
270 void invalidate(
unsigned flags);
273 virtual void onDrawLine(
const PointF& from,
const PointF& to) = 0;
275 virtual void onDrawPolyline(
const Gfx::PointF* pts,
const size_t n) = 0;
277 virtual void onFillPolygon(
const Gfx::PointF* ps,
const size_t n) = 0;
279 virtual void onDrawRect(
const Gfx::RectF& rectangle) = 0;
281 virtual void onFillRect(
const Gfx::RectF& rectangle) = 0;
288 virtual void onSetPath(
const Path& path) = 0;
290 virtual void onDrawPath() = 0;
292 virtual void onFillPath() = 0;
294 virtual void onDrawPath(
const Path& path) = 0;
296 virtual void onFillPath(
const Path& path) = 0;
320 void updateTransform();
void beginPaint(const Gfx::Paint &paint)
Begins painting with the given paint state.
Core module.
Definition: Allocator.h:33
const RectF & region() const
Returns the current paint region.
const PointF & origin() const
Returns the logical origin of the current region.
Paint state used by drawing operations.
Definition: Paint.h:50
void drawPath()
Draws the current path.
Attributes for the drawing of outlines.
Definition: Pen.h:54
void fillEllipse(const Gfx::PointF &topLeft, const Gfx::SizeF &size)
Fills an ellipse.
void fillRect(const Gfx::RectF &rectangle)
Fills a rectangle.
void setFont(const Gfx::Font &font)
Sets the current font.
const Scaling & scaling() const
Returns the logical-to-physical scaling.
const FontMetrics & fontMetrics() const
Returns metrics for the current font.
void drawRect(const Gfx::RectF &rectangle)
Draws the outline of a rectangle.
void setPath(const Path &path)
Sets the current path.
Backend canvas for drawing commands.
Definition: Canvas.h:66
Metrics that describe a font face at a given size.
Definition: FontMetrics.h:46
bool isActive() const
Returns true if painting is currently active.
void drawLine(const PointF &from, const PointF &to)
Draws a line between two points.
void drawEllipse(const Gfx::PointF &topLeft, const Gfx::SizeF &size)
Draws the outline of an ellipse.
Blend mode used for drawing operations.
Definition: CompositionMode.h:47
void fillPath(const Path &path)
Fills the given path.
void fillPolygon(const Gfx::PointF *ps, const size_t n)
Fills a polygon.
Logical-to-physical unit conversion.
Definition: Scaling.h:49
Size with floating-point width and height.
Definition: Size.h:45
void drawPath(const Path &path)
Draws the given path.
void fillPath()
Fills the current path.
Point with floating-point X and Y coordinates.
Definition: Point.h:45
void drawBitmap(const Gfx::PointF &to, const Gfx::Bitmap &bitmap, const Gfx::RectF *rect=0)
Draws a bitmap.
void setTransform(const Gfx::Transform &tx)
Sets the current transform.
void setBrush(const Brush &brush)
Sets the current brush.
Metrics for a measured line of text.
Definition: TextMetrics.h:46
const Gfx::ImageFormat & format() const
Returns the pixel format of the target.
Abstract target for drawing operations.
Definition: PaintSurface.h:55
const Gfx::Transform & transform() const
Returns the current transform.
Vector path for drawing outlines and filled shapes.
Definition: Path.h:61
Font request used for text drawing and measurement.
Definition: Font.h:56
void setCompositionMode(const Gfx::CompositionMode &mode)
Sets the current composition mode.
Basic image.
Definition: Image.h:52
void setClip(const RectF &clip)
Sets the clip rectangle.
TextMetrics textMetrics(const Pt::String &text) const
Measures a line of text.
void setScaling(const Scaling &scaling)
Sets the logical-to-physical scaling.
void setRegion(const RectF &r)
Sets the paint region.
void drawPolyline(const Gfx::PointF *ps, const size_t n)
Draws a connected sequence of line segments.
Unicode capable basic_string.
Definition: Api-String.h:44
void setPen(const Pen &pen)
Sets the current pen.
void finishPaint()
Ends the current painting operation.
void drawImage(const Gfx::PointF &to, const Gfx::Image &image, const Gfx::RectF *rect=0)
Draws an image.
void resetTransform()
Resets the transform to the identity matrix.
Fill description for shapes and text.
Definition: Brush.h:145
virtual ~Canvas()
Destroys the canvas.
Rect with floating-point coordinates.
Definition: Rect.h:45
Off-screen drawing surface backed by an image.
Definition: Bitmap.h:60
void resetClip()
Clears the clip rectangle.
void drawText(const PointF &to, const Pt::String &text, const Transform *tform=0)
Draws a line of text.