Class XppWindow
- Description:
- A class that allows you to create an X window.
You can perform simple graphics operations and interact with the
window using the keyboard or mouse.
All graphics operations are performed using the default X window
coordinate system. In this coordinate system the top left hand of the
window is (0,0) and the bottom right corner is (window_width,
window_height).
If you prefer to use a different coordinate system for graphics
operations use the XppCanvas
class instead.
- Source code:
- XppWindow.h
XppWindow.c
- Examples:
-
XppWindow(int width, int height, int x=0, int y=0, char *name = "window");
- Create an X window on the root window at position
(x,y) with the specified width
and height and window name. If
either x or y is negative then
the window must be positioned on the root window using the mouse.
-
XppWindow(XppWindow& win, int w, int h, int x=0, int y=0, int borderWidth=1);
- Create a child window within the parent window
win
at the relative position (x,y) with width w
and height h and borderwidth borderWidth.
-
void DrawPoint(int x, int y);
- Draw point at (x, y)
-
void DrawLine(int x1, int y1, int x2, int y2);
- Draw line from (x1, y1) to (x2, y2)
-
void DrawRectangle(int x, int y, int width, int height);
- Draw rectangle with top left corner at (x, y), width (w), and height (h)
-
void DrawFilledRectangle(int x, int y, int width, int height);
- Draw filled rectangle with top left corner at (x, y), width (w), and height (h)
-
void DrawSquare(int x, int y, int r);
- Draw square centered at (x, y) with sides of length 2(r)
-
void DrawFilledSquare(int x, int y, int r);
- Draw filled square centered at (x, y) with sides of length 2(r)
-
void DrawCircle(int x, int y, int r);
- Draw circle centered at (x, y) with radius (r)
-
void DrawFilledCircle(int x, int y, int r);
- Draw filled circle centered at (x, y) with radius (r)
-
void DrawText(int x, int y, char *text);
- Draw text in window at (x, y)
-
void SetAutoRedrawOnExpose(void);
- Automatically redraw the contents of the window when exposed.
If AutoRedrawOnExpose is set then window graphics operations are performed
on a background pixmap and will only be visible after a call to Flush().
-
void Flush(void);
- Flush the display.
-
void Clear(void);
- Clear the window
-
void SetDrawColor(char *colorName);
- Set the foreground drawing color
-
void SetDrawBlack(void);
- Set the foreground color to black
-
void SetDrawWhite(void);
- Set the foreground color to white
-
void Pause(void);
- Wait until the user hits a mouse button or presses a key
-
void GetCommand(char& c);
- Waits for a single character from keyboard.
Character pressed is returned in c.
-
int ScanCommand(char& c)
- Returns 1 if a character has been pressed else returns 0.
Character pressed is returned in c.
-
int ScanMouse(int& x, int& y);
- Returns 1 if mouse has been clicked else returns 0.
Coordinates of mouse are returned in x and y.
-
int Exposed(void);
- Checks if the window has been exposed.
Copyright (c) 1995 Leslie Picardo
All rights reserved