FLTK: Fl_Cairo_Window.H Source File

FLTK

Fl_Cairo_Window.H
1 //
2 // "$Id$"
3 //
4 // Main header file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 1998-2010 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18
19 /* \file
20 Fl_Cairo_Window Handling transparently a fltk window incorporte a cairo draw callback.
21 */
22
23 #ifndef FL_CAIRO_WINDOW_H
24 # define FL_CAIRO_WINDOW_H
25 # ifdef FLTK_HAVE_CAIRO
26
27 // Cairo is currently supported for the following platforms:
28 // Win32, Apple Quartz, X11
29 # include <FL/Fl.H>
30 # include <FL/Fl_Double_Window.H>
31
48 class FL_EXPORT Fl_Cairo_Window : public Fl_Double_Window {
49
50 public:
51 Fl_Cairo_Window(int w, int h) : Fl_Double_Window(w,h),draw_cb_(0) {}
52
53 protected:
55 void draw() {
56 Fl_Double_Window::draw();
57 // manual method ? if yes explicitly get a cairo_context here
58 if (!Fl::cairo_autolink_context())
59 Fl::cairo_make_current(this);
60 if (draw_cb_) draw_cb_(this, Fl::cairo_cc());
61 }
62
63 public:
65 typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def);
70 void set_draw_cb(cairo_draw_cb cb){draw_cb_=cb;}
71 private:
72 cairo_draw_cb draw_cb_;
73 };
74
75
78 # endif // FLTK_HAVE_CAIRO
79 #endif // FL_CAIRO_WINDOW_H
80
81 //
82 // End of "$Id$" .
83 //
Fl_Cairo_Window::set_draw_cb
void set_draw_cb(cairo_draw_cb cb)
You must provide a draw callback which will implement your cairo rendering.
Definition: Fl_Cairo_Window.H:70
Fl::cairo_autolink_context
static bool cairo_autolink_context()
Gets the current autolink mode for cairo support.
Definition: Fl.H:1311
Fl.H
Fl static class.
Fl::cairo_make_current
static cairo_t * cairo_make_current(Fl_Window *w)
Provides a corresponding cairo context for window wi.
Definition: Fl_Cairo.cxx:75
Fl_Cairo_Window::draw
void draw()
Overloaded to provide cairo callback support.
Definition: Fl_Cairo_Window.H:55
Fl::cairo_cc
static cairo_t * cairo_cc()
Gets the current cairo context linked with a fltk window.
Definition: Fl.H:1313
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:63
Fl_Cairo_Window
This defines a pre-configured cairo fltk window.
Definition: Fl_Cairo_Window.H:48
Fl_Double_Window
The Fl_Double_Window provides a double-buffered window.
Definition: Fl_Double_Window.H:40
Fl_Window::draw
virtual void draw()
Draws the widget.
Definition: Fl_Window_shape.cxx:340
- © 1998-2016 by Bill Spitzak and others.