FLTK 1.3.x

Fl_Native_File_Chooser_MAC.H

00001 //
00002 // "$Id: Fl_Native_File_Chooser_MAC.H 8100 2010-12-22 13:05:06Z manolo $"
00003 //
00004 // FLTK native OS file chooser widget
00005 //
00006 // Copyright 1998-2010 by Bill Spitzak and others.
00007 // Copyright 2004 Greg Ercolano.
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 #ifndef FL_DOXYGEN              // PREVENT DOXYGEN'S USE OF THIS FILE
00030 
00031 // OSX-SPECIFIC NATIVE BROWSER
00032 
00033 #include <FL/filename.H>
00034 #define MAXFILTERS      80
00035 
00036 class FL_EXPORT Fl_Native_File_Chooser {
00037 public:
00038   enum Type {
00039     BROWSE_FILE = 0,
00040     BROWSE_DIRECTORY,
00041     BROWSE_MULTI_FILE,
00042     BROWSE_MULTI_DIRECTORY,
00043     BROWSE_SAVE_FILE,
00044     BROWSE_SAVE_DIRECTORY
00045   };
00046   enum Option {
00047     NO_OPTIONS     = 0x0000,            // no options enabled
00048     SAVEAS_CONFIRM = 0x0001,            // Show native 'Save As' overwrite confirm dialog (if supported)
00049     NEW_FOLDER     = 0x0002,            // Show 'New Folder' icon (if supported)
00050     PREVIEW        = 0x0004             // enable preview mode
00051   };
00052 private:
00053   int             _btype;               // kind-of browser to show()
00054   int             _options;             // general options
00055   void           *_panel;
00056   char          **_pathnames;           // array of pathnames
00057   int             _tpathnames;          // total pathnames
00058   char           *_directory;           // default pathname to use
00059   char           *_title;               // title for window
00060   char           *_preset_file;         // the 'save as' filename
00061 
00062   char           *_filter;              // user-side search filter, eg:
00063                                         // C Files\t*.[ch]\nText Files\t*.txt"
00064 
00065   char           *_filt_names;          // filter names (tab delimited)
00066                                         // eg. "C Files\tText Files"
00067 
00068   char           *_filt_patt[MAXFILTERS];
00069                                         // array of filter patterns, eg:
00070                                         //     _filt_patt[0]="*.{cxx,h}"
00071                                         //     _filt_patt[1]="*.txt"
00072 
00073   int             _filt_total;          // parse_filter() # of filters loaded
00074   int             _filt_value;          // index of the selected filter
00075   char           *_errmsg;              // error message
00076 
00077   // Private methods
00078   void errmsg(const char *msg);
00079   void clear_pathnames();
00080   void set_single_pathname(const char *s);
00081   int get_saveas_basename(void);
00082   void clear_filters();
00083   void add_filter(const char *, const char *);
00084   void parse_filter(const char *from);
00085   int post();
00086 
00087 public:
00088   Fl_Native_File_Chooser(int val = BROWSE_FILE);
00089   ~Fl_Native_File_Chooser();
00090 
00091   // Public methods
00092   void type(int);
00093   int type() const;
00094   void options(int);
00095   int options() const;
00096   int count() const;
00097   const char *filename() const;
00098   const char *filename(int i) const;
00099   void directory(const char *);
00100   const char *directory() const;
00101   void title(const char *);
00102   const char *title() const;
00103   const char *filter() const;
00104   void filter(const char *);
00105   void filter_value(int i) { _filt_value = i; }
00106   int filter_value() { return(_filt_value); }
00107   int filters() { return(_filt_total); }
00108   void preset_file(const char *);
00109   const char *preset_file();
00110   const char *errmsg() const;
00111   int show();
00112 };
00113 
00114 #endif 
00116 //
00117 // End of "$Id: Fl_Native_File_Chooser_MAC.H 8100 2010-12-22 13:05:06Z manolo $".
00118 //