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 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 DrawText(char* msg, Location loc);

Draw a text string in the Frames' visible window starting at the specified location.

   void     DrawText(char* msg, Location loc);  

Back to the top of Canvas


Shape TextSize (char* msg);

Return the Shape of the rectangular area occupied by the given text string when the string is displayed in the Canvas. This method is typically used in conjunction with the Clear method that requires a Shape as one of its argument.

   Shape    TextSize (char* msg);               

Back to the top of Canvas


void DrawLine(Location p1, Location p2);

Draw a line segment between two points whose Locations are specified.

   void     DrawLine(Location p1, Location p2);

Back to the top of Canvas


void DrawCircle(Location center, int r);

Draw a circle of the specified radius about a specified centerpoint.

   void     DrawCircle(Location center, int r); 

Back to the top of Canvas


void Clear();

Erase the contents of the Frame's visible window.

   void     Clear();   

Back to the top of Canvas


void Clear(Location loc, Shape sh);

Erase a specified rectangular region of the Frame's visible window. Only the specified rectangular region is affected.

   void     Clear(Location loc, Shape sh);      

Back to the top of Canvas


char* getName();

Return the name of the Canvas. The name of the Canvas is defined by the Canvas's constructor. The name is useful in determining in which Canvas a given mouse event occured.

   char*    getName();                      

Back to the top of Canvas


~Canvas();

Destructor: deallocate resources held by the Canvas object.

  ~Canvas();

Back to the top of Canvas


Member Functions

public:
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();

Back to the top of Canvas


Generated from source by the Cocoon utilities on Thu Apr 02 12:40:03 1998 .

Report problems to jkotula@unimax.com