1 | // |
---|
2 | // "$Id$" |
---|
3 | // |
---|
4 | // X11 header file for the Fast Light Tool Kit (FLTK). |
---|
5 | // |
---|
6 | // Copyright 1998-2005 by Bill Spitzak and others. |
---|
7 | // |
---|
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. |
---|
12 | // |
---|
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. |
---|
17 | // |
---|
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 |
---|
21 | // USA. |
---|
22 | // |
---|
23 | // Please report all bugs and problems on the following page: |
---|
24 | // |
---|
25 | // http://www.fltk.org/str.php |
---|
26 | // |
---|
27 | |
---|
28 | // These are internal fltk symbols that are necessary or useful for |
---|
29 | // calling Xlib. You should include this file if (and ONLY if) you |
---|
30 | // need to call Xlib directly. These symbols may not exist on non-X |
---|
31 | // systems. |
---|
32 | |
---|
33 | #ifndef Fl_X_H |
---|
34 | # define Fl_X_H |
---|
35 | |
---|
36 | # include "Enumerations.H" |
---|
37 | |
---|
38 | # ifdef WIN32 |
---|
39 | # include "win32.H" |
---|
40 | # elif defined(__APPLE__) |
---|
41 | # include "mac.H" |
---|
42 | # else |
---|
43 | # if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files |
---|
44 | # pragma set woff 3322 |
---|
45 | # endif |
---|
46 | # include <X11/Xlib.h> |
---|
47 | # include <X11/Xutil.h> |
---|
48 | # if defined(_ABIN32) || defined(_ABI64) |
---|
49 | # pragma reset woff 3322 |
---|
50 | # endif |
---|
51 | # include <X11/Xatom.h> |
---|
52 | # include "Fl_Window.H" |
---|
53 | |
---|
54 | // Mirror X definition of Region to Fl_Region, for portability... |
---|
55 | typedef Region Fl_Region; |
---|
56 | |
---|
57 | FL_EXPORT void fl_open_display(); |
---|
58 | FL_EXPORT void fl_open_display(Display*); |
---|
59 | FL_EXPORT void fl_close_display(); |
---|
60 | |
---|
61 | // constant info about the X server connection: |
---|
62 | extern FL_EXPORT Display *fl_display; |
---|
63 | extern FL_EXPORT Window fl_message_window; |
---|
64 | extern FL_EXPORT int fl_screen; |
---|
65 | extern FL_EXPORT XVisualInfo *fl_visual; |
---|
66 | extern FL_EXPORT Colormap fl_colormap; |
---|
67 | |
---|
68 | // drawing functions: |
---|
69 | extern FL_EXPORT GC fl_gc; |
---|
70 | extern FL_EXPORT Window fl_window; |
---|
71 | extern FL_EXPORT XFontStruct* fl_xfont; |
---|
72 | extern FL_EXPORT void *fl_xftfont; |
---|
73 | FL_EXPORT ulong fl_xpixel(Fl_Color i); |
---|
74 | FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b); |
---|
75 | FL_EXPORT void fl_clip_region(Fl_Region); |
---|
76 | FL_EXPORT Fl_Region fl_clip_region(); |
---|
77 | FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx |
---|
78 | |
---|
79 | // feed events into fltk: |
---|
80 | FL_EXPORT int fl_handle(const XEvent&); |
---|
81 | |
---|
82 | // you can use these in Fl::add_handler() to look at events: |
---|
83 | extern FL_EXPORT const XEvent* fl_xevent; |
---|
84 | extern FL_EXPORT ulong fl_event_time; |
---|
85 | |
---|
86 | // off-screen pixmaps: create, destroy, draw into, copy to window: |
---|
87 | typedef ulong Fl_Offscreen; |
---|
88 | #define fl_create_offscreen(w,h) \ |
---|
89 | XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth) |
---|
90 | // begin/end are macros that save the old state in local variables: |
---|
91 | # define fl_begin_offscreen(pixmap) \ |
---|
92 | Window _sw=fl_window; fl_window=pixmap; fl_push_no_clip() |
---|
93 | # define fl_end_offscreen() \ |
---|
94 | fl_pop_clip(); fl_window = _sw |
---|
95 | |
---|
96 | # define fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy) \ |
---|
97 | XCopyArea(fl_display, pixmap, fl_window, fl_gc, srcx, srcy, w, h, x, y) |
---|
98 | # define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap) |
---|
99 | |
---|
100 | // Bitmap masks |
---|
101 | typedef ulong Fl_Bitmask; |
---|
102 | |
---|
103 | extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); |
---|
104 | extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data); |
---|
105 | extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); |
---|
106 | |
---|
107 | // this object contains all X-specific stuff about a window: |
---|
108 | // Warning: this object is highly subject to change! It's definition |
---|
109 | // is only here so that fl_xid can be declared inline: |
---|
110 | class FL_EXPORT Fl_X { |
---|
111 | public: |
---|
112 | Window xid; |
---|
113 | Window other_xid; |
---|
114 | Fl_Window *w; |
---|
115 | Fl_Region region; |
---|
116 | Fl_X *next; |
---|
117 | char wait_for_expose; |
---|
118 | char backbuffer_bad; // used for XDBE |
---|
119 | static Fl_X* first; |
---|
120 | static Fl_X* i(const Fl_Window* wi) {return wi->i;} |
---|
121 | void setwindow(Fl_Window* wi) {w=wi; wi->i=this;} |
---|
122 | void sendxjunk(); |
---|
123 | static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap); |
---|
124 | static Fl_X* set_xid(Fl_Window*, Window); |
---|
125 | // kludges to get around protection: |
---|
126 | void flush() {w->flush();} |
---|
127 | static void x(Fl_Window* wi, int X) {wi->x(X);} |
---|
128 | static void y(Fl_Window* wi, int Y) {wi->y(Y);} |
---|
129 | }; |
---|
130 | |
---|
131 | // convert xid <-> Fl_Window: |
---|
132 | inline Window fl_xid(const Fl_Window*w) {return Fl_X::i(w)->xid;} |
---|
133 | FL_EXPORT Fl_Window* fl_find(Window xid); |
---|
134 | |
---|
135 | extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid() |
---|
136 | extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid() |
---|
137 | |
---|
138 | // Dummy function to register a function for opening files via the window manager... |
---|
139 | inline void fl_open_callback(void (*)(const char *)) {} |
---|
140 | |
---|
141 | extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); |
---|
142 | |
---|
143 | # endif |
---|
144 | #endif |
---|
145 | |
---|
146 | // |
---|
147 | // End of "$Id$". |
---|
148 | // |
---|