FLTK 1.3.9: x.H Source File

FLTK 1.3.9

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