2 // "$Id: x.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $"
4 // X11 header file for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2002 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems to "fltk-bugs@fltk.org".
26 // These are internal fltk symbols that are necessary or useful for
27 // calling Xlib. You should include this file if (and ONLY if) you
28 // need to call Xlib directly. These symbols may not exist on non-X
34 # include "Enumerations.H"
38 # elif defined(__APPLE__)
41 # if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
42 # pragma set woff 3322
44 # include <X11/Xlib.h>
45 # include <X11/Xutil.h>
46 # if defined(_ABIN32) || defined(_ABI64)
47 # pragma reset woff 3322
49 # include <X11/Xatom.h>
50 # include "Fl_Window.H"
52 // Mirror X definition of Region to Fl_Region, for portability...
53 typedef Region Fl_Region;
55 FL_EXPORT void fl_open_display();
56 FL_EXPORT void fl_open_display(Display*);
57 FL_EXPORT void fl_close_display();
59 // constant info about the X server connection:
60 extern FL_EXPORT Display *fl_display;
61 extern FL_EXPORT Window fl_message_window;
62 extern FL_EXPORT int fl_screen;
63 extern FL_EXPORT XVisualInfo *fl_visual;
64 extern FL_EXPORT Colormap fl_colormap;
67 extern FL_EXPORT GC fl_gc;
68 extern FL_EXPORT Window fl_window;
69 extern FL_EXPORT XFontStruct* fl_xfont;
70 FL_EXPORT ulong fl_xpixel(Fl_Color i);
71 FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
72 FL_EXPORT void fl_clip_region(Fl_Region);
73 FL_EXPORT Fl_Region fl_clip_region();
74 FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
76 // feed events into fltk:
77 FL_EXPORT int fl_handle(const XEvent&);
79 // you can use these in Fl::add_handler() to look at events:
80 extern FL_EXPORT const XEvent* fl_xevent;
81 extern FL_EXPORT ulong fl_event_time;
83 // off-screen pixmaps: create, destroy, draw into, copy to window:
84 typedef ulong Fl_Offscreen;
85 #define fl_create_offscreen(w,h) \
86 XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth)
87 // begin/end are macros that save the old state in local variables:
88 # define fl_begin_offscreen(pixmap) \
89 Window _sw=fl_window; fl_window=pixmap; fl_push_no_clip()
90 # define fl_end_offscreen() \
91 fl_pop_clip(); fl_window = _sw
93 # define fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy) \
94 XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y)
95 # define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap)
98 typedef ulong Fl_Bitmask;
100 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
101 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
102 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
104 // this object contains all X-specific stuff about a window:
105 // Warning: this object is highly subject to change! It's definition
106 // is only here so that fl_xid can be declared inline:
107 class FL_EXPORT Fl_X {
114 char wait_for_expose;
115 char backbuffer_bad; // used for XDBE
117 static Fl_X* i(const Fl_Window* wi) {return wi->i;}
118 void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
120 static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
121 static Fl_X* set_xid(Fl_Window*, Window);
122 // kludges to get around protection:
123 void flush() {w->flush();}
124 static void x(Fl_Window* wi, int X) {wi->x(X);}
125 static void y(Fl_Window* wi, int Y) {wi->y(Y);}
128 // convert xid <-> Fl_Window:
129 inline Window fl_xid(const Fl_Window*w) {return Fl_X::i(w)->xid;}
130 FL_EXPORT Fl_Window* fl_find(Window xid);
132 extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
133 extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
135 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
141 // End of "$Id: x.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $".