WXP C++ Library Version 6.74.9
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
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

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)
 
virtual int init ()=0
 
virtual int setParam (const char *str)=0
 
virtual int open ()=0
 
virtual int getDevice (String &str)=0
 
virtual int resize (float rwidth, float rheight)=0
 
virtual int manage ()=0
 
virtual int unmanage ()=0
 
virtual int addCallback (const char *event, Listener *list, const void *data)=0
 
virtual int doCallback (const char *ev_str, const char *ev_data)=0
 
virtual void callback (const char *ev_str, const char *ev_data, const void *data)=0
 
virtual int close ()=0
 
virtual int update ()=0
 
virtual int clear ()=0
 
virtual int clearRect (Rect &rect)=0
 
virtual int setTitle (const char *str)=0
 
virtual int setIcon (bool val)=0
 
virtual int setFixed (bool val)=0
 
virtual int setInverse (bool val)=0
 
virtual bool getInverse ()=0
 
virtual int setBackground (const char *str)=0
 
virtual int setSize (float rwidth, float rheight)=0
 
virtual int getSize (float &width, float &height)=0
 
virtual float getWidth ()=0
 
virtual float getHeight ()=0
 
virtual int setOffset (float rx, float ry)=0
 
virtual int getOffset (float &x, float &y)=0
 
virtual int getCoords (Rect &rect)=0
 
virtual Rect getCoords ()=0
 
virtual int allocColor (float red, float grn, float blu)=0
 
virtual int setColor (int type, int ind)=0
 
virtual int setLineWidth (int type, float width)=0
 
virtual int setLineStyle (int type, int style)=0
 
virtual int setFillStyle (int type, int style)=0
 
virtual int drawLine (int type, float x1, float y1, float x2, float y2)=0
 
virtual int drawLine (int type, Points &pts)=0
 
virtual int drawFill (int type, Points &pts)=0
 
virtual int setImageAlign (int h, int v)=0
 
virtual int drawImage (Image &image, float x, float y)=0
 
virtual int drawImage (Image &image, int bgcolor, float x, float y)=0
 
virtual int getImage (Image &image)=0
 
virtual int setFont (const char *name)=0
 
virtual int setTextAlign (int h, int v)=0
 
virtual int drawText (Point &pt, const char *str)=0
 
virtual Rect getClip ()=0
 
virtual int setClip (float x1, float y1, float x2, float y2)=0
 
virtual int setClip (Rect rect)=0
 
virtual int setCursor (int type)=0
 
virtual int copyFrame (int dest, int src)=0
 
virtual int displayFrame (int ind)=0
 
virtual int clearFrame (int ind)=0
 
virtual int newFrame (int ind)=0
 
virtual int newFrame ()=0
 
virtual bool isLooping ()=0
 
virtual int getFrame ()=0
 
virtual int setFrame (int ind)=0
 
virtual int incFrame (int step)=0
 
virtual int deleteFrame (int ind)=0
 
virtual int getNumFrames ()=0
 
virtual int message (const char *str)=0
 
virtual int bell (int len)=0
 
virtual void callback (const char *ev_str, const char *ev_data, const void *data)=0
 

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
 
- Static Public Attributes inherited from WXP::Device
static const int BASE = 0
 
static const int LINE = 1
 
static const int MARK = 2
 
static const int FILL = 3
 
static const int TEXT = 4
 
static const int LAST = -1
 
static const int CUR = -2
 
static const int WIN = -3
 
static const int ALL = -4
 
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
 
static const int ALIGN_HLEFT = 1
 
static const int ALIGN_HCENTER = 2
 
static const int ALIGN_HRIGHT = 3
 
static const int ALIGN_VBOTTOM = 1
 
static const int ALIGN_VCENTER = 2
 
static const int ALIGN_VTOP = 3
 

Detailed Description

This class plots data to the X Windows device.

Author
Dan Vietor

Constructor & Destructor Documentation

◆ XWindow()

XWindow::XWindow ( )

Constructor. Initializes class data

References init().

◆ ~XWindow()

XWindow::~XWindow ( )

Destructor. Closes down X Windows

References close().

Member Function Documentation

◆ addCallback()

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

Adds a new callback to the callback list

Parameters
eventEvent on which to invoke callback
listListener class containing callback method
dataUser specified data to be sent with callback

Implements WXP::Device.

References WXP::StrLib::equal(), and newCallback().

◆ allocColor()

int XWindow::allocColor ( float  red,
float  grn,
float  blu 
)
virtual

Allocates a color into the device specific color database

Parameters
redRed value (0-1)
grnGreen value (0-1)
bluBlue value (0-1)
Returns
Device specific color index

Implements WXP::Device.

Referenced by drawImage(), and drawImage().

◆ bell()

int XWindow::bell ( int  len)
virtual

Beeps the window.

Parameters
lenLength of beep in milliseconds

Implements WXP::Device.

◆ callback()

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_strEvent description (string)
ev_dataAdditional data from event
dataUser specified data

Implements WXP::Device.

References deleteFrame(), WXP::StrLib::equal(), incFrame(), loopRate(), procCallback(), resize(), toggleLoop(), and update().

◆ checkEvent()

int XWindow::checkEvent ( )
static

Checks to see if an event is present in queue and then sends it to process_event

Parameters
displayDisplay to query events

References processEvent().

Referenced by mainloop().

◆ clear()

int XWindow::clear ( )
virtual

Clears the window, painting it with background color

Implements WXP::Device.

Referenced by deleteFrame().

◆ clearFrame()

int XWindow::clearFrame ( int  ind)
virtual

Clears a frame in loop

Parameters
indIndex in loop to clear

Implements WXP::Device.

References getFramePixmap().

Referenced by newFrame().

◆ clearRect()

int XWindow::clearRect ( Rect rect)
virtual

Implements WXP::Device.

◆ close()

int XWindow::close ( )
virtual

Closes the window

Implements WXP::Device.

References deleteFrame().

Referenced by ~XWindow().

◆ copyFrame()

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

Copies a frame

Parameters
destDestination index in loop
srcSource index in loop

Implements WXP::Device.

References getFramePixmap(), and WXP::Wxp::outDebug().

Referenced by displayFrame().

◆ deleteFrame() [1/2]

int XWindow::deleteFrame ( )

Deletes all frames in the loop

References deleteFrame().

Referenced by callback(), close(), and deleteFrame().

◆ deleteFrame() [2/2]

int XWindow::deleteFrame ( int  ind)
virtual

Deletes a frame in the loop

Parameters
indIndex of the frame to delete

Implements WXP::Device.

References clear(), displayFrame(), WXP::Wxp::outDebug(), and update().

◆ displayFrame()

int XWindow::displayFrame ( int  ind)
virtual

Displays a frame

Parameters
indIndex in loop to display

Implements WXP::Device.

References copyFrame(), WXP::Wxp::outDebug(), and update().

Referenced by deleteFrame(), and incFrame().

◆ doCallback()

int XWindow::doCallback ( const char *  ev_str,
const char *  ev_data 
)
virtual

Implements WXP::Device.

◆ drawFill()

int XWindow::drawFill ( int  type,
Points pts 
)
virtual

Draws a filled area

Parameters
typeGraphics type (LINE,MARK,FILL,TEXT)
numNumber of points
ptArray of points

Implements WXP::Device.

References WXP::Points::getNum(), WXP::Points::getX1(), and WXP::Points::getY1().

◆ drawImage() [1/2]

int XWindow::drawImage ( Image image,
float  x,
float  y 
)
virtual

Draws an image

Parameters
imageImage to use
xX location of image
yY location of image

Implements WXP::Device.

References allocColor(), WXP::Image::getPixel(), WXP::Image::setColorVal(), and WXP::Image::validData().

◆ drawImage() [2/2]

int XWindow::drawImage ( Image image,
int  bgcolor,
float  x,
float  y 
)
virtual

Draws a transparent image

Parameters
imageImage to use
bgcolorColor to make transparent in image
xX location of upper right corner of image
yY location of upper right corner of image

Implements WXP::Device.

References allocColor(), WXP::Image::getPixel(), WXP::Image::setColorVal(), and WXP::Image::validData().

◆ drawLine() [1/2]

int XWindow::drawLine ( int  type,
float  x1,
float  y1,
float  x2,
float  y2 
)
virtual

Draws a line

Parameters
typeGraphics type (LINE,MARK,FILL,TEXT)
x1First X point
y1First Y point
x2Second X point
y2Second Y point

Implements WXP::Device.

◆ drawLine() [2/2]

int XWindow::drawLine ( int  type,
Points pts 
)
virtual

Draws a line

Parameters
typeGraphics type (LINE,MARK,FILL,TEXT)
ptsArray of points

Implements WXP::Device.

References WXP::Points::getNum(), WXP::Points::getX1(), and WXP::Points::getY1().

◆ drawText()

int XWindow::drawText ( Point pt,
const char *  str 
)
virtual

Draws text to window using device fonts

Parameters
ptLocation of text
strString to plot

Implements WXP::Device.

References WXP::Point::x, and WXP::Point::y.

◆ errorHandler()

int XWindow::errorHandler ( Display *  dpy,
XErrorEvent *  event 
)
static

X error handler

Parameters
dpyX display
eventError event

Referenced by open().

◆ errorIOHandler()

int XWindow::errorIOHandler ( Display *  dpy)
static

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

Parameters
dpyX display

Referenced by open().

◆ getClip()

Rect XWindow::getClip ( )
virtual

Gets the current device specific clip rectangle

Returns
Rect class with clipping rectangle

Implements WXP::Device.

◆ getCoords() [1/2]

Rect XWindow::getCoords ( )
virtual

Gets the window coordinates

Returns
Coordinates

Implements WXP::Device.

References WXP::Rect::set().

◆ getCoords() [2/2]

int XWindow::getCoords ( Rect rect)
virtual

Gets the window coordinates

Return values
rectCoordinates

Implements WXP::Device.

References WXP::Rect::set().

◆ getDevice()

int XWindow::getDevice ( String str)
virtual

Returns device specification for direct access to window

Return values
strOutput string with specification

Implements WXP::Device.

References WXP::String::printf().

◆ getFrame()

int XWindow::getFrame ( )
virtual

Returns current frame in loop

Returns
Index in loop

Implements WXP::Device.

◆ getFramePixmap()

Pixmap XWindow::getFramePixmap ( int  ind)

Gets the Pixmap ID (local)

Parameters
indIndex into loop

Referenced by clearFrame(), and copyFrame().

◆ getHeight()

float WXP::XWindow::getHeight ( )
inlinevirtual

Implements WXP::Device.

◆ getImage()

int XWindow::getImage ( Image image)
virtual

Gets an image from the drawing window

Return values
imageImage class to put image into

Implements WXP::Device.

References WXP::Image::allocData(), WXP::Image::init(), and WXP::Image::setPixel().

◆ getInverse()

bool XWindow::getInverse ( )
virtual

Gets whether window in inverse color mode

Returns
true if inversed

Implements WXP::Device.

◆ getNumFrames()

int XWindow::getNumFrames ( )
virtual

Returns the number of frames in loop

Returns
Number of frames

Implements WXP::Device.

◆ getOffset()

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

Gets the window offset

Return values
rxUpper left X position
ryUpper left Y position

Implements WXP::Device.

◆ getSize()

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

Gets the window size

Return values
rwidthWidth
rheightHeight

Implements WXP::Device.

◆ getWidth()

float WXP::XWindow::getWidth ( )
inlinevirtual

Implements WXP::Device.

◆ incFrame()

int XWindow::incFrame ( int  step)
virtual

Increments frame in the loop

Parameters
stepStep increment (usually 1 or -1)
Returns
The resulting frame index in loop

Implements WXP::Device.

References displayFrame().

Referenced by callback(), and mainloop().

◆ init()

int XWindow::init ( )
virtual

Initializes the class data

Implements WXP::Device.

Referenced by XWindow().

◆ isLooping()

bool XWindow::isLooping ( )
virtual

Returns whether looping is active or not

Returns
Active or not

Implements WXP::Device.

◆ loopRate()

int XWindow::loopRate ( int  dir)

Changes loop rate

Parameters
dir1 = faster, -1 = slower

References WXP::Wxp::outDebug().

Referenced by callback().

◆ mainloop()

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().

◆ manage()

int XWindow::manage ( )
virtual

Turns the program over to the event manager

Implements WXP::Device.

References mainloop().

◆ message()

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

Outputs a message

Parameters
strMessage

Implements WXP::Device.

References WXP::Wxp::outDebug().

◆ newCallback()

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

Adds a new callback into callback queue

Parameters
winWindow to process data on
eventEvent type
listListener class to call when event occurs
dataUser specific data to send Listener class

Referenced by addCallback(), and open().

◆ newFrame() [1/2]

int XWindow::newFrame ( )
virtual

Creates a new frame at end of loop

Implements WXP::Device.

References newFrame().

Referenced by newFrame().

◆ newFrame() [2/2]

int XWindow::newFrame ( int  ind)
virtual

Creates a new frame

Parameters
indIndex in loop to insert new frame

Implements WXP::Device.

References clearFrame().

◆ open()

int XWindow::open ( )
virtual

◆ printGC()

int XWindow::printGC ( int  type)

Prints the contents of a X11 Graphics Context

Parameters
typeType of graphics context to print

◆ procCallback()

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
winApplicable window
typeEvent type
ev_strEvent name
ev_dataEvent specific data

Referenced by callback(), mainloop(), and processEvent().

◆ processEvent()

int XWindow::processEvent ( XEvent *  event)
static

Processes a single event and passes data onto callbacks

Parameters
eventX Event structure for the event

References WXP::Wxp::outDebug(), and procCallback().

Referenced by checkEvent(), and waitEvent().

◆ resize()

int XWindow::resize ( float  rwidth,
float  rheight 
)
virtual

Resizes the window

Parameters
rwidthNew width
rheightNew height

Implements WXP::Device.

References WXP::Wxp::outDebug().

Referenced by callback().

◆ setBackground()

int XWindow::setBackground ( const char *  str)
virtual

Sets the window title in title bar (internal reference only)

Parameters
strTitle string

Implements WXP::Device.

References WXP::StrLib::copy().

◆ setClip() [1/2]

int XWindow::setClip ( float  x1,
float  y1,
float  x2,
float  y2 
)
virtual

Sets the clipping rectangle

Parameters
x1Upper left X point
y1Upper left Y point
x2Lower right X point
y2Lower right Y point

Implements WXP::Device.

Referenced by setClip().

◆ setClip() [2/2]

int XWindow::setClip ( Rect  rect)
virtual

Sets the clipping rectangle

Parameters
rectRectangle class with clipping information

Implements WXP::Device.

References setClip(), WXP::Rect::xmax, WXP::Rect::xmin, WXP::Rect::ymax, and WXP::Rect::ymin.

◆ setColor()

int XWindow::setColor ( int  type,
int  ind 
)
virtual

Sets the color for each graphics type

Parameters
typeGraphics type (LINE,MARK,FILL,TEXT)
indDevice color index (see allocColor)
See also
XWindow::allocColor

Implements WXP::Device.

◆ setCursor()

int XWindow::setCursor ( int  type)
virtual

Sets the cursor type

Parameters
typeCursor type (CURSOR_PTR, CURSOR_STOP,...)
Returns
Old cursor type

Implements WXP::Device.

Referenced by mainloop(), and toggleLoop().

◆ setFillStyle()

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

Sets the fill style

Parameters
typeGraphics type (LINE,MARK,FILL,TEXT)
widthStyle (0=solid, >0=patterned)

Implements WXP::Device.

◆ setFixed()

int XWindow::setFixed ( bool  val)
virtual

Sets whether window size is fixed (not resizable)

Parameters
valtrue=not resizable

Implements WXP::Device.

◆ setFocus()

int XWindow::setFocus ( )

Sets the focus on the window

◆ setFont()

int XWindow::setFont ( const char *  name)
virtual

Sets the text font to use in drawing

Parameters
nameDescriptive name of font
sizeSize of font (for fixed fonts)

Implements WXP::Device.

References WXP::StrLib::copy(), WXP::StrLib::index(), WXP::Wxp::outDebug(), WXP::Wxp::outWarning(), and WXP::StrLib::splice().

◆ setFrame()

int XWindow::setFrame ( int  ind)
virtual

Sets the drawing frame in loop. All drawing primitives will be done to this frame

Parameters
indIndex in loop to use

Implements WXP::Device.

◆ setIcon()

int XWindow::setIcon ( bool  val)
virtual

Iconifies the window

Parameters
valtrue=iconify

Implements WXP::Device.

◆ setImageAlign()

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

Sets the image alignment

Parameters
hHorizontal alignment
vVertical alignment

Implements WXP::Device.

◆ setInverse()

int XWindow::setInverse ( bool  val)
virtual

Sets whether color table inverted

Parameters
valtrue=colors inverted

Implements WXP::Device.

◆ setLineStyle()

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

Sets the line style

Parameters
typeGraphics type (LINE,MARK,FILL,TEXT)
widthStyle (1=solid, >1=patterned)

Implements WXP::Device.

◆ setLineWidth()

int XWindow::setLineWidth ( int  type,
float  width 
)
virtual

Sets the line width

Parameters
typeGraphics type (LINE,MARK,FILL,TEXT)
widthWidth (1=normal)

Implements WXP::Device.

◆ setOffset()

int XWindow::setOffset ( float  rx,
float  ry 
)
virtual

Sets the offset of the window on the display

Parameters
rxUpper left X coordinate
ryUpper left Y coordinate

Implements WXP::Device.

◆ setParam()

int XWindow::setParam ( const char *  str)
virtual

◆ setSize()

int XWindow::setSize ( float  rwidth,
float  rheight 
)
virtual

Sets the size of the window

Parameters
rwidthWidth
rheightHeight

Implements WXP::Device.

◆ setTextAlign()

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

Sets the text alignment

Parameters
hHorizontal alignment
vVertical alignment

Implements WXP::Device.

◆ setTitle()

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

Sets the window title in title bar

Parameters
strTitle string

Implements WXP::Device.

References WXP::StrLib::copy().

◆ toggleLoop()

int XWindow::toggleLoop ( )

Toggles the loop from stop to loop modes

References setCursor().

Referenced by callback().

◆ unmanage()

int XWindow::unmanage ( )
virtual

Exits out of event manager

Implements WXP::Device.

◆ unsetFocus()

int XWindow::unsetFocus ( )

Unsets the focus on the window

◆ update()

int XWindow::update ( )
virtual

Refreshes/updates the display for expose events

Implements WXP::Device.

Referenced by callback(), deleteFrame(), and displayFrame().

◆ waitEvent()

int XWindow::waitEvent ( )
static

Waits on the next event and sends it to process_event

Parameters
displayDisplay to query events

References processEvent().


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