FileBrowserComponent Class Reference

A component for browsing and selecting a file or directory to open or save. More...

Inherits Component, ChangeBroadcaster, FileBrowserListener, TextEditorListener, ButtonListener, ComboBoxListener, and FileFilter.

List of all members.

Public Types

enum  FileChooserFlags {
  openMode = 1, saveMode = 2, canSelectFiles = 4, canSelectDirectories = 8,
  canSelectMultipleItems = 16, useTreeView = 32, filenameBoxIsReadOnly = 64
}
 

Various options for the browser.

More...

Public Member Functions

 FileBrowserComponent (int flags, const File &initialFileOrDirectory, const FileFilter *fileFilter, FilePreviewComponent *previewComp)
 Creates a FileBrowserComponent.
 ~FileBrowserComponent ()
 Destructor.
int getNumSelectedFiles () const throw ()
 Returns the number of files that the user has got selected.
const File getSelectedFile (int index) const throw ()
 Returns one of the files that the user has chosen.
bool currentFileIsValid () const
 Returns true if the currently selected file(s) are usable.
const File getHighlightedFile () const throw ()
 This returns the last item in the view that the user has highlighted.
const File getRoot () const
 Returns the directory whose contents are currently being shown in the listbox.
void setRoot (const File &newRootDirectory)
 Changes the directory that's being shown in the listbox.
void goUp ()
 Equivalent to pressing the "up" button to browse the parent directory.
void refresh ()
 Refreshes the directory that's currently being listed.
virtual const String getActionVerb () const
 Returns a verb to describe what should happen when the file is accepted.
bool isSaveMode () const throw ()
 Returns true if the saveMode flag was set when this component was created.
void addListener (FileBrowserListener *listener)
 Adds a listener to be told when the user selects and clicks on files.
void removeListener (FileBrowserListener *listener)
 Removes a listener.
void resized ()
void buttonClicked (Button *b)
void comboBoxChanged (ComboBox *)
void textEditorTextChanged (TextEditor &editor)
void textEditorReturnKeyPressed (TextEditor &editor)
void textEditorEscapeKeyPressed (TextEditor &editor)
void textEditorFocusLost (TextEditor &editor)
bool keyPressed (const KeyPress &key)
void selectionChanged ()
void fileClicked (const File &f, const MouseEvent &e)
void fileDoubleClicked (const File &f)
bool isFileSuitable (const File &file) const
bool isDirectorySuitable (const File &) const
FilePreviewComponentgetPreviewComponent () const throw ()

Protected Member Functions

virtual const BigInteger getRoots (StringArray &rootNames, StringArray &rootPaths)

Detailed Description

A component for browsing and selecting a file or directory to open or save.

This contains a FileListComponent and adds various boxes and controls for navigating and selecting a file. It can work in different modes so that it can be used for loading or saving a file, or for choosing a directory.

See also:
FileChooserDialogBox, FileChooser, FileListComponent

Member Enumeration Documentation

Various options for the browser.

A combination of these is passed into the FileBrowserComponent constructor.

Enumerator:
openMode 

specifies that the component should allow the user to choose an existing file with the intention of opening it.

saveMode 

specifies that the component should allow the user to specify the name of a file that will be used to save something.

canSelectFiles 

specifies that the user can select files (can be used in conjunction with canSelectDirectories).

canSelectDirectories 

specifies that the user can select directories (can be used in conjuction with canSelectFiles).

canSelectMultipleItems 

specifies that the user can select multiple items.

useTreeView 

specifies that a tree-view should be shown instead of a file list.

filenameBoxIsReadOnly 

specifies that the user can't type directly into the filename box.


Constructor & Destructor Documentation

FileBrowserComponent::FileBrowserComponent ( int  flags,
const File initialFileOrDirectory,
const FileFilter fileFilter,
FilePreviewComponent previewComp 
)

Creates a FileBrowserComponent.

Parameters:
flags A combination of flags from the FileChooserFlags enumeration, used to specify the component's behaviour. The flags must contain either openMode or saveMode, and canSelectFiles and/or canSelectDirectories.
initialFileOrDirectory The file or directory that should be selected when the component begins. If this is File::nonexistent, a default directory will be chosen.
fileFilter an optional filter to use to determine which files are shown. If this is 0 then all files are displayed. Note that a pointer is kept internally to this object, so make sure that it is not deleted before the browser object is deleted.
previewComp an optional preview component that will be used to show previews of files that the user selects
FileBrowserComponent::~FileBrowserComponent (  ) 

Destructor.


Member Function Documentation

int FileBrowserComponent::getNumSelectedFiles (  )  const throw ()

Returns the number of files that the user has got selected.

If multiple select isn't active, this will only be 0 or 1. To get the complete list of files they've chosen, pass an index to getCurrentFile().

const File FileBrowserComponent::getSelectedFile ( int  index  )  const throw ()

Returns one of the files that the user has chosen.

If the box has multi-select enabled, the index lets you specify which of the files to get - see getNumSelectedFiles() to find out how many files were chosen.

See also:
getHighlightedFile
bool FileBrowserComponent::currentFileIsValid (  )  const

Returns true if the currently selected file(s) are usable.

This can be used to decide whether the user can press "ok" for the current file. What it does depends on the mode, so for example in an "open" mode, this only returns true if a file has been selected and if it exists. In a "save" mode, a non-existent file would also be valid.

const File FileBrowserComponent::getHighlightedFile (  )  const throw ()

This returns the last item in the view that the user has highlighted.

This may be different from getCurrentFile(), which returns the value that is shown in the filename box, and if there are multiple selections, this will only return one of them.

See also:
getSelectedFile
const File FileBrowserComponent::getRoot (  )  const

Returns the directory whose contents are currently being shown in the listbox.

void FileBrowserComponent::setRoot ( const File newRootDirectory  ) 

Changes the directory that's being shown in the listbox.

void FileBrowserComponent::goUp (  ) 

Equivalent to pressing the "up" button to browse the parent directory.

void FileBrowserComponent::refresh (  ) 

Refreshes the directory that's currently being listed.

virtual const String FileBrowserComponent::getActionVerb (  )  const [virtual]

Returns a verb to describe what should happen when the file is accepted.

E.g. if browsing in "load file" mode, this will be "Open", if in "save file" mode, it'll be "Save", etc.

bool FileBrowserComponent::isSaveMode (  )  const throw ()

Returns true if the saveMode flag was set when this component was created.

void FileBrowserComponent::addListener ( FileBrowserListener listener  ) 

Adds a listener to be told when the user selects and clicks on files.

See also:
removeListener
void FileBrowserComponent::removeListener ( FileBrowserListener listener  ) 

Removes a listener.

See also:
addListener
void FileBrowserComponent::resized (  )  [virtual]

For internal use only.

Reimplemented from Component.

void FileBrowserComponent::buttonClicked ( Button b  )  [virtual]

For internal use only.

Implements ButtonListener.

void FileBrowserComponent::comboBoxChanged ( ComboBox  )  [virtual]

For internal use only.

Implements ComboBoxListener.

void FileBrowserComponent::textEditorTextChanged ( TextEditor editor  )  [virtual]

For internal use only.

Implements TextEditorListener.

void FileBrowserComponent::textEditorReturnKeyPressed ( TextEditor editor  )  [virtual]

For internal use only.

Implements TextEditorListener.

void FileBrowserComponent::textEditorEscapeKeyPressed ( TextEditor editor  )  [virtual]

For internal use only.

Implements TextEditorListener.

void FileBrowserComponent::textEditorFocusLost ( TextEditor editor  )  [virtual]

For internal use only.

Implements TextEditorListener.

bool FileBrowserComponent::keyPressed ( const KeyPress key  )  [virtual]

For internal use only.

Reimplemented from Component.

void FileBrowserComponent::selectionChanged (  )  [virtual]

For internal use only.

Implements FileBrowserListener.

void FileBrowserComponent::fileClicked ( const File f,
const MouseEvent e 
) [virtual]

For internal use only.

Implements FileBrowserListener.

void FileBrowserComponent::fileDoubleClicked ( const File f  )  [virtual]

For internal use only.

Implements FileBrowserListener.

bool FileBrowserComponent::isFileSuitable ( const File file  )  const [virtual]

For internal use only.

Implements FileFilter.

bool FileBrowserComponent::isDirectorySuitable ( const File  )  const [virtual]

For internal use only.

Implements FileFilter.

FilePreviewComponent* FileBrowserComponent::getPreviewComponent (  )  const throw ()

For internal use only.

virtual const BigInteger FileBrowserComponent::getRoots ( StringArray rootNames,
StringArray rootPaths 
) [protected, virtual]

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Apr 26 11:42:11 2010 for JUCE by  doxygen 1.6.3