FLTK 1.3.8
x.H
1//
2// "$Id$"
3//
4// X11 header file for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2012 by Bill Spitzak and others.
7//
8// This library is free software. Distribution and use rights are outlined in
9// the file "COPYING" which should have been included with this file. If this
10// file is missing or damaged, see the license at:
11//
12// http://www.fltk.org/COPYING.php
13//
14// Please report all bugs and problems on the following page:
15//
16// http://www.fltk.org/str.php
17//
18
19// These are internal fltk symbols that are necessary or useful for
20// calling Xlib. You should include this file if (and ONLY if) you
21// need to call Xlib directly. These symbols may not exist on non-X
22// systems.
23
24#if !defined(Fl_X_H) && !defined(FL_DOXYGEN)
25# define Fl_X_H
26
27# include "Enumerations.H"
28
29# ifdef WIN32
30# include "win32.H"
31# elif defined(__APPLE__)
32# include "mac.H"
33# else
34# if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
35# pragma set woff 3322
36# endif
37# include <X11/Xlib.h>
38# include <X11/Xutil.h>
39# if defined(_ABIN32) || defined(_ABI64)
40# pragma reset woff 3322
41# endif
42# include <X11/Xatom.h>
43# include "Fl_Window.H"
44// Mirror X definition of Region to Fl_Region, for portability...
45typedef Region Fl_Region;
46
47FL_EXPORT void fl_open_display();
48FL_EXPORT void fl_open_display(Display*);
49FL_EXPORT void fl_close_display();
50
51// constant info about the X server connection:
52extern FL_EXPORT Display *fl_display;
53extern FL_EXPORT int fl_screen;
54extern FL_EXPORT XVisualInfo *fl_visual;
55extern FL_EXPORT Colormap fl_colormap;
56
57
58// drawing functions:
59extern FL_EXPORT GC fl_gc;
60extern FL_EXPORT Window fl_window;
61FL_EXPORT ulong fl_xpixel(Fl_Color i);
62FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
63FL_EXPORT void fl_clip_region(Fl_Region);
64FL_EXPORT Fl_Region fl_clip_region();
65
66// feed events into fltk:
67FL_EXPORT int fl_handle(const XEvent&);
68
69// you can use these in Fl::add_handler() to look at events:
70extern FL_EXPORT const XEvent* fl_xevent;
71extern FL_EXPORT ulong fl_event_time;
72
73// off-screen pixmaps: create, destroy, draw into, copy to window:
74typedef ulong Fl_Offscreen;
75# define fl_create_offscreen(w,h) XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), w, h, fl_visual->depth)
76# define fl_create_offscreen_with_alpha(w,h) XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), w, h, 32)
77// begin/end are macros that save the old state in local variables:
78# define fl_begin_offscreen(pixmap) \
79 Window _sw=fl_window; fl_window=pixmap; \
80 GC _sgc = fl_gc; if (!_sgc) fl_gc = XCreateGC(fl_display, pixmap, 0, 0); \
81 Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \
82 fl_push_no_clip()
83# define fl_end_offscreen() \
84 fl_pop_clip(); fl_window = _sw; _ss->set_current(); \
85 if (!_sgc) XFreeGC(fl_display, fl_gc); fl_gc = _sgc
86
87extern FL_EXPORT void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
88# define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap)
89
90// Bitmap masks
91typedef ulong Fl_Bitmask;
92
93extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
94extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
95extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
96
97#if defined(FL_LIBRARY) || defined(FL_INTERNALS)
98extern FL_EXPORT Window fl_message_window;
99extern FL_EXPORT void *fl_xftfont;
100FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
101
102// access to core fonts:
103// This class provides a "smart pointer" that returns a pointer to an XFontStruct.
104// The global variable fl_xfont can be called wherever a bitmap "core" font is
105// needed, e.g. when rendering to a GL context under X11.
106// With Xlib / X11 fonts, fl_xfont will return the current selected font.
107// With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most
108// similar to (usually the same as) the current XFT font.
109class Fl_XFont_On_Demand
110{
111public:
112 Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
113 Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
114 { ptr = x.ptr; return *this; }
115 Fl_XFont_On_Demand& operator=(XFontStruct* p)
116 { ptr = p; return *this; }
117 XFontStruct* value();
118 operator XFontStruct*() { return value(); }
119 XFontStruct& operator*() { return *value(); }
120 XFontStruct* operator->() { return value(); }
121 bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
122 bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
123private:
124 XFontStruct *ptr;
125};
126extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
127extern FL_EXPORT XFontStruct* fl_X_core_font();
128
129// this object contains all X-specific stuff about a window:
130// Warning: this object is highly subject to change!
131// FL_LIBRARY or FL_INTERNALS must be defined to access this class.
132class FL_EXPORT Fl_X {
133public:
134 Window xid;
135 Window other_xid;
136 Fl_Window *w;
137 Fl_Region region;
138 Fl_X *next;
139 char wait_for_expose;
140 char backbuffer_bad; // used for XDBE
141 static Fl_X* first;
142 static Fl_X* i(const Fl_Window* wi) {return wi->i;}
143 void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
144 void sendxjunk();
145 static void set_default_icons(const Fl_RGB_Image*[], int);
146 void set_icons();
147 int set_cursor(Fl_Cursor);
148 int set_cursor(const Fl_RGB_Image*, int, int);
149 static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
150 static Fl_X* set_xid(Fl_Window*, Window);
151 // kludges to get around protection:
152 void flush() {w->flush();}
153 static void x(Fl_Window* wi, int X) {wi->x(X);}
154 static void y(Fl_Window* wi, int Y) {wi->y(Y);}
155 static int ewmh_supported();
156 static int xrender_supported();
157 static void activate_window(Window w);
158};
159
160extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
161extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
162
163inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::i(w); return xTemp ? xTemp->xid : 0; }
164
165#else
166
167extern FL_EXPORT Window fl_xid_(const Fl_Window* w);
168#define fl_xid(w) fl_xid_(w)
169
170#endif // FL_LIBRARY || FL_INTERNALS
171
172FL_EXPORT Fl_Window* fl_find(Window xid);
173
174
175// Dummy function to register a function for opening files via the window manager...
176inline void fl_open_callback(void (*)(const char *)) {}
177
178extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
179
180# endif
181#endif
182
183//
184// End of "$Id$".
185//
This file contains type definitions and general enumerations.
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:1046
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition: Enumerations.H:932
Fl_Window widget .
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:202
void x(int v)
Internal use only.
Definition: Fl_Widget.H:139
void y(int v)
Internal use only.
Definition: Fl_Widget.H:141
This widget produces an actual window.
Definition: Fl_Window.H:57
unsigned char uchar
unsigned char
Definition: fl_types.h:30
unsigned long ulong
unsigned long
Definition: fl_types.h:32
ulong fl_xpixel(uchar r, uchar g, uchar b)
Returns the X pixel number used to draw the given rgb color.
Definition: fl_color.cxx:150
void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy)
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
Definition: Fl_Double_Window.cxx:94
void fl_clip_region(Fl_Region r)
Replaces the top of the clipping stack with a clipping region of any shape.
Definition: fl_draw.H:136
void fl_open_callback(void(*cb)(const char *))
Register a function called for each file dropped onto an application icon.
Mac OS X-specific symbols.