• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

x.H

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 
00024 #if !defined(Fl_X_H) && !defined(FL_DOXYGEN) 
00025 #  define Fl_X_H
00026 
00027 #  include "Enumerations.H"
00028 
00029 #  ifdef WIN32
00030 #    include "win32.H"
00031 #  elif defined(__APPLE__)
00032 #    include "mac.H"
00033 #  else
00034 #    if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
00035 #      pragma set woff 3322
00036 #    endif
00037 #    include <X11/Xlib.h>
00038 #    include <X11/Xutil.h>
00039 #    if defined(_ABIN32) || defined(_ABI64)
00040 #      pragma reset woff 3322
00041 #    endif
00042 #    include <X11/Xatom.h>
00043 #    include "Fl_Window.H"
00044 // Mirror X definition of Region to Fl_Region, for portability...
00045 typedef Region Fl_Region;
00046 
00047 FL_EXPORT void fl_open_display();
00048 FL_EXPORT void fl_open_display(Display*);
00049 FL_EXPORT void fl_close_display();
00050 
00051 // constant info about the X server connection:
00052 extern FL_EXPORT Display *fl_display;
00053 extern FL_EXPORT int fl_screen;
00054 extern FL_EXPORT XVisualInfo *fl_visual;
00055 extern FL_EXPORT Colormap fl_colormap;
00056 
00057 
00058 // drawing functions:
00059 extern FL_EXPORT GC fl_gc;
00060 extern FL_EXPORT Window fl_window;
00061 FL_EXPORT ulong fl_xpixel(Fl_Color i);
00062 FL_EXPORT ulong fl_xpixel(uchar r, uchar g, uchar b);
00063 FL_EXPORT void fl_clip_region(Fl_Region);
00064 FL_EXPORT Fl_Region fl_clip_region();
00065 
00066 // feed events into fltk:
00067 FL_EXPORT int fl_handle(const XEvent&);
00068 
00069 // you can use these in Fl::add_handler() to look at events:
00070 extern FL_EXPORT const XEvent* fl_xevent;
00071 extern FL_EXPORT ulong fl_event_time;
00072 
00073 // off-screen pixmaps: create, destroy, draw into, copy to window:
00074 typedef ulong Fl_Offscreen;
00075 #    define fl_create_offscreen(w,h) XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), w, h, fl_visual->depth)
00076 #    define fl_create_offscreen_with_alpha(w,h) XCreatePixmap(fl_display, RootWindow(fl_display, fl_screen), w, h, 32)
00077 // begin/end are macros that save the old state in local variables:
00078 #    define fl_begin_offscreen(pixmap) \
00079   Window _sw=fl_window; fl_window=pixmap; \
00080   Fl_Surface_Device *_ss = Fl_Surface_Device::surface(); Fl_Display_Device::display_device()->set_current(); \
00081   fl_push_no_clip()
00082 #    define fl_end_offscreen() \
00083   fl_pop_clip(); fl_window = _sw; _ss->set_current()
00084 
00085 extern FL_EXPORT void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy);
00086 #    define fl_delete_offscreen(pixmap) XFreePixmap(fl_display, pixmap)
00087 
00088 // Bitmap masks
00089 typedef ulong Fl_Bitmask;
00090 
00091 extern FL_EXPORT Fl_Bitmask fl_create_bitmask(int w, int h, const uchar *data);
00092 extern FL_EXPORT Fl_Bitmask fl_create_alphamask(int w, int h, int d, int ld, const uchar *data);
00093 extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
00094 
00095 #if defined(FL_LIBRARY) || defined(FL_INTERNALS)
00096 extern FL_EXPORT Window fl_message_window;
00097 extern FL_EXPORT void *fl_xftfont;
00098 FL_EXPORT Fl_Region XRectangleRegion(int x, int y, int w, int h); // in fl_rect.cxx
00099 
00100 // access to core fonts:
00101 // This class provides a "smart pointer" that returns a pointer to an XFontStruct.
00102 // The global variable fl_xfont can be called wherever a bitmap "core" font is
00103 // needed, e.g. when rendering to a GL context under X11.
00104 // With Xlib / X11 fonts, fl_xfont will return the current selected font.
00105 // With XFT / X11 fonts, fl_xfont will attempt to return the bitmap "core" font most
00106 // similar to (usually the same as) the current XFT font.
00107 class Fl_XFont_On_Demand
00108 {
00109 public:
00110   Fl_XFont_On_Demand(XFontStruct* p = NULL) : ptr(p) { }
00111   Fl_XFont_On_Demand& operator=(const Fl_XFont_On_Demand& x)
00112   { ptr = x.ptr;  return *this; }
00113   Fl_XFont_On_Demand& operator=(XFontStruct* p)
00114   { ptr = p;  return *this; }
00115   XFontStruct* value();
00116   operator XFontStruct*() { return value(); }
00117   XFontStruct& operator*() { return *value(); }
00118   XFontStruct* operator->() { return value(); }
00119   bool operator==(const Fl_XFont_On_Demand& x) { return ptr == x.ptr; }
00120   bool operator!=(const Fl_XFont_On_Demand& x) { return ptr != x.ptr; }
00121 private:
00122   XFontStruct *ptr;
00123 };
00124 extern FL_EXPORT Fl_XFont_On_Demand fl_xfont;
00125 extern FL_EXPORT XFontStruct* fl_X_core_font();
00126 
00127 // this object contains all X-specific stuff about a window:
00128 // Warning: this object is highly subject to change!  
00129 // FL_LIBRARY or FL_INTERNALS must be defined to access this class.
00130 class FL_EXPORT Fl_X {
00131 public:
00132   Window xid;
00133   Window other_xid;
00134   Fl_Window *w;
00135   Fl_Region region;
00136   Fl_X *next;
00137   char wait_for_expose;
00138   char backbuffer_bad; // used for XDBE
00139   static Fl_X* first;
00140   static Fl_X* i(const Fl_Window* wi) {return wi->i;}
00141   void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
00142   void sendxjunk();
00143   static void set_default_icons(const Fl_RGB_Image*[], int);
00144   void set_icons();
00145   int set_cursor(Fl_Cursor);
00146   int set_cursor(const Fl_RGB_Image*, int, int);
00147   static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
00148   static Fl_X* set_xid(Fl_Window*, Window);
00149   // kludges to get around protection:
00150   void flush() {w->flush();}
00151   static void x(Fl_Window* wi, int X) {wi->x(X);}
00152   static void y(Fl_Window* wi, int Y) {wi->y(Y);}
00153   static int ewmh_supported();
00154   static int xrender_supported();
00155   static void activate_window(Window w);
00156 };
00157 
00158 extern FL_EXPORT char fl_override_redirect; // hack into Fl_X::make_xid()
00159 extern FL_EXPORT int fl_background_pixel;  // hack into Fl_X::make_xid()
00160 
00161 inline Window fl_xid(const Fl_Window* w) { Fl_X *xTemp = Fl_X::i(w); return xTemp ? xTemp->xid : 0; }
00162 
00163 #else
00164 
00165 extern FL_EXPORT Window fl_xid_(const Fl_Window* w);
00166 #define fl_xid(w) fl_xid_(w)
00167 
00168 #endif // FL_LIBRARY || FL_INTERNALS
00169 
00170 FL_EXPORT Fl_Window* fl_find(Window xid);
00171 
00172 
00173 // Dummy function to register a function for opening files via the window manager...
00174 inline void fl_open_callback(void (*)(const char *)) {}
00175 
00176 extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
00177 
00178 #  endif
00179 #endif
00180 
00181 //
00182 // End of "$Id$".
00183 //
  • © 1998-2016 by Bill Spitzak and others.     FLTK

  • © 1998-2016 by Bill Spitzak and others.     FLTK

    Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright and permission notice are preserved.