|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
#include <Fl_Native_File_Chooser_FLTK.H>

This class lets an FLTK application easily and consistently access the operating system's native file chooser. Some operating systems have very complex and specific file choosers that many users want access to specifically, instead of FLTK's default file chooser(s).
In cases where there is no native file browser, FLTK's own file browser is used instead.
To use this widget correctly, use the following include in your code:
#include <FL/Fl_Native_File_Chooser.H>
Do not include the other Fl_Native_File_Choser_XXX.H files in your code; those are platform specific files that will be included automatically depending on your build platform.
The following example shows how to pick a single file:
// Create and post the local native file chooser #include <FL/Fl_Native_File_Chooser.H> [..] Fl_Native_File_Chooser fnfc; fnfc.title("Pick a file"); fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE); fnfc.filter("Text\t*.txt\n" "C Files\t*.{cxx,h,c}"); fnfc.directory("/var/tmp"); // default directory to use // Show native chooser switch ( fnfc.show() ) { case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR case 1: printf("CANCEL\n"); break; // CANCEL default: printf("PICKED: %s\n", fnfc.filename()); break; // FILE CHOSEN }
Platform Specific Caveats
The Fl_Native_File_Chooser on different platforms.
Definition at line 82 of file Fl_Native_File_Chooser_FLTK.H.
Definition at line 92 of file Fl_Native_File_Chooser_FLTK.H.
Definition at line 46 of file Fl_Native_File_Chooser_MAC.H.
Definition at line 49 of file Fl_Native_File_Chooser_WIN32.H.
Definition at line 84 of file Fl_Native_File_Chooser_FLTK.H.
Definition at line 41 of file Fl_Native_File_Chooser_WIN32.H.
Definition at line 38 of file Fl_Native_File_Chooser_MAC.H.
| Fl_Native_File_Chooser::Fl_Native_File_Chooser | ( | int | val = BROWSE_FILE | ) |
The constructor. Internally allocates the native widgets. Optional val presets the type of browser this will be, which can also be changed with type().
Definition at line 45 of file Fl_Native_File_Chooser_FLTK.cxx.
References b, Fl_File_Chooser::browser(), Fl_Widget::callback(), Fl_Group::current(), Fl_File_Chooser::filter_value(), Fl_Widget::h(), NO_OPTIONS, NULL, Fl_File_Chooser::previewButton, type(), val, Fl_Widget::w(), w, Fl_Widget::window(), Fl_Widget::x(), and Fl_Widget::y().
| Fl_Native_File_Chooser::~Fl_Native_File_Chooser | ( | ) |
Destructor. Deallocates any resources allocated to this widget.
Definition at line 83 of file Fl_Native_File_Chooser_FLTK.cxx.
| Fl_Native_File_Chooser::Fl_Native_File_Chooser | ( | int | val = BROWSE_FILE | ) |
| Fl_Native_File_Chooser::~Fl_Native_File_Chooser | ( | ) |
| Fl_Native_File_Chooser::Fl_Native_File_Chooser | ( | int | val = BROWSE_FILE | ) |
| Fl_Native_File_Chooser::~Fl_Native_File_Chooser | ( | ) |
| int Fl_Native_File_Chooser::count | ( | ) | const |
Returns the number of filenames (or directory names) the user selected.
Example:
if ( fnfc->show() == 0 ) { // Print all filenames user selected for (int n=0; n<fnfc->count(); n++ ) { printf("%d) '%s'\n", n, fnfc->filename(n)); } }
Definition at line 362 of file Fl_Native_File_Chooser_FLTK.cxx.
References Fl_File_Chooser::count().
Referenced by filename().
| int Fl_Native_File_Chooser::count | ( | ) | const |
| int Fl_Native_File_Chooser::count | ( | ) | const |
| const char * Fl_Native_File_Chooser::directory | ( | ) | const |
Returns the current preset directory() value.
Definition at line 379 of file Fl_Native_File_Chooser_FLTK.cxx.
| void Fl_Native_File_Chooser::directory | ( | const char * | val | ) |
Preset the directory the browser will show when opened. If val is NULL, or no directory is specified, the chooser will attempt to use the last non-cancelled folder.
Definition at line 371 of file Fl_Native_File_Chooser_FLTK.cxx.
| void Fl_Native_File_Chooser::directory | ( | const char * | val | ) |
| const char* Fl_Native_File_Chooser::directory | ( | ) | const |
| void Fl_Native_File_Chooser::directory | ( | const char * | ) |
| const char* Fl_Native_File_Chooser::directory | ( | ) | const |
| const char * Fl_Native_File_Chooser::errmsg | ( | ) | const |
Returns a system dependent error message for the last method that failed. This message should at least be flagged to the user in a dialog box, or to some kind of error log. Contents will be valid only for methods that document errmsg() will have info on failures.
Definition at line 239 of file Fl_Native_File_Chooser_FLTK.cxx.
| const char* Fl_Native_File_Chooser::errmsg | ( | ) | const |
| const char* Fl_Native_File_Chooser::errmsg | ( | ) | const |
| const char* Fl_Native_File_Chooser::filename | ( | ) | const |
| const char* Fl_Native_File_Chooser::filename | ( | int | i | ) | const |
| const char * Fl_Native_File_Chooser::filename | ( | int | i | ) | const |
Return one of the filenames the user selected. Use count() to determine how many filenames the user selected.
Example:
if ( fnfc->show() == 0 ) { // Print all filenames user selected for (int n=0; n<fnfc->count(); n++ ) { printf("%d) '%s'\n", n, fnfc->filename(n)); } }
Definition at line 268 of file Fl_Native_File_Chooser_FLTK.cxx.
References count(), and Fl_File_Chooser::value().
| const char * Fl_Native_File_Chooser::filename | ( | ) | const |
Return the filename the user choose. Use this if only expecting a single filename. If more than one filename is expected, use filename(int) instead. Return value may be "" if no filename was chosen (eg. user cancelled).
Definition at line 249 of file Fl_Native_File_Chooser_FLTK.cxx.
References Fl_File_Chooser::count(), and Fl_File_Chooser::value().
Referenced by Fl_PostScript_File_Device::start_job().
| const char* Fl_Native_File_Chooser::filename | ( | ) | const |
| const char* Fl_Native_File_Chooser::filename | ( | int | i | ) | const |
| const char* Fl_Native_File_Chooser::filter | ( | ) | const |
| const char* Fl_Native_File_Chooser::filter | ( | ) | const |
| void Fl_Native_File_Chooser::filter | ( | const char * | ) |
| const char * Fl_Native_File_Chooser::filter | ( | ) | const |
Returns the filter string last set. Can be NULL if no filter was set.
Definition at line 319 of file Fl_Native_File_Chooser_FLTK.cxx.
Referenced by Fl_PostScript_File_Device::start_job().
| void Fl_Native_File_Chooser::filter | ( | const char * | val | ) |
Sets the filename filters used for browsing. The default is NULL, which browses all files.
The filter string can be any of:
The format of each filter is a wildcard, or an optional user description followed by '\t' and the wildcard.
On most platforms, each filter is available to the user via a pulldown menu in the file chooser. The 'All Files' option is always available to the user.
Definition at line 309 of file Fl_Native_File_Chooser_FLTK.cxx.
| void Fl_Native_File_Chooser::filter | ( | const char * | val | ) |
| int Fl_Native_File_Chooser::filter_value | ( | ) | const |
Returns which filter value was last selected by the user. This is only valid if the chooser returns success.
Definition at line 345 of file Fl_Native_File_Chooser_FLTK.cxx.
| void Fl_Native_File_Chooser::filter_value | ( | int | i | ) | [inline] |
Definition at line 105 of file Fl_Native_File_Chooser_MAC.H.
References i.
| int Fl_Native_File_Chooser::filter_value | ( | ) | [inline] |
Definition at line 106 of file Fl_Native_File_Chooser_MAC.H.
| int Fl_Native_File_Chooser::filter_value | ( | ) | const |
| void Fl_Native_File_Chooser::filter_value | ( | int | i | ) |
| void Fl_Native_File_Chooser::filter_value | ( | int | val | ) |
Sets which filter will be initially selected.
The first filter is indexed as 0. If filter_value()==filters(), then "All Files" was chosen. If filter_value() > filters(), then a custom filter was set.
Definition at line 337 of file Fl_Native_File_Chooser_FLTK.cxx.
References val.
| int Fl_Native_File_Chooser::filters | ( | ) | [inline] |
Definition at line 107 of file Fl_Native_File_Chooser_MAC.H.
| int Fl_Native_File_Chooser::filters | ( | ) | const |
Gets how many filters were available, not including "All Files"
Definition at line 326 of file Fl_Native_File_Chooser_FLTK.cxx.
| int Fl_Native_File_Chooser::filters | ( | ) | const [inline] |
Definition at line 108 of file Fl_Native_File_Chooser_WIN32.H.
| void Fl_Native_File_Chooser::options | ( | int | val | ) |
Sets the platform specific chooser options to val. val is expected to be one or more Fl_Native_File_Chooser::Option flags ORed together. Some platforms have OS-specific functions that can be enabled/disabled via this method.
Flag Description Win Mac Other -------------- ----------------------------------------------- ------- ------- ------- NEW_FOLDER Shows the 'New Folder' button. Ignored Used Used PREVIEW Enables the 'Preview' mode by default. Ignored Ignored Used SAVEAS_CONFIRM Confirm dialog if BROWSE_SAVE_FILE file exists. Ignored Used Used
Definition at line 148 of file Fl_Native_File_Chooser_FLTK.cxx.
References val.
Referenced by Fl_PostScript_File_Device::start_job().
| void Fl_Native_File_Chooser::options | ( | int | ) |
| void Fl_Native_File_Chooser::options | ( | int | ) |
| int Fl_Native_File_Chooser::options | ( | ) | const |
| int Fl_Native_File_Chooser::options | ( | ) | const |
Gets the platform specific Fl_Native_File_Chooser::Option flags.
Definition at line 155 of file Fl_Native_File_Chooser_FLTK.cxx.
Referenced by show().
| int Fl_Native_File_Chooser::options | ( | ) | const |
| void Fl_Native_File_Chooser::preset_file | ( | const char * | ) |
| void Fl_Native_File_Chooser::preset_file | ( | const char * | val | ) |
Sets the default filename for the chooser. Use directory() to set the default directory. Mainly used to preset the filename for save dialogs, and on most platforms can be used for opening files as well.
Definition at line 462 of file Fl_Native_File_Chooser_FLTK.cxx.
| void Fl_Native_File_Chooser::preset_file | ( | const char * | ) |
| const char * Fl_Native_File_Chooser::preset_file | ( | ) | const |
Get the preset filename.
Definition at line 470 of file Fl_Native_File_Chooser_FLTK.cxx.
| const char* Fl_Native_File_Chooser::preset_file | ( | ) | const |
| const char* Fl_Native_File_Chooser::preset_file | ( | ) |
| int Fl_Native_File_Chooser::show | ( | ) |
| int Fl_Native_File_Chooser::show | ( | ) |
Post the chooser's dialog. Blocks until dialog has been completed or cancelled.
Definition at line 166 of file Fl_Native_File_Chooser_FLTK.cxx.
References BROWSE_SAVE_FILE, buf, Fl_File_Chooser::count(), Fl_File_Chooser::directory(), Fl_File_Chooser::filter(), Fl_File_Chooser::filter_value(), FLTK_CHOOSER_CREATE, NEW_FOLDER, options(), PREVIEW, Fl_File_Chooser::preview(), SAVEAS_CONFIRM, Fl_File_Chooser::show(), Fl_File_Chooser::shown(), type(), Fl_File_Chooser::type(), Fl_Button::value(), Fl_File_Chooser::value(), and Fl::wait().
Referenced by Fl_PostScript_File_Device::start_job().
| int Fl_Native_File_Chooser::show | ( | ) |
| void Fl_Native_File_Chooser::title | ( | const char * | val | ) |
| const char* Fl_Native_File_Chooser::title | ( | ) | const |
| void Fl_Native_File_Chooser::title | ( | const char * | val | ) |
Set the title of the file chooser's dialog window. Can be NULL if no title desired. The default title varies according to the platform, so you are advised to set the title explicitly.
Definition at line 279 of file Fl_Native_File_Chooser_FLTK.cxx.
References Fl_File_Chooser::label().
Referenced by Fl_PostScript_File_Device::start_job().
| const char* Fl_Native_File_Chooser::title | ( | ) | const |
| const char * Fl_Native_File_Chooser::title | ( | ) | const |
Get the title of the file chooser's dialog window. Return value may be NULL if no title was set.
Definition at line 287 of file Fl_Native_File_Chooser_FLTK.cxx.
References Fl_File_Chooser::label().
| void Fl_Native_File_Chooser::title | ( | const char * | ) |
| int Fl_Native_File_Chooser::type | ( | ) | const |
Gets the current Fl_Native_File_Chooser::Type of browser.
Definition at line 131 of file Fl_Native_File_Chooser_FLTK.cxx.
Referenced by Fl_Native_File_Chooser(), and show().
| void Fl_Native_File_Chooser::type | ( | int | val | ) |
Sets the current Fl_Native_File_Chooser::Type of browser.
Definition at line 123 of file Fl_Native_File_Chooser_FLTK.cxx.
References Fl_File_Chooser::type(), and val.
Referenced by Fl_PostScript_File_Device::start_job().
| void Fl_Native_File_Chooser::type | ( | int | ) |
| int Fl_Native_File_Chooser::type | ( | ) | const |
| int Fl_Native_File_Chooser::type | ( | ) | const |
| void Fl_Native_File_Chooser::type | ( | int | val | ) |