unatgraph.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  unatgraph.hpp  [Native Layer: platform dependent implementation]
00004  *  Ubit Project
00005  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006  *  (C) 1999-2006 Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007  *
00008  * ***********************************************************************
00009  * COPYRIGHT NOTICE : 
00010  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00011  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00012  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00013  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00014  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016  * ***********************************************************************
00017  * ==================================================== [(c)Elc] ======= *
00018  * ==================================================== ======== ======= */
00019 
00020 #ifndef _unatgraph_hpp_
00021 #define _unatgraph_hpp_
00022 //pragma ident  "@(#)unatgraph.hpp      ubit:05.05.00"
00023 
00024 #ifdef WITH_GDK           // - - - GDK - - - - - - - - - - - - - - - - -
00025 
00026 #include <gdk/gdk.h>
00027 #define USysNull       NULL
00028 typedef GdkEvent*      USysEvent;        // also in uevent.hpp
00029 typedef guint          USysKeyCode;
00030 typedef GdkAtom        USysAtom;
00031 typedef GdkDisplay*    USysDisp;
00032 typedef GdkScreen*     USysScreen;
00033 typedef GdkVisual*     USysVisual;
00034 typedef GdkColormap*   USysColormap;
00035 typedef GdkWindow*     USysWin;
00036 typedef GdkPoint       USysPoint;
00037 typedef GdkRectangle   USysRect;
00038 typedef GdkGC*         USysGC;
00039 typedef GdkColor       USysColor;
00040 typedef guint32        USysPixel;
00041 typedef GdkFont*       USysFont;
00042 typedef GdkCursor*     USysCursor;
00043 typedef GdkImage*      USysIma;
00044 typedef GdkPixmap*     USysPix;
00045 
00046 #else                   // - - - Xlib - - - - - - - - - - - - - - - - -
00047 
00048 #include <X11/Xlib.h>
00049 #include <X11/Xutil.h>
00050 #include <X11/Xatom.h>
00051 #define USysNull       None
00052 typedef XEvent*        USysEvent;        // also in uevent.hpp
00053 typedef KeySym         USysKeyCode;
00054 typedef Atom           USysAtom;
00055 typedef Display*       USysDisp;
00056 typedef Screen*        USysScreen;
00057 typedef Visual*        USysVisual;
00058 typedef Colormap       USysColormap;
00059 typedef Window         USysWin;
00060 typedef XPoint         USysPoint;
00061 typedef XRectangle     USysRect;
00062 typedef GC             USysGC;
00063 typedef XColor         USysColor;
00064 typedef unsigned long  USysPixel;
00065 typedef XFontStruct*   USysFont;
00066 typedef Cursor         USysCursor;
00067 typedef XImage*        USysIma;
00068 typedef Pixmap         USysPix;
00069 #endif
00070 
00071 #ifdef HAVE_GL    // - - - GL - - - - - - - - - - - - - - - - - - -
00072 # include <GL/gl.h>
00073 # include <GL/glu.h>
00074 # include <GL/glx.h>
00075 #endif
00076 
00077 #include <ubit/udefs.hpp>
00078 namespace ubit {
00079 
00080 /* ==================================================== ===== ======= */
00085 struct UNatGraph {
00086   UNatGraph(UNatDisp&);
00087   void reset();
00088   
00089   void setGLColor(USysPixel);
00090   void setGLColor(USysPixel, unsigned char alpha);
00092   
00093   USysGC gc;    // note: not used in gl_mode
00094   USysDisp sys_disp;
00095   USysPixel color, bgcolor;
00096   UNatFont* font;
00097   short font_styles;
00098   float width;
00099   bool xor_mode;
00100   UNatDisp& natdisp;
00101 };
00102 
00103 /* ==================================================== ===== ======= */
00104 // OBSOLETE
00105 // {
00106 //    UXtry xtry;
00107 //    xDoTrucQuiPlante();
00108 //    if (!xtry.status()) doOnError();
00109 // }
00110 
00111 #ifdef WITH_GDK 
00112 struct UXtry { };   // A REVOIR!!!!
00113 #else
00114 struct UXtry {
00115   //NB: pas vraiment thread-safe car xerror doit etre static
00116   //(mais pas tres grave, le but 1er etant d'eviter des exit intempestifs)
00117   static int xerror;
00118   XErrorHandler xhandler;
00119   static int quietErrorHandler(Display*, XErrorEvent*);
00120   UXtry();
00121   ~UXtry();
00122   bool status();
00123 };
00124 #endif
00125 
00126 }
00127 #endif
00128 /* ==================================================== [TheEnd] ======= */
00129 /* ==================================================== [(c)Elc] ======= */

Generated on Mon Jan 29 00:20:39 2007 for Ubit by  doxygen 1.4.7