00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef _Fl_X_H_
00033 #define _Fl_X_H_
00034
00035 #include "Fl_Color.h"
00036 #include "Fl_Device.h"
00037
00038 #ifdef _WIN32_WCE
00039 #include <wince.h>
00040 #endif
00041
00042 #ifdef _WIN32
00043
00044 # include "win32.h"
00045
00046 #elif defined(__APPLE__)
00047
00048 # include "mac.h"
00049
00050 #else
00051
00053
00054
00055 #if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
00056 # pragma set woff 3322
00057 #endif
00058 #include <X11/Xlib.h>
00059 #include <X11/Xutil.h>
00060 #if defined(_ABIN32) || defined(_ABI64)
00061 # pragma reset woff 3322
00062 #endif
00063
00064 #include <X11/Xatom.h>
00065
00066
00067 #if USE_XFT
00068 # include <X11/Xft/Xft.h>
00069 #else
00070 typedef struct _XftDraw XftDraw;
00071 #endif
00072
00074
00075
00076 extern FL_API void fl_open_display();
00077 extern FL_API void fl_open_display(Display*);
00078 extern FL_API void fl_close_display();
00079
00080 extern FL_API Display* fl_display;
00081 extern FL_API Window fl_message_window;
00082 extern FL_API int fl_screen;
00083 extern FL_API XVisualInfo* fl_visual;
00084 extern FL_API Colormap fl_colormap;
00085
00087
00088
00089
00090 extern FL_API XEvent fl_xevent;
00091 extern FL_API bool fl_handle();
00092
00093
00094 extern Atom FLTKChangeScheme;
00095
00096 extern Atom FLTKChangeSettings;
00097
00098
00099 extern FL_API ulong fl_event_time;
00100
00102
00103
00104 extern FL_API Window fl_dnd_source_window;
00105 extern FL_API Atom *fl_dnd_source_types;
00106 extern FL_API Atom fl_dnd_type;
00107 extern FL_API Atom fl_dnd_source_action;
00108 extern FL_API Atom fl_dnd_action;
00109
00111
00112
00113 extern FL_API GC fl_gc;
00114 extern FL_API struct Fl_Drawable* fl_drawable;
00115 extern FL_API Window fl_window;
00116
00117 extern FL_API XFontStruct* fl_xfont();
00118
00119 extern FL_API ulong fl_pixel;
00120 extern FL_API ulong fl_xpixel(Fl_Color i);
00121 extern FL_API void fl_clip_region(Region);
00122 extern FL_API Region fl_clip_region();
00123 extern FL_API Region XRectangleRegion(int x, int y, int w, int h);
00124
00126
00127
00128
00129
00130
00131
00132
00133
00135 class FL_API Fl_Drawable {
00136 public:
00137 Window xid;
00138 XftDraw* draw;
00139 Fl_Drawable() : draw(0) {}
00140 Fl_Drawable(Pixmap p) : xid(p), draw(0) {}
00141 void create(int w, int h) {
00142 xid = XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth);
00143 }
00144 void copy(int x, int y, int w, int h, int src_x, int src_y) {
00145 XCopyArea(fl_display, xid, fl_window, fl_gc, src_x, src_y, w, h, x, y);
00146 }
00147 void free_gc();
00148 void destroy() {
00149 if (xid) {free_gc(); XFreePixmap(fl_display, xid); xid = 0;}
00150 }
00151 void make_current() {fl_drawable = this; fl_window=xid; fl_current_dev->load_identity(); }
00152 };
00153
00155
00156
00157
00158
00159
00160
00161
00162 #define fl_create_offscreen(w,h) \
00163 XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth)
00164
00165 #define fl_begin_offscreen(id) \
00166 {fl_push_matrix(); \
00167 Fl_Drawable* _sd = fl_drawable; \
00168 Fl_Drawable _nd(id); \
00169 _nd.make_current(); \
00170 fl_push_no_clip()
00171
00172 #define fl_end_offscreen() \
00173 _nd.free_gc(); _sd->make_current(); fl_pop_clip(); fl_pop_matrix();}
00174
00175 #define fl_copy_offscreen(x,y,w,h,id,srcx,srcy) \
00176 XCopyArea(fl_display, id, fl_window, fl_gc, srcx, srcy, w, h, x, y)
00177
00178 #define fl_delete_offscreen(id) XFreePixmap(fl_display, id)
00179
00181
00182
00183
00184
00185 static inline Pixmap fl_create_bitmap(const uchar* data, int w, int h) {
00186 return XCreateBitmapFromData(fl_display, fl_window, (char*)data,(w+7)&-8, h);
00187 }
00188 #define fl_delete_bitmap(id) XFreePixmap(fl_display, id)
00189
00191 #ifdef _FL_WINDOW_H_ // only include this if <fltk/Fl_Window.h> was included
00192
00193
00194
00195
00196
00197 class FL_API Fl_X : public Fl_Drawable {
00198 public:
00199 Fl_Drawable backbuffer;
00200 Fl_Window *window;
00201 Region region;
00202 void expose(int x, int y, int w, int h);
00203 Fl_X *next;
00204 bool wait_for_expose;
00205 bool backbuffer_bad;
00206 static Fl_X* first;
00207 static Fl_X* i(const Fl_Window* window) {return window->i;}
00208 void sendxjunk();
00209 static void create(Fl_Window*,
00210 XVisualInfo*, Colormap,
00211 int background = -1);
00212 };
00213
00214
00215 inline Window fl_xid(const Fl_Window*w) {return Fl_X::i(w)->xid;}
00216 Fl_Window* fl_find(Window xid);
00217
00218 #endif // _FL_WINDOW_H_
00219
00220
00221 #endif // not _WIN32
00222 #endif // _Fl_X_H_