FLTK 1.3.3: x.H Source File

FLTK 1.3.3

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

x.H
1 //
2 // "$Id: x.H 10412 2014-10-29 20:25:46Z cand $"
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
35 #if !defined(Fl_X_H) && !defined(FL_DOXYGEN)
36 # define Fl_X_H
37
38 # include "Enumerations.H"
39
40 # ifdef WIN32
41 # include "win32.H"
42 # elif defined(__APPLE__)
43 # include "mac.H"
44 # else
45 # if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
46 # pragma set woff 3322
47 # endif
48 # include <X11/Xlib.h>
49 # include <X11/Xutil.h>
50 # if defined(_ABIN32) || defined(_ABI64)
51 # pragma reset woff 3322
52 # endif
53 # include <X11/Xatom.h>
54 # include "Fl_Window.H"
55 // Mirror X definition of Region to Fl_Region, for portability...
56 typedef Region Fl_Region;
57
58 FL_EXPORT void fl_open_display();
59 FL_EXPORT void fl_open_display(Display*);
60 FL_EXPORT void fl_close_display();
61
62 // constant info about the X server connection:
63 extern FL_EXPORT Display *fl_display;
64 extern FL_EXPORT int fl_screen;
65 extern FL_EXPORT XVisualInfo *fl_visual;
66 extern FL_EXPORT Colormap fl_colormap;
67
68
69 // drawing functions:
70 extern FL_EXPORT GC fl_gc;
71 extern FL_EXPORT Window fl_window;
72 FL_EXPORT ulong fl_xpixel(Fl_Color i);
73 FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
74 FL_EXPORT void fl_clip_region(Fl_Region);
75 FL_EXPORT Fl_Region fl_clip_region();
76
77 // feed events into fltk:
78 FL_EXPORT int fl_handle(const XEvent&);
79
80 // you can use these in Fl::add_handler() to look at events:
81 extern FL_EXPORT const XEvent* fl_xevent;
82 extern FL_EXPORT ulong fl_event_time;
83
84 // off-screen pixmaps: create, destroy, draw into, copy to window:
85 typedef ulong Fl_Offscreen;
86 # define fl_create_offscreen(w,h) XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), 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; \
90 Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \
91 fl_push_no_clip()
92 # define fl_end_offscreen() \
93 fl_pop_clip(); fl_window = _sw; _ss->set_current()
94
95 extern FL_EXPORT void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
96 # define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap)
97
98 // Bitmap masks
99 typedef ulong Fl_Bitmask;
100
101 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
102 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
103 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
104
105 #if defined(FL_LIBRARY) || defined(FL_INTERNALS)
106 extern FL_EXPORT Window fl_message_window;
107 extern FL_EXPORT void *fl_xftfont;
108 FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
109
110 // access to core fonts:
111 // This class provides a "smart pointer" that returns a pointer to an XFontStruct.
112 // The global variable fl_xfont can be called wherever a bitmap "core" font is
113 // needed, e.g. when rendering to a GL context under X11.
114 // With Xlib / X11 fonts, fl_xfont will return the current selected font.
115 // With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most
116 // similar to (usually the same as) the current XFT font.
117 class FL_EXPORT Fl_XFont_On_Demand
118 {
119 public:
120 Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
121 Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
122 { ptr = x.ptr; return *this; }
123 Fl_XFont_On_Demand& operator=(XFontStruct* p)
124 { ptr = p; return *this; }
125 XFontStruct* value();
126 operator XFontStruct*() { return value(); }
127 XFontStruct& operator*() { return *value(); }
128 XFontStruct* operator->() { return value(); }
129 bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
130 bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
131 private:
132 XFontStruct *ptr;
133 };
134 extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
135
136 // this object contains all X-specific stuff about a window:
137 // Warning: this object is highly subject to change!
138 // FL_LIBRARY or FL_INTERNALS must be defined to access this class.
139 class FL_EXPORT Fl_X {
140 public:
141 Window xid;
142 Window other_xid;
143 Fl_Window *w;
144 Fl_Region region;
145 Fl_X *next;
146 char wait_for_expose;
147 char backbuffer_bad; // used for XDBE
148 static Fl_X* first;
149 static Fl_X* i(const Fl_Window* wi) {return wi->i;}
150 void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
151 void sendxjunk();
152 static void set_default_icons(const Fl_RGB_Image*[], int);
153 void set_icons();
154 int set_cursor(Fl_Cursor);
155 int set_cursor(const Fl_RGB_Image*, int, int);
156 static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
157 static Fl_X* set_xid(Fl_Window*, Window);
158 // kludges to get around protection:
159 void flush() {w->flush();}
160 static void x(Fl_Window* wi, int X) {wi->x(X);}
161 static void y(Fl_Window* wi, int Y) {wi->y(Y);}
162 static int ewmh_supported();
163 static void activate_window(Window w);
164 };
165
166 extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
167 extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
168
169 inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::i(w); return xTemp ? xTemp->xid : 0; }
170
171 #else
172
173 extern FL_EXPORT Window fl_xid_(const Fl_Window* w);
174 #define fl_xid(w) fl_xid_(w)
175
176 #endif // FL_LIBRARY || FL_INTERNALS
177
178 FL_EXPORT Fl_Window* fl_find(Window xid);
179
180
181 // Dummy function to register a function for opening files via the window manager...
182 inline void fl_open_callback(void (*)(const char *)) {}
183
184 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
185
186 # endif
187 #endif
188
189 //
190 // End of "$Id: x.H 10412 2014-10-29 20:25:46Z cand $".
191 //
Fl_Window
This widget produces an actual window.
Definition: Fl_Window.H:57
Fl_Cursor
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition: Enumerations.H:910
fl_clip_region
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
Fl_Widget::y
void y(int v)
Internal use only.
Definition: Fl_Widget.H:140
fl_open_callback
void fl_open_callback(void(*cb)(const char *))
Register a function called for each file dropped onto an application icon.
Fl_RGB_Image
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:183
ulong
unsigned long ulong
unsigned long
Definition: fl_types.h:32
Enumerations.H
This file contains type definitions and general enumerations.
Fl_Window.H
Fl_Window widget .
fl_xpixel
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
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:796
Fl_Window::flush
virtual void flush()
Forces the window to be drawn, this window is also made current and calls draw(). ...
Definition: Fl.cxx:1844
fl_copy_offscreen
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:98
mac.H
Mac OS X-specific symbols.
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
Fl_Widget::x
void x(int v)
Internal use only.
Definition: Fl_Widget.H:138
- © 1998-2014 by Bill Spitzak and others.