FLTK 1.3.2
Fl_Cairo.H
1 //
2 // "$Id: Fl_Cairo.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
3 //
4 // Main header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18 
19 /* \file
20  Handling transparently platform dependent cairo include files
21 */
22 
23 #ifndef FL_CAIRO_H
24 # define FL_CAIRO_H
25 # ifdef FLTK_HAVE_CAIRO
26 
27 // Cairo is currently supported for the following platforms:
28 // Win32, Apple Quartz, X11
29 
30 # include <FL/Fl_Export.H>
31 
32 # if defined(USE_X11) // X11
33 # include <cairo-xlib.h>
34 # elif defined(WIN32)
35 # include <cairo-win32.h>
36 # elif defined(__APPLE_QUARTZ__)
37 # include <cairo-quartz.h>
38 # else
39 # error Cairo is not supported on that platform.
40 # endif
41 
54 class FL_EXPORT Fl_Cairo_State {
55 public:
56  Fl_Cairo_State() : cc_(0), own_cc_(false), autolink_(false), window_(0), gc_(0) {}
57 
58  // access attributes
59  cairo_t* cc() const {return cc_;}
60  bool autolink() const {return autolink_;}
61 
62  void cc(cairo_t* c, bool own=true) {
63  if (cc_ && own_cc_) cairo_destroy(cc_);
64  cc_=c;
65  if (!cc_) window_=0;
66  own_cc_=own;
67  }
68  void autolink(bool b);
69  void window(void* w) {window_=w;}
70  void* window() const {return window_;}
71  void gc(void* c) {gc_=c;}
72  void* gc() const {return gc_;}
73 
74 private:
75  cairo_t * cc_; // contains the unique autoupdated cairo context
76  bool own_cc_; // indicates whether we must delete the cc, useful for internal cleanup
77  bool autolink_; // true by default, permits to prevent the automatic cairo mapping on fltk windows for custom cairo implementations
78  void* window_, *gc_; // for keeping track internally of last win+gc treated
79 };
80 
83 # endif // FLTK_HAVE_CAIRO
84 #endif // FL_CAIRO_H
85 
86 //
87 // End of "$Id: Fl_Cairo.H 8864 2011-07-19 04:49:30Z greg.ercolano $" .
88 //
void window(void *w)
Sets the window w to keep track on.
Definition: Fl_Cairo.H:69
bool autolink() const
Gets the autolink option. See Fl::cairo_autolink_context(bool)
Definition: Fl_Cairo.H:60
void * gc() const
Gets the last gc attached to a cc.
Definition: Fl_Cairo.H:72
void * window() const
Gets the last window attached to a cc.
Definition: Fl_Cairo.H:70
void gc(void *c)
Sets the gc c to keep track on.
Definition: Fl_Cairo.H:71
void cc(cairo_t *c, bool own=true)
Sets the current cairo context, own indicates cc deletion is handle externally by user...
Definition: Fl_Cairo.H:62
Contains all the necessary info on the current cairo context.
Definition: Fl_Cairo.H:54
cairo_t * cc() const
Gets the current cairo context.
Definition: Fl_Cairo.H:59