The FileChooser
widget provides a standard file selection
dialog for your applications. It supports three different selection modes -
single file selection, multiple file selection, and new file selection (for
use in "save as" situations).
The FileChooser
widget is based upon four classes:
FileBrowser
- this is a subclass of
Fl_Browser
that lists files in a specified directory or
all drives/mount points on a system.
FileChooser
- this is the high-level class that
provides the dialog window and controls.
FileIcon
- this class provides icon images for
the FileBrowser
widget and associates
filetypes/extensions with those icon images. The current code
understands SGI ".fti" files used under IRIX and ".xpm" files
used by CDE.
FileInput
- this is a subclass of
Fl_Input
that remaps the Tab key. The new mapping
allows a user to move the cursor to the end of the current
selection using the Tab key (i.e. to accept filename
completion), but if there is no selection the Tab key performs
navigation instead.
The FileIcon
class allows you to add icons for
individual file types. Normally you'll just use the
FileIcon::load_system_icons()
method to load icons
specific to your system; if the system icons can't be loaded
then generic file and folder icons are used instead. Icons are
only shown if you have loaded them.
To use the FileChooser
widget in your program, do:
#include "FileChooser.h" ... { FileIcon::load_system_icons(); // Optional... FileChooser fc("pathname", "*.pattern", type, "title"); fc.show(); while (fc.visible()) Fl::wait(); fc.count() = number of selected files fc.value() = value of first (or only) selected file fc.value(n) = value of selection "n" }