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)  

Fl_File_Chooser Class Reference

#include <Fl_File_Chooser.H>

Collaboration diagram for Fl_File_Chooser:

List of all members.

Public Types

enum  { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 }

Public Member Functions

 Fl_File_Chooser (const char *d, const char *p, int t, const char *title)
 ~Fl_File_Chooser ()
void callback (void(*cb)(Fl_File_Chooser *, void *), void *d=0)
void color (Fl_Color c)
Fl_Color color ()
int count ()
void directory (const char *d)
char * directory ()
void filter (const char *p)
const char * filter ()
int filter_value ()
void filter_value (int f)
void hide ()
void iconsize (uchar s)
uchar iconsize ()
void label (const char *l)
const char * label ()
void ok_label (const char *l)
const char * ok_label ()
void preview (int e)
int preview () const
void rescan ()
void rescan_keep_filename ()
void show ()
int shown ()
void textcolor (Fl_Color c)
Fl_Color textcolor ()
void textfont (Fl_Font f)
Fl_Font textfont ()
void textsize (Fl_Fontsize s)
Fl_Fontsize textsize ()
void type (int t)
int type ()
void * user_data () const
void user_data (void *d)
const char * value (int f=1)
void value (const char *filename)
int visible ()
Fl_Widgetadd_extra (Fl_Widget *gr)
Fl_File_Browserbrowser (void)

Public Attributes

Fl_ButtonnewButton
Fl_Check_ButtonpreviewButton

Static Public Attributes

static const char * add_favorites_label = "Add to Favorites"
static const char * all_files_label = "All Files (*)"
static const char * custom_filter_label = "Custom Filter"
static const char * existing_file_label = "Please choose an existing file!"
static const char * favorites_label = "Favorites"
static const char * filename_label = "Filename:"
static const char * filesystems_label = "File Systems"
static const char * manage_favorites_label = "Manage Favorites"
static const char * new_directory_label = "New Directory?"
static const char * new_directory_tooltip = "Create a new directory."
static const char * preview_label = "Preview"
static const char * save_label = "Save"
static const char * show_label = "Show:"
static Fl_File_Sort_Fsort = fl_numericsort

Related Functions

(Note that these are not member functions.)
void fl_file_chooser_callback (void(*cb)(const char *))
void fl_file_chooser_ok_label (const char *l)
char * fl_file_chooser (const char *message, const char *pat, const char *fname, int relative)
char * fl_dir_chooser (const char *message, const char *fname, int relative)

Detailed Description

The Fl_File_Chooser widget displays a standard file selection dialog that supports various selection modes.

Fl_File_Chooser.jpg

The Fl_File_Chooser class also exports several static values that may be used to localize or customize the appearance of all file chooser dialogs:

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)
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 fl_numericsort

The Fl_File_Chooser::sort member specifies the sort function that is used when loading the contents of a directory and can be customized at run-time.

The Fl_File_Chooser class also exports the Fl_File_Chooser::newButton and Fl_File_Chooser::previewButton widgets so that application developers can control their appearance and use. For more complex customization, consider copying the FLTK file chooser code and changing it accordingly.

Definition at line 50 of file Fl_File_Chooser.H.


Member Enumeration Documentation

anonymous enum
Enumerator:
SINGLE 
MULTI 
CREATE 
DIRECTORY 

Definition at line 52 of file Fl_File_Chooser.H.


Constructor & Destructor Documentation

Fl_File_Chooser::Fl_File_Chooser ( const char *  pathname,
const char *  pattern,
int  type,
const char *  title 
)

The constructor creates the Fl_File_Chooser dialog shown. The pathname argument can be a directory name or a complete file name (in which case the corresponding file is highlighted in the list and in the filename input field.)

The pattern argument can be a NULL string or "*" to list all files, or it can be a series of descriptions and filter strings separated by tab characters (\t). The format of filters is either "Description text (patterns)" or just "patterns". A file chooser that provides filters for HTML and image files might look like:

  "HTML Files (*.html)\tImage Files (*.{bmp,gif,jpg,png})"

The file chooser will automatically add the "All Files (*)" pattern to the end of the string you pass if you do not provide one. The first filter in the string is the default filter.

See the FLTK documentation on fl_filename_match() for the kinds of pattern strings that are supported.

The type argument can be one of the following:

  • SINGLE - allows the user to select a single, existing file.
  • MULTI - allows the user to select one or more existing files.
  • CREATE - allows the user to select a single, existing file or specify a new filename.
  • DIRECTORY - allows the user to select a single, existing directory.

The title argument is used to set the title bar text for the Fl_File_Chooser window.

Definition at line 161 of file Fl_File_Chooser.cxx.

References Fl_Widget::align(), Fl_Widget::box(), Fl_Widget::callback(), Fl_Group::current(), Fl_Button::down_box(), Fl_Menu_::down_box(), Fl_Group::end(), favorites_label, filename_label, filter(), FL_ALIGN_CLIP, FL_ALIGN_INSIDE, FL_ALIGN_LEFT, FL_ALIGN_RIGHT, FL_BORDER_BOX, fl_cancel, FL_DOWN_BOX, fl_ok, FL_WHEN_CHANGED, FL_WHEN_ENTER_KEY, Fl_Preferences::get(), h, Fl_Widget::h(), Fl_Window::hotspot(), Fl_Widget::image(), Fl_Window::label(), Fl_Widget::label(), Fl_Widget::labelfont(), Fl_Widget::labelsize(), manage_favorites_label, new_directory_tooltip, newButton, preview(), preview_label, previewButton, Fl_Group::resizable(), save_label, Fl_Window::set_modal(), Fl_Button::shortcut(), show_label, Fl_Window::size_range(), Fl_Widget::tooltip(), type(), Fl_Widget::type(), Fl_Widget::user_data(), value(), Fl_Button::value(), w, Fl_Widget::w(), Fl_Widget::when(), and Fl_Widget::window().

Fl_File_Chooser::~Fl_File_Chooser ( )

Destroys the widget and frees all memory used by it.

Definition at line 304 of file Fl_File_Chooser.cxx.

References Fl_Group::remove(), and Fl::remove_timeout().


Member Function Documentation

Fl_Widget * Fl_File_Chooser::add_extra ( Fl_Widget gr)

Adds extra widget at the bottom of Fl_File_Chooser window. Returns pointer for previous extra widget or NULL if not set previously. If argument is NULL only remove previous extra widget.

Note:
Fl_File_Chooser does not delete extra widget in destructor! To prevent memory leakage, don't forget to delete unused extra widgets

Definition at line 444 of file Fl_File_Chooser.cxx.

References Fl_Group::add(), Fl_Widget::h(), NULL, Fl_Widget::position(), Fl_Group::remove(), Fl_Group::resizable(), Fl_Widget::size(), Fl_Widget::w(), and Fl_Widget::y().

Fl_File_Browser * Fl_File_Chooser::browser ( void  ) [inline]

returns a pointer to the underlying Fl_File_Browser object

Definition at line 225 of file Fl_File_Chooser.H.

Referenced by Fl_Native_File_Chooser::Fl_Native_File_Chooser().

void Fl_File_Chooser::callback ( void(*)(Fl_File_Chooser *, void *)  cb,
void *  d = 0 
)

Sets the file chooser callback cb and associated data d

Definition at line 311 of file Fl_File_Chooser.cxx.

Referenced by fl_dir_chooser(), and fl_file_chooser().

void Fl_File_Chooser::color ( Fl_Color  c)

Sets or gets the background color of the Fl_File_Browser list.

Definition at line 316 of file Fl_File_Chooser.cxx.

References Fl_Widget::color().

Fl_Color Fl_File_Chooser::color ( )

Sets or gets the background color of the Fl_File_Browser list.

Definition at line 320 of file Fl_File_Chooser.cxx.

References Fl_Widget::color().

int Fl_File_Chooser::count ( )
void Fl_File_Chooser::directory ( const char *  pathname)

Sets or gets the current directory.

Definition at line 449 of file Fl_File_Chooser2.cxx.

References fl_filename_absolute(), FL_PATH_MAX, NULL, rescan(), shown(), and strlcpy.

Referenced by fl_file_chooser(), and Fl_Native_File_Chooser::show().

const char * Fl_File_Chooser::directory ( )

Sets or gets the current directory.

Definition at line 324 of file Fl_File_Chooser.cxx.

Referenced by value().

const char * Fl_File_Chooser::filter ( )

See void filter(const char *pattern)

Definition at line 328 of file Fl_File_Chooser.cxx.

References Fl_File_Browser::filter().

Referenced by Fl_File_Chooser().

void Fl_File_Chooser::filter ( const char *  pattern)

Sets or gets the current filename filter patterns. The filter patterns use fl_filename_match(). Multiple patterns can be used by separating them with tabs, like "*.jpg\t*.png\t*.gif\t*". In addition, you can provide human-readable labels with the patterns inside parenthesis, like "JPEG Files (*.jpg)\tPNG Files (*.png)\tGIF Files (*.gif)\tAll Files (*)" .

Use filter(NULL) to show all files.

Definition at line 998 of file Fl_File_Chooser2.cxx.

References Fl_Menu_::add(), all_files_label, Fl_Menu_::clear(), custom_filter_label, FL_PATH_MAX, NULL, start, and Fl_Choice::value().

Referenced by fl_dir_chooser(), fl_file_chooser(), and Fl_Native_File_Chooser::show().

int Fl_File_Chooser::filter_value ( )

Sets or gets the current filename filter selection.

Definition at line 332 of file Fl_File_Chooser.cxx.

References Fl_Choice::value().

Referenced by Fl_Native_File_Chooser::Fl_Native_File_Chooser(), and Fl_Native_File_Chooser::show().

void Fl_File_Chooser::filter_value ( int  f)

Sets or gets the current filename filter selection.

Definition at line 336 of file Fl_File_Chooser.cxx.

References Fl_Choice::value().

void Fl_File_Chooser::hide ( )

Hides the Fl_File_Chooser window.

Definition at line 341 of file Fl_File_Chooser.cxx.

References Fl_Double_Window::hide().

void Fl_File_Chooser::iconsize ( uchar  s)

Sets or gets the size of the icons in the Fl_File_Browser. By default the icon size is set to 1.5 times the textsize().

Definition at line 345 of file Fl_File_Chooser.cxx.

References Fl_File_Browser::iconsize().

uchar Fl_File_Chooser::iconsize ( )

Sets or gets the size of the icons in the Fl_File_Browser. By default the icon size is set to 1.5 times the textsize().

Definition at line 349 of file Fl_File_Chooser.cxx.

References Fl_File_Browser::iconsize().

void Fl_File_Chooser::label ( const char *  l)

Sets or gets the title bar text for the Fl_File_Chooser.

Definition at line 353 of file Fl_File_Chooser.cxx.

References Fl_Window::label().

Referenced by fl_dir_chooser(), fl_file_chooser(), and Fl_Native_File_Chooser::title().

const char * Fl_File_Chooser::label ( )

Sets or gets the title bar text for the Fl_File_Chooser.

Definition at line 357 of file Fl_File_Chooser.cxx.

References Fl_Window::label().

void Fl_File_Chooser::ok_label ( const char *  l)

Sets or gets the label for the "ok" button in the Fl_File_Chooser.

Definition at line 361 of file Fl_File_Chooser.cxx.

References h, Fl_Group::init_sizes(), Fl_Widget::label(), Fl_Widget::measure_label(), Fl_Widget::parent(), Fl_Widget::resize(), w, Fl_Widget::x(), and Fl_Widget::y().

Referenced by fl_file_chooser().

const char * Fl_File_Chooser::ok_label ( )

Sets or gets the label for the "ok" button in the Fl_File_Chooser.

Definition at line 370 of file Fl_File_Chooser.cxx.

References Fl_Widget::label().

int Fl_File_Chooser::preview ( ) const [inline]

Returns the current state of the preview box.

Definition at line 146 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser().

void Fl_File_Chooser::rescan ( )
int Fl_File_Chooser::shown ( )

Returns non-zero if the file chooser main window show() has been called (but not hide() see Fl_Window::shown()

Definition at line 384 of file Fl_File_Chooser.cxx.

References Fl_Window::shown().

Referenced by directory(), fl_dir_chooser(), fl_file_chooser(), rescan_keep_filename(), and Fl_Native_File_Chooser::show().

void Fl_File_Chooser::textcolor ( Fl_Color  c)

Sets or gets the current Fl_File_Browser text color.

Definition at line 388 of file Fl_File_Chooser.cxx.

References Fl_Browser_::textcolor().

Fl_Color Fl_File_Chooser::textcolor ( )

Sets or gets the current Fl_File_Browser text color.

Definition at line 392 of file Fl_File_Chooser.cxx.

References Fl_Browser_::textcolor().

Fl_Font Fl_File_Chooser::textfont ( )

Sets or gets the current Fl_File_Browser text font.

Definition at line 400 of file Fl_File_Chooser.cxx.

References Fl_Browser_::textfont().

void Fl_File_Chooser::textfont ( Fl_Font  f)

Sets or gets the current Fl_File_Browser text font.

Definition at line 396 of file Fl_File_Chooser.cxx.

References Fl_Browser_::textfont().

Fl_Fontsize Fl_File_Chooser::textsize ( )

Sets or gets the current Fl_File_Browser text size.

Definition at line 408 of file Fl_File_Chooser.cxx.

References Fl_File_Browser::textsize().

void Fl_File_Chooser::textsize ( Fl_Fontsize  s)

Sets or gets the current Fl_File_Browser text size.

Definition at line 404 of file Fl_File_Chooser.cxx.

References Fl_File_Browser::textsize().

int Fl_File_Chooser::type ( )

Sets or gets the current type of Fl_File_Chooser.

Definition at line 428 of file Fl_File_Chooser.cxx.

Referenced by Fl_File_Chooser().

void * Fl_File_Chooser::user_data ( ) const

Gets the file chooser user data d

Definition at line 432 of file Fl_File_Chooser.cxx.

void Fl_File_Chooser::user_data ( void *  d)

Sets the file chooser user data d

Definition at line 436 of file Fl_File_Chooser.cxx.

void Fl_File_Chooser::value ( const char *  pathname)

Sets or gets the current value of the selected file.

In the second form, file is a 1-based index into a list of file names. The number of selected files is returned by Fl_File_Chooser::count().

This sample code loops through all selected files:

  // Get list of filenames user selected from a MULTI chooser
  for ( int t=1; t<=chooser->count(); t++ ) {
     const char *filename = chooser->value(t);
     ...
  }

Definition at line 1500 of file Fl_File_Chooser2.cxx.

References Fl_Widget::activate(), b, Fl_Widget::deactivate(), Fl_Browser_::deselect(), directory(), fl_filename_absolute(), fl_filename_isdir(), FL_PATH_MAX, i, NULL, Fl_Input_::position(), Fl_Widget::redraw(), Fl_Browser::select(), Fl_Browser::size(), strlcpy, Fl_Browser::text(), Fl_Browser::topline(), and Fl_File_Input::value().

const char * Fl_File_Chooser::value ( int  file = 1)
int Fl_File_Chooser::visible ( )

Returns 1 if the Fl_File_Chooser window is visible.

Definition at line 440 of file Fl_File_Chooser.cxx.

References Fl_Widget::visible().


Member Data Documentation

const char * Fl_File_Chooser::add_favorites_label = "Add to Favorites" [static]

[standard text may be customized at run-time]

Definition at line 167 of file Fl_File_Chooser.H.

Referenced by rescan_keep_filename().

const char * Fl_File_Chooser::all_files_label = "All Files (*)" [static]

[standard text may be customized at run-time]

Definition at line 171 of file Fl_File_Chooser.H.

Referenced by filter().

const char * Fl_File_Chooser::custom_filter_label = "Custom Filter" [static]

[standard text may be customized at run-time]

Definition at line 175 of file Fl_File_Chooser.H.

Referenced by filter(), and rescan_keep_filename().

const char * Fl_File_Chooser::existing_file_label = "Please choose an existing file!" [static]

[standard text may be customized at run-time]

Definition at line 179 of file Fl_File_Chooser.H.

const char * Fl_File_Chooser::favorites_label = "Favorites" [static]

[standard text may be customized at run-time]

Definition at line 183 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser().

const char * Fl_File_Chooser::filename_label = "Filename:" [static]

[standard text may be customized at run-time]

Definition at line 187 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser().

const char * Fl_File_Chooser::filesystems_label = "File Systems" [static]

[standard text may be customized at run-time]

Definition at line 191 of file Fl_File_Chooser.H.

Referenced by rescan_keep_filename().

const char * Fl_File_Chooser::manage_favorites_label = "Manage Favorites" [static]

[standard text may be customized at run-time]

Definition at line 195 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser(), and rescan_keep_filename().

const char * Fl_File_Chooser::new_directory_label = "New Directory?" [static]

[standard text may be customized at run-time]

Definition at line 199 of file Fl_File_Chooser.H.

const char * Fl_File_Chooser::new_directory_tooltip = "Create a new directory." [static]

[standard text may be customized at run-time]

Definition at line 203 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser().

The "new directory" button is exported so that application developers can control the appearance and use.

Definition at line 83 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser(), and type().

const char * Fl_File_Chooser::preview_label = "Preview" [static]

[standard text may be customized at run-time]

Definition at line 207 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser().

The "preview" button is exported so that application developers can control the appearance and use.

Definition at line 94 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser(), Fl_Native_File_Chooser::Fl_Native_File_Chooser(), preview(), and rescan_keep_filename().

const char * Fl_File_Chooser::save_label = "Save" [static]

[standard text may be customized at run-time]

Definition at line 211 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser().

const char * Fl_File_Chooser::show_label = "Show:" [static]

[standard text may be customized at run-time]

Definition at line 215 of file Fl_File_Chooser.H.

Referenced by Fl_File_Chooser().

Fl_File_Sort_F * Fl_File_Chooser::sort = fl_numericsort [static]

the sort function that is used when loading the contents of a directory.

Definition at line 220 of file Fl_File_Chooser.H.

Referenced by rescan(), and rescan_keep_filename().


The documentation for this class was generated from the following files: