Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

x.h

00001 /*
00002  * $Id: x.h,v 1.9 2003/03/15 16:09:56 laza2000 Exp $
00003  *
00004  * Extended Fast Light Toolkit (EFLTK)
00005  * Copyright (C) 2002-2003 by EDE-Team
00006  * WWW: http://www.sourceforge.net/projects/ede
00007  *
00008  * Fast Light Toolkit (FLTK)
00009  * Copyright (C) 1998-2003 by Bill Spitzak and others.
00010  * WWW: http://www.fltk.org
00011  *
00012  * This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00013  * version 2. See COPYING for details.
00014  *
00015  * Author : Mikko Lahteenmaki
00016  * Email  : mikko@fltk.net
00017  *
00018  * Please report all bugs and problems to "efltk-bugs@fltk.net"
00019  *
00020  */
00021 
00022 // These are internal fltk symbols that are necessary or useful for
00023 // calling Xlib.  You should include this file if (and ONLY if) you
00024 // need to call Xlib directly.  You should avoid using this header
00025 // file in your software if at all possible.  NO FLTK HEADER FILE IS
00026 // ALLOWED TO INCLUDE THIS.
00027 //
00028 // Most of these symbols are replicated in header files
00029 // for other operating systems (win32.h, mac.h) but the definition of
00030 // the symbols is different, and usage may be somewhat different.
00031 
00032 #ifndef _Fl_X_H_
00033 #define _Fl_X_H_
00034 
00035 #include "Fl_Color.h"
00036 #include "Fl_Device.h"
00037 
00038 #ifdef _WIN32_WCE
00039 #include <wince.h>
00040 #endif
00041 
00042 #ifdef _WIN32
00043 
00044 # include "win32.h"
00045 
00046 #elif defined(__APPLE__)
00047 
00048 # include "mac.h"
00049 
00050 #else
00051 
00053 // Try to get the parts of Xlib.h included while avoiding warnings:
00054 
00055 #if defined(_ABIN32) || defined(_ABI64) // fix for broken SGI Irix X .h files
00056 # pragma set woff 3322
00057 #endif
00058 #include <X11/Xlib.h>
00059 #include <X11/Xutil.h>
00060 #if defined(_ABIN32) || defined(_ABI64)
00061 # pragma reset woff 3322
00062 #endif
00063 
00064 #include <X11/Xatom.h>
00065 
00066 // you should define USE_XFT 1 if you want to call Xft:
00067 #if USE_XFT
00068 # include <X11/Xft/Xft.h>
00069 #else
00070  typedef struct _XftDraw XftDraw;
00071 #endif
00072 
00074 // constant info about the X server connection:
00075 
00076 extern FL_API void  fl_open_display();
00077 extern FL_API void  fl_open_display(Display*);
00078 extern FL_API void  fl_close_display();
00079 
00080 extern FL_API Display*  fl_display;
00081 extern FL_API Window    fl_message_window;
00082 extern FL_API int   fl_screen;
00083 extern FL_API XVisualInfo* fl_visual;
00084 extern FL_API Colormap  fl_colormap;
00085 
00087 // event handling:
00088 
00089 // feed events into fltk by setting fl_xevent and calling fl_handle:
00090 extern FL_API XEvent    fl_xevent;
00091 extern FL_API bool  fl_handle();
00092 
00093 // Send this to all (E)FLTK app windows, to make them reload scheme
00094 extern Atom FLTKChangeScheme;
00095 // Send this to all EFLTK app windows, to make them reload settings
00096 extern Atom FLTKChangeSettings;
00097 
00098 // set by last fl_xevent with a timestamp:
00099 extern FL_API ulong fl_event_time;
00100 
00102 // DnD:
00103 
00104 extern FL_API Window fl_dnd_source_window;
00105 extern FL_API Atom *fl_dnd_source_types;
00106 extern FL_API Atom fl_dnd_type;
00107 extern FL_API Atom fl_dnd_source_action;
00108 extern FL_API Atom fl_dnd_action;
00109 
00111 // drawing functions:
00112 
00113 extern FL_API GC    fl_gc;
00114 extern FL_API struct Fl_Drawable* fl_drawable;
00115 extern FL_API Window    fl_window;
00116 
00117 extern FL_API XFontStruct* fl_xfont();
00118 
00119 extern FL_API ulong fl_pixel; // ==fl_xpixel(fl_color())
00120 extern FL_API ulong fl_xpixel(Fl_Color i);
00121 extern FL_API void  fl_clip_region(Region);
00122 extern FL_API Region    fl_clip_region();
00123 extern FL_API Region    XRectangleRegion(int x, int y, int w, int h);
00124 
00126 // This class is an offscreen image that you plan to draw to repeatedly.
00127 // It contains "context" information that may be expensive or impossible
00128 // to recreate each time for drawing. On some systems this is a base
00129 // class for Fl_X, which describes a window. Because
00130 // of differences in how these things are created & destroyed, and
00131 // the desire to have the id have a longer lifetime than this object,
00132 // intelligent constructors and destructors are not implemented.
00133 
00135 class FL_API Fl_Drawable {
00136  public:
00137   Window xid;
00138   XftDraw* draw;
00139   Fl_Drawable() : draw(0) {}
00140   Fl_Drawable(Pixmap p) : xid(p), draw(0) {}
00141   void create(int w, int h) {
00142     xid = XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth);
00143   }
00144   void copy(int x, int y, int w, int h, int src_x, int src_y) {
00145     XCopyArea(fl_display, xid, fl_window, fl_gc, src_x, src_y, w, h, x, y);
00146   }
00147   void free_gc();
00148   void destroy() {
00149     if (xid) {free_gc(); XFreePixmap(fl_display, xid); xid = 0;}
00150   }
00151   void make_current() {fl_drawable = this; fl_window=xid; fl_current_dev->load_identity(); }
00152 };
00153 
00155 // This is an offscreen image that is designed to be drawn into
00156 // exactly once and then repeatedly used as a source for copy. The
00157 // object is expected to fit into a void* space in the Fl_Image
00158 // structure. Drawing into them is surrounded by macros that save
00159 // the current graphics state in local variables and create a
00160 // temporary drawing context.
00161 
00162 #define fl_create_offscreen(w,h) \
00163   XCreatePixmap(fl_display, fl_window, w, h, fl_visual->depth)
00164 
00165 #define fl_begin_offscreen(id) \
00166   {fl_push_matrix(); \
00167   Fl_Drawable* _sd = fl_drawable; \
00168   Fl_Drawable _nd(id); \
00169   _nd.make_current(); \
00170   fl_push_no_clip()
00171 
00172 #define fl_end_offscreen() \
00173   _nd.free_gc(); _sd->make_current(); fl_pop_clip(); fl_pop_matrix();}
00174 
00175 #define fl_copy_offscreen(x,y,w,h,id,srcx,srcy) \
00176   XCopyArea(fl_display, id, fl_window, fl_gc, srcx, srcy, w, h, x, y)
00177 
00178 #define fl_delete_offscreen(id) XFreePixmap(fl_display, id)
00179 
00181 // This is a binary offscreen image created from in-memory data. This is used
00182 // as an alpha mask by Fl_Image on systems that don't support alpha
00183 // blending.
00184 
00185 static inline Pixmap fl_create_bitmap(const uchar* data, int w, int h) {
00186   return XCreateBitmapFromData(fl_display, fl_window, (char*)data,(w+7)&-8, h);
00187 }
00188 #define fl_delete_bitmap(id) XFreePixmap(fl_display, id)
00189 
00191 #ifdef _FL_WINDOW_H_ // only include this if <fltk/Fl_Window.h> was included
00192 
00193 // When fltk tells X about a window, one of these objects is created.
00194 // Warning: this object is highly subject to change!  It's definition
00195 // is only here so that fl_xid can be declared inline:
00196 
00197 class FL_API Fl_X : public Fl_Drawable {
00198 public:
00199   Fl_Drawable backbuffer;
00200   Fl_Window *window;
00201   Region region;
00202   void expose(int x, int y, int w, int h);
00203   Fl_X *next;
00204   bool wait_for_expose;
00205   bool backbuffer_bad; // used for XDBE
00206   static Fl_X* first;
00207   static Fl_X* i(const Fl_Window* window) {return window->i;}
00208   void sendxjunk();
00209   static void create(Fl_Window*,
00210              XVisualInfo*, Colormap,
00211              int background = -1);
00212 };
00213 
00214 // convert xid <-> Fl_Window:
00215 inline Window fl_xid(const Fl_Window*w) {return Fl_X::i(w)->xid;}
00216 Fl_Window* fl_find(Window xid);
00217 
00218 #endif // _FL_WINDOW_H_
00219 
00220 
00221 #endif  // not _WIN32
00222 #endif  // _Fl_X_H_

Generated on Thu Jul 31 15:33:46 2003 for eFLTK by doxygen1.2.15