Move the sources to trunk
[opencv] / otherlibs / _fltk / include / FL / x.H
1 //
2 // "$Id: x.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $"
3 //
4 // X11 header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2002 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 to "fltk-bugs@fltk.org".
24 //
25
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
29 // systems.
30
31 #ifndef Fl_X_H
32 #  define Fl_X_H
33
34 #  include "Enumerations.H"
35
36 #  ifdef WIN32
37 #    include "win32.H"
38 #  elif defined(__APPLE__)
39 #    include "mac.H"
40 #  else
41 #    if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
42 #      pragma set woff 3322
43 #    endif
44 #    include <X11/Xlib.h>
45 #    include <X11/Xutil.h>
46 #    if defined(_ABIN32) || defined(_ABI64)
47 #      pragma reset woff 3322
48 #    endif
49 #    include <X11/Xatom.h>
50 #    include "Fl_Window.H"
51
52 // Mirror X definition of Region to Fl_Region, for portability...
53 typedef Region Fl_Region;
54
55 FL_EXPORT void fl_open_display();
56 FL_EXPORT void fl_open_display(Display*);
57 FL_EXPORT void fl_close_display();
58
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;
65
66 // drawing functions:
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
75
76 // feed events into fltk:
77 FL_EXPORT int fl_handle(const XEvent&);
78
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;
82
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
92
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)
96
97 // Bitmap masks
98 typedef ulong Fl_Bitmask;
99
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);
103
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 {
108 public:
109   Window xid;
110   Window other_xid;
111   Fl_Window *w;
112   Fl_Region region;
113   Fl_X *next;
114   char wait_for_expose;
115   char backbuffer_bad; // used for XDBE
116   static Fl_X* first;
117   static Fl_X* i(const Fl_Window* wi) {return wi->i;}
118   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
119   void sendxjunk();
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);}
126 };
127
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);
131
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()
134
135 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
136
137 #  endif
138 #endif
139
140 //
141 // End of "$Id: x.H,v 1.2 2002/12/01 15:38:37 neurosurg Exp $".
142 //