FLTK 1.3.0
Fl_Cairo_Window.H
00001 //
00002 // "$Id$"
00003 //
00004 // Main header file for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software. Distribution and use rights are outlined in
00009 // the file "COPYING" which should have been included with this file.  If this
00010 // file is missing or damaged, see the license at:
00011 //
00012 //     http://www.fltk.org/COPYING.php
00013 //
00014 // Please report all bugs and problems on the following page:
00015 //
00016 //     http://www.fltk.org/str.php
00017 //
00018 
00019 /* \file
00020     Fl_Cairo_Window Handling transparently a fltk window incorporte a cairo draw callback.
00021 */
00022 
00023 #ifndef FL_CAIRO_WINDOW_H
00024 # define FL_CAIRO_WINDOW_H
00025 # ifdef FLTK_HAVE_CAIRO
00026 
00027 // Cairo is currently supported for the following platforms:
00028 // Win32, Apple Quartz, X11
00029 #  include <FL/Fl.H>
00030 #  include <FL/Fl_Double_Window.H>
00031 
00048 class FL_EXPORT Fl_Cairo_Window : public Fl_Double_Window {
00049 
00050 public:
00051   Fl_Cairo_Window(int w, int h) : Fl_Double_Window(w,h),draw_cb_(0) {}
00052 
00053 protected:
00055   void draw() {
00056     Fl_Double_Window::draw();
00057     // manual method ? if yes explicitly get a cairo_context here
00058     if (!Fl::cairo_autolink_context()) 
00059       Fl::cairo_make_current(this); 
00060     if (draw_cb_) draw_cb_(this, Fl::cairo_cc());
00061   }
00062 
00063 public:
00065   typedef void (*cairo_draw_cb) (Fl_Cairo_Window* self, cairo_t* def);
00070   void set_draw_cb(cairo_draw_cb  cb){draw_cb_=cb;}
00071 private:
00072     cairo_draw_cb draw_cb_;
00073 };
00074 
00075 
00078 # endif // FLTK_HAVE_CAIRO
00079 #endif // FL_CAIRO_WINDOW_H
00080 
00081 //
00082 // End of "$Id$" .
00083 //