Woopsi 1.0
GUI Framework for Nintendo DS Homebrew

filelistbox.h

00001 #ifndef _FILE_LISTBOX_H_
00002 #define _FILE_LISTBOX_H_
00003 
00004 #include "scrollinglistbox.h"
00005 #include "filelistboxdataitem.h"
00006 #include "gadget.h"
00007 #include "gadgeteventhandler.h"
00008 #include "gadgetstyle.h"
00009 #include "woopsistring.h"
00010 
00011 #ifdef ARM9
00012 #include <fat.h>
00013 #endif
00014 
00015 namespace WoopsiUI {
00016 
00017         class FilePath;
00018 
00031         class FileListBox : public Gadget, public GadgetEventHandler  {
00032         public:
00033 
00043                 FileListBox(s16 x, s16 y, u16 width, u16 height, u32 flags, GadgetStyle* style = NULL);
00044         
00049                 virtual void handleDoubleClickEvent(const GadgetEventArgs& e);
00050                 
00055                 virtual void handleValueChangeEvent(const GadgetEventArgs& e);
00056 
00062                 virtual inline void addOption(const char* text, const u32 value) {
00063                         _listbox->addOption(text, value);
00064                 };
00065 
00078                 virtual inline void addOption(const char* text, const u32 value, const u16 normalTextColour, const u16 normalBackColour, const u16 selectedTextColour, const u16 selectedBackColour) {
00079                         _listbox->addOption(text, value, normalTextColour, normalBackColour, selectedTextColour, selectedBackColour);
00080                 };
00081 
00086                 virtual inline void removeOption(const s32 index) {
00087                         _listbox->removeOption(index);
00088                 };
00089 
00093                 virtual inline void removeAllOptions() {
00094                         _listbox->removeAllOptions();
00095                 };
00096 
00103                 virtual inline const s32 getSelectedIndex() const {
00104                         return _listbox->getSelectedIndex();
00105                 };
00106 
00111                 virtual inline const FileListBoxDataItem* getSelectedOption() const {
00112                         return (const FileListBoxDataItem*)_listbox->getSelectedOption();
00113                 };
00114 
00119                 virtual inline void setAllowMultipleSelections(const bool allowMultipleSelections) {
00120                         _listbox->setAllowMultipleSelections(allowMultipleSelections);
00121                 };
00122 
00127                 virtual inline const FileListBoxDataItem* getOption(const s32 index) const {
00128                         return (const FileListBoxDataItem*)_listbox->getOption(index);
00129                 };
00130 
00134                 virtual inline void sort() {
00135                         _listbox->sort();
00136                 };
00137 
00142                 virtual inline const s32 getOptionCount() const {
00143                         return _listbox->getOptionCount();
00144                 };
00145 
00150                 virtual void setPath(const WoopsiString& path);
00151 
00156                 virtual void appendPath(const WoopsiString& path);
00157 
00161                 virtual const FilePath* getPath() const;
00162 
00163         protected:
00164                 ScrollingListBox* _listbox;                     
00165                 FilePath* _path;                                        
00173                 virtual void drawContents(GraphicsPort* port);
00174 
00180                 virtual void onResize(u16 width, u16 height);
00181                 
00185                 virtual ~FileListBox();
00186 
00190                 virtual void readDirectory();
00191                 
00195                 inline FileListBox(const FileListBox& fileListBox) : Gadget(fileListBox) { };
00196         };
00197 }
00198 
00199 #endif