Public Member Functions | |
int | count () |
void | directory (const char *d) |
void | filter (const char *p) |
void | preview (bool e) |
void | rescan () |
int | sort_visible () const |
void | sort_visible (int e) |
void | value (const char *filename) |
const char * | value (int f=1) |
Private Member Functions | |
void | activate_okButton_if_file () |
void | directory (const char *d, bool) |
void | favoritesButtonCB () |
void | favoritesCB (fltk::Widget *w) |
void | fileListCB () |
void | fileNameCB () |
void | newdir () |
void | showChoiceCB () |
void | update_favorites () |
void | update_preview () |
void | update_sort () |
Static Private Member Functions | |
static void | previewCB (FileChooser *fc) |
The fltk::FileChooser widget displays a standard file selection dialogue that supports various selection modes.
The fltk::FileChooser class also exports several static values that may be used to localise or customise the appearance of all file chooser dialogues:
Member | Default value |
---|---|
add_favorites_label | "Add to Favorites" |
all_files_label | "All Files (*)" |
custom_filter_label | "Custom Filter" |
existing_file_label | "Please choose an existing file!" |
favorites_label | "Favorites" |
filename_label | "Filename:" |
filesystems_label | "My Computer" (WIN32) "File Systems" (all others) |
hidden_label | "Show hidden files:" |
manage_favorites_label | "Manage Favorites" |
new_directory_label | "New Directory?" |
new_directory_tooltip | "Create a new directory." |
preview_label | "Preview" |
save_label | "Save" |
show_label | "Show:" |
sort | casenumericsort |
sort_menu_label | "Sort Method" |
The fltk::FileChooser::sort member specifies the sort function that is used when loading the contents of a directory and can be customised at run-time.
For more complex customisation, considering copying the fltk::FileChooser code and modifying it accordingly.
void FileChooser::activate_okButton_if_file | ( | ) | [private] |
Activates the OK button if a file is selected.
int FileChooser::count | ( | ) |
Calculate the number of selected files.
void FileChooser::directory | ( | const char * | d, |
bool | f | ||
) | [private] |
Modifies the FileChooser's directory, with the option to modify the displayed "name" field
Updates the FileChooser's current directory by making the filename absolute, stripping trailing '..' or '.'. This also keeps the 'suggested filename' of a file as directories are traversed.
d | A const char* containing the FileChooser's new directory |
f | A boolean representing whether or not to update the displayed filename |
void FileChooser::directory | ( | const char * | d | ) |
Set the directory in the file chooser.
Modify the FileChooser's current directory.
d | The directory to change to |
void FileChooser::favoritesButtonCB | ( | ) | [private] |
Handle favorites selections.
This function deals with adding and/or removing favorites from the FileChooser's drop down menu. It allows a user to quickly navigate amongst pre-set or personalised favorite directories.
void FileChooser::favoritesCB | ( | fltk::Widget * | w | ) | [private] |
Handle the favorites window
This function creates, populates and navigates the favorites window, opened when a user clicks "Manage Favorites". It allows users to shuffle their favorites in the order of most-used or remove favorites.
w | The clicked-on (or used) widget |
void FileChooser::fileListCB | ( | ) | [private] |
Handle clicks (and double-clicks) in the FileBrowser.
This function interprets single clicks and double clicks - a single click selects a file whereas a double click either traverses into a directory or assumes the user has selected the file they want
void FileChooser::fileNameCB | ( | ) | [private] |
Handle text entry in the FileChooser.
If a user tries to manually enter a path into the FileChooser's input box, instead of using the FileChooser to navigate, this function will make sure what is entered is in line with what is required by the FileChooser - for instance, it expands ~ to the user's home directory. It also attempts to offer tabcompletion for paths and files.
void FileChooser::filter | ( | const char * | p | ) |
Set the filter(s) for the FileChooser.
This function allows the FileChooser to use globs and (eventually) regular expressions to select multiple files of the same filetype or same filename.
p | This const char* represents the pattern to match files against. |
void FileChooser::newdir | ( | ) | [private] |
Make a new directory.
This function creates a new directory on the user's computer from inside the FileChooser. It also allows the user to name this directory. After this directory is created, the user is moved into this directory.
void FileChooser::preview | ( | bool | e | ) |
Enable or disable the preview tile.
The preview tile allows a user to view a 'snapshot' of the file they have currently selected. This loads all forms of files, from images to source code to pdf documents, but requires a SharedImage handler to correctly decypher the file data and then display it as an image.
e | A boolean flag representing whether or not to turn previews on. False turns them off, true turns them on. |
void FileChooser::previewCB | ( | FileChooser * | fc | ) | [static, private] |
Timeout handler for the preview box.
This function calls update_preview on the FileChooser after a time lapse of half a second from when a file is first selected
fc | Which FileChooser to use |
void FileChooser::rescan | ( | ) |
Rescan the current directory.
This function re-loads the current directory, scanning for new files or folders
void FileChooser::showChoiceCB | ( | ) | [private] |
Handle "Show" menu selections.
This function handles all the options in the drop-down "Show" menu. This also allows users to enter their own manual filename patterns or select from ones previously used.
void FileChooser::sort_visible | ( | int | e | ) |
Toggle the visibility of the sort menu
e | determines whether or not to show the menu |
int FileChooser::sort_visible | ( | ) | const |
Tests the visility of the sort menu
void FileChooser::update_favorites | ( | ) | [private] |
Update the favorites menu.
This function allows users to add or remove from the favorites menu
void FileChooser::update_preview | ( | ) | [private] |
Update the preview box
This function updates the contents of the preview box with an image, or failing that attempts to load the first 1 kilobyte of a file (if it contains printable characters). Failing this, the function just prints a large "?" in the place of the file to be previewed.
void FileChooser::update_sort | ( | ) | [private] |
Update the sorting method
This function completely re-loads the displayed FileList. This may be slow for large directories as it rescans completely
const char * FileChooser::value | ( | int | f = 1 | ) |
Return a selected filename.
Finds and then returns the fth file in the directory, where f is the number of the file. If the value of f is higher than the amount of files in the directory, this function returns either the value in the filename field, or failing that, NULL
f | The 'f'th file in the directory |
void FileChooser::value | ( | const char * | filename | ) |
Set the current filename.
Takes the passed filename and sets the current directory (and filename) to this name. If no name is passed, this function essentially just deactivates the OK button.
filename | The filename and/or directory |