00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef Fl_File_Chooser_H
00029 #define Fl_File_Chooser_H
00030 #include <FL/Fl.H>
00031 #include <FL/Fl_Double_Window.H>
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include <string.h>
00035 #include <FL/Fl_Group.H>
00036 #include <FL/Fl_Choice.H>
00037 #include <FL/Fl_Menu_Button.H>
00038 #include <FL/Fl_Button.H>
00039 #include <FL/Fl_Preferences.H>
00040 #include <FL/Fl_Tile.H>
00041 #include <FL/Fl_File_Browser.H>
00042 #include <FL/Fl_Box.H>
00043 #include <FL/Fl_Check_Button.H>
00044 #include <FL/Fl_File_Input.H>
00045 #include <FL/Fl_Return_Button.H>
00046 #include <FL/fl_ask.H>
00047
00048 class FL_EXPORT Fl_File_Chooser {
00049 public:
00050 enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
00051 private:
00052 static Fl_Preferences *prefs_;
00053 void (*callback_)(Fl_File_Chooser*, void *);
00054 void *data_;
00055 char directory_[FL_PATH_MAX];
00056 char pattern_[FL_PATH_MAX];
00057 char preview_text_[2048];
00058 int type_;
00059 void favoritesButtonCB();
00060 void favoritesCB(Fl_Widget *w);
00061 void fileListCB();
00062 void fileNameCB();
00063 void newdir();
00064 static void previewCB(Fl_File_Chooser *fc);
00065 void showChoiceCB();
00066 void update_favorites();
00067 void update_preview();
00068 public:
00069 Fl_File_Chooser(const char *d, const char *p, int t, const char *title);
00070 private:
00071 Fl_Double_Window *window;
00072 inline void cb_window_i(Fl_Double_Window*, void*);
00073 static void cb_window(Fl_Double_Window*, void*);
00074 Fl_Choice *showChoice;
00075 inline void cb_showChoice_i(Fl_Choice*, void*);
00076 static void cb_showChoice(Fl_Choice*, void*);
00077 Fl_Menu_Button *favoritesButton;
00078 inline void cb_favoritesButton_i(Fl_Menu_Button*, void*);
00079 static void cb_favoritesButton(Fl_Menu_Button*, void*);
00080 public:
00081 Fl_Button *newButton;
00082 private:
00083 inline void cb_newButton_i(Fl_Button*, void*);
00084 static void cb_newButton(Fl_Button*, void*);
00085 inline void cb__i(Fl_Tile*, void*);
00086 static void cb_(Fl_Tile*, void*);
00087 Fl_File_Browser *fileList;
00088 inline void cb_fileList_i(Fl_File_Browser*, void*);
00089 static void cb_fileList(Fl_File_Browser*, void*);
00090 Fl_Box *previewBox;
00091 public:
00092 Fl_Check_Button *previewButton;
00093 private:
00094 inline void cb_previewButton_i(Fl_Check_Button*, void*);
00095 static void cb_previewButton(Fl_Check_Button*, void*);
00096 public:
00097 Fl_Check_Button *showHiddenButton;
00098 private:
00099 inline void cb_showHiddenButton_i(Fl_Check_Button*, void*);
00100 static void cb_showHiddenButton(Fl_Check_Button*, void*);
00101 Fl_File_Input *fileName;
00102 inline void cb_fileName_i(Fl_File_Input*, void*);
00103 static void cb_fileName(Fl_File_Input*, void*);
00104 Fl_Return_Button *okButton;
00105 inline void cb_okButton_i(Fl_Return_Button*, void*);
00106 static void cb_okButton(Fl_Return_Button*, void*);
00107 Fl_Button *cancelButton;
00108 inline void cb_cancelButton_i(Fl_Button*, void*);
00109 static void cb_cancelButton(Fl_Button*, void*);
00110 Fl_Double_Window *favWindow;
00111 Fl_File_Browser *favList;
00112 inline void cb_favList_i(Fl_File_Browser*, void*);
00113 static void cb_favList(Fl_File_Browser*, void*);
00114 Fl_Button *favUpButton;
00115 inline void cb_favUpButton_i(Fl_Button*, void*);
00116 static void cb_favUpButton(Fl_Button*, void*);
00117 Fl_Button *favDeleteButton;
00118 inline void cb_favDeleteButton_i(Fl_Button*, void*);
00119 static void cb_favDeleteButton(Fl_Button*, void*);
00120 Fl_Button *favDownButton;
00121 inline void cb_favDownButton_i(Fl_Button*, void*);
00122 static void cb_favDownButton(Fl_Button*, void*);
00123 Fl_Button *favCancelButton;
00124 inline void cb_favCancelButton_i(Fl_Button*, void*);
00125 static void cb_favCancelButton(Fl_Button*, void*);
00126 Fl_Return_Button *favOkButton;
00127 inline void cb_favOkButton_i(Fl_Return_Button*, void*);
00128 static void cb_favOkButton(Fl_Return_Button*, void*);
00129 public:
00130 ~Fl_File_Chooser();
00131 void callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0);
00132 void color(Fl_Color c);
00133 Fl_Color color();
00134 int count();
00135 void directory(const char *d);
00136 char * directory();
00137 void filter(const char *p);
00138 const char * filter();
00139 int filter_value();
00140 void filter_value(int f);
00141 void hide();
00142 void iconsize(uchar s);
00143 uchar iconsize();
00144 void label(const char *l);
00145 const char * label();
00146 void ok_label(const char *l);
00147 const char * ok_label();
00148 void preview(int e);
00149 int preview() const { return previewButton->value(); };
00150 private:
00151 void showHidden(int e);
00152 void remove_hidden_files();
00153 public:
00154 void rescan();
00155 void rescan_keep_filename();
00156 void show();
00157 int shown();
00158 void textcolor(Fl_Color c);
00159 Fl_Color textcolor();
00160 void textfont(Fl_Font f);
00161 Fl_Font textfont();
00162 void textsize(Fl_Fontsize s);
00163 Fl_Fontsize textsize();
00164 void type(int t);
00165 int type();
00166 void * user_data() const;
00167 void user_data(void *d);
00168 const char *value(int f = 1);
00169 void value(const char *filename);
00170 int visible();
00174 static const char *add_favorites_label;
00178 static const char *all_files_label;
00182 static const char *custom_filter_label;
00186 static const char *existing_file_label;
00190 static const char *favorites_label;
00194 static const char *filename_label;
00198 static const char *filesystems_label;
00202 static const char *manage_favorites_label;
00206 static const char *new_directory_label;
00210 static const char *new_directory_tooltip;
00214 static const char *preview_label;
00218 static const char *save_label;
00222 static const char *show_label;
00226 static const char *hidden_label;
00231 static Fl_File_Sort_F *sort;
00232 private:
00233 Fl_Widget* ext_group;
00234 public:
00235 Fl_Widget* add_extra(Fl_Widget* gr);
00236 };
00237 FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0);
00238 FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0);
00239 FL_EXPORT void fl_file_chooser_callback(void (*cb)(const char*));
00240 FL_EXPORT void fl_file_chooser_ok_label(const char*l);
00241 #endif
00242
00243
00244
00245