Canvas

The Canvas class captures the abstraction of a named, interactive surface on which text and graphics can be drawn. Methods are provided for drawing lines, circles, and text strings. Mouse events that happen within the boundaries of the displayed Canvas are reported by calling the OnMouseEvent function passing the name of the Canvas as an argument. Erasure of the entire canvas or of a selected rectangular region is provided.

[ Index | Source | Summary | Member Functions ]

Quick Index


Class Summary

class Canvas
{

public:
Canvas(Frame& frame, char *name, Location location, Shape shape);
void SetDrawColor(Color color);
void SetFillColor(Color color);
void DrawText(char* msg, Location loc);
Shape TextSize (char* msg);
void DrawLine(Location p1, Location p2);
void DrawCircle(Location center, int r);
void Clear();
void Clear(Location loc, Shape sh);
char* getName();
~Canvas();
}; // Canvas

Back to the top of Canvas


Canvas(Frame& frame, char *name, Location location, Shape shape);

Construct a Canvas as a region within an existing Frame. In addition to the Canvas's name (used for reporting the occurrence of mouse events within the Canvas's area), the Location within the Frame and the Shape of the Canvas are specified. It is important that the Frame be of sufficient size so that the Canvas' position and dimensions allow the Canvas to be entirely contained within the Frame.

   Canvas(Frame& frame, char *name, Location location, Shape shape);

Back to the top of Canvas


void SetDrawColor(Color color);

Set the Color to be used when drawing text or graphics. This color remains in effect for all subsequent drawing operations until the drawing color is changed. Different Canvases may, of course, have different drawing colors.