return to index
VDKCanvas class <canvas.h>
Inherits from VDKObject
Description
This class provides a canvas widget.
Properties
EnableClear , boolean, default is
true.
It clears and refresh the screen during the configure event. User can
disable it to control the draw during the configure event.
EnableDrag boolean, default is true.
It enables DragStart/Dragging/DragStop events. The user can disable
it, then EventMotion occures.
(It is very usefull if the user is not persuated with the implemented
drag handling...)
Captured boolean, default is false.
if it is true, the canvas will receive EventMotion/Drag... events if
the cursor is outside of the area.
Methods
-
VDKCanvas(VDKForm* owner, int w = 100, int h =
100);
Constructor.
-
virtual ~VDKCanvas();
Destructor
-
void Clear();
Clear the canvas.
-
void DrawString(int x, int y, char* text);
-
void DrawText(int x, int y, char* text, int n);
-
void DrawPoint(int x, int y);
-
void DrawLine(int x, int y, int x1, int y1);
-
void DrawRect(int filled
,int x, int y, int w, int h);
Arg <filled> can be either 1 (rect will be filled with color) or
0.
-
void DrawPoint(int x, int y);
-
void DrawLine(int x, int y, int x1, int y1);
-
void DrawRect(int x, int y, int w, int h);
-
void DrawArc(int filled,int x,int y, int width,
int height,int angle1, int angle2);
-
void DrawPolygon(int filled,GdkPoint *points,
gint npoints);
-
void DrawPoints(GdkPoint *points, int npoints);
-
void DrawSegments(GdkSegment *segs, int nsegs);
-
void DrawLines(GdkPoint *points, int npoints);
-
void DrawPixmap(int x, int y,char *pixfile);
-
void DrawPixmap(int x, int y, VDKRawPixmap* pix);
-
void DrawPixmap(int x, int y, char ** data);
-
void Redraw()
Redraw the canvas without generate an expose event, normally called
after a drawing operations.
Tip:
Drawing operations on canvas are not done directly on the screen but
using an offscreen backing pixmap. When necessary relevant portions of
(or all) backing image is copied to screen. This tecnique makes drawing
operations an order of magnitude faster and avoids screen flickering. So
all drawing should be followed by Draw() or Redraw() to effectively see
the wanted effect. When applicable the best way is to establish an expose_event
response function and make drawing there followed by a Redraw() call. See
canvaswin.cc on testvdk dir for more detailed informations.
Signals
None
Events
configure_event
expose_event
button_press_event
motion_notify_event
drag_start_event
Generated when user begin to drag mouse
drag_stop_event
Generated when user ends to drag mouse
dragging_event
During user drag operations
Tip: drag_start and drag_stop use a GdkEventButton* structure, dragging_event
a GdkEventMotion*.
By default canvas uses owner background and foreground, these can
be set using properties. (see canvaswin.cc on ./testvdk dir for more informations)
EXAMPLES: ./testvdk/canvaswin.cc