summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_File_Chooser.cxx272
-rw-r--r--src/Fl_File_Chooser.fl254
-rw-r--r--src/Fl_File_Chooser2.cxx950
-rw-r--r--src/makedepend39
4 files changed, 1073 insertions, 442 deletions
diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx
index 31fd1b70e..f4a57c84a 100644
--- a/src/Fl_File_Chooser.cxx
+++ b/src/Fl_File_Chooser.cxx
@@ -5,79 +5,66 @@
inline void Fl_File_Chooser::cb_window_i(Fl_Window*, void*) {
fileName->value(directory_);
fileList->deselect();
+Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
window->hide();
}
void Fl_File_Chooser::cb_window(Fl_Window* o, void* v) {
((Fl_File_Chooser*)(o->user_data()))->cb_window_i(o,v);
}
-inline void Fl_File_Chooser::cb_dirMenu_i(Fl_Choice*, void*) {
- char pathname[1024];
-int i;
-
-pathname[0] = '\0';
-for (i = 1; i <= dirMenu->value(); i ++)
- strcat(pathname, dirMenu->text(i));
-directory(pathname);
+inline void Fl_File_Chooser::cb_showChoice_i(Fl_Choice*, void*) {
+ showChoiceCB();
}
-void Fl_File_Chooser::cb_dirMenu(Fl_Choice* o, void* v) {
- ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_dirMenu_i(o,v);
+void Fl_File_Chooser::cb_showChoice(Fl_Choice* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->parent()->user_data()))->cb_showChoice_i(o,v);
}
-inline void Fl_File_Chooser::cb_upButton_i(Fl_Button*, void*) {
- up();
+inline void Fl_File_Chooser::cb_favoritesButton_i(Fl_Menu_Button*, void*) {
+ favoritesButtonCB();
}
-void Fl_File_Chooser::cb_upButton(Fl_Button* o, void* v) {
- ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_upButton_i(o,v);
+void Fl_File_Chooser::cb_favoritesButton(Fl_Menu_Button* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->parent()->user_data()))->cb_favoritesButton_i(o,v);
}
-#include <FL/Fl_Bitmap.H>
-static unsigned char idata_up[] =
-"\0\0x\0\204\0\2\1""1\376y\200\375\200""1\200""1\200""1\200""1\200""1\200\1\
-\200\1\200\377\377\0\0";
-static Fl_Bitmap image_up(idata_up, 16, 16);
-
inline void Fl_File_Chooser::cb_newButton_i(Fl_Button*, void*) {
newdir();
}
void Fl_File_Chooser::cb_newButton(Fl_Button* o, void* v) {
- ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_newButton_i(o,v);
+ ((Fl_File_Chooser*)(o->parent()->parent()->user_data()))->cb_newButton_i(o,v);
}
+#include <FL/Fl_Bitmap.H>
static unsigned char idata_new[] =
"\0\0x\0\204\0\2\1\1\376\1\200""1\200""1\200\375\200\375\200""1\200""1\200\1\
\200\1\200\377\377\0\0";
static Fl_Bitmap image_new(idata_new, 16, 16);
-inline void Fl_File_Chooser::cb__i(Fl_Button*, void*) {
- const char *f;
-if ((f = fl_input(filter_label,
- fileList->filter())) != NULL)
-{
- fileList->filter(f);
- rescan();
-};
+inline void Fl_File_Chooser::cb__i(Fl_Tile*, void*) {
+ update_preview();
}
-void Fl_File_Chooser::cb_(Fl_Button* o, void* v) {
+void Fl_File_Chooser::cb_(Fl_Tile* o, void* v) {
((Fl_File_Chooser*)(o->parent()->user_data()))->cb__i(o,v);
}
-static unsigned char idata_allfiles[] =
-"\374?\4 \4 \4 \204!\244%\304#\364/\364/\304#\244%\204!\4 \4 \4 \374?";
-static Fl_Bitmap image_allfiles(idata_allfiles, 16, 16);
-
inline void Fl_File_Chooser::cb_fileList_i(Fl_File_Browser*, void*) {
fileListCB();
}
void Fl_File_Chooser::cb_fileList(Fl_File_Browser* o, void* v) {
- ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_fileList_i(o,v);
+ ((Fl_File_Chooser*)(o->parent()->parent()->user_data()))->cb_fileList_i(o,v);
+}
+
+inline void Fl_File_Chooser::cb_previewButton_i(Fl_Check_Button*, void*) {
+ preview(previewButton->value());
+}
+void Fl_File_Chooser::cb_previewButton(Fl_Check_Button* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->parent()->parent()->user_data()))->cb_previewButton_i(o,v);
}
inline void Fl_File_Chooser::cb_fileName_i(Fl_File_Input*, void*) {
fileNameCB();
}
void Fl_File_Chooser::cb_fileName(Fl_File_Input* o, void* v) {
- ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_fileName_i(o,v);
+ ((Fl_File_Chooser*)(o->parent()->parent()->user_data()))->cb_fileName_i(o,v);
}
inline void Fl_File_Chooser::cb_okButton_i(Fl_Return_Button*, void*) {
@@ -88,82 +75,194 @@ if (callback_)
window->hide();
}
void Fl_File_Chooser::cb_okButton(Fl_Return_Button* o, void* v) {
- ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_okButton_i(o,v);
+ ((Fl_File_Chooser*)(o->parent()->parent()->parent()->user_data()))->cb_okButton_i(o,v);
}
inline void Fl_File_Chooser::cb_Cancel_i(Fl_Button*, void*) {
fileName->value(directory_);
fileList->deselect();
+Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
window->hide();
}
void Fl_File_Chooser::cb_Cancel(Fl_Button* o, void* v) {
- ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_Cancel_i(o,v);
+ ((Fl_File_Chooser*)(o->parent()->parent()->parent()->user_data()))->cb_Cancel_i(o,v);
+}
+
+inline void Fl_File_Chooser::cb_favList_i(Fl_File_Browser*, void*) {
+ favoritesCB(favList);
+}
+void Fl_File_Chooser::cb_favList(Fl_File_Browser* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_favList_i(o,v);
+}
+
+inline void Fl_File_Chooser::cb_favUpButton_i(Fl_Button*, void*) {
+ favoritesCB(favUpButton);
+}
+void Fl_File_Chooser::cb_favUpButton(Fl_Button* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_favUpButton_i(o,v);
+}
+
+inline void Fl_File_Chooser::cb_favDeleteButton_i(Fl_Button*, void*) {
+ favoritesCB(favDeleteButton);
+}
+void Fl_File_Chooser::cb_favDeleteButton(Fl_Button* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_favDeleteButton_i(o,v);
+}
+
+inline void Fl_File_Chooser::cb_favDownButton_i(Fl_Button*, void*) {
+ favoritesCB(favDownButton);
+}
+void Fl_File_Chooser::cb_favDownButton(Fl_Button* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_favDownButton_i(o,v);
+}
+
+inline void Fl_File_Chooser::cb_favCancelButton_i(Fl_Button*, void*) {
+ favWindow->hide();
+}
+void Fl_File_Chooser::cb_favCancelButton(Fl_Button* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_favCancelButton_i(o,v);
+}
+
+inline void Fl_File_Chooser::cb_favOkButton_i(Fl_Return_Button*, void*) {
+ favoritesCB(favOkButton);
+}
+void Fl_File_Chooser::cb_favOkButton(Fl_Return_Button* o, void* v) {
+ ((Fl_File_Chooser*)(o->parent()->user_data()))->cb_favOkButton_i(o,v);
}
Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char *title) {
Fl_Window* w;
- { Fl_Window* o = window = new Fl_Window(375, 325, "Pick a File");
+ { Fl_Window* o = window = new Fl_Window(490, 380, "Choose File");
w = o;
o->callback((Fl_Callback*)cb_window, (void*)(this));
- { Fl_Choice* o = dirMenu = new Fl_Choice(95, 10, 180, 25, "Directory:");
- o->tooltip("Choose a parent directory.");
- o->down_box(FL_BORDER_BOX);
- o->callback((Fl_Callback*)cb_dirMenu);
- dirMenu->label(directory_label);
+ { Fl_Group* o = new Fl_Group(65, 10, 415, 25);
+ { Fl_Choice* o = showChoice = new Fl_Choice(65, 10, 215, 25, "Show:");
+ o->down_box(FL_BORDER_BOX);
+ o->callback((Fl_Callback*)cb_showChoice);
+ Fl_Group::current()->resizable(o);
+ showChoice->label(show_label);
+ }
+ { Fl_Menu_Button* o = favoritesButton = new Fl_Menu_Button(290, 10, 155, 25, "Favorites");
+ o->down_box(FL_BORDER_BOX);
+ o->callback((Fl_Callback*)cb_favoritesButton);
+ o->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
+ favoritesButton->label(favorites_label);
+ }
+ { Fl_Button* o = newButton = new Fl_Button(455, 10, 25, 25);
+ o->tooltip("Create a new directory.");
+ o->image(image_new);
+ o->labelsize(8);
+ o->callback((Fl_Callback*)cb_newButton);
+ }
+ o->end();
}
- { Fl_Button* o = upButton = new Fl_Button(280, 10, 25, 25);
- o->tooltip("Show the parent directory.");
- o->image(image_up);
- o->labelsize(8);
- o->callback((Fl_Callback*)cb_upButton);
- }
- { Fl_Button* o = newButton = new Fl_Button(310, 10, 25, 25);
- o->tooltip("Create a new directory.");
- o->image(image_new);
- o->labelsize(8);
- o->callback((Fl_Callback*)cb_newButton);
- }
- { Fl_Button* o = new Fl_Button(340, 10, 25, 25);
- o->tooltip("Change the filename filter.");
- o->image(image_allfiles);
- o->labelsize(28);
- o->labelcolor(4);
+ { Fl_Tile* o = new Fl_Tile(10, 45, 470, 225);
o->callback((Fl_Callback*)cb_);
- o->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
+ { Fl_File_Browser* o = fileList = new Fl_File_Browser(10, 45, 295, 225);
+ o->type(2);
+ o->callback((Fl_Callback*)cb_fileList);
+ w->hotspot(o);
+ }
+ { Fl_Box* o = previewBox = new Fl_Box(305, 45, 175, 225, "?");
+ o->box(FL_DOWN_BOX);
+ o->labelsize(100);
+ o->align(FL_ALIGN_CLIP|FL_ALIGN_INSIDE);
+ }
+ o->end();
+ Fl_Group::current()->resizable(o);
}
- { Fl_File_Browser* o = fileList = new Fl_File_Browser(10, 45, 355, 180);
+ { Fl_Group* o = new Fl_Group(0, 275, 480, 95);
+ { Fl_Group* o = new Fl_Group(10, 275, 470, 20);
+ { Fl_Check_Button* o = previewButton = new Fl_Check_Button(405, 275, 75, 20, "Preview");
+ o->down_box(FL_DOWN_BOX);
+ o->value(1);
+ o->shortcut(0x80070);
+ o->callback((Fl_Callback*)cb_previewButton);
+ previewButton->label(preview_label);
+ }
+ { Fl_Box* o = new Fl_Box(10, 275, 395, 20);
+ Fl_Group::current()->resizable(o);
+ }
+ o->end();
+ }
+ { Fl_File_Input* o = fileName = new Fl_File_Input(85, 300, 395, 35);
+ o->callback((Fl_Callback*)cb_fileName);
+ o->when(FL_WHEN_ENTER_KEY);
+ Fl_Group::current()->resizable(o);
+ fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);
+ }
+ { Fl_Box* o = new Fl_Box(0, 310, 85, 25, "Filename:");
+ o->align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);
+ o->label(filename_label);
+ }
+ { Fl_Group* o = new Fl_Group(10, 345, 470, 25);
+ { Fl_Return_Button* o = okButton = new Fl_Return_Button(320, 345, 75, 25, "OK");
+ o->callback((Fl_Callback*)cb_okButton);
+ okButton->label(fl_ok);
+ }
+ { Fl_Button* o = new Fl_Button(405, 345, 75, 25, "Cancel");
+ o->callback((Fl_Callback*)cb_Cancel);
+ o->label(fl_cancel);
+ }
+ { Fl_Box* o = new Fl_Box(10, 345, 300, 25);
+ Fl_Group::current()->resizable(o);
+ }
+ o->end();
+ }
+ o->end();
+ }
+ if (title) window->label(title);
+ o->set_modal();
+ o->end();
+ }
+ { Fl_Window* o = favWindow = new Fl_Window(355, 150, "Manage Favorites");
+ w = o;
+ o->user_data((void*)(this));
+ { Fl_File_Browser* o = favList = new Fl_File_Browser(10, 10, 300, 95);
o->type(2);
- o->callback((Fl_Callback*)cb_fileList);
- Fl_Group::current()->resizable(o);
- w->hotspot(o);
+ o->callback((Fl_Callback*)cb_favList);
}
- { Fl_File_Input* o = fileName = new Fl_File_Input(10, 245, 355, 35, "Filename:");
- o->callback((Fl_Callback*)cb_fileName);
- o->align(FL_ALIGN_TOP_LEFT);
- o->when(FL_WHEN_ENTER_KEY);
- fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);
- fileName->label(filename_label);
+ { Fl_Button* o = favUpButton = new Fl_Button(320, 10, 25, 25, "@8>");
+ o->callback((Fl_Callback*)cb_favUpButton);
}
- { Fl_Return_Button* o = okButton = new Fl_Return_Button(200, 290, 75, 25, "OK");
- o->callback((Fl_Callback*)cb_okButton);
- okButton->label(fl_ok);
+ { Fl_Button* o = favDeleteButton = new Fl_Button(320, 45, 25, 25, "X");
+ o->labelfont(1);
+ o->callback((Fl_Callback*)cb_favDeleteButton);
}
- { Fl_Button* o = new Fl_Button(285, 290, 80, 25, "Cancel");
- o->callback((Fl_Callback*)cb_Cancel);
- o->label(fl_cancel);
+ { Fl_Button* o = favDownButton = new Fl_Button(320, 80, 25, 25, "@2>");
+ o->callback((Fl_Callback*)cb_favDownButton);
}
- if (title) window->label(title);
+ { Fl_Button* o = favCancelButton = new Fl_Button(270, 115, 75, 25, "Cancel");
+ o->callback((Fl_Callback*)cb_favCancelButton);
+ favCancelButton->label(fl_cancel);
+ }
+ { Fl_Return_Button* o = favOkButton = new Fl_Return_Button(185, 115, 75, 25, "OK");
+ o->callback((Fl_Callback*)cb_favOkButton);
+ favOkButton->label(fl_ok);
+ }
+ favWindow->label(manage_favorites_label);
o->set_modal();
o->end();
}
- fileList->filter(p);
-type(t);
-value(d);
-callback_ = 0;
+ callback_ = 0;
data_ = 0;
+window->size_range(window->w(), window->h(), Fl::w(), Fl::h());
+filter(p);
+update_favorites();
+value(d);
+type(t);
+int e;
+prefs_.get("preview", e, 1);
+preview(e);
+}
+
+Fl_File_Chooser::~Fl_File_Chooser() {
+ Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
+delete window;
+delete favWindow;
}
-void Fl_File_Chooser::callback(void (*cb)(Fl_File_Chooser *, void *), void *d) {
+void Fl_File_Chooser::callback(void (*cb)(Fl_File_Chooser *, void *), void *d ) {
callback_ = cb;
data_ = d;
}
@@ -180,11 +279,6 @@ char * Fl_File_Chooser::directory() {
return directory_;
}
-void Fl_File_Chooser::filter(const char *p) {
- fileList->filter(p);
-rescan();
-}
-
const char * Fl_File_Chooser::filter() {
return (fileList->filter());
}
diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl
index a219cdfec..cc8d0fa6c 100644
--- a/src/Fl_File_Chooser.fl
+++ b/src/Fl_File_Chooser.fl
@@ -6,98 +6,183 @@ class Fl_File_Chooser {open
} {
decl {enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };} {public
}
+ decl {static Fl_Preferences prefs_;} {}
+ decl {void (*callback_)(Fl_File_Chooser*, void *);} {}
+ decl {void *data_;} {}
+ decl {char directory_[1024];} {}
+ decl {char pattern_[1024];} {}
+ decl {char preview_text_[2048];} {}
+ decl {int type_;} {}
+ decl {void favoritesButtonCB();} {}
+ decl {void favoritesCB(Fl_Widget *w);} {}
+ decl {void fileListCB();} {}
+ decl {void fileNameCB();} {}
+ decl {void newdir();} {}
+ decl {static void previewCB(Fl_File_Chooser *fc);} {}
+ decl {void showChoiceCB();} {}
+ decl {void update_favorites();} {}
+ decl {void update_preview();} {}
Function {Fl_File_Chooser(const char *d, const char *p, int t, const char *title)} {open
} {
Fl_Window window {
- label {Pick a File}
+ label {Choose File}
callback {fileName->value(directory_);
fileList->deselect();
-window->hide();} open selected
- private xywh {99 225 375 325} resizable
+Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
+window->hide();} open
+ private xywh {153 80 490 380} resizable
code0 {if (title) window->label(title);}
code1 {\#include <stdio.h>}
code2 {\#include <stdlib.h>}
code3 {\#include <string.h>} modal visible
} {
- Fl_Choice dirMenu {
- label {Directory:}
- callback {char pathname[1024];
-int i;
-
-pathname[0] = '\\0';
-for (i = 1; i <= dirMenu->value(); i ++)
- strcat(pathname, dirMenu->text(i));
-directory(pathname);} open
- private tooltip {Choose a parent directory.} xywh {95 10 180 25} down_box BORDER_BOX
- code0 {dirMenu->label(directory_label);}
- } {}
- Fl_Button upButton {
- callback {up();}
- private tooltip {Show the parent directory.} image {up.xbm} xywh {280 10 25 25} labelsize 8
- }
- Fl_Button newButton {
- callback {newdir();}
- private tooltip {Create a new directory.} image {new.xbm} xywh {310 10 25 25} labelsize 8
- }
- Fl_Button {} {
- callback {const char *f;
-if ((f = fl_input(filter_label,
- fileList->filter())) != NULL)
-{
- fileList->filter(f);
- rescan();
-}}
- private tooltip {Change the filename filter.} image {allfiles.xbm} xywh {340 10 25 25} labelsize 28 labelcolor 4 align 16
- code0 {\#include <FL/fl_ask.H>}
- }
- Fl_Browser fileList {
- callback {fileListCB();}
- private xywh {10 45 355 180} type Hold resizable hotspot
- code0 {\#include <FL/Fl_File_Browser.H>}
- class Fl_File_Browser
+ Fl_Group {} {open
+ private xywh {65 10 415 25}
+ } {
+ Fl_Choice showChoice {
+ label {Show:}
+ callback {showChoiceCB();} open
+ private xywh {65 10 215 25} down_box BORDER_BOX resizable
+ code0 {showChoice->label(show_label);}
+ } {}
+ Fl_Menu_Button favoritesButton {
+ label Favorites
+ callback {favoritesButtonCB();} open
+ private xywh {290 10 155 25} down_box BORDER_BOX align 20
+ code0 {favoritesButton->label(favorites_label);}
+ } {}
+ Fl_Button newButton {
+ callback {newdir();}
+ private tooltip {Create a new directory.} image {new.xbm} xywh {455 10 25 25} labelsize 8
+ code0 {\#include <FL/Fl_Preferences.H>}
+ }
}
- Fl_File_Input fileName {
- label {Filename:}
- callback {fileNameCB();}
- private xywh {10 245 355 35} align 5 when 8
- code0 {fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);}
- code1 {fileName->label(filename_label);}
+ Fl_Tile {} {
+ callback {update_preview();} open
+ private xywh {10 45 470 225} resizable
+ } {
+ Fl_File_Browser fileList {
+ callback {fileListCB();}
+ private xywh {10 45 295 225} type Hold hotspot
+ code0 {\#include <FL/Fl_File_Browser.H>}
+ }
+ Fl_Box previewBox {
+ label {?}
+ private xywh {305 45 175 225} box DOWN_BOX labelsize 100 align 80
+ }
}
- Fl_Return_Button okButton {
- label OK
- callback {// Do any callback that is registered...
+ Fl_Group {} {open
+ private xywh {0 275 480 95}
+ } {
+ Fl_Group {} {open
+ private xywh {10 275 470 20}
+ } {
+ Fl_Check_Button previewButton {
+ label Preview
+ callback {preview(previewButton->value());}
+ private xywh {405 275 75 20} down_box DOWN_BOX shortcut 0x80070 value 1
+ code0 {previewButton->label(preview_label);}
+ }
+ Fl_Box {} {
+ private xywh {10 275 395 20} resizable
+ }
+ }
+ Fl_File_Input fileName {
+ callback {fileNameCB();}
+ private xywh {85 300 395 35} when 8 resizable
+ code0 {fileName->when(FL_WHEN_CHANGED | FL_WHEN_ENTER_KEY_ALWAYS);}
+ }
+ Fl_Box {} {
+ label {Filename:}
+ private xywh {0 310 85 25} align 24
+ code0 {o->label(filename_label);}
+ }
+ Fl_Group {} {open
+ private xywh {10 345 470 25}
+ } {
+ Fl_Return_Button okButton {
+ label OK
+ callback {// Do any callback that is registered...
if (callback_)
(*callback_)(this, data_);
window->hide();}
- private xywh {200 290 75 25}
- code0 {\#include <FL/fl_ask.H>}
- code1 {okButton->label(fl_ok);}
- }
- Fl_Button {} {
- label Cancel
- callback {fileName->value(directory_);
+ private xywh {320 345 75 25}
+ code0 {\#include <FL/fl_ask.H>}
+ code1 {okButton->label(fl_ok);}
+ }
+ Fl_Button {} {
+ label Cancel
+ callback {fileName->value(directory_);
fileList->deselect();
+Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
window->hide();}
- private xywh {285 290 80 25}
- code0 {o->label(fl_cancel);}
+ private xywh {405 345 75 25}
+ code0 {o->label(fl_cancel);}
+ }
+ Fl_Box {} {
+ private xywh {10 345 300 25} resizable
+ }
+ }
}
}
- code {fileList->filter(p);
-type(t);
+ Fl_Window favWindow {
+ label {Manage Favorites} open
+ private xywh {580 44 355 150}
+ code0 {favWindow->label(manage_favorites_label);} modal visible
+ } {
+ Fl_File_Browser favList {
+ callback {favoritesCB(favList);}
+ private xywh {10 10 300 95} type Hold
+ }
+ Fl_Button favUpButton {
+ label {@8>}
+ callback {favoritesCB(favUpButton);}
+ private xywh {320 10 25 25}
+ }
+ Fl_Button favDeleteButton {
+ label X
+ callback {favoritesCB(favDeleteButton);}
+ private xywh {320 45 25 25} labelfont 1
+ }
+ Fl_Button favDownButton {
+ label {@2>}
+ callback {favoritesCB(favDownButton);}
+ private xywh {320 80 25 25}
+ }
+ Fl_Button favCancelButton {
+ label Cancel
+ callback {favWindow->hide();}
+ private xywh {270 115 75 25}
+ code0 {favCancelButton->label(fl_cancel);}
+ }
+ Fl_Return_Button favOkButton {
+ label OK
+ callback {favoritesCB(favOkButton);}
+ private xywh {185 115 75 25}
+ code0 {\#include <FL/fl_ask.H>}
+ code1 {favOkButton->label(fl_ok);}
+ }
+ }
+ code {callback_ = 0;
+data_ = 0;
+window->size_range(window->w(), window->h(), Fl::w(), Fl::h());
+filter(p);
+update_favorites();
value(d);
-callback_ = 0;
-data_ = 0;} {}
+type(t);
+int e;
+prefs_.get("preview", e, 1);
+preview(e);} {selected
+ }
}
- decl {void (*callback_)(Fl_File_Chooser*, void *);} {}
- decl {void *data_;} {}
- decl {char directory_[1024];} {}
- decl {int type_;} {}
- decl {void fileListCB();} {}
- decl {void fileNameCB();} {}
- decl {void newdir();} {}
- decl {void up();} {}
- Function {callback(void (*cb)(Fl_File_Chooser *, void *), void *d)} {return_type void
+ Function {~Fl_File_Chooser()} {open
+ } {
+ code {Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
+delete window;
+delete favWindow;} {}
+ }
+ Function {callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0)} {return_type void
} {
code {callback_ = cb;
data_ = d;} {}
@@ -117,10 +202,7 @@ data_ = d;} {}
} {
code {return directory_;} {}
}
- Function {filter(const char *p)} {return_type void
- } {
- code {fileList->filter(p);
-rescan();} {}
+ decl {void filter(const char *p);} {public
}
Function {filter()} {return_type {const char *}
} {
@@ -146,9 +228,13 @@ rescan();} {}
} {
code {return (window->label());} {}
}
+ decl {void preview(int e);} {public
+ }
+ decl {int preview() const { return previewButton->value(); }} {public
+ }
decl {void rescan();} {public
}
- Function {show()} {open return_type void
+ Function {show()} {return_type void
} {
code {window->hotspot(fileList);
window->show();
@@ -210,11 +296,25 @@ else
} {
code {return window->visible();} {}
}
- decl {static const char *directory_label;} {public
+ decl {static const char *add_favorites_label;} {public
+ }
+ decl {static const char *all_files_label;} {public
+ }
+ decl {static const char *existing_file_label;} {public
+ }
+ decl {static const char *favorites_label;} {public
}
decl {static const char *filename_label;} {public
}
- decl {static const char *filter_label;} {public
+ decl {static const char *filesystems_label;} {public
+ }
+ decl {static const char *manage_favorites_label;} {public
+ }
+ decl {static const char *new_directory_label;} {public
+ }
+ decl {static const char *preview_label;} {public
+ }
+ decl {static const char *show_label;} {public
}
decl {static Fl_File_Sort_F *sort;} {public
}
diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx
index 488898c6c..10e56c960 100644
--- a/src/Fl_File_Chooser2.cxx
+++ b/src/Fl_File_Chooser2.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.14 2002/06/06 21:26:12 easysw Exp $"
+// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.15 2002/06/07 15:06:32 easysw Exp $"
//
// More Fl_File_Chooser routines.
//
@@ -24,15 +24,19 @@
//
// Contents:
//
-// Fl_File_Chooser::directory() - Set the directory in the file chooser.
-// Fl_File_Chooser::count() - Return the number of selected files.
-// Fl_File_Chooser::value() - Return a selected filename.
-// Fl_File_Chooser::up() - Go up one directory.
-// Fl_File_Chooser::newdir() - Make a new directory.
-// Fl_File_Chooser::rescan() - Rescan the current directory.
-// Fl_File_Chooser::fileListCB() - Handle clicks (and double-clicks) in the
-// FileBrowser.
-// Fl_File_Chooser::fileNameCB() - Handle text entry in the FileBrowser.
+// Fl_File_Chooser::count() - Return the number of selected files.
+// Fl_File_Chooser::directory() - Set the directory in the file chooser.
+// Fl_File_Chooser::filter() - Set the filter(s) for the chooser.
+// Fl_File_Chooser::newdir() - Make a new directory.
+// Fl_File_Chooser::value() - Return a selected filename.
+// Fl_File_Chooser::rescan() - Rescan the current directory.
+// Fl_File_Chooser::favoritesButtonCB() - Handle favorites selections.
+// Fl_File_Chooser::fileListCB() - Handle clicks (and double-clicks)
+// in the Fl_File_Browser.
+// Fl_File_Chooser::fileNameCB() - Handle text entry in the FileBrowser.
+// Fl_File_Chooser::showChoiceCB() - Handle show selections.
+// quote_pathname() - Quote a pathname for a menu.
+// unquote_pathname() - Unquote a pathname from a menu.
//
//
@@ -43,11 +47,11 @@
#include <FL/filename.H>
#include <FL/fl_ask.H>
#include <FL/x.H>
+#include <FL/Fl_Shared_Image.H>
#include <stdio.h>
#include <stdlib.h>
#include "flstring.h"
-#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -62,95 +66,34 @@
//
-// File chooser label strings...
+// File chooser label strings and sort function...
//
-const char *Fl_File_Chooser::directory_label = "Directory:";
+Fl_Preferences Fl_File_Chooser::prefs_(Fl_Preferences::USER, "fltk.org", "filechooser");
+
+const char *Fl_File_Chooser::add_favorites_label = "Add to Favorites";
+const char *Fl_File_Chooser::all_files_label = "All Files (*)";
+const char *Fl_File_Chooser::existing_file_label = "Please choose an existing file!";
+const char *Fl_File_Chooser::favorites_label = "Favorites";
const char *Fl_File_Chooser::filename_label = "Filename:";
-const char *Fl_File_Chooser::filter_label = "New Filter?";
+#ifdef WIN32
+const char *Fl_File_Chooser::filesystems_label = "My Computer";
+#else
+const char *Fl_File_Chooser::filesystems_label = "File Systems";
+#endif // WIN32
+const char *Fl_File_Chooser::manage_favorites_label = "Manage Favorites";
+const char *Fl_File_Chooser::new_directory_label = "New Directory?";
+const char *Fl_File_Chooser::preview_label = "Preview";
+const char *Fl_File_Chooser::show_label = "Show:";
Fl_File_Sort_F *Fl_File_Chooser::sort = fl_numericsort;
//
-// 'Fl_File_Chooser::directory()' - Set the directory in the file chooser.
+// Local functions...
//
-void
-Fl_File_Chooser::directory(const char *d)// I - Directory to change to
-{
- char pathname[1024], // Full path of directory
- *pathptr, // Pointer into full path
- *dirptr; // Pointer into directory
- int levels; // Number of levels in directory
-
-
-// printf("Fl_File_Chooser::directory(\"%s\")\n", d == NULL ? "(null)" : d);
-
- // NULL == current directory
- if (d == NULL)
- d = ".";
-
- if (d[0] != '\0')
- {
- // Make the directory absolute...
-#if (defined(WIN32) && ! defined(__CYGWIN__))|| defined(__EMX__)
- if (d[0] != '/' && d[0] != '\\' && d[1] != ':')
-#else
- if (d[0] != '/' && d[0] != '\\')
-#endif /* WIN32 || __EMX__ */
- fl_filename_absolute(directory_, d);
- else
- strlcpy(directory_, d, sizeof(directory_));
-
- // Strip any trailing slash and/or period...
- dirptr = directory_ + strlen(directory_) - 1;
- if (*dirptr == '.')
- *dirptr-- = '\0';
- if ((*dirptr == '/' || *dirptr == '\\') && dirptr > directory_)
- *dirptr = '\0';
- }
- else
- directory_[0] = '\0';
-
- // Clear the directory menu and fill it as needed...
- dirMenu->clear();
-#if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__)
- dirMenu->add("My Computer");
-#else
- dirMenu->add("File Systems");
-#endif /* WIN32 || __EMX__ */
-
- levels = 0;
- for (dirptr = directory_, pathptr = pathname; *dirptr != '\0';)
- {
- if (*dirptr == '/' || *dirptr == '\\')
- {
- // Need to quote the slash first, and then add it to the menu...
- *pathptr++ = '\\';
- *pathptr++ = '/';
- *pathptr++ = '\0';
- dirptr ++;
-
- dirMenu->add(pathname);
- levels ++;
- pathptr = pathname;
- }
- else
- *pathptr++ = *dirptr++;
- }
-
- if (pathptr > pathname)
- {
- *pathptr = '\0';
- dirMenu->add(pathname);
- levels ++;
- }
-
- dirMenu->value(levels);
-
- // Rescan the directory...
- rescan();
-}
+static void quote_pathname(char *, const char *, int);
+static void unquote_pathname(char *, const char *, int);
//
@@ -196,230 +139,222 @@ Fl_File_Chooser::count()
//
-// 'Fl_File_Chooser::value()' - Return a selected filename.
+// 'Fl_File_Chooser::directory()' - Set the directory in the file chooser.
//
-const char * // O - Filename or NULL
-Fl_File_Chooser::value(int f) // I - File number
+void
+Fl_File_Chooser::directory(const char *d)// I - Directory to change to
{
- int i; // Looping var
- int count; // Number of selected files
- const char *name; // Current filename
- static char pathname[1024]; // Filename + directory
+ char *dirptr; // Pointer into directory
- if (!(type_ & MULTI))
- {
- name = fileName->value();
- if (name[0] == '\0') return NULL;
- else if (fl_filename_isdir(name)) {
- if (type_ & DIRECTORY) return name;
- else return NULL;
- } else return name;
- }
+// printf("Fl_File_Chooser::directory(\"%s\")\n", d == NULL ? "(null)" : d);
- for (i = 1, count = 0; i <= fileList->size(); i ++)
- if (fileList->selected(i))
- {
- // See if this file is a directory...
- name = fileList->text(i);
+ // NULL == current directory
+ if (d == NULL)
+ d = ".";
- if (directory_[0]) {
- snprintf(pathname, sizeof(pathname), "%s/%s", directory_, name);
- } else {
- strlcpy(pathname, name, sizeof(pathname));
- }
+ if (d[0] != '\0')
+ {
+ // Make the directory absolute...
+#if (defined(WIN32) && ! defined(__CYGWIN__))|| defined(__EMX__)
+ if (d[0] != '/' && d[0] != '\\' && d[1] != ':')
+#else
+ if (d[0] != '/' && d[0] != '\\')
+#endif /* WIN32 || __EMX__ */
+ fl_filename_absolute(directory_, d);
+ else
+ strlcpy(directory_, d, sizeof(directory_));
- if (!fl_filename_isdir(pathname))
- {
- // Nope, see if this this is "the one"...
- count ++;
- if (count == f)
- return ((const char *)pathname);
- }
- }
+ // Strip any trailing slash and/or period...
+ dirptr = directory_ + strlen(directory_) - 1;
+ if (*dirptr == '.')
+ *dirptr-- = '\0';
+ if ((*dirptr == '/' || *dirptr == '\\') && dirptr > directory_)
+ *dirptr = '\0';
+ }
+ else
+ directory_[0] = '\0';
- return (NULL);
+ // Rescan the directory...
+ rescan();
}
//
-// 'Fl_File_Chooser::value()' - Set the current filename.
+// 'Fl_File_Chooser::favoritesButtonCB()' - Handle favorites selections.
//
void
-Fl_File_Chooser::value(const char *filename) // I - Filename + directory
+Fl_File_Chooser::favoritesButtonCB()
{
- int i, // Looping var
- count; // Number of items in list
- char *slash; // Directory separator
- char pathname[1024]; // Local copy of filename
+ int value; // Current selection
+ char pathname[1024], // Pathname
+ menuname[2048]; // Menu name
-// printf("Fl_File_Chooser::value(\"%s\")\n", filename == NULL ? "(null)" : filename);
+ value = favoritesButton->value();
- // See if the filename is the "My System" directory...
- if (filename == NULL || !filename[0]) {
- // Yes, just change the current directory...
- directory(filename);
- fileName->value("");
- okButton->deactivate();
- return;
- }
+ if (!value) {
+ // Add current directory to favorites...
+ if (getenv("HOME")) value = favoritesButton->size() - 5;
+ else value = favoritesButton->size() - 4;
- // Switch to single-selection mode as needed
- if (type_ & MULTI)
- type(SINGLE);
+ sprintf(menuname, "favorite%02d", value);
- // See if there is a directory in there...
- fl_filename_absolute(pathname, sizeof(pathname), filename);
+ prefs_.set(menuname, directory_);
- if ((slash = strrchr(pathname, '/')) == NULL)
- slash = strrchr(pathname, '\\');
+ quote_pathname(menuname, directory_, sizeof(menuname));
+ favoritesButton->add(menuname);
- if (slash != NULL)
- {
- // Yes, change the display to the directory...
- *slash++ = '\0';
+ if (favoritesButton->size() > 104) {
+ ((Fl_Menu_Item *)favoritesButton->menu())[0].deactivate();
+ }
+ } else if (value == 1) {
+ // Manage favorites...
+ favoritesCB(0);
+ } else if (value == 2) {
+ // Filesystems/My Computer
+ directory("");
+ } else {
+ unquote_pathname(pathname, favoritesButton->text(value), sizeof(pathname));
directory(pathname);
}
- else
- {
- directory(".");
- slash = pathname;
- }
+}
- // Set the input field to the absolute path...
- if (slash > pathname) slash[-1] = '/';
- fileName->value(pathname);
- fileName->position(0, strlen(pathname));
- okButton->activate();
+//
+// 'Fl_File_Chooser::favoritesCB()' - Handle favorites dialog.
+//
- // Then find the file in the file list and select it...
- count = fileList->size();
+void
+Fl_File_Chooser::favoritesCB(Fl_Widget *w)
+ // I - Widget
+{
+ int i; // Looping var
+ char name[32], // Preference name
+ pathname[1024]; // Directory in list
- fileList->deselect(0);
- fileList->redraw();
- for (i = 1; i <= count; i ++)
-#if defined(WIN32) || defined(__EMX__)
- if (strcasecmp(fileList->text(i), slash) == 0) {
-#else
- if (strcmp(fileList->text(i), slash) == 0) {
-#endif // WIN32 || __EMX__
-// printf("Selecting line %d...\n", i);
- fileList->topline(i);
- fileList->select(i);
- break;
+ if (!w) {
+ // Load the favorites list...
+ favList->clear();
+ favList->deselect();
+
+ for (i = 0; i < 100; i ++) {
+ // Get favorite directory 0 to 99...
+ sprintf(name, "favorite%02d", i);
+
+ prefs_.get(name, pathname, "", sizeof(pathname));
+
+ // Stop on the first empty favorite...
+ if (!pathname[0]) break;
+
+ // Add the favorite to the list...
+ favList->add(pathname,
+ Fl_File_Icon::find(pathname, Fl_File_Icon::DIRECTORY));
}
-}
+ favUpButton->deactivate();
+ favDeleteButton->deactivate();
+ favDownButton->deactivate();
+ favOkButton->deactivate();
+
+ favWindow->hotspot(favList);
+ favWindow->show();
+ } else if (w == favList) {
+ i = favList->value();
+ if (i) {
+ if (i > 1) favUpButton->activate();
+ else favUpButton->deactivate();
+
+ favDeleteButton->activate();
+
+ if (i < favList->size()) favDownButton->activate();
+ else favDownButton->deactivate();
+ } else {
+ favUpButton->deactivate();
+ favDeleteButton->deactivate();
+ favDownButton->deactivate();
+ }
+ } else if (w == favUpButton) {
+ i = favList->value();
-//
-// 'Fl_File_Chooser::up()' - Go up one directory.
-//
+ favList->insert(i - 1, favList->text(i), favList->data(i));
+ favList->remove(i + 1);
+ favList->select(i - 1);
-void
-Fl_File_Chooser::up()
-{
- char *slash; // Trailing slash
+ if (i == 2) favUpButton->deactivate();
+ favDownButton->activate();
- if ((slash = strrchr(directory_, '/')) == NULL)
- slash = strrchr(directory_, '\\');
+ favOkButton->activate();
+ } else if (w == favDeleteButton) {
+ i = favList->value();
- if (directory_[0] != '\0')
- dirMenu->value(dirMenu->value() - 1);
+ favList->remove(i);
- if (slash != NULL)
- *slash = '\0';
- else
- {
- upButton->deactivate();
- directory_[0] = '\0';
- }
+ if (i > favList->size()) i --;
+ favList->select(i);
- rescan();
-}
+ if (i < favList->size()) favDownButton->activate();
+ else favDownButton->deactivate();
+ if (i > 1) favUpButton->activate();
+ else favUpButton->deactivate();
-//
-// 'Fl_File_Chooser::newdir()' - Make a new directory.
-//
+ if (!i) favDeleteButton->deactivate();
-void
-Fl_File_Chooser::newdir()
-{
- const char *dir; // New directory name
- char pathname[1024]; // Full path of directory
+ favOkButton->activate();
+ } else if (w == favDownButton) {
+ i = favList->value();
+ favList->insert(i + 2, favList->text(i), favList->data(i));
+ favList->remove(i);
+ favList->select(i + 1);
- // Get a directory name from the user
- if ((dir = fl_input("New Directory?", NULL)) == NULL)
- return;
+ if ((i + 1) == favList->size()) favDownButton->deactivate();
- // Make it relative to the current directory as needed...
-#if (defined(WIN32) && ! defined (__CYGWIN__)) || defined(__EMX__)
- if (dir[0] != '/' && dir[0] != '\\' && dir[1] != ':')
-#else
- if (dir[0] != '/' && dir[0] != '\\')
-#endif /* WIN32 || __EMX__ */
- snprintf(pathname, sizeof(pathname), "%s/%s", directory_, dir);
- else
- strlcpy(pathname, dir, sizeof(pathname));
+ favUpButton->activate();
- // Create the directory; ignore EEXIST errors...
-#if defined(WIN32) && ! defined (__CYGWIN__)
- if (mkdir(pathname))
-#else
- if (mkdir(pathname, 0777))
-#endif /* WIN32 */
- if (errno != EEXIST)
- {
- fl_alert("Unable to create directory!");
- return;
+ favOkButton->activate();
+ } else if (w == favOkButton) {
+ // Copy the new list over...
+ for (i = 0; i < favList->size(); i ++) {
+ // Set favorite directory 0 to 99...
+ sprintf(name, "favorite%02d", i);
+
+ prefs_.set(name, favList->text(i + 1));
}
- // Show the new directory...
- directory(pathname);
-}
+ // Clear old entries as necessary...
+ for (; i < 100; i ++) {
+ // Clear favorite directory 0 to 99...
+ sprintf(name, "favorite%02d", i);
+ prefs_.get(name, pathname, "", sizeof(pathname));
-//
-// 'Fl_File_Chooser::rescan()' - Rescan the current directory.
-//
-
-void
-Fl_File_Chooser::rescan()
-{
- char pathname[1024]; // New pathname for filename field
+ if (pathname[0]) prefs_.set(name, "");
+ else break;
+ }
-// printf("Fl_File_Chooser::rescan(); directory = \"%s\"\n", directory_);
+ update_favorites();
- // Clear the current filename
- strlcpy(pathname, directory_, sizeof(pathname));
- if (pathname[strlen(pathname) - 1] != '/') {
- strlcat(pathname, "/", sizeof(pathname));
+ favWindow->hide();
}
- fileName->value(pathname);
- okButton->deactivate();
-
- // Build the file list...
- fileList->load(directory_, sort);
}
//
// 'Fl_File_Chooser::fileListCB()' - Handle clicks (and double-clicks) in the
-// FileBrowser.
+// Fl_File_Browser.
//
void
Fl_File_Chooser::fileListCB()
{
- char *filename, // New filename
- pathname[1024]; // Full pathname to file
+ char *filename, // New filename
+ pathname[1024]; // Full pathname to file
filename = (char *)fileList->text(fileList->value());
@@ -440,16 +375,12 @@ Fl_File_Chooser::fileListCB()
if (fl_filename_isdir(pathname))
#endif /* WIN32 || __EMX__ */
{
+ // Change directories...
directory(pathname);
- upButton->activate();
}
else
{
- // Do any callback that is registered...
- if (callback_)
- (*callback_)(this, data_);
-
- // Hide the window...
+ // Hide the window - picked the file...
window->hide();
}
}
@@ -461,6 +392,14 @@ Fl_File_Chooser::fileListCB()
fileName->value(pathname);
+ // Update the preview box...
+ Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this);
+ Fl::add_timeout(1.0, (Fl_Timeout_Handler)previewCB, this);
+
+ // Do any callback that is registered...
+ if (callback_) (*callback_)(this, data_);
+
+ // Activate the OK button as needed...
if (!fl_filename_isdir(pathname) || (type_ & DIRECTORY))
okButton->activate();
}
@@ -537,9 +476,11 @@ Fl_File_Chooser::fileNameCB()
if (type_ & MULTI)
type(SINGLE);
+ // Update the preview box...
+ update_preview();
+
// Do any callback that is registered...
- if (callback_)
- (*callback_)(this, data_);
+ if (callback_) (*callback_)(this, data_);
// Hide the window to signal things are done...
window->hide();
@@ -547,7 +488,7 @@ Fl_File_Chooser::fileNameCB()
else
{
// File doesn't exist, so beep at and alert the user...
- fl_alert("Please choose an existing file!");
+ fl_alert(existing_file_label);
}
}
else if (Fl::event_key() != FL_Delete &&
@@ -675,5 +616,492 @@ Fl_File_Chooser::fileNameCB()
//
-// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.14 2002/06/06 21:26:12 easysw Exp $".
+// 'Fl_File_Chooser::filter()' - Set the filter(s) for the chooser.
+//
+
+void
+Fl_File_Chooser::filter(const char *p) // I - Pattern(s)
+{
+ char *copyp, // Copy of pattern
+ *start, // Start of pattern
+ *end; // End of pattern
+ int allfiles; // Do we have a "*" pattern?
+
+
+ // Make sure we have a pattern...
+ if (!p || !*p) p = "*";
+
+ // Copy the pattern string...
+ copyp = strdup(p);
+
+ // Separate the pattern string as necessary...
+ showChoice->clear();
+ showChoice->add("bla");
+ showChoice->clear();
+
+ for (start = copyp, allfiles = 0; start && *start; start = end) {
+ end = strchr(start, '\t');
+ if (end) *end++ = '\0';
+
+ if (strcmp(start, "*") == 0) {
+ showChoice->add(all_files_label);
+ allfiles = 1;
+ } else {
+ showChoice->add(start);
+ if (strstr(start, "(*)") != NULL) allfiles = 1;
+ }
+ }
+
+ free(copyp);
+
+ if (!allfiles) showChoice->add(all_files_label);
+
+ showChoice->value(0);
+ showChoiceCB();
+}
+
+
+//
+// 'Fl_File_Chooser::newdir()' - Make a new directory.
+//
+
+void
+Fl_File_Chooser::newdir()
+{
+ const char *dir; // New directory name
+ char pathname[1024]; // Full path of directory
+
+
+ // Get a directory name from the user
+ if ((dir = fl_input(new_directory_label, NULL)) == NULL)
+ return;
+
+ // Make it relative to the current directory as needed...
+#if (defined(WIN32) && ! defined (__CYGWIN__)) || defined(__EMX__)
+ if (dir[0] != '/' && dir[0] != '\\' && dir[1] != ':')
+#else
+ if (dir[0] != '/' && dir[0] != '\\')
+#endif /* WIN32 || __EMX__ */
+ snprintf(pathname, sizeof(pathname), "%s/%s", directory_, dir);
+ else
+ strlcpy(pathname, dir, sizeof(pathname));
+
+ // Create the directory; ignore EEXIST errors...
+#if defined(WIN32) && ! defined (__CYGWIN__)
+ if (mkdir(pathname))
+#else
+ if (mkdir(pathname, 0777))
+#endif /* WIN32 */
+ if (errno != EEXIST)
+ {
+ fl_alert("%s", strerror(errno));
+ return;
+ }
+
+ // Show the new directory...
+ directory(pathname);
+}
+
+
+//
+// 'Fl_File_Chooser::preview()' - Enable or disable the preview tile.
+//
+
+void
+Fl_File_Chooser::preview(int e)// I - 1 = enable preview, 0 = disable preview
+{
+ previewButton->value(e);
+ prefs_.set("preview", e);
+
+ if (e) {
+ int w = previewBox->h() * 2 / 3;
+ fileList->resize(fileList->x(), fileList->y(),
+ window->w() - 20 - w, fileList->h());
+ previewBox->resize(window->w() - 10 - w, previewBox->y(),
+ w, previewBox->h());
+
+ update_preview();
+ } else {
+ fileList->resize(fileList->x(), fileList->y(),
+ window->w() - 20, fileList->h());
+ previewBox->resize(window->w() - 10, previewBox->y(),
+ 0, previewBox->h());
+ }
+
+ fileList->parent()->redraw();
+}
+
+
+//
+// 'Fl_File_Chooser::previewCB()' - Timeout handler for the preview box.
+//
+
+void
+Fl_File_Chooser::previewCB(Fl_File_Chooser *fc) { // I - File chooser
+ fc->update_preview();
+}
+
+
+//
+// 'Fl_File_Chooser::rescan()' - Rescan the current directory.
+//
+
+void
+Fl_File_Chooser::rescan()
+{
+ char pathname[1024]; // New pathname for filename field
+
+ // Clear the current filename
+ strlcpy(pathname, directory_, sizeof(pathname));
+ if (pathname[strlen(pathname) - 1] != '/') {
+ strlcat(pathname, "/", sizeof(pathname));
+ }
+ fileName->value(pathname);
+ okButton->deactivate();
+
+ // Build the file list...
+ fileList->load(directory_, sort);
+
+ // Update the preview box...
+ update_preview();
+}
+
+
+//
+// 'Fl_File_Chooser::showChoiceCB()' - Handle show selections.
+//
+
+void
+Fl_File_Chooser::showChoiceCB()
+{
+ const char *item, // Selected item
+ *patstart; // Start of pattern
+ char *patend; // End of pattern
+
+
+ item = showChoice->text(showChoice->value());
+
+ if ((patstart = strchr(item, '(')) == NULL) {
+ strlcpy(pattern_, item, sizeof(pattern_));
+ } else {
+ strlcpy(pattern_, patstart + 1, sizeof(pattern_));
+ if ((patend = strrchr(pattern_, ')')) != NULL) *patend = '\0';
+ }
+
+ fileList->filter(pattern_);
+ rescan();
+}
+
+
+//
+// 'Fl_File_Chooser::update_favorites()' - Update the favorites menu.
+//
+
+void
+Fl_File_Chooser::update_favorites()
+{
+ int i; // Looping var
+ char pathname[1024], // Pathname
+ menuname[2048]; // Menu name
+ const char *home; // Home directory
+
+
+ favoritesButton->clear();
+ favoritesButton->add("bla");
+ favoritesButton->clear();
+ favoritesButton->add(add_favorites_label, FL_ALT + 'a', 0);
+ favoritesButton->add(manage_favorites_label, FL_ALT + 'm', 0, 0, FL_MENU_DIVIDER);
+ favoritesButton->add(filesystems_label, FL_ALT + 'f', 0);
+
+ if ((home = getenv("HOME")) != NULL) {
+ quote_pathname(menuname, home, sizeof(menuname));
+ favoritesButton->add(menuname, FL_ALT + 'h', 0);
+ }
+
+ for (i = 0; i < 100; i ++) {
+ sprintf(menuname, "favorite%02d", i);
+ prefs_.get(menuname, pathname, "", sizeof(pathname));
+ if (!pathname[0]) break;
+
+ quote_pathname(menuname, pathname, sizeof(menuname));
+
+ if (i < 10) favoritesButton->add(menuname, FL_ALT + '0' + i, 0);
+ else favoritesButton->add(menuname);
+ }
+
+ if (i == 100) ((Fl_Menu_Item *)favoritesButton->menu())[0].deactivate();
+}
+
+
+//
+// 'Fl_File_Chooser::update_preview()' - Update the preview box...
+//
+
+void
+Fl_File_Chooser::update_preview()
+{
+ const char *filename; // Current filename
+ Fl_Shared_Image *image, // New image
+ *oldimage; // Old image
+ int pbw, pbh; // Width and height of preview box
+ int w, h; // Width and height of preview image
+
+
+ if (!previewButton->value()) return;
+
+ if ((filename = value()) == NULL) image = NULL;
+ else {
+ window->cursor(FL_CURSOR_WAIT);
+ Fl::check();
+
+ image = Fl_Shared_Image::get(filename);
+
+ if (image) {
+ window->cursor(FL_CURSOR_DEFAULT);
+ Fl::check();
+ }
+ }
+
+ oldimage = (Fl_Shared_Image *)previewBox->image();
+
+ if (oldimage) while (oldimage->refcount()) oldimage->release();
+
+ previewBox->image(0);
+
+ if (!image) {
+ FILE *fp;
+ int bytes;
+ char *ptr;
+
+ if (filename) fp = fopen(filename, "rb");
+ else fp = NULL;
+
+ if (fp != NULL) {
+ // Try reading the first 1k of data for a label...
+ bytes = fread(preview_text_, 1, sizeof(preview_text_) - 1, fp);
+ preview_text_[bytes] = '\0';
+ fclose(fp);
+ } else {
+ // Assume we can't read any data...
+ preview_text_[0] = '\0';
+ }
+
+ window->cursor(FL_CURSOR_DEFAULT);
+ Fl::check();
+
+ // Scan the buffer for printable chars...
+ for (ptr = preview_text_; *ptr && (isprint(*ptr) || isspace(*ptr)); ptr ++);
+
+ if (*ptr || ptr == preview_text_) {
+ // Non-printable file, just show a big ?...
+ previewBox->label(filename ? "?" : 0);
+ previewBox->align(FL_ALIGN_CLIP);
+ previewBox->labelsize(100);
+ previewBox->labelfont(FL_HELVETICA);
+ } else {
+ // Show the first 1k of text...
+ int size = previewBox->h() / 20;
+ if (size < 6) size = 6;
+ else if (size > 14) size = 14;
+
+ previewBox->label(preview_text_);
+ previewBox->align((Fl_Align)(FL_ALIGN_CLIP | FL_ALIGN_INSIDE |
+ FL_ALIGN_LEFT | FL_ALIGN_TOP));
+ previewBox->labelsize(size);
+ previewBox->labelfont(FL_COURIER);
+ }
+ } else {
+ pbw = previewBox->w() - 20;
+ pbh = previewBox->h() - 20;
+
+ if (image->w() > pbw || image->h() > pbh) {
+ w = pbw;
+ h = w * image->h() / image->w();
+
+ if (h > pbh) {
+ h = pbh;
+ w = h * image->w() / image->h();
+ }
+
+ oldimage = (Fl_Shared_Image *)image->copy(w, h);
+ previewBox->image((Fl_Image *)oldimage);
+
+ image->release();
+ } else {
+ previewBox->image((Fl_Image *)image);
+ }
+
+ previewBox->align(FL_ALIGN_CLIP);
+ previewBox->label(0);
+ }
+
+ previewBox->redraw();
+}
+
+
+//
+// 'Fl_File_Chooser::value()' - Return a selected filename.
+//
+
+const char * // O - Filename or NULL
+Fl_File_Chooser::value(int f) // I - File number
+{
+ int i; // Looping var
+ int count; // Number of selected files
+ const char *name; // Current filename
+ static char pathname[1024]; // Filename + directory
+
+
+ if (!(type_ & MULTI))
+ {
+ name = fileName->value();
+ if (name[0] == '\0') return NULL;
+ else if (fl_filename_isdir(name)) {
+ if (type_ & DIRECTORY) return name;
+ else return NULL;
+ } else return name;
+ }
+
+ for (i = 1, count = 0; i <= fileList->size(); i ++)
+ if (fileList->selected(i))
+ {
+ // See if this file is a directory...
+ name = fileList->text(i);
+
+ if (directory_[0]) {
+ snprintf(pathname, sizeof(pathname), "%s/%s", directory_, name);
+ } else {
+ strlcpy(pathname, name, sizeof(pathname));
+ }
+
+ if (!fl_filename_isdir(pathname))
+ {
+ // Nope, see if this this is "the one"...
+ count ++;
+ if (count == f)
+ return ((const char *)pathname);
+ }
+ }
+
+ return (NULL);
+}
+
+
+//
+// 'Fl_File_Chooser::value()' - Set the current filename.
+//
+
+void
+Fl_File_Chooser::value(const char *filename) // I - Filename + directory
+{
+ int i, // Looping var
+ count; // Number of items in list
+ char *slash; // Directory separator
+ char pathname[1024]; // Local copy of filename
+
+
+// printf("Fl_File_Chooser::value(\"%s\")\n", filename == NULL ? "(null)" : filename);
+
+ // See if the filename is the "My System" directory...
+ if (filename == NULL || !filename[0]) {
+ // Yes, just change the current directory...
+ directory(filename);
+ fileName->value("");
+ okButton->deactivate();
+ return;
+ }
+
+ // Switch to single-selection mode as needed
+ if (type_ & MULTI)
+ type(SINGLE);
+
+ // See if there is a directory in there...
+ fl_filename_absolute(pathname, sizeof(pathname), filename);
+
+ if ((slash = strrchr(pathname, '/')) == NULL)
+ slash = strrchr(pathname, '\\');
+
+ if (slash != NULL)
+ {
+ // Yes, change the display to the directory...
+ *slash++ = '\0';
+ directory(pathname);
+ }
+ else
+ {
+ directory(".");
+ slash = pathname;
+ }
+
+ // Set the input field to the absolute path...
+ if (slash > pathname) slash[-1] = '/';
+
+ fileName->value(pathname);
+ fileName->position(0, strlen(pathname));
+ okButton->activate();
+
+ // Then find the file in the file list and select it...
+ count = fileList->size();
+
+ fileList->deselect(0);
+ fileList->redraw();
+
+ for (i = 1; i <= count; i ++)
+#if defined(WIN32) || defined(__EMX__)
+ if (strcasecmp(fileList->text(i), slash) == 0) {
+#else
+ if (strcmp(fileList->text(i), slash) == 0) {
+#endif // WIN32 || __EMX__
+// printf("Selecting line %d...\n", i);
+ fileList->topline(i);
+ fileList->select(i);
+ break;
+ }
+}
+
+
+//
+// 'quote_pathname()' - Quote a pathname for a menu.
+//
+
+static void
+quote_pathname(char *dst, // O - Destination string
+ const char *src, // I - Source string
+ int dstsize) // I - Size of destination string
+{
+ dstsize --;
+
+ while (*src && dstsize > 1) {
+ if (*src == '/')
+ *dst++ = '\\';
+
+ *dst++ = *src++;
+ }
+
+ *dst = '\0';
+}
+
+
+//
+// 'unquote_pathname()' - Unquote a pathname from a menu.
+//
+
+static void
+unquote_pathname(char *dst, // O - Destination string
+ const char *src, // I - Source string
+ int dstsize) // I - Size of destination string
+{
+ dstsize --;
+
+ while (*src && dstsize > 1) {
+ if (*src == '\\') src ++;
+ *dst++ = *src++;
+ }
+
+ *dst = '\0';
+}
+
+
+//
+// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.15 2002/06/07 15:06:32 easysw Exp $".
//
diff --git a/src/makedepend b/src/makedepend
index dfa611993..9bb8e90f9 100644
--- a/src/makedepend
+++ b/src/makedepend
@@ -72,27 +72,34 @@ Fl_File_Browser.o: ../FL/Fl_File_Icon.H ../FL/Fl.H ../FL/filename.H
Fl_File_Browser.o: ../FL/fl_draw.H ../FL/filename.H flstring.h ../config.h
Fl_File_Chooser.o: ../FL/Fl_File_Chooser.H ../FL/Fl.H ../FL/Enumerations.H
Fl_File_Chooser.o: ../FL/Fl_Export.H ../FL/Fl_Window.H ../FL/Fl_Group.H
-Fl_File_Chooser.o: ../FL/Fl_Widget.H ../FL/Fl_Choice.H ../FL/Fl_Menu_.H
-Fl_File_Chooser.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Button.H ../FL/fl_ask.H
+Fl_File_Chooser.o: ../FL/Fl_Widget.H ../FL/Fl_Group.H ../FL/Fl_Choice.H
+Fl_File_Chooser.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H
+Fl_File_Chooser.o: ../FL/Fl_Menu_Button.H ../FL/Fl_Button.H
+Fl_File_Chooser.o: ../FL/Fl_Preferences.H ../FL/Fl_Tile.H
Fl_File_Chooser.o: ../FL/Fl_File_Browser.H ../FL/Fl_Browser.H
Fl_File_Chooser.o: ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H
Fl_File_Chooser.o: ../FL/Fl_Valuator.H ../FL/Fl_File_Icon.H ../FL/Fl.H
-Fl_File_Chooser.o: ../FL/filename.H ../FL/Fl_File_Input.H ../FL/Fl_Input.H
-Fl_File_Chooser.o: ../FL/Fl_Input_.H ../FL/Fl_Return_Button.H
-Fl_File_Chooser.o: ../FL/Fl_Button.H ../FL/Fl_Bitmap.H ../FL/Fl_Image.H
-Fl_File_Chooser.o: ../FL/x.H ../FL/Fl_Window.H
+Fl_File_Chooser.o: ../FL/filename.H ../FL/Fl_Box.H ../FL/Fl_Check_Button.H
+Fl_File_Chooser.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H
+Fl_File_Chooser.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
+Fl_File_Chooser.o: ../FL/Fl_Return_Button.H ../FL/fl_ask.H ../FL/Fl_Bitmap.H
+Fl_File_Chooser.o: ../FL/Fl_Image.H ../FL/x.H ../FL/Fl_Window.H
Fl_File_Chooser2.o: ../FL/Fl_File_Chooser.H ../FL/Fl.H ../FL/Enumerations.H
Fl_File_Chooser2.o: ../FL/Fl_Export.H ../FL/Fl_Window.H ../FL/Fl_Group.H
-Fl_File_Chooser2.o: ../FL/Fl_Widget.H ../FL/Fl_Choice.H ../FL/Fl_Menu_.H
-Fl_File_Chooser2.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Button.H ../FL/fl_ask.H
+Fl_File_Chooser2.o: ../FL/Fl_Widget.H ../FL/Fl_Group.H ../FL/Fl_Choice.H
+Fl_File_Chooser2.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H
+Fl_File_Chooser2.o: ../FL/Fl_Menu_Button.H ../FL/Fl_Button.H
+Fl_File_Chooser2.o: ../FL/Fl_Preferences.H ../FL/Fl_Tile.H
Fl_File_Chooser2.o: ../FL/Fl_File_Browser.H ../FL/Fl_Browser.H
Fl_File_Chooser2.o: ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H
Fl_File_Chooser2.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
Fl_File_Chooser2.o: ../FL/Fl_File_Icon.H ../FL/Fl.H ../FL/filename.H
+Fl_File_Chooser2.o: ../FL/Fl_Box.H ../FL/Fl_Check_Button.H
+Fl_File_Chooser2.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H
Fl_File_Chooser2.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
-Fl_File_Chooser2.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
-Fl_File_Chooser2.o: ../FL/filename.H ../FL/x.H ../FL/Fl_Window.H flstring.h
-Fl_File_Chooser2.o: ../config.h
+Fl_File_Chooser2.o: ../FL/Fl_Return_Button.H ../FL/fl_ask.H ../FL/filename.H
+Fl_File_Chooser2.o: ../FL/x.H ../FL/Fl_Window.H ../FL/Fl_Shared_Image.H
+Fl_File_Chooser2.o: ../FL/Fl_Image.H ../FL/x.H flstring.h ../config.h
Fl_File_Icon.o: flstring.h ../config.h ../FL/Fl_File_Icon.H ../FL/Fl.H
Fl_File_Icon.o: ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Widget.H
Fl_File_Icon.o: ../FL/fl_draw.H ../FL/filename.H
@@ -342,13 +349,15 @@ fl_engraved_label.o: ../FL/Fl_Widget.H ../FL/fl_draw.H
fl_file_dir.o: flstring.h ../config.h ../FL/filename.H
fl_file_dir.o: ../FL/Fl_File_Chooser.H ../FL/Fl.H ../FL/Enumerations.H
fl_file_dir.o: ../FL/Fl_Export.H ../FL/Fl_Window.H ../FL/Fl_Group.H
-fl_file_dir.o: ../FL/Fl_Widget.H ../FL/Fl_Choice.H ../FL/Fl_Menu_.H
-fl_file_dir.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Button.H ../FL/fl_ask.H
+fl_file_dir.o: ../FL/Fl_Widget.H ../FL/Fl_Group.H ../FL/Fl_Choice.H
+fl_file_dir.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H ../FL/Fl_Menu_Button.H
+fl_file_dir.o: ../FL/Fl_Button.H ../FL/Fl_Preferences.H ../FL/Fl_Tile.H
fl_file_dir.o: ../FL/Fl_File_Browser.H ../FL/Fl_Browser.H ../FL/Fl_Browser_.H
fl_file_dir.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
fl_file_dir.o: ../FL/Fl_File_Icon.H ../FL/Fl.H ../FL/filename.H
-fl_file_dir.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
-fl_file_dir.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
+fl_file_dir.o: ../FL/Fl_Box.H ../FL/Fl_Check_Button.H ../FL/Fl_Light_Button.H
+fl_file_dir.o: ../FL/Fl_Button.H ../FL/Fl_File_Input.H ../FL/Fl_Input.H
+fl_file_dir.o: ../FL/Fl_Input_.H ../FL/Fl_Return_Button.H ../FL/fl_ask.H
fl_font.o: flstring.h ../config.h ../FL/Fl.H ../FL/Enumerations.H
fl_font.o: ../FL/Fl_Export.H ../FL/fl_draw.H ../FL/x.H ../FL/Fl_Window.H
fl_font.o: Fl_Font.H fl_font_x.cxx