FLTK 1.3.x

Fl_Native_File_Chooser_FLTK.H

00001 //
00002 // "$Id: Fl_Native_File_Chooser_FLTK.H 8093 2010-12-21 09:48:57Z greg.ercolano $"
00003 //
00004 // FLTK native OS file chooser widget
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 // Copyright 2005 by Nathan Vander Wilt.
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Library General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Library General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Library General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022 // USA.
00023 //
00024 // Please report all bugs and problems on the following page:
00025 //
00026 //     http://www.fltk.org/str.php
00027 //
00028 
00029 /* \file
00030    Fl_Native_File_Chooser widget. */
00031 
00032 #include <FL/Fl_File_Chooser.H>
00033 #include <unistd.h>             // _POSIX_NAME_MAX
00034 
00082 class FL_EXPORT Fl_Native_File_Chooser {
00083 public:
00084   enum Type {
00085     BROWSE_FILE = 0,                    
00086     BROWSE_DIRECTORY,                   
00087     BROWSE_MULTI_FILE,                  
00088     BROWSE_MULTI_DIRECTORY,             
00089     BROWSE_SAVE_FILE,                   
00090     BROWSE_SAVE_DIRECTORY               
00091   };
00092   enum Option {
00093     NO_OPTIONS     = 0x0000,            
00094     SAVEAS_CONFIRM = 0x0001,            
00095     NEW_FOLDER     = 0x0002,            
00096     PREVIEW        = 0x0004,            
00097   };
00098 private:
00099   int   _btype;                 // kind-of browser to show()
00100   int   _options;               // general options
00101   int   _nfilters;
00102   char *_filter;                // user supplied filter
00103   char *_parsedfilt;            // parsed filter
00104   int   _filtvalue;             // selected filter
00105   char *_preset_file;
00106   char *_prevvalue;             // Returned filename
00107   char *_directory;
00108   char *_errmsg;                // error message
00109   char *_old_dir;
00110   Fl_File_Chooser *_file_chooser;
00111 
00112   // added by MG
00113   Fl_File_Browser *my_fileList;
00114   Fl_Check_Button *show_hidden;
00115   int prev_filtervalue;
00116   static void show_hidden_cb(Fl_Check_Button *o, void *data);
00117   static void remove_hidden_files(Fl_File_Browser *my_fileList);
00118 
00119   // Private methods
00120   void errmsg(const char *msg);
00121   int type_fl_file(int);
00122   void parse_filter();
00123   void keeplocation();
00124   int exist_dialog();
00125 
00126 public:
00127   Fl_Native_File_Chooser(int val=BROWSE_FILE);
00128   ~Fl_Native_File_Chooser();
00129 
00130   // Public methods
00131   void type(int);
00132   int type() const;
00133   void options(int);
00134   int options() const;
00135   int count() const;
00136   const char *filename() const;
00137   const char *filename(int i) const;
00138   void directory(const char *val);
00139   const char *directory() const;
00140   void title(const char *);
00141   const char* title() const;
00142   const char *filter() const;
00143   void filter(const char *);
00144   int filters() const;
00145   void filter_value(int i);
00146   int filter_value() const;
00147   void preset_file(const char*);
00148   const char* preset_file() const;
00149   const char *errmsg() const;
00150   int show();
00151 };
00152 
00153 //
00154 // End of "$Id: Fl_Native_File_Chooser_FLTK.H 8093 2010-12-21 09:48:57Z greg.ercolano $".
00155 //