Woopsi 1.0
GUI Framework for Nintendo DS Homebrew
|
#include <filerequester.h>
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 | handleActionEvent (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) |
virtual const FilePath * | getPath () const |
virtual const WoopsiString & | getTextBoxFileName () const |
Protected Member Functions | |
virtual void | onResize (u16 width, u16 height) |
virtual | ~FileRequester () |
FileRequester (const FileRequester &fileRequester) | |
Protected Attributes | |
Button * | _okButton |
Button * | _cancelButton |
FileListBox * | _listbox |
TextBox * | _fileNameTextBox |
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:
Note that including libfat increases the ROM size by ~100K. Also note that in the SDL build of Woopsi, the FileRequester shows dummy folders and files. As file I/O is not standard in C, creating a working, cross-platform FileRequester for SDL is a more troublesome task than it really justifies. The dummy data allows for the SDL UI to be tested away from the DS, which is all it is really intended to do.
WoopsiUI::FileRequester::FileRequester | ( | s16 | x, |
s16 | y, | ||
u16 | width, | ||
u16 | height, | ||
const WoopsiString & | title, | ||
const WoopsiString & | path, | ||
u32 | flags, | ||
GadgetStyle * | style = NULL |
||
) |
Constructor.
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.
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.
text | Text to show in the option. |
value | The value of the option. |
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.
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::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.
virtual const s32 WoopsiUI::FileRequester::getOptionCount | ( | ) | const [inline, virtual] |
Get the total number of options.
virtual const FilePath* WoopsiUI::FileRequester::getPath | ( | ) | const [virtual] |
Get the current path.
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.
virtual const FileListBoxDataItem* WoopsiUI::FileRequester::getSelectedOption | ( | ) | const [inline, virtual] |
Get the selected option. Returns NULL if nothing is selected.
virtual const WoopsiString& WoopsiUI::FileRequester::getTextBoxFileName | ( | ) | const [virtual] |
Get the filename contained in the filename textbox.
virtual void WoopsiUI::FileRequester::handleActionEvent | ( | const GadgetEventArgs & | e | ) | [virtual] |
Handles events raised by its sub-gadgets.
e | Event arguments. |
Reimplemented from WoopsiUI::GadgetEventHandler.
virtual void WoopsiUI::FileRequester::handleReleaseEvent | ( | const GadgetEventArgs & | e | ) | [virtual] |
Handles events raised by its sub-gadgets.
e | Event arguments. |
Reimplemented from WoopsiUI::AmigaWindow.
virtual void WoopsiUI::FileRequester::handleValueChangeEvent | ( | const GadgetEventArgs & | e | ) | [virtual] |
Handles events raised by its sub-gadgets.
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.
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.
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.
allowMultipleSelections | True to allow multiple selections. |
virtual void WoopsiUI::FileRequester::setPath | ( | const char * | path | ) | [virtual] |
Set the displayed path.
path | The new path. |
virtual void WoopsiUI::FileRequester::sort | ( | ) | [inline, virtual] |
Sort the options alphabetically by the text of the options.
Button* WoopsiUI::FileRequester::_cancelButton [protected] |
Pointer to the cancel button
TextBox* WoopsiUI::FileRequester::_fileNameTextBox [protected] |
Pointer to the file name textbox
FileListBox* WoopsiUI::FileRequester::_listbox [protected] |
Pointer to the list box
Button* WoopsiUI::FileRequester::_okButton [protected] |
Pointer to the OK button