VSTGUI  4.4
Graphical User Interface Framework not only for VST plugins
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
CDrawContext Class Referenceabstract

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

+ Inheritance diagram for CDrawContext:

Classes

struct  Transform
 Add a transform to all draw routines. More...
 

Public Member Functions

virtual double getScaleFactor () const
 
virtual void beginDraw ()
 
virtual void endDraw ()
 
virtual bool isTypeOf (IdStringPtr s) const
 
virtual CBaseObjectnewCopy () const
 
Line Mode
virtual void setLineStyle (const CLineStyle &style)
 set the current line style More...
 
const CLineStylegetLineStyle () const
 get the current line style More...
 
virtual void setLineWidth (CCoord width)
 set the current line width More...
 
CCoord getLineWidth () const
 get the current line width More...
 
Draw Mode
virtual void setDrawMode (CDrawMode mode)
 set the current draw mode, see CDrawMode More...
 
CDrawMode getDrawMode () const
 get the current draw mode, see CDrawMode More...
 
Clipping
virtual void setClipRect (const CRect &clip)
 set the current clip More...
 
CRectgetClipRect (CRect &clip) const
 get the current clip More...
 
virtual void resetClipRect ()
 reset the clip to the default state More...
 
Color
virtual void setFillColor (const CColor &color)
 set current fill color More...
 
CColor getFillColor () const
 get current fill color More...
 
virtual void setFrameColor (const CColor &color)
 set current stroke color More...
 
CColor getFrameColor () const
 get current stroke color More...
 
Font
virtual void setFontColor (const CColor &color)
 set current font color More...
 
CColor getFontColor () const
 get current font color More...
 
virtual 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
virtual void setGlobalAlpha (float newAlpha)
 sets the global alpha value[0..1] More...
 
float getGlobalAlpha () const
 get current global alpha value More...
 
Global State Stack
virtual void saveGlobalState ()
 
virtual void restoreGlobalState ()
 
Transformation
const CGraphicsTransformgetCurrentTransform () const
 
const CRectgetAbsoluteClipRect () const
 
- Public Member Functions inherited from CBaseObject
 CBaseObject ()
 
virtual ~CBaseObject ()
 
virtual void beforeDelete ()
 
virtual void forget ()
 decrease refcount and delete object if refcount == 0 More...
 
virtual void remember ()
 increase refcount More...
 
virtual int32_t getNbReference () const
 get refcount More...
 
virtual CMessageResult notify (CBaseObject *sender, IdStringPtr message)
 

Protected Member Functions

 CDrawContext (const CRect &surfaceRect)
 
 ~CDrawContext ()
 
virtual void init ()
 
void pushTransform (const CGraphicsTransform &transformation)
 
void popTransform ()
 
const CStringgetDrawString (UTF8StringPtr string)
 
void clearDrawString ()
 

Protected Attributes

CStringdrawStringHelper
 
CRect surfaceRect
 
CDrawContextState currentState
 

Draw primitives

typedef std::pair< CPoint, CPointLinePair
 
typedef std::vector< LinePairLineList
 
typedef std::vector< CPointPointList
 
void moveTo (const CPoint &point)
 
void lineTo (const CPoint &point)
 
void getLoc (CPoint &where) const
 
void drawLines (const CPoint *points, const int32_t &numberOfLines)
 
void drawPolygon (const CPoint *pPoints, int32_t numberOfPoints, const CDrawStyle drawStyle=kDrawStroked)
 
void drawLine (const CPoint &start, const CPoint &end)
 
virtual void drawLine (const LinePair &line)=0
 draw a line More...
 
virtual void drawLines (const LineList &lines)=0
 draw multiple lines at once More...
 
virtual void drawPolygon (const PointList &polygonPointList, const CDrawStyle drawStyle=kDrawStroked)=0
 draw a polygon More...
 
virtual void drawRect (const CRect &rect, const CDrawStyle drawStyle=kDrawStroked)=0
 draw a rect More...
 
virtual void drawArc (const CRect &rect, const float startAngle1, const float endAngle2, const CDrawStyle drawStyle=kDrawStroked)=0
 draw an arc, angles are in degree More...
 
virtual void drawEllipse (const CRect &rect, const CDrawStyle drawStyle=kDrawStroked)=0
 draw an ellipse More...
 
virtual void drawPoint (const CPoint &point, const CColor &color)=0
 draw a point More...
 
virtual void drawBitmap (CBitmap *bitmap, const CRect &dest, const CPoint &offset=CPoint(0, 0), float alpha=1.f)=0
 don't call directly, please use CBitmap::draw instead More...
 
virtual void drawBitmapNinePartTiled (CBitmap *bitmap, const CRect &dest, const CNinePartTiledDescription &desc, float alpha=1.f)
 
virtual void fillRectWithBitmap (CBitmap *bitmap, const CRect &srcRect, const CRect &dstRect, float alpha)
 
virtual void clearRect (const CRect &rect)=0
 clears the rect (makes r = 0, g = 0, b = 0, a = 0) More...
 

Graphics Paths

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

Detailed Description

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

Member Typedef Documentation

typedef std::vector<LinePair> LineList
typedef std::pair<CPoint, CPoint> LinePair
typedef std::vector<CPoint> PointList

Member Enumeration Documentation

Enumerator
kPathFilled 
kPathFilledEvenOdd 
kPathStroked 

Constructor & Destructor Documentation

CDrawContext ( const CRect surfaceRect)
protected
~CDrawContext ( )
protected

Member Function Documentation

virtual void beginDraw ( )
inlinevirtual
void clearDrawString ( )
protected
virtual void clearRect ( const CRect rect)
pure virtual

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

virtual CGraphicsPath* createGraphicsPath ( )
pure virtual

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

virtual CGraphicsPath* createTextPath ( const CFontRef  font,
UTF8StringPtr  text 
)
pure virtual

create a graphics path from a text

virtual void drawArc ( const CRect rect,
const float  startAngle1,
const float  endAngle2,
const CDrawStyle  drawStyle = kDrawStroked 
)
pure virtual

draw an arc, angles are in degree

virtual void drawBitmap ( CBitmap bitmap,
const CRect dest,
const CPoint offset = CPoint(0, 0),
float  alpha = 1.f 
)
pure virtual

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

void drawBitmapNinePartTiled ( CBitmap bitmap,
const CRect dest,
const CNinePartTiledDescription desc,
float  alpha = 1.f 
)
virtual
virtual void drawEllipse ( const CRect rect,
const CDrawStyle  drawStyle = kDrawStroked 
)
pure virtual

draw an ellipse

virtual void drawGraphicsPath ( CGraphicsPath path,
PathDrawMode  mode = kPathFilled,
CGraphicsTransform transformation = 0 
)
pure virtual
void drawLine ( const CPoint start,
const CPoint end 
)
inline
virtual void drawLine ( const LinePair line)
pure virtual

draw a line

void drawLines ( const CPoint points,
const int32_t &  numberOfLines 
)
Deprecated:
use drawLines (const LineList&)
virtual void drawLines ( const LineList lines)
pure virtual

draw multiple lines at once

virtual void drawPoint ( const CPoint point,
const CColor color 
)
pure virtual

draw a point

void drawPolygon ( const CPoint pPoints,
int32_t  numberOfPoints,
const CDrawStyle  drawStyle = kDrawStroked 
)
Deprecated:
use drawPolygon (const PointList&)
virtual void drawPolygon ( const PointList polygonPointList,
const CDrawStyle  drawStyle = kDrawStroked 
)
pure virtual

draw a polygon

virtual void drawRect ( const CRect rect,
const CDrawStyle  drawStyle = kDrawStroked 
)
pure virtual

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

virtual void endDraw ( )
inlinevirtual
virtual void fillLinearGradient ( CGraphicsPath path,
const CGradient gradient,
const CPoint startPoint,
const CPoint endPoint,
bool  evenOdd = false,
CGraphicsTransform transformation = 0 
)
pure virtual
virtual void fillRadialGradient ( CGraphicsPath path,
const CGradient gradient,
const CPoint center,
CCoord  radius,
const CPoint originOffset = CPoint(0, 0),
bool  evenOdd = false,
CGraphicsTransform transformation = 0 
)
pure virtual
void fillRectWithBitmap ( CBitmap bitmap,
const CRect srcRect,
const CRect dstRect,
float  alpha 
)
virtual
const CRect& getAbsoluteClipRect ( ) const
inline
CRect & getClipRect ( CRect clip) const

get the current clip

const CGraphicsTransform & getCurrentTransform ( ) const
CDrawMode getDrawMode ( ) const
inline

get the current draw mode, see CDrawMode

const CString & getDrawString ( UTF8StringPtr  string)
protected
CColor getFillColor ( ) const
inline

get current fill color

const CFontRef getFont ( ) const
inline

get current font

CColor getFontColor ( ) const
inline

get current font color

CColor getFrameColor ( ) const
inline

get current stroke color

float getGlobalAlpha ( ) const
inline

get current global alpha value

const CLineStyle& getLineStyle ( ) const
inline

get the current line style

CCoord getLineWidth ( ) const
inline

get the current line width

void getLoc ( CPoint where) const
inline
virtual double getScaleFactor ( ) const
inlinevirtual
CCoord getStringWidth ( UTF8StringPtr  pStr)

get the width of an UTF-8 encoded string

CCoord getStringWidth ( IPlatformString *  pStr)

get the width of a platform string

void init ( )
protectedvirtual
virtual bool isTypeOf ( IdStringPtr  s) const
inlinevirtual
void lineTo ( const CPoint point)
Deprecated:
use drawLine
void moveTo ( const CPoint point)
Deprecated:
use drawLine
virtual CBaseObject* newCopy ( ) const
inlinevirtual
void popTransform ( )
protected
void pushTransform ( const CGraphicsTransform transformation)
protected
void resetClipRect ( )
virtual

reset the clip to the default state

void restoreGlobalState ( )
virtual
void saveGlobalState ( )
virtual
void setClipRect ( const CRect clip)
virtual

set the current clip

void setDrawMode ( CDrawMode  mode)
virtual

set the current draw mode, see CDrawMode

void setFillColor ( const CColor color)
virtual

set current fill color

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

set current font

void setFontColor ( const CColor color)
virtual

set current font color

void setFrameColor ( const CColor color)
virtual

set current stroke color

void setGlobalAlpha ( float  newAlpha)
virtual

sets the global alpha value[0..1]

void setLineStyle ( const CLineStyle style)
virtual

set the current line style

void setLineWidth ( CCoord  width)
virtual

set the current line width

Member Data Documentation

CDrawContextState currentState
protected
CString* drawStringHelper
protected
CRect surfaceRect
protected

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