# WoopsiUI::FileRequester Class Reference

`#include <filerequester.h>`

Inheritance diagram for WoopsiUI::FileRequester:

List of all members.

## Public Member Functions
| FileRequester (s16 x, s16 y, u16 width, u16 height, const WoopsiString &title, const WoopsiString &path, u32 flags, GadgetStyle *style=NULL)
virtual void | handleReleaseEvent (const GadgetEventArgs &e)
virtual void | handleValueChangeEvent (const GadgetEventArgs &e)
virtual void | addOption (const char *text, const u32 value)
virtual void | addOption (const char *text, const u32 value, const u16 normalTextColour, const u16 normalBackColour, const u16 selectedTextColour, const u16 selectedBackColour)
virtual void | removeOption (const s32 index)
virtual void | removeAllOptions ()
virtual const s32 | getSelectedIndex () const
virtual const FileListBoxDataItem * | getSelectedOption () const
virtual void | setAllowMultipleSelections (const bool allowMultipleSelections)
virtual const FileListBoxDataItem * | getOption (const s32 index) const
virtual void | sort ()
virtual const s32 | getOptionCount () const
virtual void | setPath (const char *path)
virtual void | appendPath (const char *path)
## Protected Member Functions
virtual void | onResize (u16 width, u16 height)
virtual | ~FileRequester ()
| FileRequester (const FileRequester &fileRequester)
## Protected Attributes
Button * | _okButton
Button * | _cancelButton
FileListBox * | _listbox

## Detailed Description

Class providing a window containing a file listbox, an OK button and a Cancel button. Designed to allow users selection a file from the filesytem. When a file is selected the requester will automatically close.

To read the value of the selected option or options, you should listen for the value changed event. This will fire when the user double-clicks an option or clicks the OK button.

To add this class to a project:

- Enable libfat in the makefile by changing the line that reads LIBS := -lnds9 to LIBS := -lfat -lnds9
- Call "fatInitDefault();" somewhere in your setup code.

Note that including libfat increases the ROM size by ~100K. Also note that this code is not compatible with the SDL build of Woopsi.

## Constructor & Destructor Documentation

WoopsiUI::FileRequester::FileRequester | ( | s16 | x,
|  | s16 | y,
|  | u16 | width,
|  | u16 | height,
|  | const WoopsiString & | title,
|  | const WoopsiString & | path,
|  | u32 | flags,
|  | GadgetStyle * | style = `NULL` |
| ) |  |  |

Constructor.

Parameters:

  | x | The x co-ordinate of the window.
  | y | The y co-ordinate of the window.
  | width | The width of the window.
  | height | The height of the window.
  | title | The title of the window.
  | path | The initial path that the requester will show.
  | flags | Standard flags.
  | style | Optional gadget style.

virtual WoopsiUI::FileRequester::~FileRequester | ( |  | ) | `[inline, protected, virtual]`

Destructor.

WoopsiUI::FileRequester::FileRequester | ( | const FileRequester & | fileRequester | ) | `[inline, protected]`

Copy constructor is protected to prevent usage.

## Member Function Documentation

virtual void WoopsiUI::FileRequester::addOption | ( | const char * | text,
|  | const u32 | value,
|  | const u16 | normalTextColour,
|  | const u16 | normalBackColour,
|  | const u16 | selectedTextColour,
|  | const u16 | selectedBackColour |
| ) |  |  | `[inline, virtual]`

Add a new option to the gadget. Does not redraw the gadget.

Parameters:

  | text | Text to show in the option.
  | value | The value of the option.
  | normalTextColour | Colour to draw the text with when not selected.
  | normalBackColour | Colour to draw the background with when not selected.
  | selectedTextColour | Colour to draw the text with when selected.
  | selectedBackColour | Colour to draw the background with when selected.

virtual void WoopsiUI::FileRequester::addOption | ( | const char * | text,
|  | const u32 | value |
| ) |  |  | `[inline, virtual]`

Add a new option to the gadget using default colours. Does not redraw the gadget.

Parameters:

  | text | Text to show in the option.
  | value | The value of the option.

virtual void WoopsiUI::FileRequester::appendPath | ( | const char * | path | ) | `[virtual]`

Append a new path component to the current path. Automatically inserts trailing slash.

virtual const FileListBoxDataItem* WoopsiUI::FileRequester::getOption | ( | const s32 | index | ) | const`[inline, virtual]`

Get the specified option.

Returns:
  The specified option.

virtual const s32 WoopsiUI::FileRequester::getOptionCount | ( |  | ) | const`[inline, virtual]`

Get the total number of options.

Returns:
  The number of options.

virtual const s32 WoopsiUI::FileRequester::getSelectedIndex | ( |  | ) | const`[inline, virtual]`

Get the selected index. Returns -1 if nothing is selected. If more than one option is selected, the index of the first selected option is returned.

Returns:
  The selected index.

virtual const FileListBoxDataItem* WoopsiUI::FileRequester::getSelectedOption | ( |  | ) | const`[inline, virtual]`

Get the selected option. Returns NULL if nothing is selected.

Returns:
  The selected option.

virtual void WoopsiUI::FileRequester::handleReleaseEvent | ( | const GadgetEventArgs & | e | ) | `[virtual]`

Handles events raised by its sub-gadgets.

Parameters:

  | e | Event arguments.

Reimplemented from WoopsiUI::AmigaWindow.

virtual void WoopsiUI::FileRequester::handleValueChangeEvent | ( | const GadgetEventArgs & | e | ) | `[virtual]`

Handles events raised by its sub-gadgets.

Parameters:

  | e | Event arguments.

Reimplemented from WoopsiUI::GadgetEventHandler.

virtual void WoopsiUI::FileRequester::onResize | ( | u16 | width,
|  | u16 | height |
| ) |  |  | `[protected, virtual]`

Resize the textbox to the new dimensions.

Parameters:

  | width | The new width.
  | height | The new height.

Reimplemented from WoopsiUI::AmigaWindow.

virtual void WoopsiUI::FileRequester::removeAllOptions | ( |  | ) | `[inline, virtual]`

Remove all options from the gadget. Does not redraw the gadget.

virtual void WoopsiUI::FileRequester::removeOption | ( | const s32 | index | ) | `[inline, virtual]`

Remove an option from the gadget by its index. Does not redraw the gadget.

Parameters:

  | index | The index of the option to remove.

virtual void WoopsiUI::FileRequester::setAllowMultipleSelections | ( | const bool | allowMultipleSelections | ) | `[inline, virtual]`

Sets whether multiple selections are possible or not. Does not redraw the gadget.

Parameters:

  | allowMultipleSelections | True to allow multiple selections.

virtual void WoopsiUI::FileRequester::setPath | ( | const char * | path | ) | `[virtual]`

Set the displayed path.

Parameters:

  | path | The new path.

virtual void WoopsiUI::FileRequester::sort | ( |  | ) | `[inline, virtual]`

Sort the options alphabetically by the text of the options.

## Member Data Documentation

Button* WoopsiUI::FileRequester::_cancelButton`[protected]`

Pointer to the cancel button

FileListBox* WoopsiUI::FileRequester::_listbox`[protected]`

Pointer to the list box

Button* WoopsiUI::FileRequester::_okButton`[protected]`

Pointer to the OK button

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

- filerequester.h