source: NonGTP/FLTK/include/fltk/x.h @ 773

Revision 773, 5.5 KB checked in by gumbau, 19 years ago (diff)

FLTK imported to SVN repository to be linked agains the GeoTool? application

Line 
1//
2// "$Id: x.h 4408 2005-07-09 06:41:56Z spitzak $"
3//
4// Copyright 1998-2004 by Bill Spitzak and others.
5//
6// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Library General Public
8// License as published by the Free Software Foundation; either
9// version 2 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14// Library General Public License for more details.
15//
16// You should have received a copy of the GNU Library General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19// USA.
20//
21// Please report all bugs and problems to "fltk-bugs@fltk.org".
22
23// Declarations of internal fltk symbols that are useful for calling
24// Xlib functions. You should include this file if (and ONLY if) you
25// need to call Xlib directly.  You should avoid using this header
26// file in your software if at all possible.  NO FLTK HEADER FILE IS
27// ALLOWED TO INCLUDE THIS.
28//
29// For historic reasons, this file will also include the correct
30// header file for other operating systems. As all three major systems
31// now have multiple drawing libraries (Linux has X11/Cairo, Windows
32// has GDI32/LongHorn/DirectX, and Mac has Carbon/Aqua/X11, and all
33// have OpenGL) not all the symbols in here may be usable with a given
34// compilation of fltk.
35
36#ifndef fltk_x_h
37#define fltk_x_h
38
39#include "draw.h"
40
41#if defined(_WIN32) && !USE_X11
42# include "win32.h"
43
44#elif defined(__APPLE__) && !USE_X11
45# define USE_QUARTZ 1
46# include "mac.h"
47
48#else
49#define USE_X11 1
50
51////////////////////////////////////////////////////////////////
52// Try to get the parts of Xlib.h included while avoiding warnings:
53
54#ifndef DOXYGEN
55# define Window XWindow
56
57// pragmas are to fix the broken SGI Irix Xlib header files:
58# if !defined(__GNUC__) && (defined(_ABIN32) || defined(_ABI64))
59#  pragma set woff 3322
60# endif
61# include <X11/Xlib.h>
62# include <X11/Xutil.h>
63# if !defined(__GNUC__) && (defined(_ABIN32) || defined(_ABI64))
64#  pragma reset woff 3322
65# endif
66
67# include <X11/Xatom.h>
68
69# if USE_XFT
70#  include <X11/Xft/Xft.h>
71# else
72 typedef struct _XftDraw XftDraw;
73# endif
74
75# if USE_CAIRO
76#  include <cairo.h>
77#  include <cairo-xlib.h>
78# else
79 typedef struct cairo cairo_t;
80# endif
81
82#include <X11/extensions/XInput.h>
83#include <X11/extensions/XI.h>
84
85# undef Window
86
87# if defined(__FreeBSD__) || defined(__APPLE__) || defined(__CYGWIN__)
88typedef unsigned long   ulong;
89typedef unsigned int    uint;
90typedef unsigned char   uchar;
91# endif
92
93#endif
94
95extern FL_API Region    XRectangleRegion(int x, int y, int w, int h);
96
97namespace fltk {
98
99////////////////////////////////////////////////////////////////
100// constant info about the X server connection:
101
102extern FL_API void      open_display();
103extern FL_API void      open_display(Display*);
104extern FL_API void      close_display();
105
106extern FL_API Display*  xdisplay;
107extern FL_API XWindow   message_window;
108extern FL_API int       xscreen;
109extern FL_API XVisualInfo* xvisual;
110extern FL_API Colormap  xcolormap;
111
112////////////////////////////////////////////////////////////////
113// event handling:
114
115// feed events into fltk by setting xevent and calling handle:
116extern FL_API XEvent    xevent;
117extern FL_API bool      handle();
118
119// set by last xevent with a timestamp:
120extern FL_API ulong     event_time;
121
122////////////////////////////////////////////////////////////////
123// DnD:
124
125extern FL_API XWindow dnd_source_window;
126extern FL_API Atom *dnd_source_types;
127extern FL_API Atom dnd_type;
128extern FL_API Atom dnd_source_action;
129extern FL_API Atom dnd_action;
130
131////////////////////////////////////////////////////////////////
132// drawing functions:
133
134extern FL_API cairo_t*  cc;
135extern FL_API XftDraw*  xftc;
136extern FL_API GC        gc;
137extern FL_API XWindow   xwindow;
138extern FL_API ulong     current_xpixel;
139extern FL_API ulong     xpixel(Color i);
140extern FL_API void      clip_region(Region);
141extern FL_API Region    clip_region();
142
143extern FL_API void      draw_into(XWindow, int w, int h);
144extern FL_API void      stop_drawing(XWindow);
145
146#define HFONT XFontStruct*
147extern FL_API HFONT     xfont();
148
149////////////////////////////////////////////////////////////////
150// only include this if <fltk/Window.h> was included:
151#if defined(fltk_Window_h) || defined(DOXYGEN)
152
153// When fltk tells X about a window, one of these objects is created.
154// Warning: this object is highly subject to change!  It's definition
155// is only here so that xid(Window) can be declared inline:
156
157class FL_API CreatedWindow {
158public:
159  XWindow xid;
160  XWindow backbuffer;
161  XWindow frontbuffer;
162  Window *window;
163  Region region;
164  void expose(const Rectangle&);
165  CreatedWindow *next;
166  bool wait_for_expose;
167  bool backbuffer_bad; // used for XDBE
168  bool overlay; // true if redraw_overlay was called
169  ::Cursor cursor;
170  const Widget* cursor_for;
171  static CreatedWindow* first;
172  static CreatedWindow* find(const Window* window) {return window->i;}
173  void sendxjunk();
174  static void create(Window*,
175                     XVisualInfo*, Colormap,
176                     int background = -1);
177  static CreatedWindow* set_xid(Window*, XWindow);
178  Rectangle current_size;
179};
180
181// convert xid <-> Window:
182inline XWindow xid(const Window*w) {return CreatedWindow::find(w)->xid;}
183Window* find(XWindow xid);
184
185#endif // Window_h
186////////////////////////////////////////////////////////////////
187
188}
189
190#endif  // not _WIN32
191#endif
192
193//
194// End of "$Id: x.h 4408 2005-07-09 06:41:56Z spitzak $".
195//
Note: See TracBrowser for help on using the repository browser.