Fl_Native_File_Chooser_MAC.H 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // "$Id: Fl_Native_File_Chooser_MAC.H 7788 2010-10-31 20:47:50Z matt $"
  3. //
  4. // FLTK native OS file chooser widget
  5. //
  6. // Copyright 1998-2009 by Bill Spitzak and others.
  7. // Copyright 2004 Greg Ercolano.
  8. //
  9. // This library is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU Library General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. //
  14. // This library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. // Library General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU Library General Public
  20. // License along with this library; if not, write to the Free Software
  21. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  22. // USA.
  23. //
  24. // Please report all bugs and problems on the following page:
  25. //
  26. // http://www.fltk.org/str.php
  27. //
  28. #ifndef FL_DOXYGEN // PREVENT DOXYGEN'S USE OF THIS FILE
  29. // OSX-SPECIFIC NATIVE BROWSER
  30. #include <Carbon/Carbon.h>
  31. #undef check // necessary for use of Fl::check()
  32. #include <FL/filename.H>
  33. #define MAXFILTERS 80
  34. class Fl_Native_File_Chooser {
  35. public:
  36. enum Type {
  37. BROWSE_FILE = 0,
  38. BROWSE_DIRECTORY,
  39. BROWSE_MULTI_FILE,
  40. BROWSE_MULTI_DIRECTORY,
  41. BROWSE_SAVE_FILE,
  42. BROWSE_SAVE_DIRECTORY
  43. };
  44. enum Option {
  45. NO_OPTIONS = 0x0000, // no options enabled
  46. SAVEAS_CONFIRM = 0x0001, // Show native 'Save As' overwrite confirm dialog (if supported)
  47. NEW_FOLDER = 0x0002, // Show 'New Folder' icon (if supported)
  48. PREVIEW = 0x0004 // enable preview mode
  49. };
  50. private:
  51. int _btype; // kind-of browser to show()
  52. int _options; // general options
  53. void *_panel;
  54. char **_pathnames; // array of pathnames
  55. int _tpathnames; // total pathnames
  56. char *_directory; // default pathname to use
  57. char *_title; // title for window
  58. char *_preset_file; // the 'save as' filename
  59. char *_filter; // user-side search filter, eg:
  60. // C Files\t*.[ch]\nText Files\t*.txt"
  61. char *_filt_names; // filter names (tab delimited)
  62. // eg. "C Files\tText Files"
  63. char *_filt_patt[MAXFILTERS];
  64. // array of filter patterns, eg:
  65. // _filt_patt[0]="*.{cxx,h}"
  66. // _filt_patt[1]="*.txt"
  67. int _filt_total; // parse_filter() # of filters loaded
  68. int _filt_value; // index of the selected filter
  69. char *_errmsg; // error message
  70. // Private methods
  71. void errmsg(const char *msg);
  72. void clear_pathnames();
  73. void set_single_pathname(const char *s);
  74. int get_saveas_basename(void);
  75. void clear_filters();
  76. void add_filter(const char *, const char *);
  77. void parse_filter(const char *from);
  78. int post();
  79. public:
  80. Fl_Native_File_Chooser(int val = BROWSE_FILE);
  81. ~Fl_Native_File_Chooser();
  82. // Public methods
  83. void type(int);
  84. int type() const;
  85. void options(int);
  86. int options() const;
  87. int count() const;
  88. const char *filename() const;
  89. const char *filename(int i) const;
  90. void directory(const char *);
  91. const char *directory() const;
  92. void title(const char *);
  93. const char *title() const;
  94. const char *filter() const;
  95. void filter(const char *);
  96. void filter_value(int i) { _filt_value = i; }
  97. int filter_value() { return(_filt_value); }
  98. int filters() { return(_filt_total); }
  99. void preset_file(const char *);
  100. const char *preset_file();
  101. const char *errmsg() const;
  102. int show();
  103. };
  104. #endif /*!FL_DOXYGEN*/
  105. //
  106. // End of "$Id: Fl_Native_File_Chooser_MAC.H 7788 2010-10-31 20:47:50Z matt $".
  107. //