VSTGUI: CDrawContext Class Reference

VSTGUI 4.10 Graphical User Interface Framework not only for VST plugins

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Public Member Functions | Protected Member Functions | List of all members
CDrawContext Class Reference

A drawing context encapsulates the drawing context of the underlying OS. More...

Inheritance diagram for CDrawContext:

## Classes
struct | Impl
struct | Transform
| Add a transform to all draw routines. More...

## Public Member Functions
void | beginDraw ()
void | endDraw ()
const CRect & | getSurfaceRect () const
| CDrawContext (const PlatformGraphicsDeviceContextPtr device, const CRect &surfaceRect, double scaleFactor)
| ~CDrawContext () noexceptoverride
const PlatformGraphicsDeviceContextPtr & | getPlatformDeviceContext () const
void | setBitmapInterpolationQuality (BitmapInterpolationQuality quality)
| set the current bitmap interpolation quality
BitmapInterpolationQuality | getBitmapInterpolationQuality () const
| get the current bitmap interpolation quality
Line Mode
void | setLineStyle (const CLineStyle &style)
| set the current line style
const CLineStyle & | getLineStyle () const
| get the current line style
void | setLineWidth (CCoord width)
| set the current line width
CCoord | getLineWidth () const
| get the current line width
Draw Mode
void | setDrawMode (CDrawMode mode)
| set the current draw mode, see CDrawMode
CDrawMode | getDrawMode () const
| get the current draw mode, see CDrawMode
Clipping
void | setClipRect (const CRect &clip)
| set the current clip
CRect & | getClipRect (CRect &clip) const
| get the current clip
void | resetClipRect ()
| reset the clip to the default state
Color
void | setFillColor (const CColor &color)
| set current fill color
CColor | getFillColor () const
| get current fill color
void | setFrameColor (const CColor &color)
| set current stroke color
CColor | getFrameColor () const
| get current stroke color
Font
void | setFontColor (const CColor &color)
| set current font color
CColor | getFontColor () const
| get current font color
void | setFont (const CFontRef font, const CCoord &size=0, const int32_t &style=-1)
| set current font
const CFontRef | getFont () const
| get current font
Text
CCoord | getStringWidth (UTF8StringPtr pStr)
| get the width of an UTF-8 encoded string
void | drawString (UTF8StringPtr string, const CRect &_rect, const CHoriTxtAlign hAlign=kCenterText, bool antialias=true)
| draw an UTF-8 encoded string
void | drawString (UTF8StringPtr string, const CPoint &_point, bool antialias=true)
| draw an UTF-8 encoded string
CCoord | getStringWidth (IPlatformString *pStr)
| get the width of a platform string
void | drawString (IPlatformString *string, const CRect &_rect, const CHoriTxtAlign hAlign=kCenterText, bool antialias=true)
| draw a platform string
void | drawString (IPlatformString *string, const CPoint &_point, bool antialias=true)
| draw a platform string
Global Alpha State
void | setGlobalAlpha (float newAlpha)
| sets the global alpha value[0..1]
float | getGlobalAlpha () const
| get current global alpha value
Global State Stack
void | saveGlobalState ()
void | restoreGlobalState ()
Transformation
const CGraphicsTransform & | getCurrentTransform () const
const CRect & | getAbsoluteClipRect () const
double | getScaleFactor () const
| returns the backend scale factor.
CCoord | getHairlineSize () const
| returns the current line size which corresponds to one pixel on screen.
Public Member Functions inherited from ReferenceCounted< T >
| ReferenceCounted ()=default
virtual | ~ReferenceCounted () noexcept=default
| ReferenceCounted (const ReferenceCounted &)
ReferenceCounted & | operator= (const ReferenceCounted &)
void | forget () override
| decrease refcount and delete object if refcount == 0
void | remember () override
| increase refcount
virtual int32_t | getNbReference () const
| get refcount

## Protected Member Functions
| CDrawContext ()=delete
| CDrawContext (const CRect &surfaceRect)
void | init ()
void | pushTransform (const CGraphicsTransform &transformation)
void | popTransform ()
const UTF8String & | getDrawString (UTF8StringPtr string)
void | clearDrawString ()

## Draw primitives
using | LinePair = VSTGUI::LinePair
using | LineList = VSTGUI::LineList
using | PointList = VSTGUI::PointList
void | drawLine (const CPoint &start, const CPoint &end)
void | drawLine (const LinePair &line)
| draw a line
void | drawLines (const LineList &lines)
| draw multiple lines at once
void | drawPolygon (const PointList &polygonPointList, const CDrawStyle drawStyle=kDrawStroked)
| draw a polygon
void | drawRect (const CRect &rect, const CDrawStyle drawStyle=kDrawStroked)
| draw a rect
void | drawArc (const CRect &rect, const float startAngle1, const float endAngle2, const CDrawStyle drawStyle=kDrawStroked)
| draw an arc, angles are in degree
void | drawEllipse (const CRect &rect, const CDrawStyle drawStyle=kDrawStroked)
| draw an ellipse
void | drawPoint (const CPoint &point, const CColor &color)
| draw a point
void | drawBitmap (CBitmap *bitmap, const CRect &dest, const CPoint &offset=CPoint(0, 0), float alpha=1.f)
| don't call directly, please use CBitmap::draw instead
void | drawBitmapNinePartTiled (CBitmap *bitmap, const CRect &dest, const CNinePartTiledDescription &desc, float alpha=1.f)
void | fillRectWithBitmap (CBitmap *bitmap, const CRect &srcRect, const CRect &dstRect, float alpha)
void | clearRect (const CRect &rect)
| clears the rect (makes r = 0, g = 0, b = 0, a = 0)

## Graphics Paths
enum | PathDrawMode { kPathFilled, kPathFilledEvenOdd, kPathStroked }
CGraphicsPath * | createGraphicsPath ()
| create a graphics path object, you need to forget it after usage
CGraphicsPath * | createTextPath (const CFontRef font, UTF8StringPtr text)
| create a graphics path from a text
CGraphicsPath * | createRoundRectGraphicsPath (const CRect &size, CCoord radius)
| create a rect with round corners as graphics path, you need to forget it after usage
void | drawGraphicsPath (CGraphicsPath *path, PathDrawMode mode=kPathFilled, CGraphicsTransform *transformation=nullptr)
void | fillLinearGradient (CGraphicsPath *path, const CGradient &gradient, const CPoint &startPoint, const CPoint &endPoint, bool evenOdd=false, CGraphicsTransform *transformation=nullptr)
void | fillRadialGradient (CGraphicsPath *path, const CGradient &gradient, const CPoint &center, CCoord radius, const CPoint &originOffset=CPoint(0, 0), bool evenOdd=false, CGraphicsTransform *transformation=nullptr)

## Detailed Description

A drawing context encapsulates the drawing context of the underlying OS.

## Member Typedef Documentation

using LineList = VSTGUI::LineList

using LinePair = VSTGUI::LinePair

using PointList = VSTGUI::PointList

## Member Enumeration Documentation

enum PathDrawMode

Enumerator
kPathFilled |
kPathFilledEvenOdd |
kPathStroked |

## Constructor & Destructor Documentation

CDrawContext | ( | const PlatformGraphicsDeviceContextPtr | device,
|  | const CRect & | surfaceRect,
|  | double | scaleFactor
| ) |  |

~CDrawContext | ( |  | ) |
| overridenoexcept

CDrawContext | ( |  | ) |
| protecteddelete

CDrawContext | ( | const CRect & | surfaceRect | ) |
| explicitprotected

## Member Function Documentation

void beginDraw | ( |  | ) |

void clearDrawString | ( |  | ) |
| protected

void clearRect | ( | const CRect & | rect | ) |

clears the rect (makes r = 0, g = 0, b = 0, a = 0)

CGraphicsPath * createGraphicsPath | ( |  | ) |

create a graphics path object, you need to forget it after usage

CGraphicsPath * createRoundRectGraphicsPath | ( | const CRect & | size,
|  | CCoord | radius
| ) |  |

create a rect with round corners as graphics path, you need to forget it after usage

CGraphicsPath * createTextPath | ( | const CFontRef | font,
|  | UTF8StringPtr | text
| ) |  |

create a graphics path from a text

void drawArc | ( | const CRect & | rect,
|  | const float | startAngle1,
|  | const float | endAngle2,
|  | const CDrawStyle | drawStyle = `kDrawStroked`
| ) |  |

draw an arc, angles are in degree

void drawBitmap | ( | CBitmap * | bitmap,
|  | const CRect & | dest,
|  | const CPoint & | offset = `CPoint (0, 0)`,
|  | float | alpha = `1.f`
| ) |  |

don't call directly, please use CBitmap::draw instead

void drawBitmapNinePartTiled | ( | CBitmap * | bitmap,
|  | const CRect & | dest,
|  | const CNinePartTiledDescription & | desc,
|  | float | alpha = `1.f`
| ) |  |

void drawEllipse | ( | const CRect & | rect,
|  | const CDrawStyle | drawStyle = `kDrawStroked`
| ) |  |

draw an ellipse

void drawGraphicsPath | ( | CGraphicsPath * | path,
|  | PathDrawMode | mode = `kPathFilled`,
|  | CGraphicsTransform * | transformation = `nullptr`
| ) |  |

void drawLine | ( | const CPoint & | start,
|  | const CPoint & | end
| ) |  |
| inline

void drawLine | ( | const LinePair & | line | ) |

draw a line

void drawLines | ( | const LineList & | lines | ) |

draw multiple lines at once

void drawPoint | ( | const CPoint & | point,
|  | const CColor & | color
| ) |  |

draw a point

void drawPolygon | ( | const PointList & | polygonPointList,
|  | const CDrawStyle | drawStyle = `kDrawStroked`
| ) |  |

draw a polygon

void drawRect | ( | const CRect & | rect,
|  | const CDrawStyle | drawStyle = `kDrawStroked`
| ) |  |

draw a rect

void drawString | ( | UTF8StringPtr | string,
|  | const CRect & | _rect,
|  | const CHoriTxtAlign | hAlign = `kCenterText`,
|  | bool | antialias = `true`
| ) |  |

draw an UTF-8 encoded string

void drawString | ( | UTF8StringPtr | string,
|  | const CPoint & | _point,
|  | bool | antialias = `true`
| ) |  |

draw an UTF-8 encoded string

void drawString | ( | IPlatformString * | string,
|  | const CRect & | _rect,
|  | const CHoriTxtAlign | hAlign = `kCenterText`,
|  | bool | antialias = `true`
| ) |  |

draw a platform string

void drawString | ( | IPlatformString * | string,
|  | const CPoint & | _point,
|  | bool | antialias = `true`
| ) |  |

draw a platform string

void endDraw | ( |  | ) |

void fillLinearGradient | ( | CGraphicsPath * | path,
|  | const CGradient & | gradient,
|  | const CPoint & | startPoint,
|  | const CPoint & | endPoint,
|  | bool | evenOdd = `false`,
|  | CGraphicsTransform * | transformation = `nullptr`
| ) |  |

void fillRadialGradient | ( | CGraphicsPath * | path,
|  | const CGradient & | gradient,
|  | const CPoint & | center,
|  | CCoord | radius,
|  | const CPoint & | originOffset = `CPoint (0, 0)`,
|  | bool | evenOdd = `false`,
|  | CGraphicsTransform * | transformation = `nullptr`
| ) |  |

void fillRectWithBitmap | ( | CBitmap * | bitmap,
|  | const CRect & | srcRect,
|  | const CRect & | dstRect,
|  | float | alpha
| ) |  |

const CRect & getAbsoluteClipRect | ( |  | ) | const

BitmapInterpolationQuality getBitmapInterpolationQuality | ( |  | ) | const

get the current bitmap interpolation quality

CRect & getClipRect | ( | CRect & | clip | ) | const

get the current clip

const CGraphicsTransform & getCurrentTransform | ( |  | ) | const

CDrawMode getDrawMode | ( |  | ) | const

get the current draw mode, see CDrawMode

const UTF8String & getDrawString | ( | UTF8StringPtr | string | ) |
| protected

CColor getFillColor | ( |  | ) | const

get current fill color

const CFontRef getFont | ( |  | ) | const

get current font

CColor getFontColor | ( |  | ) | const

get current font color

CColor getFrameColor | ( |  | ) | const

get current stroke color

float getGlobalAlpha | ( |  | ) | const

get current global alpha value

CCoord getHairlineSize | ( |  | ) | const

returns the current line size which corresponds to one pixel on screen.

do not cache this value, instead ask for it every time you need it.

const CLineStyle & getLineStyle | ( |  | ) | const

get the current line style

CCoord getLineWidth | ( |  | ) | const

get the current line width

const PlatformGraphicsDeviceContextPtr & getPlatformDeviceContext | ( |  | ) | const

double getScaleFactor | ( |  | ) | const

returns the backend scale factor.

CCoord getStringWidth | ( | UTF8StringPtr | pStr | ) |

get the width of an UTF-8 encoded string

CCoord getStringWidth | ( | IPlatformString * | pStr | ) |

get the width of a platform string

const CRect & getSurfaceRect | ( |  | ) | const

void init | ( |  | ) |
| protected

void popTransform | ( |  | ) |
| protected

void pushTransform | ( | const CGraphicsTransform & | transformation | ) |
| protected

void resetClipRect | ( |  | ) |

reset the clip to the default state

void restoreGlobalState | ( |  | ) |

void saveGlobalState | ( |  | ) |

void setBitmapInterpolationQuality | ( | BitmapInterpolationQuality | quality | ) |

set the current bitmap interpolation quality

void setClipRect | ( | const CRect & | clip | ) |

set the current clip

void setDrawMode | ( | CDrawMode | mode | ) |

set the current draw mode, see CDrawMode

void setFillColor | ( | const CColor & | color | ) |

set current fill color

void setFont | ( | const CFontRef | font,
|  | const CCoord & | size = `0`,
|  | const int32_t & | style = `-1`
| ) |  |

set current font

void setFontColor | ( | const CColor & | color | ) |

set current font color

void setFrameColor | ( | const CColor & | color | ) |

set current stroke color

void setGlobalAlpha | ( | float | newAlpha | ) |

sets the global alpha value[0..1]

void setLineStyle | ( | const CLineStyle & | style | ) |

set the current line style

void setLineWidth | ( | CCoord | width | ) |

set the current line width

The documentation for this class was generated from the following files:

- cdrawcontext.h
- cdrawcontext.cpp