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

A draw context using a bitmap as it's back buffer. More...

+ Inheritance diagram for COffscreenContext:
+ Collaboration diagram for COffscreenContext:

Public Member Functions

CBitmapgetBitmap () const
 
virtual void beginDraw ()
 
virtual void endDraw ()
 
virtual bool isTypeOf (IdStringPtr s) const
 
virtual CBaseObjectnewCopy () const
 
COffscreenContext Methods
void copyFrom (CDrawContext *pContext, CRect destRect, CPoint srcOffset=CPoint(0, 0))
 copy from offscreen to pContext More...
 
CCoord getWidth () const
 
CCoord getHeight () const
 
Draw primitives
virtual void moveTo (const CPoint &point)
 move line position to point More...
 
virtual void lineTo (const CPoint &point)=0
 draw a line from current position to point More...
 
void getLoc (CPoint &where) const
 
virtual void drawLines (const CPoint *points, const int32_t &numberOfLines)=0
 draw multiple lines at once More...
 
virtual void drawPolygon (const CPoint *pPoints, int32_t numberOfPoints, 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 clearRect (const CRect &rect)=0
 clears the rect (makes r = 0, g = 0, b = 0, a = 0) More...
 
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 CFontRefgetFont () 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...
 
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 ()
 
Offset Transformation
virtual void setOffset (const CPoint &offset)
 
const CPointgetOffset () const
 
Reference Counting Methods
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...
 
Message Methods
virtual CMessageResult notify (CBaseObject *sender, IdStringPtr message)
 

Static Public Member Functions

static COffscreenContextcreate (CFrame *frame, CCoord width, CCoord height)
 

Protected Member Functions

 COffscreenContext (CBitmap *bitmap)
 
 COffscreenContext (const CRect &surfaceRect)
 
 ~COffscreenContext ()
 
virtual void init ()
 
const CStringgetDrawString (UTF8StringPtr string)
 
void clearDrawString ()
 

Protected Attributes

CBitmapbitmap
 
CStringdrawStringHelper
 
CRect surfaceRect
 
CDrawContextState currentState
 
std::stack< CDrawContextState * > globalStatesStack
 

Graphics Paths

virtual CGraphicsPathcreateGraphicsPath ()=0
 create a graphics path object, you need to forget it after usage 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
 
enum  PathDrawMode { kPathFilled, kPathFilledEvenOdd, kPathStroked }
 

Detailed Description

A draw context using a bitmap as it's back buffer.

There are two usage scenarios :

Drawing into a bitmap and then push the contents into another draw context

COffscreenContext* offscreen = COffscreenContext::create (frame, 100, 100);
if (offscreen)
{
offscreen->beginDraw ();
// ...
// draw into offscreen
// ...
offscreen->endDraw ();
offscreen->copyFrom (otherContext, destRect);
offscreen->forget ();
}

Drawing static content into a bitmap and reuse the bitmap for drawing

if (cachedBitmap == 0)
{
COffscreenContext* offscreen = COffscreenContext::create (frame, 100, 100);
if (offscreen)
{
offscreen->beginDraw ();
// ...
// draw into offscreen
// ...
offscreen->endDraw ();
cachedBitmap = offscreen->getBitmap ();
if (cachedBitmap)
cachedBitmap->remember ();
offscreen->forget ();
}
}
if (cachedBitmap)
{
// ...
}

Member Enumeration Documentation

enum PathDrawMode
inherited
Enumerator
kPathFilled 
kPathFilledEvenOdd 
kPathStroked 

Constructor & Destructor Documentation

COffscreenContext ( CBitmap bitmap)
protected

+ Here is the call graph for this function:

COffscreenContext ( const CRect surfaceRect)
protected
~COffscreenContext ( )
protected

+ Here is the call graph for this function:

Member Function Documentation

virtual void beginDraw ( )
inlinevirtualinherited
void clearDrawString ( )
protectedinherited

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void clearRect ( const CRect rect)
pure virtualinherited

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

void copyFrom ( CDrawContext pContext,
CRect  destRect,
CPoint  srcOffset = CPoint (0, 0) 
)

copy from offscreen to pContext

+ Here is the call graph for this function:

COffscreenContext * create ( CFrame frame,
CCoord  width,
CCoord  height 
)
static

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual CGraphicsPath* createGraphicsPath ( )
pure virtualinherited

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

+ Here is the caller graph for this function:

CGraphicsPath * createRoundRectGraphicsPath ( const CRect size,
CCoord  radius 
)
inherited

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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 virtualinherited

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

+ Here is the caller graph for this function:

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

draw an ellipse

+ Here is the caller graph for this function:

virtual void drawGraphicsPath ( CGraphicsPath path,
PathDrawMode  mode = kPathFilled,
CGraphicsTransform transformation = 0 
)
pure virtualinherited

+ Here is the caller graph for this function:

virtual void drawLines ( const CPoint points,
const int32_t &  numberOfLines 
)
pure virtualinherited

draw multiple lines at once

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

draw a point

virtual void drawPolygon ( const CPoint pPoints,
int32_t  numberOfPoints,
const CDrawStyle  drawStyle = kDrawStroked 
)
pure virtualinherited

draw a polygon

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

draw a rect

+ Here is the caller graph for this function:

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

draw an UTF-8 encoded string

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void drawString ( UTF8StringPtr  string,
const CPoint _point,
bool  antialias = true 
)
inherited

draw an UTF-8 encoded string

+ Here is the call graph for this function:

virtual void endDraw ( )
inlinevirtualinherited
virtual void fillLinearGradient ( CGraphicsPath path,
const CGradient gradient,
const CPoint startPoint,
const CPoint endPoint,
bool  evenOdd = false,
CGraphicsTransform transformation = 0 
)
pure virtualinherited

+ Here is the caller graph for this function:

virtual void forget ( )
inlinevirtualinherited

decrease refcount and delete object if refcount == 0

CBitmap* getBitmap ( ) const
inline
CRect & getClipRect ( CRect clip) const
inherited

get the current clip

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CDrawMode getDrawMode ( ) const
inlineinherited

get the current draw mode, see CDrawMode

const CString & getDrawString ( UTF8StringPtr  string)
protectedinherited

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CColor getFillColor ( ) const
inlineinherited

get current fill color

const CFontRef& getFont ( ) const
inlineinherited

get current font

CColor getFontColor ( ) const
inlineinherited

get current font color

CColor getFrameColor ( ) const
inlineinherited

get current stroke color

float getGlobalAlpha ( ) const
inlineinherited

get current global alpha value

+ Here is the caller graph for this function:

CCoord getHeight ( ) const
inline

+ Here is the call graph for this function:

const CLineStyle& getLineStyle ( ) const
inlineinherited

get the current line style

CCoord getLineWidth ( ) const
inlineinherited

get the current line width

void getLoc ( CPoint where) const
inlineinherited
virtual int32_t getNbReference ( ) const
inlinevirtualinherited

get refcount

const CPoint& getOffset ( ) const
inlineinherited
CCoord getStringWidth ( UTF8StringPtr  pStr)
inherited

get the width of an UTF-8 encoded string

+ Here is the call graph for this function:

CCoord getWidth ( ) const
inline

+ Here is the call graph for this function:

void init ( )
protectedvirtualinherited

+ Here is the call graph for this function:

virtual bool isTypeOf ( IdStringPtr  s) const
inlinevirtualinherited
virtual void lineTo ( const CPoint point)
pure virtualinherited

draw a line from current position to point

+ Here is the caller graph for this function:

void moveTo ( const CPoint point)
virtualinherited

move line position to point

+ Here is the caller graph for this function:

virtual CBaseObject* newCopy ( ) const
inlinevirtualinherited
virtual void remember ( )
inlinevirtualinherited

increase refcount

+ Here is the caller graph for this function:

void resetClipRect ( )
virtualinherited

reset the clip to the default state

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

set the current clip

+ Here is the caller graph for this function:

void setDrawMode ( CDrawMode  mode)
virtualinherited

set the current draw mode, see CDrawMode

+ Here is the caller graph for this function:

void setFillColor ( const CColor color)
virtualinherited

set current fill color

+ Here is the caller graph for this function:

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

set current font

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void setFontColor ( const CColor color)
virtualinherited

set current font color

+ Here is the caller graph for this function:

void setFrameColor ( const CColor color)
virtualinherited

set current stroke color

+ Here is the caller graph for this function:

void setGlobalAlpha ( float  newAlpha)
virtualinherited

sets the global alpha value[0..1]

+ Here is the caller graph for this function:

void setLineStyle ( const CLineStyle style)
virtualinherited

set the current line style

+ Here is the caller graph for this function:

void setLineWidth ( CCoord  width)
virtualinherited

set the current line width

+ Here is the caller graph for this function:

void setOffset ( const CPoint offset)
virtualinherited

+ Here is the caller graph for this function:

Member Data Documentation

CBitmap* bitmap
protected
CDrawContextState currentState
protectedinherited
CString* drawStringHelper
protectedinherited
std::stack<CDrawContextState*> globalStatesStack
protectedinherited
CRect surfaceRect
protectedinherited

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