FLTK 1.3.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Native_File_Chooser.H
Go to the documentation of this file.
1 //
2 // "$Id: Fl_Native_File_Chooser.H 9704 2012-10-19 11:23:51Z manolo $"
3 //
4 // FLTK native OS file chooser widget
5 //
6 // Copyright 1998-2010 by Bill Spitzak and others.
7 // Copyright 2004 Greg Ercolano.
8 //
9 // This library is free software. Distribution and use rights are outlined in
10 // the file "COPYING" which should have been included with this file. If this
11 // file is missing or damaged, see the license at:
12 //
13 // http://www.fltk.org/COPYING.php
14 //
15 // Please report all bugs and problems on the following page:
16 //
17 // http://www.fltk.org/str.php
18 //
19
23 #ifndef FL_NATIVE_FILE_CHOOSER_H
24 #define FL_NATIVE_FILE_CHOOSER_H
25
26 /* \file
27 Fl_Native_File_Chooser widget. */
28
29 // Use Windows' chooser
30 #ifdef WIN32
31 // #define _WIN32_WINNT 0x0501 // needed for OPENFILENAME's 'FlagsEx'
32 #include <stdio.h>
33 #include <stdlib.h> // malloc
34 #include <windows.h>
35 #include <commdlg.h> // OPENFILENAME, GetOpenFileName()
36 #include <shlobj.h> // BROWSEINFO, SHBrowseForFolder()
37 #endif
38
39 // Use Apple's chooser
40 #ifdef __APPLE__
41 #define MAXFILTERS 80
42 #endif
43
44 // All else falls back to FLTK's own chooser
45 #if ! defined(__APPLE__) && !defined(WIN32)
46 #include <FL/Fl_File_Chooser.H>
47 #include <unistd.h> // _POSIX_NAME_MAX
48 #else
49 #include <FL/filename.H> // FL_EXPORT
50 #endif
51
52
105 class FL_EXPORT Fl_Native_File_Chooser {
106 public:
107 enum Type {
108 BROWSE_FILE = 0,
109 BROWSE_DIRECTORY,
110 BROWSE_MULTI_FILE,
111 BROWSE_MULTI_DIRECTORY,
112 BROWSE_SAVE_FILE,
113 BROWSE_SAVE_DIRECTORY
114 };
115 enum Option {
116 NO_OPTIONS = 0x0000,
117 SAVEAS_CONFIRM = 0x0001,
118 NEW_FOLDER = 0x0002,
119 PREVIEW = 0x0004
120 };
122 static const char *file_exists_message;
123
124 public:
125 Fl_Native_File_Chooser(int val=BROWSE_FILE);
126 ~Fl_Native_File_Chooser();
127
128 // Public methods
129 void type(int);
130 int type() const;
131 void options(int);
132 int options() const;
133 int count() const;
134 const char *filename() const;
135 const char *filename(int i) const;
136 void directory(const char *val);
137 const char *directory() const;
138 void title(const char *);
139 const char* title() const;
140 const char *filter() const;
141 void filter(const char *);
142 int filters() const;
143 void filter_value(int i);
144 int filter_value() const;
145 void preset_file(const char*);
146 const char* preset_file() const;
147 const char *errmsg() const;
148 int show();
149
150 #ifdef WIN32
151 private:
152 int _btype; // kind-of browser to show()
153 int _options; // general options
154 OPENFILENAMEW _ofn; // GetOpenFileName() & GetSaveFileName() struct
155 BROWSEINFO _binf; // SHBrowseForFolder() struct
156 char **_pathnames; // array of pathnames
157 int _tpathnames; // total pathnames
158 char *_directory; // default pathname to use
159 char *_title; // title for window
160 char *_filter; // user-side search filter
161 char *_parsedfilt; // filter parsed for Windows dialog
162 int _nfilters; // number of filters parse_filter counted
163 char *_preset_file; // the file to preselect
164 char *_errmsg; // error message
165
166 // Private methods
167 void errmsg(const char *msg);
168
169 void clear_pathnames();
170 void set_single_pathname(const char *s);
171 void add_pathname(const char *s);
172
173 void FreePIDL(LPITEMIDLIST pidl);
174 void ClearOFN();
175 void ClearBINF();
176 void Win2Unix(char *s);
177 void Unix2Win(char *s);
178 int showfile();
179 static int CALLBACK Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data);
180 int showdir();
181
182 void parse_filter(const char *);
183 void clear_filters();
184 void add_filter(const char *, const char *);
185 #endif
186
187 #ifdef __APPLE__
188 private:
189 int _btype; // kind-of browser to show()
190 int _options; // general options
191 void *_panel;
192 char **_pathnames; // array of pathnames
193 int _tpathnames; // total pathnames
194 char *_directory; // default pathname to use
195 char *_title; // title for window
196 char *_preset_file; // the 'save as' filename
197
198 char *_filter; // user-side search filter, eg:
199 // C Files\t*.[ch]\nText Files\t*.txt"
200
201 char *_filt_names; // filter names (tab delimited)
202 // eg. "C Files\tText Files"
203
204 char *_filt_patt[MAXFILTERS];
205 // array of filter patterns, eg:
206 // _filt_patt[0]="*.{cxx,h}"
207 // _filt_patt[1]="*.txt"
208
209 int _filt_total; // parse_filter() # of filters loaded
210 int _filt_value; // index of the selected filter
211 char *_errmsg; // error message
212
213 // Private methods
214 void errmsg(const char *msg);
215 void clear_pathnames();
216 void set_single_pathname(const char *s);
217 int get_saveas_basename(void);
218 void clear_filters();
219 void add_filter(const char *, const char *);
220 void parse_filter(const char *from);
221 int post();
222 int runmodal();
223 #endif
224
225 #if ! defined(__APPLE__) && !defined(WIN32)
226 private:
227 int _btype; // kind-of browser to show()
228 int _options; // general options
229 int _nfilters;
230 char *_filter; // user supplied filter
231 char *_parsedfilt; // parsed filter
232 int _filtvalue; // selected filter
233 char *_preset_file;
234 char *_prevvalue; // Returned filename
235 char *_directory;
236 char *_errmsg; // error message
237 Fl_File_Chooser *_file_chooser;
238
239 // Private methods
240 void errmsg(const char *msg);
241 int type_fl_file(int);
242 void parse_filter();
243 void keeplocation();
244 int exist_dialog();
245 #endif
246 };
247
248
249 #endif /*FL_NATIVE_FILE_CHOOSER_H*/
250
251 //
252 // End of "$Id: Fl_Native_File_Chooser.H 9704 2012-10-19 11:23:51Z manolo $".
253 //
Fl_Native_File_Chooser::Option
Option
Definition: Fl_Native_File_Chooser.H:115
Fl_Native_File_Chooser
This class lets an FLTK application easily and consistently access the operating system&#39;s native file...
Definition: Fl_Native_File_Chooser.H:105
Fl_Native_File_Chooser::Type
Type
Definition: Fl_Native_File_Chooser.H:107
filename.H
File names and URI utility functions.
Fl_Native_File_Chooser::file_exists_message
static const char * file_exists_message
Localizable message.
Definition: Fl_Native_File_Chooser.H:122
Fl_File_Chooser
The Fl_File_Chooser widget displays a standard file selection dialog that supports various selection ...
Definition: Fl_File_Chooser.H:41
Fl_Native_File_Chooser::BROWSE_MULTI_FILE
browse files (lets user choose multiple files)
Definition: Fl_Native_File_Chooser.H:110
Fl_Native_File_Chooser::BROWSE_MULTI_DIRECTORY
browse directories (lets user choose multiple directories)
Definition: Fl_Native_File_Chooser.H:111
Fl_Native_File_Chooser::BROWSE_DIRECTORY
browse directories (lets user choose one directory)
Definition: Fl_Native_File_Chooser.H:109
Fl_Native_File_Chooser::BROWSE_SAVE_FILE
browse to save a file
Definition: Fl_Native_File_Chooser.H:112
- © 1998-2012 by Bill Spitzak and others.