FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Cairo_Window.H
Go to the documentation of this file.
1//
2// Fl_Cairo_Window 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
21#ifndef FL_CAIRO_WINDOW_H
22# define FL_CAIRO_WINDOW_H
23
24#include <FL/fl_config.h>
25
26# ifdef FLTK_HAVE_CAIRO
27
28// Cairo is currently supported for the following platforms:
29// Win32, Apple Quartz, X11, Wayland
30
31# include <FL/Fl.H>
32# include <FL/Fl_Double_Window.H>
33
89class FL_EXPORT Fl_Cairo_Window : public Fl_Double_Window {
90
91public:
92 Fl_Cairo_Window(int W, int H, const char *L = 0)
93 : Fl_Double_Window(W, H, L), draw_cb_(0) {}
94 Fl_Cairo_Window(int X, int Y, int W, int H, const char *L = 0)
95 : Fl_Double_Window(X, Y, W, H, L), draw_cb_(0) {}
96
97protected:
101 if (draw_cb_) { // call the Cairo draw callback
102 // manual method ? if yes explicitly get a cairo_context here
105 draw_cb_(this, Fl::cairo_cc());
106 // flush Cairo drawings: necessary at least for Windows
108 }
109 }
110
111public:
113 typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def);
114
119 void set_draw_cb(cairo_draw_cb cb) { draw_cb_ = cb; }
120private:
121 cairo_draw_cb draw_cb_;
122};
123
124
127# endif // FLTK_HAVE_CAIRO
128#endif // FL_CAIRO_WINDOW_H
Fl static class.
This defines an FLTK window with Cairo support.
Definition Fl_Cairo_Window.H:89
void draw() FL_OVERRIDE
Overloaded to provide Cairo callback support.
Definition Fl_Cairo_Window.H:99
void set_draw_cb(cairo_draw_cb cb)
You must provide a draw callback that implements your Cairo rendering.
Definition Fl_Cairo_Window.H:119
The Fl_Double_Window provides a double-buffered window.
Definition Fl_Double_Window.H:31
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:926
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
static cairo_t * cairo_cc()
Gets the current Cairo context linked with a fltk window.
Definition Fl.H:1444
static bool cairo_autolink_context()
Gets the current autolink mode for Cairo support.
Definition Fl.H:1439
static cairo_t * cairo_make_current(Fl_Window *w)
Provides a Cairo context for window wi.
Definition Fl_Cairo.cxx:100
static void cairo_flush(cairo_t *c)
Flush Cairo drawings on Cairo context c.
Definition Fl.H:1489