FLTK 1.3.4
Fl_Cairo_Window.H
1 //
2 // "$Id: Fl_Cairo_Window.H 8864 2011-07-19 04:49:30Z greg.ercolano $"
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() {
57  // manual method ? if yes explicitly get a cairo_context here
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: Fl_Cairo_Window.H 8864 2011-07-19 04:49:30Z greg.ercolano $" .
83 //
virtual void draw()
Draws the widget.
Definition: Fl_Window_shape.cxx:339
Fl static class.
The Fl_Double_Window provides a double-buffered window.
Definition: Fl_Double_Window.H:40
static bool cairo_autolink_context()
Gets the current autolink mode for cairo support.
Definition: Fl.H:1309
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
static cairo_t * cairo_make_current(Fl_Window *w)
Provides a corresponding cairo context for window wi.
Definition: Fl_Cairo.cxx:75
static cairo_t * cairo_cc()
Gets the current cairo context linked with a fltk window.
Definition: Fl.H:1311
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
This defines a pre-configured cairo fltk window.
Definition: Fl_Cairo_Window.H:48
void draw()
Overloaded to provide cairo callback support.
Definition: Fl_Cairo_Window.H:55