VSTGUI 4.10 Graphical User Interface Framework not only for VST plugins

Classes | List of all members
CDrawContext Class Reference

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

`#include <cdrawcontext.h>`

Inheritance diagram for CDrawContext:

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

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

## Graphics Paths
enum | PathDrawMode { kPathFilled , kPathFilledEvenOdd , kPathStroked }
CGraphicsPath * | createGraphicsPath ()
| create a graphics path object, you need to forget it after usage More...
CGraphicsPath * | createTextPath (const CFontRef font, UTF8StringPtr text)
| create a graphics path from a text More...
CGraphicsPath * | createRoundRectGraphicsPath (const CRect &size, CCoord radius)
| create a rect with round corners as graphics path, you need to forget it after usage More...
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)
void | beginDraw ()
void | endDraw ()
const CRect & | getSurfaceRect () const
| CDrawContext (const PlatformGraphicsDeviceContextPtr device, const CRect &surfaceRect, double scaleFactor)
| ~CDrawContext () noexcept override
const PlatformGraphicsDeviceContextPtr & | getPlatformDeviceContext () const
| 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 More...
void | drawLines (const LineList &lines)
| draw multiple lines at once More...
void | drawPolygon (const PointList &polygonPointList, const CDrawStyle drawStyle=kDrawStroked)
| draw a polygon More...
void | drawRect (const CRect &rect, const CDrawStyle drawStyle=kDrawStroked)
| draw a rect More...
void | drawArc (const CRect &rect, const float startAngle1, const float endAngle2, const CDrawStyle drawStyle=kDrawStroked)
| draw an arc, angles are in degree More...
void | drawEllipse (const CRect &rect, const CDrawStyle drawStyle=kDrawStroked)
| draw an ellipse More...
void | drawPoint (const CPoint &point, const CColor &color)
| draw a point More...
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 More...
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) More...
void | setBitmapInterpolationQuality (BitmapInterpolationQuality quality)
| set the current bitmap interpolation quality More...
BitmapInterpolationQuality | getBitmapInterpolationQuality () const
| get the current bitmap interpolation quality More...

## Detailed Description

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

## Member Typedef Documentation

## ◆ LineList

using LineList = VSTGUI::LineList

## ◆ LinePair

using LinePair = VSTGUI::LinePair

## ◆ PointList

using PointList = VSTGUI::PointList

## Member Enumeration Documentation

## ◆ PathDrawMode

enum PathDrawMode

Enumerator
kPathFilled |
kPathFilledEvenOdd |
kPathStroked |

## Constructor & Destructor Documentation

## ◆ CDrawContext() [1/3]

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

## ◆ ~CDrawContext()

~CDrawContext | ( |  | ) |
| override noexcept

## ◆ CDrawContext() [2/3]

CDrawContext | ( |  | ) |
| protected delete

## ◆ CDrawContext() [3/3]

CDrawContext | ( | const CRect & | surfaceRect | ) |
| explicit protected

## Member Function Documentation

## ◆ beginDraw()

void beginDraw | ( |  | ) |

## ◆ clearDrawString()

void clearDrawString | ( |  | ) |
| protected

## ◆ clearRect()

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

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

## ◆ createGraphicsPath()

CGraphicsPath * createGraphicsPath | ( |  | ) |

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

## ◆ createRoundRectGraphicsPath()

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

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

## ◆ createTextPath()

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

create a graphics path from a text

## ◆ drawArc()

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

draw an arc, angles are in degree

## ◆ drawBitmap()

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

## ◆ drawBitmapNinePartTiled()

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

## ◆ drawEllipse()

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

draw an ellipse

## ◆ drawGraphicsPath()

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

## ◆ drawLine() [1/2]

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

## ◆ drawLine() [2/2]

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

draw a line

## ◆ drawLines()

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

draw multiple lines at once

## ◆ drawPoint()

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

draw a point

## ◆ drawPolygon()

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

draw a polygon

## ◆ drawRect()

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

draw a rect

## ◆ drawString() [1/4]

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

draw a platform string

## ◆ drawString() [2/4]

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

draw a platform string

## ◆ drawString() [3/4]

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

draw an UTF-8 encoded string

## ◆ drawString() [4/4]

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

draw an UTF-8 encoded string

## ◆ endDraw()

void endDraw | ( |  | ) |

## ◆ fillLinearGradient()

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

## ◆ fillRadialGradient()

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

## ◆ fillRectWithBitmap()

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

## ◆ getAbsoluteClipRect()

const CRect & getAbsoluteClipRect | ( |  | ) | const

## ◆ getBitmapInterpolationQuality()

BitmapInterpolationQuality getBitmapInterpolationQuality | ( |  | ) | const

get the current bitmap interpolation quality

## ◆ getClipRect()

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

get the current clip

## ◆ getCurrentTransform()

const CGraphicsTransform & getCurrentTransform | ( |  | ) | const

## ◆ getDrawMode()

CDrawMode getDrawMode | ( |  | ) | const

get the current draw mode, see CDrawMode

## ◆ getDrawString()

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

## ◆ getFillColor()

CColor getFillColor | ( |  | ) | const

get current fill color

## ◆ getFont()

const CFontRef getFont | ( |  | ) | const

get current font

## ◆ getFontColor()

CColor getFontColor | ( |  | ) | const

get current font color

## ◆ getFrameColor()

CColor getFrameColor | ( |  | ) | const

get current stroke color

## ◆ getGlobalAlpha()

float getGlobalAlpha | ( |  | ) | const

get current global alpha value

## ◆ getHairlineSize()

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.

## ◆ getLineStyle()

const CLineStyle & getLineStyle | ( |  | ) | const

get the current line style

## ◆ getLineWidth()

CCoord getLineWidth | ( |  | ) | const

get the current line width

## ◆ getPlatformDeviceContext()

const PlatformGraphicsDeviceContextPtr & getPlatformDeviceContext | ( |  | ) | const

## ◆ getScaleFactor()

double getScaleFactor | ( |  | ) | const

returns the backend scale factor.

## ◆ getStringWidth() [1/2]

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

get the width of a platform string

## ◆ getStringWidth() [2/2]

CCoord getStringWidth | ( | UTF8StringPtr | pStr | ) |

get the width of an UTF-8 encoded string

## ◆ getSurfaceRect()

const CRect & getSurfaceRect | ( |  | ) | const

## ◆ init()

void init | ( |  | ) |
| protected

## ◆ popTransform()

void popTransform | ( |  | ) |
| protected

## ◆ pushTransform()

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

## ◆ resetClipRect()

void resetClipRect | ( |  | ) |

reset the clip to the default state

## ◆ restoreGlobalState()

void restoreGlobalState | ( |  | ) |

## ◆ saveGlobalState()

void saveGlobalState | ( |  | ) |

## ◆ setBitmapInterpolationQuality()

void setBitmapInterpolationQuality | ( | BitmapInterpolationQuality | quality | ) |

set the current bitmap interpolation quality

## ◆ setClipRect()

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

set the current clip

## ◆ setDrawMode()

void setDrawMode | ( | CDrawMode | mode | ) |

set the current draw mode, see CDrawMode

## ◆ setFillColor()

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

set current fill color

## ◆ setFont()

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

set current font

## ◆ setFontColor()

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

set current font color

## ◆ setFrameColor()

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

set current stroke color

## ◆ setGlobalAlpha()

void setGlobalAlpha | ( | float | newAlpha | ) |

sets the global alpha value[0..1]

## ◆ setLineStyle()

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

set the current line style

## ◆ setLineWidth()

void setLineWidth | ( | CCoord | width | ) |

set the current line width

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

- cdrawcontext.h
- cdrawcontext.cpp