Class XppCanvas

 XppWindow 
   |
   +----XppCanvas


Description:
A class that allows you to create a window and specify an arbitrary window coordinate system. All graphics drawing are performed with respect to this coordinate system.

Source code:
XppCanvas.h
XppCanvas.c

Examples:

XppCanvas(int width, int height, int x=0, int y=0, char *name = "canvas");
Create a canvas on the root window at position (x,y) with the specified width and height and name. If either x or y is negative then the canvas must be positioned on the root window using the mouse.

XppCanvas(XppWindow& win, int width, int height, int x=0, int y=0);
Create a child canvas within the parent window win at the relative position (x,y) with width w and height h.

void SetDrawingCoordinates(double left,double right,double down,double up);
Specify the canvas coordinate system. Coordinates of the upper-left corner are (left,up). The coordinates of the lower-right corner are specified as (right,down). The default canvas coordinate system is the usual X window coordinate system, ie. upper-left corner is (0,0) , lower-right corner is (canvas_width, canvas, height).

void DrawPoint(double x, double y);
Draw point at (x, y)
void DrawLine(double x1, double y1, double x2, double y2);
Draw line from (x1, y1) to (x2, y2)
void DrawRectangle(double x, double y, double width, double height);
Draw rectangle with top left corner at (x, y), width (w), and height (h)
void DrawFilledRectangle(double x, double y, double width, double height);
Draw filled rectangle with top left corner at (x, y), width (w), and height (h)
void DrawRectangleToFit(double x1, double y1, double x2, double y2);
Draw rectangle with diagonally opposite corners (x1,y1) and (x2,y2)
void DrawFilledRectangleToFit(double x1, double y1, double x2, double y2);
Draw filled rectangle with diagonally opposite corners (x1,y1) and (x2,y2)
void DrawSquare(double x, double y, double r);
Draw square centered at (x, y) with sides of length 2(r)
void DrawFilledSquare(double x, double y, double r);
Draw filled square centered at (x, y) with sides of length 2(r)
void DrawCircle(double x, double y, double r);
Draw circle centered at (x, y) with radius (r)
void DrawFilledCircle(double x, double y, double r);
Draw filled circle centered at (x, y) with radius (r)
void DrawText(double x, double y, char *text);
Draw text in canvas at (x, y)

void DrawXAxis(double atY);
Draw an X axis at y=atY.
void DrawYAxis(double atX);
Draw a Y axis at x=atX.
void DrawXYAxes(double atX, double atY);
Draw an X axis at y=atY and a Y axis at x=atX.

int ScanMouse(double& x, double& y);
Returns 1 if mouse has been clicked else returns 0. Coordinates of mouse in the canvas coordinate system is returned in x and y.

Copyright (c) 1995 Leslie Picardo
All rights reserved