FLTK 1.4.5: Fl_Cairo_Window.H Source File

FLTK 1.4.5

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
20
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
38
88*/
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:
98 /** Overloaded to provide Cairo callback support. */
99 void draw() FL_OVERRIDE {
100 Fl_Double_Window::draw();
101 if (draw_cb_) { // call the Cairo draw callback
102 // manual method ? if yes explicitly get a cairo_context here
103 if (!Fl::cairo_autolink_context())
104 Fl::cairo_make_current(this);
105 draw_cb_(this, Fl::cairo_cc());
106 // flush Cairo drawings: necessary at least for Windows
107 Fl::cairo_flush(Fl::cairo_cc());
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
126
127# endif // FLTK_HAVE_CAIRO
128#endif // FL_CAIRO_WINDOW_H
Fl.H
Fl static class.
Fl_Cairo_Window::cairo_draw_cb
void(* cairo_draw_cb)(Fl_Cairo_Window *self, cairo_t *def)
The Cairo draw callback prototype you need to implement.
Definition Fl_Cairo_Window.H:112
Fl_Cairo_Window::set_draw_cb
void set_draw_cb(cairo_draw_cb cb)
You must provide a draw callback that implements your Cairo rendering.
Definition Fl_Cairo_Window.H:118
Fl_Double_Window::Fl_Double_Window
Fl_Double_Window(int W, int H, const char *l=0)
Creates a new Fl_Double_Window widget using the given position, size, and label (title) string.
Definition Fl_Double_Window.cxx:31
Fl_Group::draw
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:943
Fl_Window::draw
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Window.cxx:494
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
Fl::cairo_cc
static cairo_t * cairo_cc()
Gets the current Cairo context linked with a fltk window.
Definition Fl.H:1470
Fl::cairo_make_current
static cairo_t * cairo_make_current(Fl_Window *w)
Provides a Cairo context for window wi.
Definition Fl_Cairo.cxx:100
Fl::cairo_flush
static void cairo_flush(cairo_t *c)
Flush Cairo drawings on Cairo context c.
Definition Fl.H:1515
Fl::cairo_autolink_context
static void cairo_autolink_context(bool alink)
When FLTK_HAVE_CAIRO is defined and cairo_autolink_context() is true, any current window dc is linked...
Definition Fl.H:1454