FLTK 1.3.0
Fl_Cairo.H
00001 //
00002 // "$Id: Fl_Cairo.H 8198 2011-01-06 10:24:58Z manolo $"
00003 //
00004 // Main header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00027 
00028 /* \file
00029     Handling transparently platform dependent cairo include files 
00030 */
00031 
00032 #ifndef FL_CAIRO_H
00033 # define FL_CAIRO_H
00034 # ifdef FLTK_HAVE_CAIRO
00035 
00036 // Cairo is currently supported for the following platforms:
00037 // Win32, Apple Quartz, X11
00038 
00039 # include <FL/Fl_Export.H>
00040 
00041 # if defined(USE_X11) // X11
00042 #  include <cairo-xlib.h>
00043 # elif defined(WIN32)
00044 #  include <cairo-win32.h>
00045 # elif defined(__APPLE_QUARTZ__)
00046 #  include <cairo-quartz.h>
00047 # else
00048 #  error Cairo is not supported on that platform.
00049 # endif
00050 
00063 class FL_EXPORT Fl_Cairo_State {
00064 public:
00065   Fl_Cairo_State() : cc_(0), own_cc_(false), autolink_(false), window_(0), gc_(0) {}
00066 
00067     // access attributes
00068     cairo_t* cc() const {return cc_;}            
00069     bool autolink() const {return autolink_;}    
00070 
00071     void cc(cairo_t* c, bool own=true)  {        
00072         if (cc_ && own_cc_) cairo_destroy(cc_); 
00073         cc_=c;
00074         if (!cc_) window_=0;
00075         own_cc_=own;
00076     }
00077     void  autolink(bool b);                     
00078     void  window(void* w)  {window_=w;}         
00079     void* window() const {return window_;}      
00080     void  gc(void* c)  {gc_=c;}                 
00081     void* gc() const {return gc_;}              
00082 
00083 private:
00084     cairo_t * cc_;       // contains the unique autoupdated cairo context
00085     bool own_cc_;        // indicates whether we must delete the cc, useful for internal cleanup
00086     bool autolink_;      // true by default, permits to prevent the automatic cairo mapping on fltk windows for custom cairo implementations
00087     void* window_, *gc_; // for keeping track internally of last win+gc treated
00088 };
00089 
00092 # endif // FLTK_HAVE_CAIRO
00093 #endif // FL_CAIRO_H
00094 
00095 //
00096 // End of "$Id: Fl_Cairo.H 8198 2011-01-06 10:24:58Z manolo $" .
00097 //