30#include <FL/Fl_File_Icon.H>
31#define FLTK_CHOOSER_SINGLE Fl_File_Chooser::SINGLE
32#define FLTK_CHOOSER_DIRECTORY Fl_File_Chooser::DIRECTORY
33#define FLTK_CHOOSER_MULTI Fl_File_Chooser::MULTI
34#define FLTK_CHOOSER_CREATE Fl_File_Chooser::CREATE
36#include "Fl_Native_File_Chooser_common.cxx"
75 _filter = strfree(_filter);
76 _parsedfilt = strfree(_parsedfilt);
77 _preset_file = strfree(_preset_file);
78 _prevvalue = strfree(_prevvalue);
79 _directory = strfree(_directory);
80 _errmsg = strfree(_errmsg);
85 _errmsg = strfree(_errmsg);
86 _errmsg = strnew(msg);
90int Fl_Native_File_Chooser::type_fl_file(
int val) {
93 return(FLTK_CHOOSER_SINGLE);
95 return(FLTK_CHOOSER_SINGLE | FLTK_CHOOSER_DIRECTORY);
97 return(FLTK_CHOOSER_MULTI);
99 return(FLTK_CHOOSER_DIRECTORY | FLTK_CHOOSER_MULTI);
101 return(FLTK_CHOOSER_SINGLE | FLTK_CHOOSER_CREATE);
103 return(FLTK_CHOOSER_DIRECTORY | FLTK_CHOOSER_MULTI | FLTK_CHOOSER_CREATE);
105 return(FLTK_CHOOSER_SINGLE);
114 _file_chooser->type(type_fl_file(val));
158 _file_chooser->filter(_parsedfilt);
164 _file_chooser->filter_value(_filtvalue);
167 if ( _directory && _directory[0] ) {
168 _file_chooser->directory(_directory);
170 _file_chooser->directory(_prevvalue);
174 if ( _preset_file ) {
175 _file_chooser->value(_preset_file);
183 _file_chooser->type(_file_chooser->type() | FLTK_CHOOSER_CREATE);
186 _file_chooser->show();
189 while ( _file_chooser->shown() ) {
193 if ( _file_chooser->value() && _file_chooser->value()[0] ) {
194 _prevvalue = strfree(_prevvalue);
195 _prevvalue = strnew(_file_chooser->value());
196 _filtvalue = _file_chooser->filter_value();
201 if ( stat(_file_chooser->value(), &buf) != -1 ) {
202 if ( buf.st_mode & S_IFREG ) {
203 if ( exist_dialog() == 0 ) {
211 if ( _file_chooser->count() )
return(0);
221 return(_errmsg ? _errmsg :
"No error");
231 if ( _file_chooser->count() > 0 )
return(_file_chooser->value());
250 if ( i < _file_chooser->
count() )
251 return(_file_chooser->value(i+1));
261 _file_chooser->label(val);
269 return(_file_chooser->label());
291 _filter = strfree(_filter);
292 _filter = strnew(val);
344 return(_file_chooser->count());
353 _directory = strfree(_directory);
354 _directory = strnew(val);
374void Fl_Native_File_Chooser::parse_filter() {
375 _parsedfilt = strfree(_parsedfilt);
380 int has_name = strchr(in,
'\t') ? 1 : 0;
382 char mode = has_name ?
'n' :
'w';
383 char wildcard[1024] =
"";
384 char name[1024] =
"";
396 if ( mode !=
'n' )
goto regchar;
411 sprintf(comp,
"%s%.511s(%.511s)", ((_parsedfilt)?
"\t":
""),
413 _parsedfilt = strapp(_parsedfilt, comp);
418 wildcard[0] = name[0] =
'\0';
419 mode = strchr(in,
'\t') ?
'n' :
'w';
421 if ( *in ==
'\0' )
return;
428 case 'n': chrcat(name, *in);
continue;
429 case 'w': chrcat(wildcard, *in);
continue;
444 _preset_file = strfree(_preset_file);
445 _preset_file = strnew(val);
452 return(_preset_file);
456int Fl_Native_File_Chooser::exist_dialog() {
Fl_Native_File_Chooser widget.
The Fl_File_Chooser widget displays a standard file selection dialog that supports various selection ...
Definition Fl_File_Chooser.H:50
static const char * file_exists_message
Localizable message.
Definition Fl_Native_File_Chooser.H:175
int filter_value() const
Returns which filter value was last selected by the user.
Definition Fl_Native_File_Chooser_FLTK.cxx:326
const char * filter() const
Returns the filter string last set.
Definition Fl_Native_File_Chooser_FLTK.cxx:300
const char * errmsg() const
Returns a system dependent error message for the last method that failed.
Definition Fl_Native_File_Chooser_FLTK.cxx:220
~Fl_Native_File_Chooser()
Destructor.
Definition Fl_Native_File_Chooser_FLTK.cxx:73
const char * preset_file() const
Get the preset filename.
Definition Fl_Native_File_Chooser_FLTK.cxx:451
const char * filename() const
Return the filename the user choose.
Definition Fl_Native_File_Chooser_FLTK.cxx:230
Fl_Native_File_Chooser(int val=BROWSE_FILE)
The constructor.
Definition Fl_Native_File_Chooser_FLTK.cxx:45
int filters() const
Gets how many filters were available, not including "All Files".
Definition Fl_Native_File_Chooser_FLTK.cxx:307
@ BROWSE_DIRECTORY
browse directories (lets user choose one directory)
Definition Fl_Native_File_Chooser.H:162
@ BROWSE_MULTI_FILE
browse files (lets user choose multiple files)
Definition Fl_Native_File_Chooser.H:163
@ BROWSE_SAVE_FILE
browse to save a file
Definition Fl_Native_File_Chooser.H:165
@ BROWSE_SAVE_DIRECTORY
browse to save a directory
Definition Fl_Native_File_Chooser.H:166
@ BROWSE_MULTI_DIRECTORY
browse directories (lets user choose multiple directories)
Definition Fl_Native_File_Chooser.H:164
@ BROWSE_FILE
browse files (lets user choose one file)
Definition Fl_Native_File_Chooser.H:161
int show()
Post the chooser's dialog.
Definition Fl_Native_File_Chooser_FLTK.cxx:155
@ NEW_FOLDER
Show 'New Folder' icon (if supported)
Definition Fl_Native_File_Chooser.H:171
@ NO_OPTIONS
no options enabled
Definition Fl_Native_File_Chooser.H:169
@ PREVIEW
enable preview mode
Definition Fl_Native_File_Chooser.H:172
@ SAVEAS_CONFIRM
Show native 'Save As' overwrite confirm dialog (if supported)
Definition Fl_Native_File_Chooser.H:170
const char * title() const
Get the title of the file chooser's dialog window.
Definition Fl_Native_File_Chooser_FLTK.cxx:268
const char * directory() const
Returns the current preset directory() value.
Definition Fl_Native_File_Chooser_FLTK.cxx:360
int options() const
Gets the platform specific Fl_Native_File_Chooser::Option flags.
Definition Fl_Native_File_Chooser_FLTK.cxx:144
int type() const
Gets the current Fl_Native_File_Chooser::Type of browser.
Definition Fl_Native_File_Chooser_FLTK.cxx:120
int count() const
Returns the number of filenames (or directory names) the user selected.
Definition Fl_Native_File_Chooser_FLTK.cxx:343
static int wait()
Waits until "something happens" and then returns.
Definition Fl.cxx:605
FL_EXPORT const char * fl_ok
string pointer used in common dialogs, you can change it to another language
Definition fl_ask.cxx:269
FL_EXPORT const char * fl_cancel
string pointer used in common dialogs, you can change it to another language
Definition fl_ask.cxx:270