Add missing Fl_Cairo_Window constructors (STR #3160).

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12993 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2018-07-27 09:05:12 +00:00
parent 1f5588c3dd
commit bf19362179
3 changed files with 20 additions and 13 deletions

View File

@ -102,6 +102,8 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2017
Other Improvements
- (add new items here)
- Fl_Cairo_Window constructors are now compatible with Fl_Double_Window
constructors - fixed missing constructors (STR #3160).
- The include file for platform specific functions and definitions
(FL/x.H) has been replaced with FL/platform.H. FL/x.H is deprecated
but still available for backwards compatibility (STR #3435).

View File

@ -3,7 +3,7 @@
//
// Main header file for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2010 by Bill Spitzak and others.
// Copyright 1998-2018 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@ -17,7 +17,7 @@
//
/* \file
Fl_Cairo_Window Handling transparently a fltk window incorporte a cairo draw callback.
Fl_Cairo_Window Handling transparently a FLTK window incorporating a cairo draw callback.
*/
#ifndef FL_CAIRO_WINDOW_H
@ -35,11 +35,13 @@
*/
/**
This defines a pre-configured cairo fltk window.
This defines a FLTK window with cairo support.
This class overloads the virtual draw() method for you,
so that the only thing you have to do is to provide your cairo code.
All cairo context handling is achieved transparently.
\note You can alternatively define your custom cairo fltk window,
\note You can alternatively define your custom cairo FLTK window,
and thus at least override the draw() method to provide custom cairo
support. In this case you will probably use Fl::cairo_make_current(Fl_Window*)
to attach a context to your window. You should do it only when your window is
@ -48,7 +50,10 @@
class FL_EXPORT Fl_Cairo_Window : public Fl_Double_Window {
public:
Fl_Cairo_Window(int w, int h) : Fl_Double_Window(w,h),draw_cb_(0) {}
Fl_Cairo_Window(int W, int H, const char *L = 0)
: Fl_Double_Window(W, H, L), draw_cb_(0) {}
Fl_Cairo_Window(int X, int Y, int W, int H, const char *L = 0)
: Fl_Double_Window(X, Y, W, H, L), draw_cb_(0) {}
protected:
/** Overloaded to provide cairo callback support */
@ -67,7 +72,7 @@ public:
You must provide a draw callback which will implement your cairo rendering.
This method will permit you to set your cairo callback to \p cb.
*/
void set_draw_cb(cairo_draw_cb cb){draw_cb_=cb;}
void set_draw_cb(cairo_draw_cb cb) { draw_cb_ = cb; }
private:
cairo_draw_cb draw_cb_;
};

View File

@ -138,14 +138,14 @@ int main(int argc, char** argv) {
#ifdef AUTOLINK
Fl::cairo_autolink_context(true);
#endif
Fl_Cairo_Window window(300,300);
window.resizable(&window);
window.color(FL_WHITE);
window.set_draw_cb(my_cairo_draw_cb);
window.show(argc,argv);
Fl_Cairo_Window window(300, 300, "FLTK loves Cairo");
return Fl::run();
window.resizable(&window);
window.color(FL_WHITE);
window.set_draw_cb(my_cairo_draw_cb);
window.show(argc,argv);
return Fl::run();
}
#else
#include <FL/fl_ask.H>