CDrawContext
#include <vstgui.h>
class CDrawContext;
A drawing context encapsulates the drawing context of the underlying OS. It
implements the drawing functions.
CDrawContext (
CFrame *frame, void *systemContext, void *window = 0);
Create a drawing context.
frame |
The parent frame. |
systemContext |
- |
window |
The output of a drawing context is the given window. |
Example :
void MyPlug::idle () {
static CDrawContext drawContext
(frame, NULL, systemWindow);
AEffGUIEditor::idle ();
myControl->update (drawContext);
}
virtual ~CDrawContext ();
Destroy a drawContext object.
Move the current pen position to specified point.
Draw a line from the current pen position to the specified point (this point
(pixel) is not drawn).
void polyLine (
CPoint& *pPoint, long numberOfPoints);
Draw a polyline defined by a list of points. p is an array of points of size
numberofPoints.
void fillPolygon (
CPoint& *pPoint, long numberOfPoints);
Draw a filled polygon without its boundary. p is an array of points. if the
first and the last point are different, the polygon will be closed. The fill
color is set by setFillColor.
void drawRect (
CRect& rect);
The given rect is framed using the current frame color.
void fillRect (
CRect& rect);
The given rect is filled with the current fill color (note that with MOTIF the
fill and the frame color are the same), its boundary is not drawn.
An arc included in the given rect with a begin angle defined by point1 and a end
angle defined by point2 is framed (these 2 points ara defined as in Windows).
Same as the previous function, but the arc is filled without its boundary.
void drawEllipse (
CRect& rect);
An ellipse is drawn in the given rect.
void fillEllipse (
CRect& rect);
An filled ellipse is drawn in the given rect without its boundary.
A point is drawn at a given position with a specified color.
Returns the color of the point.
void floodFill (
CPoint& start);
From the point
start
, fills the area in all directions til the
color doesn't change.
Sets the style to draw a line. It affects the functions lineTo, drawArc,
polyLine, etc. The default setting is kLineSolid.
Gets the current style to draw a line.
void setLineWidth (int width);
Sets the width of the pen drawing a frame. It affects the functions lineTo,
drawArc, polyLine, etc. The default setting is 1.
int getLineWidth ();
Gets the current width of the pen drawing a frame.
Sets the current drawing mode.
Gets the current drawing mode.
void setClipRect (const
CRect &clip);
Sets a given clipping rectangle to this context.
Gets the current clipping rectangle.
void resetClipRect ();
Reset the clipping area to its frame size.
void setFillColor (
CColor color);
Sets the fill color (Note that with MOTIF, this affect the frame color!).
Gets the current fill color.
void setFrameColor (
CColor color);
Sets the frame color (Note that with MOTIF, this affect the fill color and the
font color!).
Gets the current frame color.
void setFontColor (
CColor color);
Sets the font color (Note that with MOTIF, this affect the frame color!).
Gets the current font color.
void setFont (
CFont fontID, const long size = 0, long style = 0);
Sets the current font.
Gets the current font.
long getStringWidth (const char *pStr);
Returns the string width (pixels) of the given text in the current font.
void drawString (const char *string,
CRect& rect,
const short opaque = false, const
CHoriTxtAlignhAlign = kCenterText));
The string is drawn within the rectangle using a given alignment. The opaque
function allows to draw or not a background.
long getMouseButtons ();
Returns the current mouse button used with Modifiers (see CButton).
void getMouseLocation (
CPoint& point);
Returns the current position of the mouse.
bool waitDoubleClick ();
Returns true if a double-click occurs.
bool waitDrag ();
Actually dragging into the context.
void *getWindow ();
Returns the window of the frame.
void setWindow (void *ptr);
Sets the window of the frame.
Returns the current position of the pen.
Example :
void ScoView::update (CDrawContext *context) {
long x, y;
CPoint p;
CColor greenColor = {0, 255, 0, 0};
context->setFrameColor (greenColor);
context->moveTo (p(x, y));
...
// draw the line
context->lineTo (p(x, y));
}
Returns the frame for the context.
void *getSystemContext ();