FLTK 1.4.5: Fl_Cairo.H Source File

FLTK 1.4.5

Loading...
Searching...
No Matches
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-2023 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
32
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
46
56 class FL_EXPORT Fl_Cairo_State {
57public:
58 Fl_Cairo_State()
59 : cc_(0)
60 , own_cc_(false)
61 , autolink_(false)
62 , window_(0)
63 , gc_(0) {}
64
65 // access attributes
66 cairo_t *cc() const { return cc_; }
67 bool autolink() const { return autolink_; }
76 void cc(cairo_t *c, bool own = true) {
77 if (cc_ && own_cc_)
78 cairo_destroy(cc_);
79 cc_ = c;
80 if (!cc_)
81 window_ = 0;
82 own_cc_ = own;
83 }
84 void autolink(bool b);
85 void window(void *w) { window_ = w; }
86 void *window() const { return window_; }
87 void gc(void *c) { gc_ = c; }
88 void *gc() const { return gc_; }
89
90private:
91 cairo_t *cc_; // contains the unique autoupdated cairo context
92 bool own_cc_; // indicates whether we must delete the cc, useful for internal cleanup
93 bool autolink_; // false by default, prevents the automatic cairo mapping on fltk windows
94 // for custom cairo implementations.
95 void *window_, *gc_; // for keeping track internally of last win+gc treated
96};
97
99
100#endif // FLTK_HAVE_CAIRO
101#endif // FL_CAIRO_H
Fl.H
Fl static class.
Fl_Cairo_State::window
void window(void *w)
Sets the window w to keep track on.
Definition Fl_Cairo.H:85
Fl_Cairo_State::cc
void cc(cairo_t *c, bool own=true)
Sets the current cairo context.
Definition Fl_Cairo.H:76
Fl_Cairo_State::gc
void * gc() const
Gets the last gc attached to a cc.
Definition Fl_Cairo.H:88
Fl_Cairo_State::window
void * window() const
Gets the last window attached to a cc.
Definition Fl_Cairo.H:86
Fl_Cairo_State::gc
void gc(void *c)
Sets the gc c to keep track on.
Definition Fl_Cairo.H:87
Fl_Cairo_State::cc
cairo_t * cc() const
Gets the current cairo context.
Definition Fl_Cairo.H:66
Fl_Cairo_State::autolink
bool autolink() const
Gets the autolink option. See Fl::cairo_autolink_context(bool).
Definition Fl_Cairo.H:67