FLTK 1.4.0
platform.H
1 //
2 // Platform header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2020 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 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
17 // These are FLTK symbols that are necessary or useful for calling
18 // platform specific functions. This file #include's certain platform
19 // specific system header files that are necessary to declare platform
20 // specific FLTK functions, for instance "Windows.h" under Windows.
21 
22 // You should include this file if (and ONLY if) you need to call
23 // platform specific functions directly.
24 
25 // See FLTK documentation: chapter "Operating System Issues" on when
26 // you need to #include <FL/platform.H>
27 
28 #if !defined(FL_PLATFORM_H) && !defined(FL_DOXYGEN)
29 # define FL_PLATFORM_H
30 
31 # include <FL/Fl_Export.H>
32 # include <FL/platform_types.h>
33 # include <FL/fl_types.h> // for uchar
34 class Fl_Window;
35 
36 # ifdef _WIN32
37 # include "win32.H"
38 # elif defined(__APPLE__)
39 # include "mac.H"
40 # elif defined(__ANDROID__)
41 # include "android.H"
42 # else // X11
43 # include <FL/fl_types.h>
44 # include <FL/Enumerations.H>
45 # if !defined(USE_X11)
46 # define USE_X11 1
47 # endif
48 # if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
49 # pragma set woff 3322
50 # endif
51 # include <X11/Xlib.h>
52 # include <X11/Xutil.h>
53 # if defined(_ABIN32) || defined(_ABI64)
54 # pragma reset woff 3322
55 # endif
56 # include <X11/Xatom.h>
57 
58 // constant info about the X server connection:
59 extern FL_EXPORT Display *fl_display;
60 extern FL_EXPORT int fl_screen;
61 extern FL_EXPORT XVisualInfo *fl_visual;
62 extern FL_EXPORT Colormap fl_colormap;
63 
64 // drawing functions:
65 extern FL_EXPORT GC fl_gc;
66 FL_EXPORT ulong fl_xpixel(Fl_Color i);
67 FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
68 
69 // feed events into fltk:
70 FL_EXPORT int fl_handle(const XEvent&);
71 
72 // you can use these in Fl::add_handler() to look at events:
73 extern FL_EXPORT const XEvent* fl_xevent;
74 extern FL_EXPORT ulong fl_event_time;
75 
76 #if defined(FL_LIBRARY) || defined(FL_INTERNALS)
77 extern FL_EXPORT Window fl_message_window;
78 extern FL_EXPORT void *fl_xftfont;
79 
80 // access to core fonts:
81 // This class provides a "smart pointer" that returns a pointer to an XFontStruct.
82 // The global variable fl_xfont can be called wherever a bitmap "core" font is
83 // needed, e.g. when rendering to a GL context under X11.
84 // With Xlib / X11 fonts, fl_xfont will return the current selected font.
85 // With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most
86 // similar to (usually the same as) the current XFT font.
87 class FL_EXPORT Fl_XFont_On_Demand
88 {
89 public:
90  Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
91  Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
92  { ptr = x.ptr; return *this; }
93  Fl_XFont_On_Demand& operator=(XFontStruct* p)
94  { ptr = p; return *this; }
95  XFontStruct* value();
96  operator XFontStruct*() { return value(); }
97  XFontStruct& operator*() { return *value(); }
98  XFontStruct* operator->() { return value(); }
99  bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
100  bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
101 private:
102  XFontStruct *ptr;
103 };
104 extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
105 
106 extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
107 extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid()
108 
109 #endif // FL_LIBRARY || FL_INTERNALS
110 
111 # endif // X11
112 
113 //
114 // cross-platform declarations
115 //
116 #if defined(FL_LIBRARY) || defined(FL_INTERNALS)
117 # include <FL/Fl_Window.H>
118 
119 class FL_EXPORT Fl_X {
120 public:
121  Window xid;
122  Fl_Window* w;
123  Fl_Region region;
124  Fl_X *next;
125  // static variables, static functions and member functions
126  static Fl_X* first;
127  static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;}
128 # if defined(USE_X11) // for backward compatibility
129  static void make_xid(Fl_Window*, XVisualInfo* =fl_visual, Colormap=fl_colormap);
130  static Fl_X* set_xid(Fl_Window*, Window);
131 # endif
132 };
133 
134 inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::i(w); return xTemp ? xTemp->xid : 0; }
135 #else
136 extern FL_EXPORT Window fl_xid_(const Fl_Window* w);
137 # define fl_xid(w) fl_xid_(w)
138 #endif // FL_LIBRARY || FL_INTERNALS
139 
140 extern FL_EXPORT Fl_Window* fl_find(Window xid);
141 extern FL_EXPORT void fl_open_display();
142 extern FL_EXPORT void fl_close_display();
143 extern FL_EXPORT Window fl_window;
144 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
145 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
146 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
147 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
148 extern FL_EXPORT void fl_open_callback(void (*)(const char *));
149 
150 #endif // !FL_PLATFORM_H
This file contains type definitions and general enumerations.
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition: Enumerations.H:1041
void fl_open_display()
Opens the display.
Definition: Fl.cxx:2004
Fl_Window widget .
This widget produces an actual window.
Definition: Fl_Window.H:52
This file contains simple "C"-style type definitions.
unsigned char uchar
unsigned char
Definition: fl_types.h:28
unsigned long ulong
unsigned long
Definition: fl_types.h:30
void fl_open_callback(void(*cb)(const char *))
Register a function called for each file dropped onto an application icon.
Definition: Fl.cxx:2033
Mac OS X-specific symbols.
Definitions of platform-dependent types.
opaque Fl_Region
a region made of several rectangles
Definition: platform_types.h:37
opaque Fl_Bitmask
mask
Definition: platform_types.h:36