This class plots data to the X Windows device. More...
#include "../include/XWindow.h"
Classes | |
| struct | XCallbackItem |
| struct | XFrame |
Public Member Functions | |
| XWindow () | |
| ~XWindow () | |
| int | init () |
| int | setParam (const char *str) |
| int | open () |
| int | getDevice (String &str) |
| int | resize (float rwidth, float rheight) |
| int | addCallback (const char *event, Listener *list, const void *data) |
| int | doCallback (const char *ev_str, const char *ev_data) |
| void | callback (const char *ev_str, const char *ev_data, const void *data) |
| int | close () |
| int | setFocus () |
| int | unsetFocus () |
| int | update () |
| int | clear () |
| int | clearRect (Rect &rect) |
| int | manage () |
| int | unmanage () |
| int | setTitle (const char *str) |
| const char * | getTitle () |
| int | setIcon (bool val) |
| int | setFixed (bool val) |
| int | setCursor (int type) |
| int | getCursor () |
| int | setInverse (bool val) |
| bool | getInverse () |
| int | setBackground (const char *str) |
| int | setSize (float rwidth, float rheight) |
| int | getSize (float &width, float &height) |
| float | getWidth () |
| float | getHeight () |
| int | setOffset (float rx, float ry) |
| int | getOffset (float &x, float &y) |
| int | getCoords (Rect &rect) |
| Rect | getCoords () |
| int | allocColor (float red, float grn, float blu) |
| int | setColor (int type, int ind) |
| int | setLineWidth (int type, float width) |
| int | setLineStyle (int type, int style) |
| int | setFillStyle (int type, int style) |
| int | drawLine (int type, float x1, float y1, float x2, float y2) |
| int | drawLine (int type, Points &pts) |
| int | drawFill (int type, Points &pts) |
| int | setImageAlign (int h, int v) |
| int | drawImage (Image &image, float x, float y) |
| int | drawImage (Image &image, int bgcolor, float x, float y) |
| int | getImage (Image &image) |
| int | setFont (const char *name) |
| int | setTextAlign (int h, int v) |
| int | drawText (Point &pt, const char *str) |
| Rect | getClip () |
| int | setClip (float x1, float y1, float x2, float y2) |
| int | setClip (Rect rect) |
| Pixmap | getFramePixmap (int ind) |
| int | copyFrame (int dest, int src) |
| int | displayFrame (int ind) |
| int | clearFrame (int ind) |
| int | newFrame (int ind) |
| int | newFrame () |
| bool | isLooping () |
| int | getFrame () |
| int | setFrame (int ind) |
| int | incFrame (int step) |
| int | deleteFrame (int ind) |
| int | deleteFrame () |
| int | getNumFrames () |
| int | loopRate (int dir) |
| int | toggleLoop () |
| int | message (const char *str) |
| int | printGC (int type) |
| int | bell (int len) |
Static Public Member Functions | |
| static int | mainloop () |
| static int | waitEvent () |
| static int | checkEvent () |
| static int | addWindow (Window &win) |
| static int | processEvent (XEvent *event) |
| static int | procCallback (Window win, int type, const char *ev_str, const char *ev_data) |
| static int | newCallback (Window win, int event, Listener *list, const void *data) |
| static int | deleteCallbacks (Window) |
| static int | errorHandler (Display *dpy, XErrorEvent *error) |
| static int | errorIOHandler (Display *dpy) |
Static Public Attributes | |
| static const int | AnyEvent = 0 |
| static const int | Redraw = 50 |
| static const int | WINDOW = 1 |
| static const int | PIXMAP = 2 |
| static const int | CURSOR_X = 0 |
| static const int | CURSOR_PTR = 1 |
| static const int | CURSOR_MOVE = 2 |
| static const int | CURSOR_LOOP = 3 |
| static const int | CURSOR_STOP = 4 |
| static const int | CURSOR_DRAW = 5 |
| static const int | CURSOR_RECT = 6 |
| static const int | CURSOR_PLUS = 6 |
| static const int | CURSOR_TEXT = 7 |
| static const int | CURSOR_WAIT = 8 |
This class plots data to the X Windows device.
| XWindow::XWindow | ( | ) |
Constructor. Initializes class data
References init().
| XWindow::~XWindow | ( | ) |
Destructor. Closes down X Windows
References close().
| int XWindow::addCallback | ( | const char * | event, | |
| Listener * | list, | |||
| const void * | data | |||
| ) | [virtual] |
Adds a new callback to the callback list
| event | Event on which to invoke callback | |
| list | Listener class containing callback method | |
| data | User specified data to be sent with callback |
Implements WXP::Device.
References WXP::StrLib::equal(), and newCallback().
| int XWindow::allocColor | ( | float | red, | |
| float | grn, | |||
| float | blu | |||
| ) | [virtual] |
Allocates a color into the device specific color database
| red | Red value (0-1) | |
| grn | Green value (0-1) | |
| blu | Blue value (0-1) |
Implements WXP::Device.
Referenced by drawImage().
| int XWindow::bell | ( | int | len | ) | [virtual] |
| void XWindow::callback | ( | const char * | ev_str, | |
| const char * | ev_data, | |||
| const void * | data | |||
| ) | [virtual] |
Internal callback for processing events specific to this class
| ev_str | Event description (string) | |
| ev_data | Additional data from event | |
| data | User specified data |
Implements WXP::Device.
References deleteFrame(), WXP::StrLib::equal(), incFrame(), loopRate(), procCallback(), resize(), toggleLoop(), and update().
| int XWindow::checkEvent | ( | ) | [static] |
Checks to see if an event is present in queue and then sends it to process_event
| display | Display to query events |
References processEvent().
Referenced by mainloop().
| int XWindow::clear | ( | ) | [virtual] |
Clears the window, painting it with background color
Implements WXP::Device.
Referenced by deleteFrame(), and open().
| int XWindow::clearFrame | ( | int | ind | ) | [virtual] |
Clears a frame in loop
| ind | Index in loop to clear |
Implements WXP::Device.
References getFramePixmap().
Referenced by newFrame().
| int XWindow::close | ( | ) | [virtual] |
| int XWindow::copyFrame | ( | int | dest, | |
| int | src | |||
| ) | [virtual] |
Copies a frame
| dest | Destination index in loop | |
| src | Source index in loop |
Implements WXP::Device.
References getFramePixmap().
Referenced by displayFrame().
| int XWindow::deleteFrame | ( | ) |
Deletes all frames in the loop
Referenced by callback(), and close().
| int XWindow::deleteFrame | ( | int | ind | ) | [virtual] |
Deletes a frame in the loop
| ind | Index of the frame to delete |
Implements WXP::Device.
References clear(), displayFrame(), WXP::Wxp::outDebug(), and update().
| int XWindow::displayFrame | ( | int | ind | ) | [virtual] |
Displays a frame
| ind | Index in loop to display |
Implements WXP::Device.
References copyFrame(), WXP::Wxp::outDebug(), and update().
Referenced by deleteFrame(), and incFrame().
| int XWindow::drawFill | ( | int | type, | |
| Points & | pts | |||
| ) | [virtual] |
Draws a filled area
| type | Graphics type (LINE,MARK,FILL,TEXT) | |
| num | Number of points | |
| pt | Array of points |
Implements WXP::Device.
References WXP::Points::getNum().
| int XWindow::drawImage | ( | Image & | image, | |
| int | bgcolor, | |||
| float | x, | |||
| float | y | |||
| ) | [virtual] |
Draws a transparent image
| image | Image to use | |
| bgcolor | Color to make transparent in image | |
| x | X location of upper right corner of image | |
| y | Y location of upper right corner of image |
Implements WXP::Device.
References allocColor(), WXP::Image::getPixel(), WXP::Image::setColorVal(), and WXP::Image::validData().
| int XWindow::drawImage | ( | Image & | image, | |
| float | x, | |||
| float | y | |||
| ) | [virtual] |
Draws an image
| image | Image to use | |
| x | X location of image | |
| y | Y location of image |
Implements WXP::Device.
References allocColor(), WXP::Image::getPixel(), WXP::Image::setColorVal(), and WXP::Image::validData().
| int XWindow::drawLine | ( | int | type, | |
| Points & | pts | |||
| ) | [virtual] |
Draws a line
| type | Graphics type (LINE,MARK,FILL,TEXT) | |
| pts | Array of points |
Implements WXP::Device.
References WXP::Points::getNum().
| int XWindow::drawLine | ( | int | type, | |
| float | x1, | |||
| float | y1, | |||
| float | x2, | |||
| float | y2 | |||
| ) | [virtual] |
Draws a line
| type | Graphics type (LINE,MARK,FILL,TEXT) | |
| x1 | First X point | |
| y1 | First Y point | |
| x2 | Second X point | |
| y2 | Second Y point |
Implements WXP::Device.
| int XWindow::drawText | ( | Point & | pt, | |
| const char * | str | |||
| ) | [virtual] |
Draws text to window using device fonts
| pt | Location of text | |
| str | String to plot |
Implements WXP::Device.
References WXP::Point::x, and WXP::Point::y.
| int XWindow::errorHandler | ( | Display * | dpy, | |
| XErrorEvent * | event | |||
| ) | [static] |
| int XWindow::errorIOHandler | ( | Display * | dpy | ) | [static] |
X IO error handler. Usually called when connection broken to X server. Causes program to exit.
| dpy | X display |
Referenced by open().
| Rect XWindow::getClip | ( | ) | [virtual] |
Gets the current device specific clip rectangle
Implements WXP::Device.
| Rect XWindow::getCoords | ( | ) | [virtual] |
| int XWindow::getCoords | ( | Rect & | rect | ) | [virtual] |
| int XWindow::getDevice | ( | String & | str | ) | [virtual] |
Returns device specification for direct access to window
| str | Output string with specification |
Implements WXP::Device.
References WXP::String::printf().
| int XWindow::getFrame | ( | ) | [virtual] |
| Pixmap XWindow::getFramePixmap | ( | int | ind | ) |
Gets the Pixmap ID (local)
| ind | Index into loop |
Referenced by clearFrame(), and copyFrame().
| int XWindow::getImage | ( | Image & | image | ) | [virtual] |
Gets an image from the window
| image | Image class to put image into |
Implements WXP::Device.
References WXP::Image::allocData(), WXP::Image::init(), and WXP::Image::setPixel().
| bool XWindow::getInverse | ( | ) | [virtual] |
| int XWindow::getNumFrames | ( | ) | [virtual] |
| int XWindow::getOffset | ( | float & | rx, | |
| float & | ry | |||
| ) | [virtual] |
Gets the window offset
| rx | Upper left X position | |
| ry | Upper left Y position |
Implements WXP::Device.
| int XWindow::getSize | ( | float & | rwidth, | |
| float & | rheight | |||
| ) | [virtual] |
| int XWindow::incFrame | ( | int | step | ) | [virtual] |
Increments frame in the loop
| step | Step increment (usually 1 or -1) |
Implements WXP::Device.
References displayFrame().
Referenced by callback(), and mainloop().
| int XWindow::init | ( | ) | [virtual] |
| bool XWindow::isLooping | ( | ) | [virtual] |
| int XWindow::loopRate | ( | int | dir | ) |
Changes loop rate
| dir | 1 = faster, -1 = slower |
References WXP::Wxp::outMessage().
Referenced by callback().
| int XWindow::mainloop | ( | ) | [static] |
Main loop of program that just waits for events to be processed
References checkEvent(), incFrame(), procCallback(), and setCursor().
Referenced by manage().
| int XWindow::manage | ( | ) | [virtual] |
| int XWindow::message | ( | const char * | str | ) | [virtual] |
| int XWindow::newCallback | ( | Window | win, | |
| int | event, | |||
| Listener * | list, | |||
| const void * | data | |||
| ) | [static] |
Adds a new callback into callback queue
| win | Window to process data on | |
| event | Event type | |
| list | Listener class to call when event occurs | |
| data | User specific data to send Listener class |
Referenced by addCallback(), and open().
| int XWindow::newFrame | ( | ) | [virtual] |
Creates a new frame at end of loop
Implements WXP::Device.
| int XWindow::newFrame | ( | int | ind | ) | [virtual] |
Creates a new frame
| ind | Index in loop to insert new frame |
Implements WXP::Device.
References clearFrame().
| int XWindow::open | ( | ) | [virtual] |
Opens a window
Implements WXP::Device.
References clear(), WXP::StrLib::equal(), errorHandler(), errorIOHandler(), newCallback(), WXP::Wxp::outWarning(), WXP::StrLib::replace(), and WXP::StrLib::valid().
| int XWindow::printGC | ( | int | type | ) |
Prints the contents of a X11 Graphics Context
| type | Type of graphics context to print |
| int XWindow::procCallback | ( | Window | win, | |
| int | type, | |||
| const char * | ev_str, | |||
| const char * | ev_data | |||
| ) | [static] |
Passes event information to each of the callbacks
| win | Applicable window | |
| type | Event type | |
| ev_str | Event name | |
| ev_data | Event specific data |
Referenced by callback(), mainloop(), and processEvent().
| int XWindow::processEvent | ( | XEvent * | event | ) | [static] |
Processes a single event and passes data onto callbacks
| event | X Event structure for the event |
References WXP::Wxp::outDebug(), and procCallback().
Referenced by checkEvent(), and waitEvent().
| int XWindow::resize | ( | float | rwidth, | |
| float | rheight | |||
| ) | [virtual] |
Resizes the window
| rwidth | New width | |
| rheight | New height |
Implements WXP::Device.
Referenced by callback().
| int XWindow::setBackground | ( | const char * | str | ) | [virtual] |
Sets the window title in title bar (internal reference only)
| str | Title string |
Implements WXP::Device.
References WXP::StrLib::copy().
| int XWindow::setClip | ( | Rect | rect | ) | [virtual] |
Sets the clipping rectangle
| rect | Rectangle class with clipping information |
Implements WXP::Device.
References setClip().
| int XWindow::setClip | ( | float | x1, | |
| float | y1, | |||
| float | x2, | |||
| float | y2 | |||
| ) | [virtual] |
Sets the clipping rectangle
| x1 | Upper left X point | |
| y1 | Upper left Y point | |
| x2 | Lower right X point | |
| y2 | Lower right Y point |
Implements WXP::Device.
Referenced by setClip().
| int XWindow::setColor | ( | int | type, | |
| int | ind | |||
| ) | [virtual] |
Sets the color for each graphics type
| type | Graphics type (LINE,MARK,FILL,TEXT) | |
| ind | Device color index (see allocColor) |
Implements WXP::Device.
| int XWindow::setCursor | ( | int | type | ) | [virtual] |
Sets the cursor type
| type | Cursor type (CURSOR_PTR, CURSOR_STOP,...) |
Implements WXP::Device.
Referenced by mainloop(), and toggleLoop().
| int XWindow::setFillStyle | ( | int | type, | |
| int | style | |||
| ) | [virtual] |
Sets the fill style
| type | Graphics type (LINE,MARK,FILL,TEXT) | |
| width | Style (0=solid, >0=patterned) |
Implements WXP::Device.
| int XWindow::setFixed | ( | bool | val | ) | [virtual] |
Sets whether window size is fixed (not resizable)
| val | true=not resizable |
Implements WXP::Device.
| int XWindow::setFocus | ( | ) |
Sets the focus on the window
| int XWindow::setFont | ( | const char * | name | ) | [virtual] |
Sets the text font to use in drawing
| name | Descriptive name of font | |
| size | Size of font (for fixed fonts) |
Implements WXP::Device.
References WXP::Wxp::outWarning().
| int XWindow::setFrame | ( | int | ind | ) | [virtual] |
Sets the drawing frame in loop. All drawing primitives will be done to this frame
| ind | Index in loop to use |
Implements WXP::Device.
| int XWindow::setIcon | ( | bool | val | ) | [virtual] |
| int XWindow::setImageAlign | ( | int | h, | |
| int | v | |||
| ) | [virtual] |
Sets the image alignment
| h | Horizontal alignment | |
| v | Vertical alignment |
Implements WXP::Device.
| int XWindow::setInverse | ( | bool | val | ) | [virtual] |
| int XWindow::setLineStyle | ( | int | type, | |
| int | style | |||
| ) | [virtual] |
Sets the line style
| type | Graphics type (LINE,MARK,FILL,TEXT) | |
| width | Style (1=solid, >1=patterned) |
Implements WXP::Device.
| int XWindow::setLineWidth | ( | int | type, | |
| float | width | |||
| ) | [virtual] |
Sets the line width
| type | Graphics type (LINE,MARK,FILL,TEXT) | |
| width | Width (1=normal) |
Implements WXP::Device.
| int XWindow::setOffset | ( | float | rx, | |
| float | ry | |||
| ) | [virtual] |
Sets the offset of the window on the display
| rx | Upper left X coordinate | |
| ry | Upper left Y coordinate |
Implements WXP::Device.
| int XWindow::setParam | ( | const char * | str | ) | [virtual] |
Sets parameters for the X Windows display
| str | String containing parameters |
Implements WXP::Device.
References WXP::StrLib::copy(), WXP::Strings::equal(), WXP::Strings::getChar(), WXP::Strings::getLength(), WXP::Strings::getNum(), WXP::Strings::getString(), WXP::Strings::index(), and WXP::Strings::scanf().
| int XWindow::setSize | ( | float | rwidth, | |
| float | rheight | |||
| ) | [virtual] |
| int XWindow::setTextAlign | ( | int | h, | |
| int | v | |||
| ) | [virtual] |
Sets the text alignment
| h | Horizontal alignment | |
| v | Vertical alignment |
Implements WXP::Device.
| int XWindow::setTitle | ( | const char * | str | ) | [virtual] |
Sets the window title in title bar
| str | Title string |
Implements WXP::Device.
References WXP::StrLib::copy().
| int XWindow::toggleLoop | ( | ) |
| int XWindow::unmanage | ( | ) | [virtual] |
Exits out of event manager
Implements WXP::Device.
| int XWindow::unsetFocus | ( | ) |
Unsets the focus on the window
| int XWindow::update | ( | ) | [virtual] |
Refreshes/updates the display for expose events
Implements WXP::Device.
Referenced by callback(), deleteFrame(), and displayFrame().
| int XWindow::waitEvent | ( | ) | [static] |
Waits on the next event and sends it to process_event
| display | Display to query events |
References processEvent().
1.6.1