A component that displays the files in a directory as a listbox. More...
Inherits ListBox, DirectoryContentsDisplayComponent, ListBoxModel, and ChangeListener.
Public Member Functions | |
| FileListComponent (DirectoryContentsList &listToShow) | |
| Creates a listbox to show the contents of a specified directory. | |
| ~FileListComponent () | |
| Destructor. | |
| int | getNumSelectedFiles () const |
| Returns the number of files the user has got selected. | |
| const File | getSelectedFile (int index=0) const |
| Returns one of the files that the user has currently selected. | |
| void | deselectAllFiles () |
| Deselects any files that are currently selected. | |
| void | scrollToTop () |
| Scrolls to the top of the list. | |
| void | changeListenerCallback (ChangeBroadcaster *) |
| Your subclass should implement this method to receive the callback. | |
| int | getNumRows () |
| This has to return the number of items in the list. | |
| void | paintListBoxItem (int, Graphics &, int, int, bool) |
| This method must be implemented to draw a row of the list. | |
| Component * | refreshComponentForRow (int rowNumber, bool isRowSelected, Component *existingComponentToUpdate) |
| This is used to create or update a custom component to go in a row of the list. | |
| void | selectedRowsChanged (int lastRowSelected) |
| Override this to be informed when rows are selected or deselected. | |
| void | deleteKeyPressed (int currentSelectedRow) |
| Override this to be informed when the delete key is pressed. | |
| void | returnKeyPressed (int currentSelectedRow) |
| Override this to be informed when the return key is pressed. | |
A component that displays the files in a directory as a listbox.
This implements the DirectoryContentsDisplayComponent base class so that it can be used in a FileBrowserComponent.
To attach a listener to it, use its DirectoryContentsDisplayComponent base class and the FileBrowserListener class.
| FileListComponent::FileListComponent | ( | DirectoryContentsList & | listToShow ) |
Creates a listbox to show the contents of a specified directory.
| FileListComponent::~FileListComponent | ( | ) |
Destructor.
| int FileListComponent::getNumSelectedFiles | ( | ) | const [virtual] |
Returns the number of files the user has got selected.
Implements DirectoryContentsDisplayComponent.
| const File FileListComponent::getSelectedFile | ( | int | index = 0 ) |
const [virtual] |
Returns one of the files that the user has currently selected.
The index should be in the range 0 to (getNumSelectedFiles() - 1).
Implements DirectoryContentsDisplayComponent.
| void FileListComponent::deselectAllFiles | ( | ) | [virtual] |
Deselects any files that are currently selected.
Implements DirectoryContentsDisplayComponent.
| void FileListComponent::scrollToTop | ( | ) | [virtual] |
Scrolls to the top of the list.
Implements DirectoryContentsDisplayComponent.
| void FileListComponent::changeListenerCallback | ( | ChangeBroadcaster * | source ) | [virtual] |
Your subclass should implement this method to receive the callback.
| source | the ChangeBroadcaster that triggered the callback. |
Implements ChangeListener.
| int FileListComponent::getNumRows | ( | ) | [virtual] |
This has to return the number of items in the list.
Implements ListBoxModel.
| void FileListComponent::paintListBoxItem | ( | int | rowNumber, |
| Graphics & | g, | ||
| int | width, | ||
| int | height, | ||
| bool | rowIsSelected | ||
| ) | [virtual] |
This method must be implemented to draw a row of the list.
Implements ListBoxModel.
| Component* FileListComponent::refreshComponentForRow | ( | int | rowNumber, |
| bool | isRowSelected, | ||
| Component * | existingComponentToUpdate | ||
| ) | [virtual] |
This is used to create or update a custom component to go in a row of the list.
Any row may contain a custom component, or can just be drawn with the paintListBoxItem() method and handle mouse clicks with listBoxItemClicked().
This method will be called whenever a custom component might need to be updated - e.g. when the table is changed, or TableListBox::updateContent() is called.
If you don't need a custom component for the specified row, then return 0.
If you do want a custom component, and the existingComponentToUpdate is null, then this method must create a suitable new component and return it.
If the existingComponentToUpdate is non-null, it will be a pointer to a component previously created by this method. In this case, the method must either update it to make sure it's correctly representing the given row (which may be different from the one that the component was created for), or it can delete this component and return a new one.
The component that your method returns will be deleted by the ListBox when it is no longer needed.
Reimplemented from ListBoxModel.
| void FileListComponent::selectedRowsChanged | ( | int | lastRowSelected ) | [virtual] |
Override this to be informed when rows are selected or deselected.
This will be called whenever a row is selected or deselected. If a range of rows is selected all at once, this will just be called once for that event.
| lastRowSelected | the last row that the user selected. If no rows are currently selected, this may be -1. |
Reimplemented from ListBoxModel.
| void FileListComponent::deleteKeyPressed | ( | int | lastRowSelected ) | [virtual] |
Override this to be informed when the delete key is pressed.
If no rows are selected when they press the key, this won't be called.
| lastRowSelected | the last row that had been selected when they pressed the key - if there are multiple selections, this might not be very useful |
Reimplemented from ListBoxModel.
| void FileListComponent::returnKeyPressed | ( | int | lastRowSelected ) | [virtual] |
Override this to be informed when the return key is pressed.
If no rows are selected when they press the key, this won't be called.
| lastRowSelected | the last row that had been selected when they pressed the key - if there are multiple selections, this might not be very useful |
Reimplemented from ListBoxModel.