Author: manolo
Date: 2012-05-21 02:56:45 -0700 (Mon, 21 May 2012)
New Revision: 9540
Log:
Fixed FLTK1 compatibility with Fl_File_Chooser.
The callback of the internal fltk3::FileBrowser object gets called sending its
corresponding FLTK1 widget
as first argument. This callback is changed here to account for the true first
argument.
This restores the file_chooser test1 demo that crashed.
Modified:
branches/branch-3.0/include/FL/Fl_File_Chooser.H
branches/branch-3.0/include/fltk3/FileChooser.h
Modified: branches/branch-3.0/include/FL/Fl_File_Chooser.H
===================================================================
--- branches/branch-3.0/include/FL/Fl_File_Chooser.H 2012-05-20 17:14:48 UTC
(rev 9539)
+++ branches/branch-3.0/include/FL/Fl_File_Chooser.H 2012-05-21 09:56:45 UTC
(rev 9540)
@@ -59,16 +59,25 @@
Fl_Button *newButton;
Fl_Check_Button *previewButton;
+ static void browser_cb(Fl_Widget *w1, void *v) {
+ fltk3::FileBrowser* o = (fltk3::FileBrowser*)(w1->_p);
+ fltk3::FileChooser::cb_fileList(o,v);
+ }
+
public:
enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
+
Fl_File_Chooser(const char *d, const char *p, int t, const char *title)
: fltk3::FileChooser(d, p, t, title) {
fltk3::FileBrowser *b3 = fltk3::FileChooser::browser();
Fl_Widget *b1 = new Fl_File_Browser();
b3->wrapper(b1);
b1->_p = b3;
+ // when b3's callback will be called it will be sent b1 as 1st argument
+ // thus we change b3's callback accordingly
+ b3->callback((fltk3::Callback*)browser_cb);
}
Fl_Widget* add_extra(Fl_Widget* gr) {
Modified: branches/branch-3.0/include/fltk3/FileChooser.h
===================================================================
--- branches/branch-3.0/include/fltk3/FileChooser.h 2012-05-20 17:14:48 UTC
(rev 9539)
+++ branches/branch-3.0/include/fltk3/FileChooser.h 2012-05-21 09:56:45 UTC
(rev 9540)
@@ -47,9 +47,12 @@
#include <fltk3/ReturnButton.h>
#include <fltk3/ask.h>
+class Fl_File_Chooser;
+
namespace fltk3 {
class FLTK3_EXPORT FileChooser {
+ friend class ::Fl_File_Chooser;
public:
enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
private:
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit