FLTK 1.5.0
Fl_Cairo.H
Go to the documentation of this file.
1//
2// Main Cairo support header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2025 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
33#ifndef FL_CAIRO_H
34#define FL_CAIRO_H
35
36#include <FL/Fl.H>
37
38# ifdef FLTK_HAVE_CAIRO
39
40# include <cairo.h>
41
55class FL_EXPORT Fl_Cairo_State {
56public:
58 : cc_(0)
59 , own_cc_(false)
60 , autolink_(false)
61 , window_(0)
62 , gc_(0) {}
63
64 // access attributes
65 cairo_t *cc() const { return cc_; }
66 bool autolink() const { return autolink_; }
75 void cc(cairo_t *c, bool own = true) {
76 if (cc_ && own_cc_)
77 cairo_destroy(cc_);
78 cc_ = c;
79 if (!cc_)
80 window_ = 0;
81 own_cc_ = own;
82 }
83 void autolink(bool b);
84 void window(void *w) { window_ = w; }
85 void *window() const { return window_; }
86 void gc(void *c) { gc_ = c; }
87 void *gc() const { return gc_; }
88
89private:
90 cairo_t *cc_; // contains the unique autoupdated cairo context
91 bool own_cc_; // indicates whether we must delete the cc, useful for internal cleanup
92 bool autolink_; // false by default, prevents the automatic cairo mapping on fltk windows
93 // for custom cairo implementations.
94 void *window_, *gc_; // for keeping track internally of last win+gc treated
95};
96
99#endif // FLTK_HAVE_CAIRO
100#endif // FL_CAIRO_H
Fl static class.
Contains all the necessary info on the current cairo context.
Definition: Fl_Cairo.H:55
void window(void *w)
Sets the window w to keep track on.
Definition: Fl_Cairo.H:84
void cc(cairo_t *c, bool own=true)
Sets the current cairo context.
Definition: Fl_Cairo.H:75
void * gc() const
Gets the last gc attached to a cc.
Definition: Fl_Cairo.H:87
void * window() const
Gets the last window attached to a cc.
Definition: Fl_Cairo.H:85
void gc(void *c)
Sets the gc c to keep track on.
Definition: Fl_Cairo.H:86
cairo_t * cc() const
Gets the current cairo context.
Definition: Fl_Cairo.H:65
bool autolink() const
Gets the autolink option. See Fl::cairo_autolink_context(bool)
Definition: Fl_Cairo.H:66