Author: fabien
Date: 2008-02-22 14:50:59 -0800 (Fri, 22 Feb 2008)
New Revision: 6040
Log:
+ Changed the modal event loop of file_chooser() and dir_chooser()
to use a new exec() method that delegates to Window::exec() internally.
This exec() method should handle unpleasant side effects with other modal
windows when closing the file_chooser dialog window.
+ Updated FileChooser.fl to reflect modifications made in the cxx/h files.
Please do not edit these files directly (except the include header)
Thanks.
Modified:
trunk/fltk/FileChooser.h
trunk/src/FileChooser.cxx
trunk/src/FileChooser.fl
trunk/src/file_chooser.cxx
Modified: trunk/fltk/FileChooser.h
===================================================================
--- trunk/fltk/FileChooser.h 2008-02-22 20:04:05 UTC (rev 6039)
+++ trunk/fltk/FileChooser.h 2008-02-22 22:50:59 UTC (rev 6040)
@@ -1,8 +1,8 @@
-// generated by Fast Light User Interface Designer (fluid) version 2.0100
+// generated by Fast Light User Interface Designer (fluid) version 2.1000
#ifndef FileChooser_h
#define FileChooser_h
-// Header for //\n// "$Id: FileChooser.fl 5067 2006-05-02 12:00...
+// Header for //\n// "$Id: FileChooser.fl 5447 2006-09-19 00:09...
#include <fltk/DoubleBufferWindow.h>
#include <stdio.h>
#include <stdlib.h>
@@ -20,7 +20,7 @@
#include <fltk/ReturnButton.h>
#include <fltk/ask.h>
-namespace fltk {
+namespace fltk {
class FL_API FileChooser {
public:
@@ -42,6 +42,7 @@
void showChoiceCB();
void update_favorites();
void update_preview();
+ int favorites_showing;
public:
FileChooser(const char *d, const char *p, int t, const char *title);
private:
@@ -51,7 +52,6 @@
fltk::Choice *showChoice;
inline void cb_showChoice_i(fltk::Choice*, void*);
static void cb_showChoice(fltk::Choice*, void*);
- int favorites_showing;
fltk::PopupMenu *favoritesButton;
inline void cb_favoritesButton_i(fltk::PopupMenu*, void*);
static void cb_favoritesButton(fltk::PopupMenu*, void*);
@@ -128,6 +128,7 @@
void rescan();
void show();
void show(int x, int y);
+ bool exec(Window* p, bool grab);
int shown();
void textcolor(Color c);
Color textcolor();
@@ -161,5 +162,5 @@
};
extern FL_API void file_chooser_ok_label(const char*l);
}
-// Header for //\n// End of "$Id: FileChooser.fl 5067 2006-05-0...
+// Header for //\n// End of "$Id: FileChooser.fl 5447 2006-09-1...
#endif
Modified: trunk/src/FileChooser.cxx
===================================================================
--- trunk/src/FileChooser.cxx 2008-02-22 20:04:05 UTC (rev 6039)
+++ trunk/src/FileChooser.cxx 2008-02-22 22:50:59 UTC (rev 6040)
@@ -1,7 +1,7 @@
-// generated by Fast Light User Interface Designer (fluid) version 2.0100
+// generated by Fast Light User Interface Designer (fluid) version 2.1000
-#include <fltk/FileChooser.h>
-// Code for //\n// "$Id: FileChooser.fl 5067 2006-05-02 12:00...
+#include "../fltk/FileChooser.h"
+// Code for //\n// "$Id: FileChooser.fl 5447 2006-09-19 00:09...
#include <fltk/draw.h>
#include <fltk/run.h>
#include <fltk/Cursor.h>
@@ -144,8 +144,10 @@
}
FileChooser::FileChooser(const char *d, const char *p, int t, const char
*title) {
+ fltk::DoubleBufferWindow* w;
{fltk::DoubleBufferWindow* o = window = new fltk::DoubleBufferWindow(490,
380, "Choose File");
o->type(241);
+ o->shortcut(0xff1b);
o->callback((fltk::Callback*)cb_window, (void*)(this));
o->begin();
{fltk::Group* o = new fltk::Group(65, 10, 415, 25);
@@ -153,6 +155,7 @@
{fltk::Choice* o = showChoice = new fltk::Choice(0, 0, 215, 25,
"Show:");
o->labelfont(fltk::HELVETICA_BOLD);
o->callback((fltk::Callback*)cb_showChoice);
+ fltk::Group::current()->resizable(o);
showChoice->label(show_label);
fltk::Group::current()->resizable(o);
}
@@ -174,11 +177,10 @@
o->callback((fltk::Callback*)cb_);
o->begin();
{fltk::FileBrowser* o = fileList = new fltk::FileBrowser(0, 0, 295,
225);
- o->type(0);
o->labelsize(14);
o->callback((fltk::Callback*)cb_fileList);
((fltk::Window*)(o->parent()->parent()))->hotspot(o);
- fileList->when(fltk::WHEN_CHANGED);
+ fileList->type(0);fileList->when(fltk::WHEN_CHANGED);
}
{fltk::InvisibleBox* o = previewBox = new fltk::InvisibleBox(295, 0,
175, 225, "?");
o->set_vertical();
@@ -242,13 +244,15 @@
o->set_modal();
}
{fltk::DoubleBufferWindow* o = favWindow = new
fltk::DoubleBufferWindow(355, 150, "Manage Favorites");
+ w = o;
o->type(241);
+ o->shortcut(0xff1b);
o->user_data((void*)(this));
o->begin();
{fltk::FileBrowser* o = favList = new fltk::FileBrowser(10, 10, 300, 95);
- o->type(0);
o->callback((fltk::Callback*)cb_favList);
o->when(fltk::WHEN_CHANGED);
+ o->type(0);
}
{fltk::Group* o = new fltk::Group(320, 10, 25, 95);
o->set_vertical();
@@ -287,6 +291,7 @@
o->end();
favWindow->label(manage_favorites_label);
favWindow->resizable(fileList);
+ o->shortcut(0xff1b);
o->set_modal();
o->resizable(o);
}
@@ -365,7 +370,7 @@
int w=0, h=0;
okButton->measure_label(w, h);
w+=70;
- okButton->resize(cancelButton->x() - w , cancelButton->y(),w-10 , 25);
+ okButton->resize(cancelButton->x()- w, cancelButton->y(),w-10, 25);
okButton->parent()->init_sizes();
}
@@ -384,8 +389,8 @@
}
void FileChooser::show(int x, int y) {
+ window->show();
window->resize(x, y,window->w(),window->h());
- window->show();
fltk::flush();
fltk::cursor(fltk::CURSOR_WAIT);
rescan();
@@ -393,6 +398,10 @@
fileName->take_focus();
}
+bool FileChooser::exec(Window* p, bool grab) {
+ return window->exec(p, grab);
+}
+
int FileChooser::shown() {
return window->shown();
}
@@ -423,7 +432,7 @@
void FileChooser::type(int t) {
type_ = t;
- if (t & FileChooser::MULTI)
+ if (t & MULTI)
fileList->type(Browser::MULTI);
else
fileList->type(Browser::NORMAL);
@@ -454,13 +463,12 @@
}
void FileChooser::favorites(int e) {
- favorites_showing = e;
- update_favorites();
+ favorites_showing = e;
+ update_favorites();
}
int FileChooser::favorites() const {
- return favorites_showing;
+ return favorites_showing;
}
-
FL_API void file_chooser_ok_label(const char*l);
-// Code for //\n// End of "$Id: FileChooser.fl 5067 2006-05-0...
+// Code for //\n// End of "$Id: FileChooser.fl 5447 2006-09-1...
Modified: trunk/src/FileChooser.fl
===================================================================
--- trunk/src/FileChooser.fl 2008-02-22 20:04:05 UTC (rev 6039)
+++ trunk/src/FileChooser.fl 2008-02-22 22:50:59 UTC (rev 6040)
@@ -61,6 +61,7 @@
decl {void showChoiceCB();} {}
decl {void update_favorites();} {}
decl {void update_preview();} {}
+ decl {int favorites_showing;} {}
Function {FileChooser(const char *d, const char *p, int t, const char
*title)} {open
} {
{fltk::Window} window {
@@ -88,7 +89,8 @@
label Favorites
callback {favoritesButtonCB();} open
private xywh {225 0 155 25} align 48
- extra_code {favoritesButton->label(favorites_label);}
+ extra_code {favoritesButton->label(favorites_label);
+favorites_showing = 1;}
} {}
{fltk::Button} newButton {
callback {newdir();}
@@ -107,7 +109,7 @@
callback {fileListCB();}
private xywh {0 0 295 225} type Single hotspot labelsize 14
extra_code {\#include <fltk/FileBrowser.h>
- fileList->when(fltk::WHEN_CHANGED);}
+ fileList->type(0);fileList->when(fltk::WHEN_CHANGED);}
}
{fltk::InvisibleBox} previewBox {
label {?}
@@ -177,13 +179,14 @@
label {Manage Favorites} open
private xywh {440 69 355 150} type Double resizable
extra_code {favWindow->label(manage_favorites_label);
-favWindow->resizable(fileList);} modal visible
+favWindow->resizable(fileList);
+o->shortcut(0xff1b);} modal visible
} {
{fltk::FileBrowser} favList {
callback {favoritesCB(favList);}
private xywh {10 10 300 95} type Single when CHANGED
- }
- {fltk::Group} {} {open
+ extra_code {o->type(0);}
+ } {fltk::Group} {} {open
xywh {320 10 25 95}
extra_code {o->resizable(0);}
} {
@@ -303,8 +306,8 @@
code {okButton->label(l);
int w=0, h=0;
okButton->measure_label(w, h);
-okButton->resize(cancelButton->x() - 50 - w, cancelButton->y(),
- w + 40, 25);
+w+=70;
+okButton->resize(cancelButton->x()- w, cancelButton->y(),w-10, 25);
okButton->parent()->init_sizes();} {}
}
Function {ok_label()} {return_type {const char *}
@@ -337,6 +340,10 @@
fltk::cursor(fltk::CURSOR_DEFAULT);
fileName->take_focus();} {}
}
+ Function {exec(Window* p, bool grab)} {return_type bool
+ } {
+ code {return window->exec(p, grab);} {}
+ }
Function {shown()} {open return_type int
} {
code {return window->shown();} {}
@@ -401,6 +408,15 @@
} {
code {return window->visible();} {}
}
+ Function {favorites(int e)} {return_type void
+ } {
+ code {favorites_showing = e;
+update_favorites();} {}
+ }
+ Function {favorites() const} {return_type int
+ } {
+ code {return favorites_showing;} {}
+ }
decl {static const char *add_favorites_label;} {public
}
decl {static const char *all_files_label;} {public
Modified: trunk/src/file_chooser.cxx
===================================================================
--- trunk/src/file_chooser.cxx 2008-02-22 20:04:05 UTC (rev 6039)
+++ trunk/src/file_chooser.cxx 2008-02-22 22:50:59 UTC (rev 6040)
@@ -69,22 +69,22 @@
if (!fc) {
if (!fname || !*fname) fname = ".";
-
+
fc = new FileChooser(fname, pat, FileChooser::CREATE, message);
fc->callback(callback, 0);
}
- fc->type(FileChooser::CREATE);
- fc->filter(pat);
- fc->label(message);
-
- if (!fname || !*fname) {
- if (fc->filter() != pat && (!pat || !fc->filter() ||
- strcmp(pat, fc->filter())) && fc->value()) {
- // if pattern is different, remove name but leave old directory:
- strlcpy(retname, fc->value(), sizeof(retname));
-
+ fc->type(FileChooser::CREATE);
+ fc->filter(pat);
+ fc->label(message);
+
+ if (!fname || !*fname) {
+ if (fc->filter() != pat && (!pat || !fc->filter() ||
+ strcmp(pat, fc->filter())) && fc->value()) {
+ // if pattern is different, remove name but leave old directory:
+ strlcpy(retname, fc->value(), sizeof(retname));
+
char *p = strrchr(retname, '/');
-
+
if (p) {
// If the filename is "/foo", then the directory will be "/", not
// ""...
@@ -93,27 +93,28 @@
else
*p = '\0';
}
-
+
// Set the directory...
fc->directory(retname);
- }
- fc->show();
- fc->value(fname);
}
- else {
- fc->ok_label(current_label);
- fc->show();
- fc->value(fname);
- }
-
- while (fc->visible()) fltk::wait();
-
+ fc->show();
+ fc->value(fname);
+ }
+ else {
+ fc->ok_label(current_label);
+ fc->show();
+ fc->value(fname);
+ }
+
+ //while (fc->visible()) fltk::wait();
+ fc->exec(0, true);
+
if (fc->value() && relative) {
- fltk::filename_relative(retname, sizeof(retname), fc->value());
-
+ fltk::filename_relative(retname, sizeof(retname), fc->value());
+
return retname;
} else if (fc->value()) {
- fltk::filename_absolute(retname, sizeof(retname), fc->value());
+ fltk::filename_absolute(retname, sizeof(retname), fc->value());
return retname;
}
else return 0;
@@ -146,7 +147,8 @@
fc->show();
- while (fc->visible()) fltk::wait();
+ // while (fc->visible()) fltk::wait();
+ fc->exec(0, true);
if (fc->value() && relative) {
fltk::filename_relative(retname, sizeof(retname), fc->value());
@@ -250,7 +252,7 @@
fc->text(fname);
fc->label(message);
}
- fc->exec();
+ fc->exec(0,true);
return fc->text();
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit