WXP C++ Library Version 6.74.6
Loading...
Searching...
No Matches
XWindow.h
1#ifndef _WINC_XWINDOW
2#define _WINC_XWINDOW
3
4#include <X11/Xlib.h>
5
6#include <WXP/Device.h>
7#include <WXP/Image.h>
8#include <WXP/Listener.h>
9#include <WXP/Point.h>
10#include <WXP/Points.h>
11#include <WXP/Rect.h>
12#include <WXP/String.h>
13
14namespace WXP {
15 class XWindow : public Device, public Listener {
16 struct XFrame {
17 char title[50];
18 Pixmap pixmap;
19 float delay;
20 int flag;
21 };
22
23 struct XCallbackItem {
24 int type;
25 Window window;
26 Listener *listener;
27 const void *data;
28 struct XCallbackItem *next;
29 };
30
31 static Display *display;
32 static int managed;
33 static int num_errors;
34 static int error;
35 static int error_print;
36 static XCallbackItem *callbackroot;
37 static XWindow *windows[10];
38 static int num_windows;
39
40 int type;
41 bool inverse;
42 int width, height;
43 int x, y;
44 int fixed;
45 bool mapped;
46 bool icon;
47 bool opened;
48 char name[30];
49 char connect[40];
50 char title[60];
51 int window_num;
52 int show_win_num;
53
54 int screen; /* X display screen */
55 Colormap color_map; /* Default color map */
56 Window window; /* The base window */
57 Window dwindow; /* The backing pixmap */
58 Window drawing; /* The drawing pixmap */
59 Visual *visual; /* The display visual */
60 int depth; /* The display depth */
61
62 Pixmap icon_pixmap; /* Icon pixmap */
63 Cursor cursor_x; /* X cursor for X */
64 Cursor cursor_ptr; /* X cursor for pointing */
65 Cursor cursor_move; /* X cursor for panning */
66 Cursor cursor_loop; /* X cursor for looping */
67 Cursor cursor_stop; /* X cursor for stop mode */
68 Cursor cursor_draw; /* X cursor for line drawing */
69 Cursor cursor_rect; /* X cursor for rectangle drawing */
70 Cursor cursor_text; /* X cursor for drawing text */
71 Cursor cursor_wait; /* X cursor for waiting */
72 int cursor; /* Current cursor type */
73
74 int fore_color;
75 int back_color;
76 char background[40];
77 int bg_color;
78
79 XRectangle clip;
80
81 GC base_gc;
82 GC draw_gc;
83 GC line_gc;
84 GC text_gc;
85 GC fill_gc;
86 GC mark_gc;
87 int line_style;
88 int line_width;
89 Pixmap fill_pat[20]; /* Fill pattern pixmaps */
90 int text_halign;
91 int text_valign;
92 XFontStruct *font_info;
93 int image_halign;
94 int image_valign;
95
96 /* Loop data */
97 int max_frame;
98 int num_frame;
99 int cur_frame;
100 int looping;
101 int direct;
102 float delay;
103 float end_delay;
104 int start_frame;
105 int end_frame;
106 XFrame *frames;
107
108 int initStatic();
109 int printImage( XImage *ximage );
110
111 public:
112 XWindow();
113 ~XWindow();
114 int init();
115 int setParam( const char *str );
116 int open();
117 int getDevice( String &str );
118 int resize(float rwidth, float rheight);
119 int addCallback( const char *event, Listener *list, const void *data );
120 int doCallback( const char *ev_str, const char *ev_data );
121 void callback( const char *ev_str, const char *ev_data, const void *data );
122 int close();
123 int setFocus();
124 int unsetFocus();
125 int update();
126 int clear();
127 int clearRect( Rect &rect );
128 int manage();
129 int unmanage();
130 int setTitle( const char *str );
131 inline const char *getTitle(){ return title; };
132 int setIcon(bool val);
133 int setFixed(bool val);
134 int setCursor(int type);
135 inline int getCursor(){ return cursor; };
136 int setInverse(bool val);
137 bool getInverse();
138 int setBackground( const char *str );
139 int setSize(float rwidth, float rheight);
140 int getSize(float &width, float &height);
141 inline float getWidth() { return width; };
142 inline float getHeight() { return height; };
143 int setOffset(float rx, float ry);
144 int getOffset(float &x, float &y);
145 int getCoords( Rect &rect );
146 Rect getCoords();
147 int allocColor( float red, float grn, float blu );
148 int setColor( int type, int ind );
149 int setLineWidth( int type, float width );
150 int setLineStyle( int type, int style );
151 int setFillStyle( int type, int style );
152 int drawLine( int type, float x1, float y1, float x2, float y2 );
153 int drawLine( int type, Points &pts );
154 int drawFill( int type, Points &pts );
155 int setImageAlign( int h, int v );
156 int drawImage( Image &image, float x, float y );
157 int drawImage( Image &image, int bgcolor, float x, float y );
158 int getImage( Image &image );
159 int setFont( const char *name );
160 int setTextAlign( int h, int v );
161 int drawText( Point &pt, const char *str );
162 Rect getClip();
163 int setClip( float x1, float y1, float x2, float y2 );
164 int setClip( Rect rect );
165 Pixmap getFramePixmap( int ind );
166 int copyFrame( int dest, int src );
167 int displayFrame( int ind );
168 int clearFrame( int ind );
169 int newFrame( int ind );
170 int newFrame();
171 bool isLooping();
172 int getFrame();
173 int setFrame( int ind );
174 int incFrame( int step );
175 int deleteFrame( int ind );
176 int deleteFrame();
177 int getNumFrames();
178 int loopRate( int dir );
179 int toggleLoop();
180 int message( const char *str );
181 int printGC( int type );
182 int bell( int len );
183
184 static int mainloop();
185 static int waitEvent();
186 static int checkEvent();
187 static int addWindow( Window &win );
188 static int processEvent( XEvent *event );
189 static int procCallback( Window win, int type, const char *ev_str, const char *ev_data );
190 static int newCallback( Window win, int event, Listener *list, const void *data );
191 static int deleteCallbacks( Window );
192 static int errorHandler( Display *dpy, XErrorEvent *error );
193 static int errorIOHandler( Display *dpy );
194
195 static const int AnyEvent = 0;
196 static const int Redraw = 50;
197
198 static const int WINDOW = 1;
199 static const int PIXMAP = 2;
200
201 static const int CURSOR_X = 0;
202 static const int CURSOR_PTR = 1;
203 static const int CURSOR_MOVE = 2;
204 static const int CURSOR_LOOP = 3;
205 static const int CURSOR_STOP = 4;
206 static const int CURSOR_DRAW = 5;
207 static const int CURSOR_RECT = 6;
208 static const int CURSOR_PLUS = 6;
209 static const int CURSOR_TEXT = 7;
210 static const int CURSOR_WAIT = 8;
211 };
212}
213#endif
This virtual class defines methods for output to generic device.
Definition: Device.h:19
This class defines an image.
Definition: Image.h:19
This virtual class defines the callback method for use with plotting.
Definition: Listener.h:11
This class creates an array a 2D points (x, y)
Definition: Points.h:8
This is a variable length string class.
Definition: String.h:5
This class plots data to the X Windows device.
Definition: XWindow.h:15
int close()
Definition: XWindow.cc:991
int setSize(float rwidth, float rheight)
Definition: XWindow.cc:1207
int init()
Definition: XWindow.cc:512
int setIcon(bool val)
Definition: XWindow.cc:1131
int manage()
Definition: XWindow.cc:1055
int drawFill(int type, Points &pts)
Definition: XWindow.cc:1459
Pixmap getFramePixmap(int ind)
Definition: XWindow.cc:1886
int message(const char *str)
Definition: XWindow.cc:2243
int allocColor(float red, float grn, float blu)
Definition: XWindow.cc:1282
static int procCallback(Window win, int type, const char *ev_str, const char *ev_data)
Definition: XWindow.cc:311
int setLineStyle(int type, int style)
Definition: XWindow.cc:1344
Rect getClip()
Definition: XWindow.cc:1270
int setFixed(bool val)
Definition: XWindow.cc:1140
int setFont(const char *name)
Definition: XWindow.cc:1491
int setTitle(const char *str)
Definition: XWindow.cc:1118
int getFrame()
Definition: XWindow.cc:2003
int deleteFrame()
Definition: XWindow.cc:2071
int toggleLoop()
Definition: XWindow.cc:2140
XWindow()
Definition: XWindow.cc:484
static int errorIOHandler(Display *dpy)
Definition: XWindow.cc:474
int clear()
Definition: XWindow.cc:1073
int resize(float rwidth, float rheight)
Definition: XWindow.cc:873
int setOffset(float rx, float ry)
Definition: XWindow.cc:1218
static int waitEvent()
Definition: XWindow.cc:99
int loopRate(int dir)
Definition: XWindow.cc:2156
int addCallback(const char *event, Listener *list, const void *data)
Definition: XWindow.cc:977
int open()
Definition: XWindow.cc:618
int getDevice(String &str)
Definition: XWindow.cc:863
int unsetFocus()
Definition: XWindow.cc:1048
int drawImage(Image &image, float x, float y)
Definition: XWindow.cc:1616
int setFrame(int ind)
Definition: XWindow.cc:2012
int setTextAlign(int h, int v)
Definition: XWindow.cc:1548
int setParam(const char *str)
Definition: XWindow.cc:574
static int checkEvent()
Definition: XWindow.cc:115
static int processEvent(XEvent *event)
Definition: XWindow.cc:129
int printGC(int type)
Definition: XWindow.cc:2189
int unmanage()
Definition: XWindow.cc:1065
int drawLine(int type, float x1, float y1, float x2, float y2)
Definition: XWindow.cc:1406
int displayFrame(int ind)
Definition: XWindow.cc:1926
bool getInverse()
Definition: XWindow.cc:1189
int setBackground(const char *str)
Definition: XWindow.cc:1197
bool isLooping()
Definition: XWindow.cc:1995
int setLineWidth(int type, float width)
Definition: XWindow.cc:1322
int setClip(float x1, float y1, float x2, float y2)
Definition: XWindow.cc:1852
int setImageAlign(int h, int v)
Definition: XWindow.cc:1604
Rect getCoords()
Definition: XWindow.cc:1259
int incFrame(int step)
Definition: XWindow.cc:2084
int setColor(int type, int ind)
Definition: XWindow.cc:1302
void callback(const char *ev_str, const char *ev_data, const void *data)
Definition: XWindow.cc:918
int setFillStyle(int type, int style)
Definition: XWindow.cc:1378
int setFocus()
Definition: XWindow.cc:1041
~XWindow()
Definition: XWindow.cc:491
int setInverse(bool val)
Definition: XWindow.cc:1180
int copyFrame(int dest, int src)
Definition: XWindow.cc:1906
int setCursor(int type)
Definition: XWindow.cc:1150
static int errorHandler(Display *dpy, XErrorEvent *error)
Definition: XWindow.cc:454
int getSize(float &width, float &height)
Definition: XWindow.cc:1229
int drawText(Point &pt, const char *str)
Definition: XWindow.cc:1559
int getNumFrames()
Definition: XWindow.cc:2181
static int mainloop()
Definition: XWindow.cc:395
int update()
Definition: XWindow.cc:1107
int getImage(Image &image)
Definition: XWindow.cc:1811
static int newCallback(Window win, int event, Listener *list, const void *data)
Definition: XWindow.cc:350
int getOffset(float &x, float &y)
Definition: XWindow.cc:1240
int clearFrame(int ind)
Definition: XWindow.cc:1946
int newFrame()
Definition: XWindow.cc:1984
int bell(int len)
Definition: XWindow.cc:2231
All WXP classes fall under the WXP namespace.
Definition: Angle.h:4
This struct sets a 3D point (x, y, z)
Definition: Point.h:5
This structure defines rectangle coordinates.
Definition: Rect.h:5