WXP::XWindow Class Reference

This class plots data to the X Windows device. More...

#include "../include/XWindow.h"

Inheritance diagram for WXP::XWindow:
WXP::Device WXP::Listener

List of all members.

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

Detailed Description

This class plots data to the X Windows device.

Author:
Dan Vietor

Constructor & Destructor Documentation

XWindow::XWindow (  ) 

Constructor. Initializes class data

References init().

XWindow::~XWindow (  ) 

Destructor. Closes down X Windows

References close().


Member Function Documentation

int XWindow::addCallback ( const char *  event,
Listener list,
const void *  data 
) [virtual]

Adds a new callback to the callback list

Parameters:
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

Parameters:
red Red value (0-1)
grn Green value (0-1)
blu Blue value (0-1)
Returns:
Device specific color index

Implements WXP::Device.

Referenced by drawImage().

int XWindow::bell ( int  len  )  [virtual]

Beeps the window.

Parameters:
len Length of beep in milliseconds

Implements WXP::Device.

void XWindow::callback ( const char *  ev_str,
const char *  ev_data,
const void *  data 
) [virtual]

Internal callback for processing events specific to this class

Parameters:
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

Parameters:
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

Parameters:
ind Index in loop to clear

Implements WXP::Device.

References getFramePixmap().

Referenced by newFrame().

int XWindow::close (  )  [virtual]

Closes the window

Implements WXP::Device.

References deleteFrame().

Referenced by ~XWindow().

int XWindow::copyFrame ( int  dest,
int  src 
) [virtual]

Copies a frame

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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]

X error handler

Parameters:
dpy X display
event Error event

Referenced by open().

int XWindow::errorIOHandler ( Display *  dpy  )  [static]

X IO error handler. Usually called when connection broken to X server. Causes program to exit.

Parameters:
dpy X display

Referenced by open().

Rect XWindow::getClip (  )  [virtual]

Gets the current device specific clip rectangle

Returns:
Rect class with clipping rectangle

Implements WXP::Device.

Rect XWindow::getCoords (  )  [virtual]

Gets the window coordinates

Returns:
Coordinates

Implements WXP::Device.

int XWindow::getCoords ( Rect rect  )  [virtual]

Gets the window coordinates

Return values:
rect Coordinates

Implements WXP::Device.

int XWindow::getDevice ( String str  )  [virtual]

Returns device specification for direct access to window

Return values:
str Output string with specification

Implements WXP::Device.

References WXP::String::printf().

int XWindow::getFrame (  )  [virtual]

Returns current frame in loop

Returns:
Index in loop

Implements WXP::Device.

Pixmap XWindow::getFramePixmap ( int  ind  ) 

Gets the Pixmap ID (local)

Parameters:
ind Index into loop

Referenced by clearFrame(), and copyFrame().

int XWindow::getImage ( Image image  )  [virtual]

Gets an image from the window

Return values:
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]

Gets whether window in inverse color mode

Returns:
true if inversed

Implements WXP::Device.

int XWindow::getNumFrames (  )  [virtual]

Returns the number of frames in loop

Returns:
Number of frames

Implements WXP::Device.

int XWindow::getOffset ( float &  rx,
float &  ry 
) [virtual]

Gets the window offset

Return values:
rx Upper left X position
ry Upper left Y position

Implements WXP::Device.

int XWindow::getSize ( float &  rwidth,
float &  rheight 
) [virtual]

Gets the window size

Return values:
rwidth Width
rheight Height

Implements WXP::Device.

int XWindow::incFrame ( int  step  )  [virtual]

Increments frame in the loop

Parameters:
step Step increment (usually 1 or -1)
Returns:
The resulting frame index in loop

Implements WXP::Device.

References displayFrame().

Referenced by callback(), and mainloop().

int XWindow::init (  )  [virtual]

Initializes the class data

Implements WXP::Device.

Referenced by XWindow().

bool XWindow::isLooping (  )  [virtual]

Returns whether looping is active or not

Returns:
Active or not

Implements WXP::Device.

int XWindow::loopRate ( int  dir  ) 

Changes loop rate

Parameters:
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]

Turns the program over to the event manager

Implements WXP::Device.

References mainloop().

int XWindow::message ( const char *  str  )  [virtual]

Outputs a message

Parameters:
str Message

Implements WXP::Device.

References WXP::Wxp::outDebug().

int XWindow::newCallback ( Window  win,
int  event,
Listener list,
const void *  data 
) [static]

Adds a new callback into callback queue

Parameters:
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

Parameters:
ind Index in loop to insert new frame

Implements WXP::Device.

References clearFrame().

int XWindow::open (  )  [virtual]
int XWindow::printGC ( int  type  ) 

Prints the contents of a X11 Graphics Context

Parameters:
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

Parameters:
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

Parameters:
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

Parameters:
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)

Parameters:
str Title string

Implements WXP::Device.

References WXP::StrLib::copy().

int XWindow::setClip ( Rect  rect  )  [virtual]

Sets the clipping rectangle

Parameters:
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

Parameters:
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

Parameters:
type Graphics type (LINE,MARK,FILL,TEXT)
ind Device color index (see allocColor)
See also:
XWindow::allocColor

Implements WXP::Device.

int XWindow::setCursor ( int  type  )  [virtual]

Sets the cursor type

Parameters:
type Cursor type (CURSOR_PTR, CURSOR_STOP,...)
Returns:
Old cursor type

Implements WXP::Device.

Referenced by mainloop(), and toggleLoop().

int XWindow::setFillStyle ( int  type,
int  style 
) [virtual]

Sets the fill style

Parameters:
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)

Parameters:
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

Parameters:
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

Parameters:
ind Index in loop to use

Implements WXP::Device.

int XWindow::setIcon ( bool  val  )  [virtual]

Iconifies the window

Parameters:
val true=iconify

Implements WXP::Device.

int XWindow::setImageAlign ( int  h,
int  v 
) [virtual]

Sets the image alignment

Parameters:
h Horizontal alignment
v Vertical alignment

Implements WXP::Device.

int XWindow::setInverse ( bool  val  )  [virtual]

Sets whether color table inverted

Parameters:
val true=colors inverted

Implements WXP::Device.

int XWindow::setLineStyle ( int  type,
int  style 
) [virtual]

Sets the line style

Parameters:
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

Parameters:
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

Parameters:
rx Upper left X coordinate
ry Upper left Y coordinate

Implements WXP::Device.

int XWindow::setParam ( const char *  str  )  [virtual]
int XWindow::setSize ( float  rwidth,
float  rheight 
) [virtual]

Sets the size of the window

Parameters:
rwidth Width
rheight Height

Implements WXP::Device.

int XWindow::setTextAlign ( int  h,
int  v 
) [virtual]

Sets the text alignment

Parameters:
h Horizontal alignment
v Vertical alignment

Implements WXP::Device.

int XWindow::setTitle ( const char *  str  )  [virtual]

Sets the window title in title bar

Parameters:
str Title string

Implements WXP::Device.

References WXP::StrLib::copy().

int XWindow::toggleLoop (  ) 

Toggles the loop from stop to loop modes

References setCursor().

Referenced by callback().

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

Parameters:
display Display to query events

References processEvent().


The documentation for this class was generated from the following files:

Generated on 8 Jan 2010 for WXP C++ Library by  doxygen 1.6.1