FLTK
Fl_Cairo.H
1 //
2 // Main header file for the Fast Light Tool Kit (FLTK).
3 //
4 // Copyright 1998-2016 by Bill Spitzak and others.
5 //
6 // This library is free software. Distribution and use rights are outlined in
7 // the file "COPYING" which should have been included with this file. If this
8 // file is missing or damaged, see the license at:
9 //
10 // https://www.fltk.org/COPYING.php
11 //
12 // Please see the following page on how to report bugs and issues:
13 //
14 // https://www.fltk.org/bugs.php
15 //
16 
17 /* \file
18  Handling transparently platform dependent cairo include files
19 */
20 
21 #ifndef FL_CAIRO_H
22 # define FL_CAIRO_H
23 # ifdef FLTK_HAVE_CAIRO
24 
25 // Cairo is currently supported for the following platforms:
26 // Win32, Apple Quartz, X11
27 
28 # include <FL/Fl_Export.H>
29 
30 # include <cairo.h>
31 
44 class FL_EXPORT Fl_Cairo_State {
45 public:
46  Fl_Cairo_State() : cc_(0), own_cc_(false), autolink_(false), window_(0), gc_(0) {}
47 
48  // access attributes
49  cairo_t* cc() const {return cc_;}
50  bool autolink() const {return autolink_;}
51 
59  void cc(cairo_t* c, bool own=true) {
60  if (cc_ && own_cc_) cairo_destroy(cc_);
61  cc_=c;
62  if (!cc_) window_=0;
63  own_cc_=own;
64  }
65  void autolink(bool b);
66  void window(void* w) {window_=w;}
67  void* window() const {return window_;}
68  void gc(void* c) {gc_=c;}
69  void* gc() const {return gc_;}
70 
71 private:
72  cairo_t * cc_; // contains the unique autoupdated cairo context
73  bool own_cc_; // indicates whether we must delete the cc, useful for internal cleanup
74  bool autolink_; // false by default, prevents the automatic cairo mapping on fltk windows
75  // for custom cairo implementations.
76  void* window_, *gc_; // for keeping track internally of last win+gc treated
77 };
78 
81 # endif // FLTK_HAVE_CAIRO
82 #endif // FL_CAIRO_H
void window(void *w)
Sets the window w to keep track on.
Definition: Fl_Cairo.H:66
bool autolink() const
Gets the autolink option. See Fl::cairo_autolink_context(bool)
Definition: Fl_Cairo.H:50
cairo_t * cc() const
Gets the current cairo context.
Definition: Fl_Cairo.H:49
void * gc() const
Gets the last gc attached to a cc.
Definition: Fl_Cairo.H:69
void gc(void *c)
Sets the gc c to keep track on.
Definition: Fl_Cairo.H:68
void cc(cairo_t *c, bool own=true)
Sets the current cairo context.
Definition: Fl_Cairo.H:59
void * window() const
Gets the last window attached to a cc.
Definition: Fl_Cairo.H:67
Contains all the necessary info on the current cairo context.
Definition: Fl_Cairo.H:44