PaintContext Class Reference

#include <Pt/Gfx/PaintContext.h>

Active painting session on a surface. More...

Inherits NonCopyable.

Inherited by PaintContext.

Public Member Functions

 PaintContext (PaintSurface &surface)
 Constructs a context using the paint surface.
 PaintContext (PaintSurface &surface, const RectF &clip)
 Constructs a context using the paint surface and an initial clip rect.
virtual ~PaintContext ()
 Destructor.
const Gfx::ImageFormatformat () const
 Returns the image format.
const Gfx::SizeF & size () const
 Returns the size in physical pixels.
const Scalingscaling () const
 Returns the scaling from logical to physical pixels.
const RectF * clip () const
 Returns the default clip rect or null if clipping is disabled.
void setClip (const RectF &clip)
 Sets the default clip rect for painters on this context.
void resetClip ()
 Resets the default clip rect.
CanvasgetCanvas (Canvas *canvas)
 Returns a canvas for backend drawing.
void sync ()
 Synchronizes pending drawing operations.
void finish ()
 Finishes painting on the surface.

Protected Member Functions

virtual void onDetachSurface (PaintSurface &surface)
 Handles detachment from the surface.

Detailed Description

PaintContext attaches to a PaintSurface for the duration of a paint. It can install a default clip that every painter on this session intersects. Format, size, and scaling are those of the surface. Destroying the context detaches it. The surface must outlive the context.

Forms passes a context into widget paint handlers. A caller can also construct a Painter on a context that already exists. Constructing a Painter directly on a surface creates the session without an explicit context.