Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

unatgraph.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  unatgraph.hpp  [Native Layer: platform dependent implementation]
00004  *  Ubit Project  [Elc][2003]
00005  *  Author: Eric Lecolinet
00006  *
00007  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00008  *
00009  *  (C) 1999-2003 Eric Lecolinet @ ENST Paris
00010  *  WWW: http://www.enst.fr/~elc/ubit   Email: elc@enst.fr (subject: ubit)
00011  *
00012  * ***********************************************************************
00013  * COPYRIGHT NOTICE : 
00014  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00015  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00016  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00017  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00018  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00019  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00020  * ***********************************************************************
00021  *
00022  * ==================================================== [Elc:03] ======= *
00023  * ==================================================== ======== ======= */
00024 
00025 #ifndef _unatgraph_hpp_
00026 #define _unatgraph_hpp_
00027 //pragma ident  "@(#)unatgraph.hpp      ubit:03.06.04"
00028 #include <ubit/ubit_config.h>
00029 #include <X11/Xlib.h>
00030 #include <X11/Xutil.h>
00031 #ifdef WITH_GL
00032 #  include <GL/gl.h>
00033 #  include <GL/glu.h>
00034 #  include <GL/glx.h>
00035 #endif
00036 #include <ubit/uevent.hpp>
00037 #include <ubit/ucolor.hpp>
00038 
00039 
00040 typedef union _XEvent*  UX_Event;        // also in uevent.hpp
00041 typedef Display*        UX_Display;
00042 typedef Screen*         UX_Screen;
00043 typedef Visual*         UX_Visual;
00044 typedef XVisualInfo*    UX_VisualInfo;
00045 typedef Colormap        UX_Colormap;
00046 typedef Window          UX_Window;
00047 typedef GC              UX_GC;
00048 typedef XFontStruct*    UX_Font;
00049 typedef Cursor          UX_Cursor;
00050 typedef unsigned long   UX_Color;
00051 typedef Pixmap          UX_Pixmap;
00052 typedef XImage*         UX_Image;
00053 typedef XRectangle      UX_Rectangle;
00054 typedef Atom            UX_Atom;
00055 
00056 /* ==================================================== [Elc:02] ======= */
00057 /* ==================================================== ======== ======= */
00058 // sert a catcher les X Errors safely
00059 // usage (att: les { } sont essentiels!)
00060 // {
00061 //    UXtry xtry;
00062 //    xDoTrucQuiPlante();
00063 //    if (!xtry.status()) doOnError();
00064 // }
00065 
00066 struct UXtry {
00067   //NB: pas vraiment thread-safe car xerror doit etre static
00068   //(mais pas tres grave, le but 1er etant d'eviter des exit intempestifs)
00069   static int xerror;
00070   XErrorHandler xhandler;
00071   static int quietErrorHandler(Display *, XErrorEvent *xer);
00072 
00073   UXtry();
00074   ~UXtry();
00075   bool status();
00076 };
00077 
00078 /* ==================================================== [Elc:02] ======= */
00079 /* ==================================================== ======== ======= */
00081 //(en fait il n'y a generalement qu'un seul natgraph pour toute l'appli)
00082 
00083 struct UNatGraph {
00084   UGraph*    graph_lock;
00085   UX_GC      gc;
00086   UX_Color   color, bgcolor;
00087   UX_Font    font;
00088   short      font_styles, thickness;
00089   bool       xor_mode;
00090 #ifdef WITH_GL
00091   GLuint     glFontList;
00092 #endif
00093 
00094   UNatGraph(class UNatDisp*);
00095 
00096   void reset();
00097   void lock(UGraph*);
00098   void unlock();
00099   bool isLocked()     {return (graph_lock != null);}
00100 
00101   UX_GC    getGC()      {return gc;}   // !NB: Implementation dependent
00102   UX_Color getPixel()   {return color;}
00103   UX_Color getBgpixel() {return bgcolor;}
00104   UX_Font  getFont()    {return font;}
00105 #ifdef WITH_GL
00106   GLuint getGLFontList() {return glFontList;}
00107 #endif
00108 };
00109 
00110 
00111 #endif
00112 /* ==================================================== [TheEnd] ======= */
00113 /* ==================================================== [Elc:03] ======= */

Generated on Sun Jul 3 23:15:48 2005 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.4.3-20050530