summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--FL/Fl_File_Chooser.H89
-rw-r--r--FL/mac.H16
-rw-r--r--FL/win32.H8
-rw-r--r--documentation/Fl_File_Chooser.html104
-rw-r--r--documentation/Fl_File_Chooser.jpgbin0 -> 30831 bytes
-rw-r--r--documentation/filechooser.gifbin20189 -> 0 bytes
-rw-r--r--fluid/Fluid_Image.cxx6
-rw-r--r--fluid/fluid.cxx10
-rw-r--r--fluid/makedepend30
-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
-rw-r--r--test/file_chooser.cxx290
-rw-r--r--test/makedepend61
16 files changed, 1552 insertions, 578 deletions
diff --git a/CHANGES b/CHANGES
index 96e6c3826..d678b32af 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,7 @@
CHANGES IN FLTK 1.1.0rc3
- Documentation updates.
+ - New file chooser from design contest.
- Did some testing with Valgrind and fixed some memory
problems in Fl_Help_View::Fl_HelpView,
Fl_Menu_::remove(), Fl_Text_Display::draw_vline(), and
diff --git a/FL/Fl_File_Chooser.H b/FL/Fl_File_Chooser.H
index 69f8b8d1f..1f214fdb5 100644
--- a/FL/Fl_File_Chooser.H
+++ b/FL/Fl_File_Chooser.H
@@ -7,35 +7,63 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <FL/Fl_Group.H>
#include <FL/Fl_Choice.H>
+#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Button.H>
-#include <FL/fl_ask.H>
+#include <FL/Fl_Preferences.H>
+#include <FL/Fl_Tile.H>
#include <FL/Fl_File_Browser.H>
+#include <FL/Fl_Box.H>
+#include <FL/Fl_Check_Button.H>
#include <FL/Fl_File_Input.H>
#include <FL/Fl_Return_Button.H>
+#include <FL/fl_ask.H>
class Fl_File_Chooser {
public:
enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
+private:
+ static Fl_Preferences prefs_;
+ void (*callback_)(Fl_File_Chooser*, void *);
+ void *data_;
+ char directory_[1024];
+ char pattern_[1024];
+ char preview_text_[2048];
+ int type_;
+ void favoritesButtonCB();
+ void favoritesCB(Fl_Widget *w);
+ void fileListCB();
+ void fileNameCB();
+ void newdir();
+ static void previewCB(Fl_File_Chooser *fc);
+ void showChoiceCB();
+ void update_favorites();
+ void update_preview();
+public:
Fl_File_Chooser(const char *d, const char *p, int t, const char *title);
private:
Fl_Window *window;
inline void cb_window_i(Fl_Window*, void*);
static void cb_window(Fl_Window*, void*);
- Fl_Choice *dirMenu;
- inline void cb_dirMenu_i(Fl_Choice*, void*);
- static void cb_dirMenu(Fl_Choice*, void*);
- Fl_Button *upButton;
- inline void cb_upButton_i(Fl_Button*, void*);
- static void cb_upButton(Fl_Button*, void*);
+ Fl_Choice *showChoice;
+ inline void cb_showChoice_i(Fl_Choice*, void*);
+ static void cb_showChoice(Fl_Choice*, void*);
+ Fl_Menu_Button *favoritesButton;
+ inline void cb_favoritesButton_i(Fl_Menu_Button*, void*);
+ static void cb_favoritesButton(Fl_Menu_Button*, void*);
Fl_Button *newButton;
inline void cb_newButton_i(Fl_Button*, void*);
static void cb_newButton(Fl_Button*, void*);
- inline void cb__i(Fl_Button*, void*);
- static void cb_(Fl_Button*, void*);
+ inline void cb__i(Fl_Tile*, void*);
+ static void cb_(Fl_Tile*, void*);
Fl_File_Browser *fileList;
inline void cb_fileList_i(Fl_File_Browser*, void*);
static void cb_fileList(Fl_File_Browser*, void*);
+ Fl_Box *previewBox;
+ Fl_Check_Button *previewButton;
+ inline void cb_previewButton_i(Fl_Check_Button*, void*);
+ static void cb_previewButton(Fl_Check_Button*, void*);
Fl_File_Input *fileName;
inline void cb_fileName_i(Fl_File_Input*, void*);
static void cb_fileName(Fl_File_Input*, void*);
@@ -44,16 +72,28 @@ private:
static void cb_okButton(Fl_Return_Button*, void*);
inline void cb_Cancel_i(Fl_Button*, void*);
static void cb_Cancel(Fl_Button*, void*);
- void (*callback_)(Fl_File_Chooser*, void *);
- void *data_;
- char directory_[1024];
- int type_;
- void fileListCB();
- void fileNameCB();
- void newdir();
- void up();
+ Fl_Window *favWindow;
+ Fl_File_Browser *favList;
+ inline void cb_favList_i(Fl_File_Browser*, void*);
+ static void cb_favList(Fl_File_Browser*, void*);
+ Fl_Button *favUpButton;
+ inline void cb_favUpButton_i(Fl_Button*, void*);
+ static void cb_favUpButton(Fl_Button*, void*);
+ Fl_Button *favDeleteButton;
+ inline void cb_favDeleteButton_i(Fl_Button*, void*);
+ static void cb_favDeleteButton(Fl_Button*, void*);
+ Fl_Button *favDownButton;
+ inline void cb_favDownButton_i(Fl_Button*, void*);
+ static void cb_favDownButton(Fl_Button*, void*);
+ Fl_Button *favCancelButton;
+ inline void cb_favCancelButton_i(Fl_Button*, void*);
+ static void cb_favCancelButton(Fl_Button*, void*);
+ Fl_Return_Button *favOkButton;
+ inline void cb_favOkButton_i(Fl_Return_Button*, void*);
+ static void cb_favOkButton(Fl_Return_Button*, void*);
public:
- void callback(void (*cb)(Fl_File_Chooser *, void *), void *d);
+ ~Fl_File_Chooser();
+ void callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0);
void color(Fl_Color c);
Fl_Color color();
int count();
@@ -66,6 +106,8 @@ public:
uchar iconsize();
void label(const char *l);
const char * label();
+ void preview(int e);
+ int preview() const { return previewButton->value(); };
void rescan();
void show();
int shown();
@@ -80,9 +122,16 @@ public:
const char *value(int f = 1);
void value(const char *filename);
int visible();
- static const char *directory_label;
+ static const char *add_favorites_label;
+ static const char *all_files_label;
+ static const char *existing_file_label;
+ static const char *favorites_label;
static const char *filename_label;
- static const char *filter_label;
+ static const char *filesystems_label;
+ static const char *manage_favorites_label;
+ static const char *new_directory_label;
+ static const char *preview_label;
+ static const char *show_label;
static Fl_File_Sort_F *sort;
};
FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0);
diff --git a/FL/mac.H b/FL/mac.H
index 42595126b..cb222f807 100644
--- a/FL/mac.H
+++ b/FL/mac.H
@@ -1,5 +1,5 @@
//
-// "$Id: mac.H,v 1.1.2.7 2002/04/15 12:19:00 easysw Exp $"
+// "$Id: mac.H,v 1.1.2.8 2002/06/07 15:06:31 easysw Exp $"
//
// Mac header file for the Fast Light Tool Kit (FLTK).
//
@@ -27,15 +27,15 @@
// include this file if "__APPLE__" is defined. This is to encourage
// portability of even the system-specific code...
-
-#ifndef FL_MAC_H
-# define FL_MAC_H
+#ifndef Fl_X_H
+# error "Never use <FL/mac.H> directly; include <FL/x.H> instead."
+#endif // !Fl_X_H
// Standard MacOS Carbon API includes...
-# include <Carbon/Carbon.h>
+#include <Carbon/Carbon.h>
// Now make some fixes to the headers...
-# undef check // Dunno where this comes from...
+#undef check // Dunno where this comes from...
// Some random X equivalents
typedef WindowPtr Window;
@@ -114,9 +114,7 @@ extern void fl_open_display();
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
-#endif // !FL_MAC_H
-
//
-// End of "$Id: mac.H,v 1.1.2.7 2002/04/15 12:19:00 easysw Exp $".
+// End of "$Id: mac.H,v 1.1.2.8 2002/06/07 15:06:31 easysw Exp $".
//
diff --git a/FL/win32.H b/FL/win32.H
index 59a9974a7..928d1b238 100644
--- a/FL/win32.H
+++ b/FL/win32.H
@@ -1,5 +1,5 @@
//
-// "$Id: win32.H,v 1.15.2.3.2.6 2002/04/15 12:19:00 easysw Exp $"
+// "$Id: win32.H,v 1.15.2.3.2.7 2002/06/07 15:06:31 easysw Exp $"
//
// WIN32 header file for the Fast Light Tool Kit (FLTK).
//
@@ -27,6 +27,10 @@
// include this file if WIN32 is defined. This is to encourage
// portability of even the system-specific code...
+#ifndef Fl_X_H
+# error "Never use <FL/win32.H> directly; include <FL/x.H> instead."
+#endif // !Fl_X_H
+
#include <windows.h>
// In some of the distributions, the gcc header files are missing some stuff:
#ifndef LPMINMAXINFO
@@ -130,5 +134,5 @@ extern FL_EXPORT void fl_delete_bitmask(Fl_Bitmask bm);
extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b);
//
-// End of "$Id: win32.H,v 1.15.2.3.2.6 2002/04/15 12:19:00 easysw Exp $".
+// End of "$Id: win32.H,v 1.15.2.3.2.7 2002/06/07 15:06:31 easysw Exp $".
//
diff --git a/documentation/Fl_File_Chooser.html b/documentation/Fl_File_Chooser.html
index c349ea5bd..b25d40870 100644
--- a/documentation/Fl_File_Chooser.html
+++ b/documentation/Fl_File_Chooser.html
@@ -25,35 +25,62 @@
<P>The <CODE>Fl_File_Chooser</CODE> widget displays a standard file selection
dialog that supports various selection modes.
-<CENTER><IMG SRC="filechooser.gif" WIDTH="397" HEIGHT="322" ALT="Fl_File_Chooser widget"></CENTER>
+<CENTER><IMG SRC="Fl_File_Chooser.jpg" WIDTH="498" HEIGHT="408" ALT="Fl_File_Chooser widget"></CENTER>
<P>The <CODE>Fl_File_Chooser</CODE> class also exports several static values
that may be used to localize or customize the appearance of all file chooser
dialogs:
-<UL>
-
- <LI><TT>const char
- *Fl_File_Chooser::directory_label</TT> <P>The label used
- for the directory chooser at the top of the file
- chooser. The default value is "Directory:".</P></LI>
-
- <LI><TT>const char *Fl_File_Chooser::filename_label</TT>
- <P>The label used for the filename field at the bottom
- of the file chooser. The default value is
- "Filename:".</P></LI>
-
- <LI><TT>const char *Fl_File_Chooser::filter_label</TT>
- <P>The label used for the filter text field. The default
- value is "Filter:".</P></LI>
-
- <LI><TT>Fl_File_Sort_F *Fl_File_Chooser::sort</TT>
- <P>The sort function used when loading the contents of a
- directory. The default value is <TT>fl_numericsort</TT>.
- Other values are described in the reference page for <A
- HREF="functions.html#fl_filename_list"><TT>fl_filename_list</TT></A></P></LI>
-
-</UL>
+<CENTER><TABLE BORDER="1">
+<TR>
+ <TH>Member</TH>
+ <TH>Default value</TH>
+</TR>
+<TR>
+ <TD><TT>add_favorites_label</TT></TD>
+ <TD>"Add to Favorites"</TD>
+</TR>
+<TR>
+ <TD><TT>all_files_label</TT></TD>
+ <TD>"All Files (*)"</TD>
+</TR>
+<TR>
+ <TD><TT>existing_file_label</TT></TD>
+ <TD>"Please choose an existing file!"</TD>
+</TR>
+<TR>
+ <TD><TT>favorites_label</TT></TD>
+ <TD>"Favorites"</TD>
+</TR>
+<TR>
+ <TD><TT>filename_label</TT></TD>
+ <TD>"Filename:"</TD>
+</TR>
+<TR>
+ <TD><TT>filesystems_label</TT></TD>
+ <TD>"My Computer" (WIN32)<BR>
+ "File Systems" (all others)</TD>
+</TR>
+<TR>
+ <TD><TT>manage_favorites_label</TT></TD>
+ <TD>"Manage Favorites"</TD>
+</TR>
+<TR>
+ <TD><TT>preview_label</TT></TD>
+ <TD>"Preview"</TD>
+</TR>
+<TR>
+ <TD><TT>show_label</TT></TD>
+ <TD>"Show:"</TD>
+</TR>
+<TR>
+ <TD><TT>sort</TT></TD>
+ <TD>fl_numericsort</TD>
+</TR>
+</TABLE></CENTER>
+
+<P>The <TT>sort</TT> member specifies the sort function that is
+used when loading the contents of a directory.
<H3>Methods</H3>
@@ -68,6 +95,7 @@ dialogs:
<LI><A HREF="#Fl_File_Chooser.hide">hide</A>
<LI><A HREF="#Fl_File_Chooser.iconsize">iconsize</A>
<LI><A HREF="#Fl_File_Chooser.label">label</A>
+ <LI><A HREF="#Fl_File_Chooser.preview">preview</A>
<LI><A HREF="#Fl_File_Chooser.rescan">rescan</A>
<LI><A HREF="#Fl_File_Chooser.show">show</A>
<LI><A HREF="#Fl_File_Chooser.textcolor">textcolor</A>
@@ -88,10 +116,23 @@ complete file name (in which case the corresponding file is highlighted
in the list and in the filename input field.)
<P>The <CODE>pattern</CODE> argument can be a <CODE>NULL</CODE>
-string or <CODE>"*"</CODE> to list all files. See the FLTK
-documentation on <A
+string or <CODE>"*"</CODE> to list all files, or it can be a
+series of descriptions and filter strings separated by tab
+characters (<TT>\t</TT>). The format of filters is either
+"Description text (patterns)" or just "patterns". A file chooser
+that provides filters for HTML and image files might look like:
+
+<UL><PRE>
+"HTML Files (*.html)\tImage Files (*.{bmp,gif,jpg,png})"
+</PRE></UL>
+
+<P>The file chooser will automatically add the "All Files (*)"
+pattern to the end of the string you pass if you do not provide
+one. The first filter in the string is the default filter.
+
+<P>See the FLTK documentation on <A
HREF="functions.html#fl_filename_match"><CODE>fl_filename_match()</CODE></A>
-for other kinds of patterns.
+for the kinds of pattern strings that are supported.
<P>The <CODE>type</CODE> argument can be one of the following:
@@ -147,6 +188,12 @@ const char *label()</A></H4>
<P>Sets or gets the title bar text for the <CODE>Fl_File_Chooser</CODE>.
+<H4><A NAME="Fl_File_Chooser.preview">void preview(int e)<BR>
+int preview()</A></H4>
+
+<P>The first form enables or disables the preview box in the file chooser.
+The second form returns the current state of the preview box.
+
<H4><A NAME="Fl_File_Chooser.rescan">void rescan()</A></H4>
<P>Reloads the current directory in the <CODE>Fl_File_Browser</CODE>.
@@ -185,8 +232,5 @@ const char *value()</A></H4>
<P>Returns 1 if the <CODE>Fl_File_Chooser</CODE> window is visible.
-<HR>
-
-
</BODY>
</HTML>
diff --git a/documentation/Fl_File_Chooser.jpg b/documentation/Fl_File_Chooser.jpg
new file mode 100644
index 000000000..050227d58
--- /dev/null
+++ b/documentation/Fl_File_Chooser.jpg
Binary files differ
diff --git a/documentation/filechooser.gif b/documentation/filechooser.gif
deleted file mode 100644
index 2efdf9db7..000000000
--- a/documentation/filechooser.gif
+++ /dev/null
Binary files differ
diff --git a/fluid/Fluid_Image.cxx b/fluid/Fluid_Image.cxx
index c9f4d9c9c..0addb39d4 100644
--- a/fluid/Fluid_Image.cxx
+++ b/fluid/Fluid_Image.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fluid_Image.cxx,v 1.7.2.9.2.9 2002/05/16 12:47:43 easysw Exp $"
+// "$Id: Fluid_Image.cxx,v 1.7.2.9.2.10 2002/06/07 15:06:32 easysw Exp $"
//
// Pixmap label support for the Fast Light Tool Kit (FLTK).
//
@@ -210,7 +210,7 @@ Fluid_Image::~Fluid_Image() {
const char *ui_find_image_name;
Fluid_Image *ui_find_image(const char *oldname) {
goto_source_dir();
- const char *name = fl_file_chooser("Image?","*.{bm|bmp|gif|jpg|pbm|pgm|png|ppm|xbm|xpm}",oldname);
+ const char *name = fl_file_chooser("Image?","Image Files (*.{bm|bmp|gif|jpg|pbm|pgm|png|ppm|xbm|xpm})",oldname);
ui_find_image_name = name;
Fluid_Image *ret = (name && *name) ? Fluid_Image::find(name) : 0;
leave_source_dir();
@@ -219,5 +219,5 @@ Fluid_Image *ui_find_image(const char *oldname) {
//
-// End of "$Id: Fluid_Image.cxx,v 1.7.2.9.2.9 2002/05/16 12:47:43 easysw Exp $".
+// End of "$Id: Fluid_Image.cxx,v 1.7.2.9.2.10 2002/06/07 15:06:32 easysw Exp $".
//
diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx
index 1f8bbc8d7..4b99572cc 100644
--- a/fluid/fluid.cxx
+++ b/fluid/fluid.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fluid.cxx,v 1.15.2.13.2.26 2002/05/16 12:47:43 easysw Exp $"
+// "$Id: fluid.cxx,v 1.15.2.13.2.27 2002/06/07 15:06:32 easysw Exp $"
//
// FLUID main entry for the Fast Light Tool Kit (FLTK).
//
@@ -116,7 +116,7 @@ Fl_Window *main_window;
void save_cb(Fl_Widget *, void *v) {
const char *c = filename;
if (v || !c || !*c) {
- if (!(c=fl_file_chooser("Save to:", "*.f[ld]", c))) return;
+ if (!(c=fl_file_chooser("Save to:", "FLUID Files (*.f[ld])", c))) return;
set_filename(c);
}
if (!write_file(c)) {
@@ -149,7 +149,7 @@ void open_cb(Fl_Widget *, void *v) {
if (!v && modflag && !fl_ask("Discard changes?")) return;
const char *c;
const char *oldfilename;
- if (!(c = fl_file_chooser("Open:", "*.f[ld]", filename))) return;
+ if (!(c = fl_file_chooser("Open:", "FLUID Files (*.f[ld])", filename))) return;
oldfilename = filename;
filename = NULL;
set_filename(c);
@@ -192,7 +192,7 @@ void open_history_cb(Fl_Widget *, void *v) {
void new_cb(Fl_Widget *, void *v) {
if (!v && modflag && !fl_ask("Discard changes?")) return;
const char *c;
- if (!(c = fl_file_chooser("New:", "*.f[ld]", 0))) return;
+ if (!(c = fl_file_chooser("New:", "FLUID Files (*.f[ld])", 0))) return;
delete_all();
set_filename(c);
modflag = 0;
@@ -795,5 +795,5 @@ int main(int argc,char **argv) {
}
//
-// End of "$Id: fluid.cxx,v 1.15.2.13.2.26 2002/05/16 12:47:43 easysw Exp $".
+// End of "$Id: fluid.cxx,v 1.15.2.13.2.27 2002/06/07 15:06:32 easysw Exp $".
//
diff --git a/fluid/makedepend b/fluid/makedepend
index 740eefe6f..fd764ebf2 100644
--- a/fluid/makedepend
+++ b/fluid/makedepend
@@ -97,11 +97,13 @@ Fluid_Image.o: ../FL/Fl_Wizard.H ../FL/Fl_Menu_.H ../FL/Fl_Menu_Button.H
Fluid_Image.o: ../FL/Fl_Menu_.H ../FL/Fl_Choice.H ../FL/Fl_Menu_Bar.H
Fluid_Image.o: ../src/flstring.h ../config.h ../FL/filename.H
Fluid_Image.o: ../FL/Fl_File_Chooser.H ../FL/Fl_Window.H ../FL/Fl_Button.H
-Fluid_Image.o: ../FL/fl_ask.H ../FL/Fl_File_Browser.H ../FL/Fl_Browser.H
-Fluid_Image.o: ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H
-Fluid_Image.o: ../FL/Fl_Valuator.H ../FL/Fl_File_Icon.H ../FL/Fl.H
-Fluid_Image.o: ../FL/filename.H ../FL/Fl_File_Input.H ../FL/Fl_Input.H
-Fluid_Image.o: ../FL/Fl_Input_.H ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
+Fluid_Image.o: ../FL/Fl_Preferences.H ../FL/Fl_Tile.H ../FL/Fl_File_Browser.H
+Fluid_Image.o: ../FL/Fl_Browser.H ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H
+Fluid_Image.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/Fl_File_Icon.H
+Fluid_Image.o: ../FL/Fl.H ../FL/filename.H ../FL/Fl_Box.H
+Fluid_Image.o: ../FL/Fl_Check_Button.H ../FL/Fl_Light_Button.H
+Fluid_Image.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
+Fluid_Image.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H ../FL/fl_ask.H
code.o: ../src/flstring.h ../config.h ../FL/Fl.H ../FL/Enumerations.H
code.o: ../FL/Fl_Export.H Fl_Type.h ../FL/Fl_Widget.H ../FL/Fl_Menu.H
code.o: ../FL/Fl_Menu_Item.H Fluid_Image.h ../FL/Fl_Shared_Image.H
@@ -160,17 +162,17 @@ fluid.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/fl_draw.H
fluid.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Hold_Browser.H ../FL/Fl_Browser.H
fluid.o: ../FL/Fl_Browser_.H ../FL/Fl_Menu_Bar.H ../FL/Fl_Menu_.H
fluid.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/fl_ask.H ../FL/fl_draw.H
-fluid.o: ../FL/Fl_File_Chooser.H ../FL/Fl_Window.H ../FL/Fl_Choice.H
-fluid.o: ../FL/Fl_File_Browser.H ../FL/Fl_File_Icon.H ../FL/filename.H
+fluid.o: ../FL/Fl_File_Chooser.H ../FL/Fl_Window.H ../FL/Fl_Group.H
+fluid.o: ../FL/Fl_Choice.H ../FL/Fl_Menu_Button.H ../FL/Fl_Preferences.H
+fluid.o: ../FL/Fl_Tile.H ../FL/Fl_File_Browser.H ../FL/Fl_File_Icon.H
+fluid.o: ../FL/filename.H ../FL/Fl_Check_Button.H ../FL/Fl_Light_Button.H
fluid.o: ../FL/Fl_File_Input.H ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
fluid.o: ../FL/fl_message.H ../FL/fl_ask.H ../FL/filename.H ../src/flstring.h
-fluid.o: ../config.h alignment_panel.h ../FL/Fl_Preferences.H
-fluid.o: ../FL/Fl_Tooltip.H ../FL/Fl_Widget.H ../FL/Fl_Tabs.H
-fluid.o: ../FL/Fl_Group.H ../FL/Fl_Light_Button.H ../FL/Fl_Check_Button.H
-fluid.o: ../FL/Fl_Light_Button.H ../FL/Fl_Browser.H about_panel.h Fl_Type.h
-fluid.o: ../FL/Fl_Menu.H ../FL/Fl_Menu_Item.H Fluid_Image.h
-fluid.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H ../FL/Fl_Pack.H
-fluid.o: ../FL/Fl_Wizard.H ../FL/Fl_Menu_.H ../FL/Fl_Menu_Button.H
+fluid.o: ../config.h alignment_panel.h ../FL/Fl_Tooltip.H ../FL/Fl_Widget.H
+fluid.o: ../FL/Fl_Tabs.H ../FL/Fl_Light_Button.H ../FL/Fl_Browser.H
+fluid.o: about_panel.h Fl_Type.h ../FL/Fl_Menu.H ../FL/Fl_Menu_Item.H
+fluid.o: Fluid_Image.h ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H
+fluid.o: ../FL/Fl_Pack.H ../FL/Fl_Wizard.H ../FL/Fl_Menu_.H
align_widget.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
align_widget.o: Fl_Widget_Type.h Fl_Type.h ../FL/Fl_Widget.H ../FL/Fl_Menu.H
align_widget.o: ../FL/Fl_Menu_Item.H Fluid_Image.h ../FL/Fl_Shared_Image.H
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
diff --git a/test/file_chooser.cxx b/test/file_chooser.cxx
index 3637250b8..2da5133f0 100644
--- a/test/file_chooser.cxx
+++ b/test/file_chooser.cxx
@@ -1,9 +1,9 @@
//
-// "$Id: file_chooser.cxx,v 1.4.2.3.2.4 2002/01/01 15:11:32 easysw Exp $"
+// "$Id: file_chooser.cxx,v 1.4.2.3.2.5 2002/06/07 15:06:32 easysw Exp $"
//
-// File chooser test program for the Fast Light Tool Kit (FLTK).
+// File chooser test program.
//
-// Copyright 1998-2002 by Bill Spitzak and others.
+// Copyright 1999-2002 by Michael Sweet.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -22,39 +22,273 @@
//
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//
+// Contents:
+//
+// main() - Create a file chooser and wait for a selection to
+// be made.
+// close_callback() - Close the main window...
+// fc_callback() - Handle choices in the file chooser...
+// pdf_check() - Check for and load the first page of a PDF file.
+// ps_check() - Check for and load the first page of a PostScript
+// file.
+// show_callback() - Show the file chooser...
+//
+
+//
+// Include necessary headers...
+//
-#include <FL/Fl.H>
-#include <FL/Fl_Button.H>
-#include <FL/Fl_Window.H>
-#include <FL/Fl_Input.H>
+#include <stdio.h>
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_File_Icon.H>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
+#include <FL/Fl_Shared_Image.H>
+#include <FL/Fl_PNM_Image.H>
+#include "../src/flstring.h"
-Fl_Input *pattern, *current;
-void pickfile(Fl_Widget *) {
- const char *p;
- p = fl_file_chooser("Pick a file",pattern->value(),current->value());
- if (p) current->value(p);
-}
+//
+// Globals...
+//
+
+Fl_Input *filter;
+Fl_File_Browser *files;
+Fl_File_Chooser *fc;
+Fl_Shared_Image *image = 0;
+
-int main(int argc, char **argv) {
+//
+// Functions...
+//
+
+void close_callback(void);
+void fc_callback(Fl_File_Chooser *, void *);
+Fl_Image *pdf_check(const char *, uchar *, int);
+Fl_Image *ps_check(const char *, uchar *, int);
+void show_callback(void);
+
+
+//
+// 'main()' - Create a file chooser and wait for a selection to be made.
+//
+
+int // O - Exit status
+main(int argc, // I - Number of command-line arguments
+ char *argv[]) // I - Command-line arguments
+{
+ Fl_Window *window;// Main window
+ Fl_Button *button;// Buttons
+ Fl_File_Icon *icon; // New file icon
+
+
+ // Make the file chooser...
+ Fl::scheme(NULL);
Fl_File_Icon::load_system_icons();
- Fl_Window window(310,110);
- pattern = new Fl_Input(100,10,200,25,"Pattern:");
- pattern->static_value("*");
- current = new Fl_Input(100,40,200,25,"Current:");
- Fl_Button button(200,75,100,25,"&Choose file");
- button.callback(pickfile);
- window.end();
- window.show(argc, argv);
- return Fl::run();
+
+ fc = new Fl_File_Chooser(".", "*", Fl_File_Chooser::MULTI, "Fl_File_Chooser Test");
+ fc->callback(fc_callback);
+// fc->type(Fl_File_Chooser::MULTI);
+// fc->color((Fl_Color)196);
+
+ // Register the PS and PDF image types...
+ Fl_Shared_Image::add_handler(pdf_check);
+ Fl_Shared_Image::add_handler(ps_check);
+
+ // Make the main window...
+ window = new Fl_Window(400, 200, "File Chooser Test");
+
+ filter = new Fl_Input(50, 10, 315, 25, "Filter:");
+ if (argc > 1)
+ filter->value(argv[1]);
+ else
+ filter->value("PDF Files (*.pdf)\t"
+ "PostScript Files (*.ps)\t"
+ "Image Files (*.{bmp,gif,jpg,png})\t"
+ "C/C++ Source Files (*.{c,C,cc,cpp,cxx})");
+
+ button = new Fl_Button(365, 10, 25, 25);
+ button->labelcolor(FL_YELLOW);
+ button->callback((Fl_Callback *)show_callback);
+
+ icon = Fl_File_Icon::find(".", Fl_File_Icon::DIRECTORY);
+ icon->label(button);
+
+ files = new Fl_File_Browser(50, 45, 340, 110, "Files:");
+ files->align(FL_ALIGN_LEFT);
+
+ button = new Fl_Button(340, 165, 50, 25, "Close");
+ button->callback((Fl_Callback *)close_callback);
+
+ window->end();
+ window->show();
+
+ Fl::run();
+
+ return (0);
}
+
+//
+// 'close_callback()' - Close the main window...
+//
+
+void
+close_callback(void)
+{
+ exit(0);
+}
+
+
+//
+// 'fc_callback()' - Handle choices in the file chooser...
+//
+
+void
+fc_callback(Fl_File_Chooser *fc, // I - File chooser
+ void *data) // I - Data
+{
+ const char *filename; // Current filename
+
+
+ printf("fc_callback(fc = %p, data = %p)\n", fc, data);
+
+ filename = fc->value();
+
+ printf(" filename = \"%s\"\n", filename ? filename : "(null)");
+}
+
+
+//
+// 'pdf_check()' - Check for and load the first page of a PDF file.
+//
+
+Fl_Image * // O - Page image or NULL
+pdf_check(const char *name, // I - Name of file
+ uchar *header, // I - Header data
+ int headerlen) // I - Length of header data
+{
+ const char *home; // Home directory
+ char preview[1024], // Preview filename
+ command[1024]; // Command
+
+
+ if (memcmp(header, "%PDF", 4) != 0)
+ return 0;
+
+ home = getenv("HOME");
+ snprintf(preview, sizeof(preview), "%s/.preview.ppm", home ? home : "");
+
+ snprintf(command, sizeof(command),
+ "gs -r100 -dFIXED -sDEVICE=ppmraw -dQUIET -dNOPAUSE -dBATCH "
+ "-sstdout=\"%%stderr\" -sOUTPUTFILE=\'%s\' "
+ "-dFirstPage=1 -dLastPage=1 \'%s\' 2>/dev/null", preview, name);
+
+ if (system(command)) return 0;
+
+ return new Fl_PNM_Image(preview);
+}
+
+
+//
+// 'ps_check()' - Check for and load the first page of a PostScript file.
+//
+
+Fl_Image * // O - Page image or NULL
+ps_check(const char *name, // I - Name of file
+ uchar *header, // I - Header data
+ int headerlen) // I - Length of header data
+{
+ const char *home; // Home directory
+ char preview[1024], // Preview filename
+ outname[1024], // Preview PS file
+ command[1024]; // Command
+ FILE *in, // Input file
+ *out; // Output file
+ int page; // Current page
+ char line[256]; // Line from file
+
+
+ if (memcmp(header, "%!", 2) != 0)
+ return 0;
+
+ home = getenv("HOME");
+ snprintf(preview, sizeof(preview), "%s/.preview.ppm", home ? home : "");
+
+ if (memcmp(header, "%!PS", 4) == 0) {
+ // PS file has DSC comments; extract the first page...
+ snprintf(outname, sizeof(outname), "%s/.preview.ps", home ? home : "");
+
+ if (strcmp(name, outname) != 0) {
+ in = fopen(name, "rb");
+ out = fopen(outname, "wb");
+ page = 0;
+
+ while (fgets(line, sizeof(line), in) != NULL) {
+ if (strncmp(line, "%%Page:", 7) == 0) {
+ page ++;
+ if (page > 1) break;
+ }
+
+ fputs(line, out);
+ }
+
+ fclose(in);
+ fclose(out);
+ }
+ } else {
+ // PS file doesn't have DSC comments; do the whole file...
+ strlcpy(outname, name, sizeof(outname));
+ }
+
+ snprintf(command, sizeof(command),
+ "gs -r100 -dFIXED -sDEVICE=ppmraw -dQUIET -dNOPAUSE -dBATCH "
+ "-sstdout=\"%%stderr\" -sOUTPUTFILE=\'%s\' \'%s\' 2>/dev/null",
+ preview, outname);
+
+ if (system(command)) return 0;
+
+ return new Fl_PNM_Image(preview);
+}
+
+
+//
+// 'show_callback()' - Show the file chooser...
+//
+
+void
+show_callback(void)
+{
+ int i; // Looping var
+ int count; // Number of files selected
+ char relative[1024]; // Relative filename
+
+
+ fc->show();
+ if (filter->value()[0])
+ fc->filter(filter->value());
+
+ fc->show();
+
+ while (fc->visible())
+ Fl::wait();
+
+ count = fc->count();
+ if (count > 0)
+ {
+ files->clear();
+
+ for (i = 1; i <= count; i ++)
+ {
+ fl_filename_relative(relative, sizeof(relative), fc->value(i));
+
+ files->add(relative,
+ Fl_File_Icon::find(fc->value(i), Fl_File_Icon::PLAIN));
+ }
+
+ files->redraw();
+ }
+}
+
+
//
-// End of "$Id: file_chooser.cxx,v 1.4.2.3.2.4 2002/01/01 15:11:32 easysw Exp $".
+// End of "$Id: file_chooser.cxx,v 1.4.2.3.2.5 2002/06/07 15:06:32 easysw Exp $".
//
diff --git a/test/makedepend b/test/makedepend
index 86b02c0a9..60adb457f 100644
--- a/test/makedepend
+++ b/test/makedepend
@@ -57,11 +57,12 @@ colbrowser.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Clock.H ../FL/Fl_Counter.H
colbrowser.o: ../FL/Fl_Dial.H ../FL/Fl_Free.H ../FL/fl_ask.H
colbrowser.o: ../FL/fl_show_colormap.H ../FL/filename.H
colbrowser.o: ../FL/Fl_File_Chooser.H ../FL/Fl.H ../FL/Fl_Window.H
-colbrowser.o: ../FL/Fl_Choice.H ../FL/Fl_Button.H ../FL/fl_ask.H
-colbrowser.o: ../FL/Fl_File_Browser.H ../FL/Fl_File_Icon.H
-colbrowser.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
-colbrowser.o: ../FL/Fl_Return_Button.H ../FL/Fl_Input.H
-colbrowser.o: ../FL/Fl_Menu_Button.H ../FL/Fl_Positioner.H
+colbrowser.o: ../FL/Fl_Group.H ../FL/Fl_Choice.H ../FL/Fl_Menu_Button.H
+colbrowser.o: ../FL/Fl_Button.H ../FL/Fl_Preferences.H ../FL/Fl_Tile.H
+colbrowser.o: ../FL/Fl_File_Browser.H ../FL/Fl_File_Icon.H ../FL/Fl_Box.H
+colbrowser.o: ../FL/Fl_Check_Button.H ../FL/Fl_File_Input.H ../FL/Fl_Input.H
+colbrowser.o: ../FL/Fl_Input_.H ../FL/Fl_Return_Button.H ../FL/fl_ask.H
+colbrowser.o: ../FL/Fl_Input.H ../FL/Fl_Menu_Button.H ../FL/Fl_Positioner.H
colbrowser.o: ../FL/Fl_Value_Slider.H ../FL/Fl_Timer.H
color_chooser.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
color_chooser.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
@@ -106,27 +107,31 @@ doublebuffer.o: ../FL/Fl_Valuator.H ../FL/math.h
editor.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Group.H
editor.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H ../FL/Fl_Group.H
editor.o: ../FL/Fl_Widget.H ../FL/fl_ask.H ../FL/Fl_File_Chooser.H
-editor.o: ../FL/Fl_Window.H ../FL/Fl_Choice.H ../FL/Fl_Button.H
-editor.o: ../FL/Fl_File_Browser.H ../FL/Fl_Browser.H ../FL/Fl_Browser_.H
-editor.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
-editor.o: ../FL/Fl_File_Icon.H ../FL/Fl.H ../FL/filename.H
-editor.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
-editor.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H ../FL/Fl_Menu_Bar.H
-editor.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H ../FL/Fl_Text_Buffer.H
-editor.o: ../FL/Fl_Text_Editor.H ../FL/Fl_Text_Display.H ../FL/fl_draw.H
-editor.o: ../FL/Fl_Text_Buffer.H
+editor.o: ../FL/Fl_Window.H ../FL/Fl_Choice.H ../FL/Fl_Menu_Button.H
+editor.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H ../FL/Fl_Button.H
+editor.o: ../FL/Fl_Preferences.H ../FL/Fl_Tile.H ../FL/Fl_File_Browser.H
+editor.o: ../FL/Fl_Browser.H ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H
+editor.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/Fl_File_Icon.H
+editor.o: ../FL/Fl.H ../FL/filename.H ../FL/Fl_Box.H ../FL/Fl_Check_Button.H
+editor.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H ../FL/Fl_File_Input.H
+editor.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/Fl_Return_Button.H
+editor.o: ../FL/Fl_Menu_Bar.H ../FL/Fl_Text_Buffer.H ../FL/Fl_Text_Editor.H
+editor.o: ../FL/Fl_Text_Display.H ../FL/fl_draw.H ../FL/Fl_Text_Buffer.H
fast_slow.o: fast_slow.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fast_slow.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
fast_slow.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/Fl_Box.H
file_chooser.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
file_chooser.o: ../FL/Fl_Button.H ../FL/Fl_Window.H ../FL/Fl_Group.H
file_chooser.o: ../FL/Fl_Widget.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
-file_chooser.o: ../FL/Fl_File_Chooser.H ../FL/Fl_Choice.H ../FL/fl_ask.H
+file_chooser.o: ../FL/Fl_File_Chooser.H ../FL/Fl_Group.H ../FL/Fl_Choice.H
+file_chooser.o: ../FL/Fl_Menu_Button.H ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H
+file_chooser.o: ../FL/Fl_Preferences.H ../FL/Fl_Tile.H
file_chooser.o: ../FL/Fl_File_Browser.H ../FL/Fl_Browser.H
file_chooser.o: ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H
file_chooser.o: ../FL/Fl_Valuator.H ../FL/Fl_File_Icon.H ../FL/Fl.H
-file_chooser.o: ../FL/filename.H ../FL/Fl_File_Input.H
-file_chooser.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
+file_chooser.o: ../FL/filename.H ../FL/Fl_Box.H ../FL/Fl_Check_Button.H
+file_chooser.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H
+file_chooser.o: ../FL/Fl_File_Input.H ../FL/Fl_Return_Button.H ../FL/fl_ask.H
file_chooser.o: ../FL/Fl_File_Icon.H
fonts.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Window.H
fonts.o: ../FL/Fl_Group.H ../FL/Fl_Widget.H ../FL/Fl_Hold_Browser.H
@@ -144,10 +149,12 @@ forms.o: ../FL/Fl_Check_Button.H ../FL/Fl_Chart.H ../FL/Fl_Choice.H
forms.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H ../FL/Fl_Clock.H
forms.o: ../FL/Fl_Counter.H ../FL/Fl_Dial.H ../FL/Fl_Free.H ../FL/fl_ask.H
forms.o: ../FL/fl_show_colormap.H ../FL/filename.H ../FL/Fl_File_Chooser.H
-forms.o: ../FL/Fl.H ../FL/Fl_Window.H ../FL/Fl_Choice.H ../FL/Fl_Button.H
-forms.o: ../FL/fl_ask.H ../FL/Fl_File_Browser.H ../FL/Fl_File_Icon.H
-forms.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
-forms.o: ../FL/Fl_Return_Button.H ../FL/Fl_Input.H ../FL/Fl_Menu_Button.H
+forms.o: ../FL/Fl.H ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Choice.H
+forms.o: ../FL/Fl_Menu_Button.H ../FL/Fl_Button.H ../FL/Fl_Preferences.H
+forms.o: ../FL/Fl_Tile.H ../FL/Fl_File_Browser.H ../FL/Fl_File_Icon.H
+forms.o: ../FL/Fl_Box.H ../FL/Fl_Check_Button.H ../FL/Fl_File_Input.H
+forms.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/Fl_Return_Button.H
+forms.o: ../FL/fl_ask.H ../FL/Fl_Input.H ../FL/Fl_Menu_Button.H
forms.o: ../FL/Fl_Positioner.H ../FL/Fl_Value_Slider.H ../FL/Fl_Timer.H
forms.o: srs.xbm
fractals.o: ../config.h ../FL/glut.H ../FL/gl.h ../FL/Enumerations.H
@@ -257,13 +264,17 @@ pixmap_browser.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
pixmap_browser.o: ../FL/Fl_Box.H ../FL/Fl_Window.H ../FL/Fl_Group.H
pixmap_browser.o: ../FL/Fl_Widget.H ../FL/Fl_Button.H ../FL/Fl_Shared_Image.H
pixmap_browser.o: ../FL/Fl_Image.H ../FL/x.H ../FL/Fl_Window.H
-pixmap_browser.o: ../FL/Fl_File_Chooser.H ../FL/Fl_Choice.H ../FL/fl_ask.H
+pixmap_browser.o: ../FL/Fl_File_Chooser.H ../FL/Fl_Group.H ../FL/Fl_Choice.H
+pixmap_browser.o: ../FL/Fl_Menu_Button.H ../FL/Fl_Menu_.H
+pixmap_browser.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Preferences.H ../FL/Fl_Tile.H
pixmap_browser.o: ../FL/Fl_File_Browser.H ../FL/Fl_Browser.H
pixmap_browser.o: ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H
pixmap_browser.o: ../FL/Fl_Valuator.H ../FL/Fl_File_Icon.H ../FL/Fl.H
-pixmap_browser.o: ../FL/filename.H ../FL/Fl_File_Input.H ../FL/Fl_Input.H
-pixmap_browser.o: ../FL/Fl_Input_.H ../FL/Fl_Return_Button.H
-pixmap_browser.o: ../FL/Fl_Button.H ../FL/fl_message.H ../FL/fl_ask.H
+pixmap_browser.o: ../FL/filename.H ../FL/Fl_Check_Button.H
+pixmap_browser.o: ../FL/Fl_Light_Button.H ../FL/Fl_Button.H
+pixmap_browser.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
+pixmap_browser.o: ../FL/Fl_Return_Button.H ../FL/fl_ask.H ../FL/fl_message.H
+pixmap_browser.o: ../FL/fl_ask.H
pixmap.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H ../FL/Fl_Window.H
pixmap.o: ../FL/Fl_Group.H ../FL/Fl_Widget.H ../FL/Fl_Button.H
pixmap.o: ../FL/Fl_Pixmap.H ../FL/Fl_Image.H ../FL/x.H ../FL/Fl_Window.H