2 // "$Id: Fl_Cairo_Window.H 8198 2011-01-06 10:24:58Z manolo $"
4 // Main header file for the Fast Light Tool Kit (FLTK).
6 // Copyright 1998-2010 by Bill Spitzak and others.
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // Please report all bugs and problems on the following page:
25 // http://www.fltk.org/str.php
29 Fl_Cairo_Window Handling transparently a fltk window incorporte a cairo draw callback.
32 #ifndef FL_CAIRO_WINDOW_H
33 # define FL_CAIRO_WINDOW_H
34 # ifdef FLTK_HAVE_CAIRO
36 // Cairo is currently supported for the following platforms:
37 // Win32, Apple Quartz, X11
39 # include <FL/Fl_Double_Window.H>
42 \addtogroup group_cairo
47 This defines a pre-configured cairo fltk window.
48 This class overloads the virtual draw() method for you,
49 so that the only thing you have to do is to provide your cairo code.
50 All cairo context handling is achieved transparently.
51 \note You can alternatively define your custom cairo fltk window,
52 and thus at least override the draw() method to provide custom cairo
53 support. In this case you will probably use Fl::cairo_make_current(Fl_Window*)
54 to attach a context to your window. You should do it only when your window is
55 the current window. \see Fl_Window::current()
57 class FL_EXPORT Fl_Cairo_Window : public Fl_Double_Window {
60 Fl_Cairo_Window(int w, int h) : Fl_Double_Window(w,h),draw_cb_(0) {}
63 /** Overloaded to provide cairo callback support */
65 Fl_Double_Window::draw();
66 // manual method ? if yes explicitly get a cairo_context here
67 if (draw_cb_) draw_cb_(this, Fl::cairo_cc());
71 /** This defines the cairo draw callback prototype that you must further */
72 typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def);
74 You must provide a draw callback which will implement your cairo rendering.
75 This method will permit you to set your cairo callback to \p cb.
77 void set_draw_cb(cairo_draw_cb cb){draw_cb_=cb;}
79 cairo_draw_cb draw_cb_;
85 # endif // FLTK_HAVE_CAIRO
86 #endif // FL_CAIRO_WINDOW_H
89 // End of "$Id: Fl_Cairo_Window.H 8198 2011-01-06 10:24:58Z manolo $" .