FLTK 1.3.0
|
00001 // 00002 // "$Id$" 00003 // 00004 // X11 header file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 1998-2012 by Bill Spitzak and others. 00007 // 00008 // This library is free software. Distribution and use rights are outlined in 00009 // the file "COPYING" which should have been included with this file. If this 00010 // file is missing or damaged, see the license at: 00011 // 00012 // http://www.fltk.org/COPYING.php 00013 // 00014 // Please report all bugs and problems on the following page: 00015 // 00016 // http://www.fltk.org/str.php 00017 // 00018 00019 // These are internal fltk symbols that are necessary or useful for 00020 // calling Xlib. You should include this file if (and ONLY if) you 00021 // need to call Xlib directly. These symbols may not exist on non-X 00022 // systems. 00023 00035 #if !defined(Fl_X_H) && !defined(FL_DOXYGEN) 00036 # define Fl_X_H 00037 00038 # include "Enumerations.H" 00039 00040 # ifdef WIN32 00041 # include "win32.H" 00042 # elif defined(__APPLE__) 00043 # include "mac.H" 00044 # else 00045 # if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files 00046 # pragma set woff 3322 00047 # endif 00048 # include <X11/Xlib.h> 00049 # include <X11/Xutil.h> 00050 # if defined(_ABIN32) || defined(_ABI64) 00051 # pragma reset woff 3322 00052 # endif 00053 # include <X11/Xatom.h> 00054 # include "Fl_Window.H" 00055 # include "Xutf8.h" 00056 // Mirror X definition of Region to Fl_Region, for portability... 00057 typedef Region Fl_Region; 00058 00059 FL_EXPORT void fl_open_display(); 00060 FL_EXPORT void fl_open_display(Display*); 00061 FL_EXPORT void fl_close_display(); 00062 00063 // constant info about the X server connection: 00064 extern FL_EXPORT Display *fl_display; 00065 extern FL_EXPORT int fl_screen; 00066 extern FL_EXPORT XVisualInfo *fl_visual; 00067 extern FL_EXPORT Colormap fl_colormap; 00068 00069 00070 // drawing functions: 00071 extern FL_EXPORT GC fl_gc; 00072 extern FL_EXPORT Window fl_window; 00073 FL_EXPORT ulong fl_xpixel(Fl_Color i); 00074 FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b); 00075 FL_EXPORT void fl_clip_region(Fl_Region); 00076 FL_EXPORT Fl_Region fl_clip_region(); 00077 00078 // feed events into fltk: 00079 FL_EXPORT int fl_handle(const XEvent&); 00080 00081 // you can use these in Fl::add_handler() to look at events: 00082 extern FL_EXPORT const XEvent* fl_xevent; 00083 extern FL_EXPORT ulong fl_event_time; 00084 00085 // off-screen pixmaps: create, destroy, draw into, copy to window: 00086 typedef ulong Fl_Offscreen; 00087 # define fl_create_offscreen(w,h) \ 00088 XCreatePixmap(fl_display, \ 00089 (Fl_Surface_Device::surface() == Fl_Display_Device::display_device() ? \ 00090 fl_window : fl_xid(Fl::first_window()) ) , \ 00091 w, h, fl_visual->depth) 00092 // begin/end are macros that save the old state in local variables: 00093 # define fl_begin_offscreen(pixmap) \ 00094 Window _sw=fl_window; fl_window=pixmap; \ 00095 Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \ 00096 fl_push_no_clip() 00097 # define fl_end_offscreen() \ 00098 fl_pop_clip(); fl_window = _sw; _ss->set_current() 00099 00100 extern void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); 00101 # define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap) 00102 00103 // Bitmap masks 00104 typedef ulong Fl_Bitmask; 00105 00106 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data); 00107 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data); 00108 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm); 00109 00110 #if defined(FL_LIBRARY) || defined(FL_INTERNALS) 00111 extern FL_EXPORT Window fl_message_window; 00112 extern FL_EXPORT void *fl_xftfont; 00113 FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx 00114 00115 // access to core fonts: 00116 // This class provides a "smart pointer" that returns a pointer to an XFontStruct. 00117 // The global variable fl_xfont can be called wherever a bitmap "core" font is 00118 // needed, e.g. when rendering to a GL context under X11. 00119 // With Xlib / X11 fonts, fl_xfont will return the current selected font. 00120 // With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most 00121 // similar to (usually the same as) the current XFT font. 00122 class Fl_XFont_On_Demand 00123 { 00124 public: 00125 Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { } 00126 Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x) 00127 { ptr = x.ptr; return *this; } 00128 Fl_XFont_On_Demand& operator=(XFontStruct* p) 00129 { ptr = p; return *this; } 00130 XFontStruct* value(); 00131 operator XFontStruct*() { return value(); } 00132 XFontStruct& operator*() { return *value(); } 00133 XFontStruct* operator->() { return value(); } 00134 bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; } 00135 bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; } 00136 private: 00137 XFontStruct *ptr; 00138 }; 00139 extern FL_EXPORT Fl_XFont_On_Demand fl_xfont; 00140 00141 // this object contains all X-specific stuff about a window: 00142 // Warning: this object is highly subject to change! 00143 // FL_LIBRARY or FL_INTERNALS must be defined to access this class. 00144 class FL_EXPORT Fl_X { 00145 public: 00146 Window xid; 00147 Window other_xid; 00148 Fl_Window *w; 00149 Fl_Region region; 00150 Fl_X *next; 00151 char wait_for_expose; 00152 char backbuffer_bad; // used for XDBE 00153 static Fl_X* first; 00154 static Fl_X* i(const Fl_Window* wi) {return wi->i;} 00155 void setwindow(Fl_Window* wi) {w=wi; wi->i=this;} 00156 void sendxjunk(); 00157 static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap); 00158 static Fl_X* set_xid(Fl_Window*, Window); 00159 // kludges to get around protection: 00160 void flush() {w->flush();} 00161 static void x(Fl_Window* wi, int X) {wi->x(X);} 00162 static void y(Fl_Window* wi, int Y) {wi->y(Y);} 00163 static int ewmh_supported(); 00164 }; 00165 00166 extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid() 00167 extern FL_EXPORT int fl_background_pixel; // hack into Fl_X::make_xid() 00168 00169 inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::i(w); return xTemp ? xTemp->xid : 0; } 00170 00171 #else 00172 00173 extern Window fl_xid_(const Fl_Window* w); 00174 #define fl_xid(w) fl_xid_(w) 00175 00176 #endif // FL_LIBRARY || FL_INTERNALS 00177 00178 FL_EXPORT Fl_Window* fl_find(Window xid); 00179 00180 00181 // Dummy function to register a function for opening files via the window manager... 00182 inline void fl_open_callback(void (*)(const char *)) {} 00183 00184 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); 00185 00186 # endif 00187 #endif 00188 00189 // 00190 // End of "$Id$". 00191 //