struct CCL::IGraphics

Overview

Graphics interface for drawing 2D shapes, images, and text. More…

#include <igraphics.h>

struct IGraphics: public CCL::IUnknown
{
    // enums

    enum DrawTextOptions;
    enum Modes;

    // methods

    virtual tresult CCL_API saveState () = 0;
    virtual tresult CCL_API restoreState () = 0;
    virtual tresult CCL_API addClip (RectRef rect) = 0;
    virtual tresult CCL_API addClip (RectFRef rect) = 0;
    virtual tresult CCL_API addClip (IGraphicsPath* path) = 0;
    virtual tresult CCL_API addTransform (TransformRef matrix) = 0;
    virtual int CCL_API getMode () = 0;
    virtual float CCL_API getContentScaleFactor () const = 0;
    virtual tresult CCL_API clearRect (RectRef rect) = 0;
    virtual tresult CCL_API clearRect (RectFRef rect) = 0;
    virtual tresult CCL_API fillRect (RectRef rect, BrushRef brush) = 0;
    virtual tresult CCL_API fillRect (RectFRef rect, BrushRef brush) = 0;
    virtual tresult CCL_API drawRect (RectRef rect, PenRef pen) = 0;
    virtual tresult CCL_API drawRect (RectFRef rect, PenRef pen) = 0;
    virtual tresult CCL_API drawLine (PointRef p1, PointRef p2, PenRef pen) = 0;
    virtual tresult CCL_API drawLine (PointFRef p1, PointFRef p2, PenRef pen) = 0;
    virtual tresult CCL_API drawEllipse (RectRef rect, PenRef pen) = 0;
    virtual tresult CCL_API drawEllipse (RectFRef rect, PenRef pen) = 0;
    virtual tresult CCL_API fillEllipse (RectRef rect, BrushRef brush) = 0;
    virtual tresult CCL_API fillEllipse (RectFRef rect, BrushRef brush) = 0;
    virtual tresult CCL_API drawPath (IGraphicsPath* path, PenRef pen) = 0;
    virtual tresult CCL_API fillPath (IGraphicsPath* path, BrushRef brush) = 0;

    virtual tresult CCL_API drawRoundRect (
        RectRef rect,
        Coord rx,
        Coord ry,
        PenRef pen
    ) = 0;

    virtual tresult CCL_API drawRoundRect (
        RectFRef rect,
        CoordF rx,
        CoordF ry,
        PenRef pen
    ) = 0;

    virtual tresult CCL_API fillRoundRect (
        RectRef rect,
        Coord rx,
        Coord ry,
        BrushRef brush
    ) = 0;

    virtual tresult CCL_API fillRoundRect (
        RectFRef rect,
        CoordF rx,
        CoordF ry,
        BrushRef brush
    ) = 0;

    virtual tresult CCL_API drawTriangle (const Point points [3], PenRef pen) = 0;
    virtual tresult CCL_API drawTriangle (const PointF points [3], PenRef pen) = 0;
    virtual tresult CCL_API fillTriangle (const Point points [3], BrushRef brush) = 0;
    virtual tresult CCL_API fillTriangle (const PointF points [3], BrushRef brush) = 0;

    virtual tresult CCL_API drawString (
        RectRef rect,
        StringRef text,
        FontRef font,
        BrushRef brush,
        AlignmentRef alignment = Alignment ()
    ) = 0;

    virtual tresult CCL_API drawString (
        RectFRef rect,
        StringRef text,
        FontRef font,
        BrushRef brush,
        AlignmentRef alignment = Alignment ()
    ) = 0;

    virtual tresult CCL_API drawString (
        PointRef point,
        StringRef text,
        FontRef font,
        BrushRef brush,
        int options = 0
    ) = 0;

    virtual tresult CCL_API drawString (
        PointFRef point,
        StringRef text,
        FontRef font,
        BrushRef brush,
        int options = 0
    ) = 0;

    virtual int CCL_API getStringWidth (StringRef text, FontRef font) = 0;
    virtual CoordF CCL_API getStringWidthF (StringRef text, FontRef font) = 0;
    virtual tresult CCL_API measureString (Rect& size, StringRef text, FontRef font) = 0;

    virtual tresult CCL_API measureString (
        RectF& size,
        StringRef text,
        FontRef font
    ) = 0;

    virtual tresult CCL_API measureText (
        Rect& size,
        Coord lineWidth,
        StringRef text,
        FontRef font
    ) = 0;

    virtual tresult CCL_API measureText (
        RectF& size,
        CoordF lineWidth,
        StringRef text,
        FontRef font
    ) = 0;

    virtual tresult CCL_API drawText (
        RectRef rect,
        StringRef text,
        FontRef font,
        BrushRef brush,
        TextFormatRef format = TextFormat ()
    ) = 0;

    virtual tresult CCL_API drawText (
        RectFRef rect,
        StringRef text,
        FontRef font,
        BrushRef brush,
        TextFormatRef format = TextFormat ()
    ) = 0;

    virtual tresult CCL_API drawTextLayout (
        PointRef pos,
        ITextLayout* textLayout,
        BrushRef brush,
        int options = 0
    ) = 0;

    virtual tresult CCL_API drawTextLayout (
        PointFRef pos,
        ITextLayout* textLayout,
        BrushRef brush,
        int options = 0
    ) = 0;

    virtual tresult CCL_API drawImage (
        IImage* image,
        PointRef pos,
        const ImageMode* mode = nullptr
    ) = 0;

    virtual tresult CCL_API drawImage (
        IImage* image,
        PointFRef pos,
        const ImageMode* mode = nullptr
    ) = 0;

    virtual tresult CCL_API drawImage (
        IImage* image,
        RectRef src,
        RectRef dst,
        const ImageMode* mode = nullptr
    ) = 0;

    virtual tresult CCL_API drawImage (
        IImage* image,
        RectFRef src,
        RectFRef dst,
        const ImageMode* mode = nullptr
    ) = 0;
};

Inherited Members

public:
    // methods

    virtual tresult CCL_API queryInterface (UIDRef iid, void** ptr) = 0;
    virtual unsigned int CCL_API retain () = 0;
    virtual unsigned int CCL_API release () = 0;

Detailed Documentation

Graphics interface for drawing 2D shapes, images, and text.

Methods

virtual tresult CCL_API saveState () = 0

Save current state to internal stack (clipping and transformation).

virtual tresult CCL_API restoreState () = 0

Restore previous state from internal stack.

virtual tresult CCL_API addClip (RectRef rect) = 0

Append rectangle to current clipping region.

virtual tresult CCL_API addClip (IGraphicsPath* path) = 0

Append path to current clipping region.

virtual tresult CCL_API addTransform (TransformRef matrix) = 0

Append transformation matrix.

virtual int CCL_API getMode () = 0

Get graphics mode.

Use AntiAliasSetter for setting it in the current scope.

virtual float CCL_API getContentScaleFactor () const = 0

Get points to pixels scaling factor.

virtual tresult CCL_API clearRect (RectRef rect) = 0

Clear rectangle with transparent black.

virtual tresult CCL_API fillRect (RectRef rect, BrushRef brush) = 0

Fill rectangle with given brush.

virtual tresult CCL_API drawRect (RectRef rect, PenRef pen) = 0

Stroke rectangle with given pen.

virtual tresult CCL_API drawLine (PointRef p1, PointRef p2, PenRef pen) = 0

Stroke line with given pen.

virtual tresult CCL_API drawEllipse (RectRef rect, PenRef pen) = 0

Stroke ellipse with given pen.

virtual tresult CCL_API fillEllipse (RectRef rect, BrushRef brush) = 0

Fill ellipse with given brush.

virtual tresult CCL_API drawPath (IGraphicsPath* path, PenRef pen) = 0

Stroke path with given pen.

virtual tresult CCL_API fillPath (IGraphicsPath* path, BrushRef brush) = 0

Fill path with given brush.

virtual tresult CCL_API drawRoundRect (
    RectRef rect,
    Coord rx,
    Coord ry,
    PenRef pen
) = 0

Stroke rounded rectangle with given pen.

virtual tresult CCL_API fillRoundRect (
    RectRef rect,
    Coord rx,
    Coord ry,
    BrushRef brush
) = 0

Fill rounded rectangle with given brush.

virtual tresult CCL_API drawTriangle (const Point points [3], PenRef pen) = 0

Stroke triangle with given pen.

virtual tresult CCL_API fillTriangle (const Point points [3], BrushRef brush) = 0

Fill triangle with given brush.

virtual tresult CCL_API drawString (
    RectRef rect,
    StringRef text,
    FontRef font,
    BrushRef brush,
    AlignmentRef alignment = Alignment ()
) = 0

Draw Unicode string with given brush and alignment in bounding rectangle (clips to bounding rect).

virtual tresult CCL_API drawString (
    RectFRef rect,
    StringRef text,
    FontRef font,
    BrushRef brush,
    AlignmentRef alignment = Alignment ()
) = 0

Draw Unicode string with given brush and alignment in bounding rectangle (clips to bounding rect, float coordinates).

virtual tresult CCL_API drawString (
    PointRef point,
    StringRef text,
    FontRef font,
    BrushRef brush,
    int options = 0
) = 0

Draw Unicode string with given brush at given point (left/top or optionally anchored to baseline).

virtual tresult CCL_API drawString (
    PointFRef point,
    StringRef text,
    FontRef font,
    BrushRef brush,
    int options = 0
) = 0

Draw Unicode string with given brush at given point, (left/top or optionally anchored to baseline, float coordinates).

virtual int CCL_API getStringWidth (StringRef text, FontRef font) = 0

Get width of Unicode string with given font.

virtual CoordF CCL_API getStringWidthF (StringRef text, FontRef font) = 0

Get width of Unicode string with given font (float coordinate).

virtual tresult CCL_API measureString (Rect& size, StringRef text, FontRef font) = 0

Measure extent of Unicode string with given font.

virtual tresult CCL_API measureString (
    RectF& size,
    StringRef text,
    FontRef font
) = 0

Measure extent of Unicode string with given font (float coordinates).

virtual tresult CCL_API measureText (
    Rect& size,
    Coord lineWidth,
    StringRef text,
    FontRef font
) = 0

Measure extent of multiline Unicode text based on lineWidth.

virtual tresult CCL_API measureText (
    RectF& size,
    CoordF lineWidth,
    StringRef text,
    FontRef font
) = 0

Measure extent of multiline Unicode text based on lineWidth (float coordinates).

virtual tresult CCL_API drawText (
    RectRef rect,
    StringRef text,
    FontRef font,
    BrushRef brush,
    TextFormatRef format = TextFormat ()
) = 0

Draw multiline Unicode text in bounding rectangle (clips to bounding rect).

virtual tresult CCL_API drawText (
    RectFRef rect,
    StringRef text,
    FontRef font,
    BrushRef brush,
    TextFormatRef format = TextFormat ()
) = 0

Draw multiline Unicode text in bounding rectangle (clips to bounding rect, float coordinates).

virtual tresult CCL_API drawTextLayout (
    PointRef pos,
    ITextLayout* textLayout,
    BrushRef brush,
    int options = 0
) = 0

Draw formatted text described by ITextLayout object (no clipping).

virtual tresult CCL_API drawTextLayout (
    PointFRef pos,
    ITextLayout* textLayout,
    BrushRef brush,
    int options = 0
) = 0

Draw formatted text described by ITextLayout object (no clipping, float coordinates).

virtual tresult CCL_API drawImage (
    IImage* image,
    PointRef pos,
    const ImageMode* mode = nullptr
) = 0

Draw image at given position.

virtual tresult CCL_API drawImage (
    IImage* image,
    RectRef src,
    RectRef dst,
    const ImageMode* mode = nullptr
) = 0

Draw portion of image.

If size of source and destination rectangle differ, scaling is applied.