Woopsi 1.0
GUI Framework for Nintendo DS Homebrew
|
00001 #ifndef _LISTBOX_H_ 00002 #define _LISTBOX_H_ 00003 00004 #include "scrollingpanel.h" 00005 #include "listdataeventhandler.h" 00006 #include "listdata.h" 00007 #include "listboxdataitem.h" 00008 #include "gadgetstyle.h" 00009 #include "listboxbase.h" 00010 00011 namespace WoopsiUI { 00012 00021 class ListBox : public ListBoxBase, public ScrollingPanel, public ListDataEventHandler { 00022 public: 00023 00035 ListBox(s16 x, s16 y, u16 width, u16 height, GadgetStyle* style = NULL); 00036 00042 virtual void addOption(const WoopsiString& text, const u32 value); 00043 00048 virtual void addOption(ListBoxDataItem* option); 00049 00054 virtual void removeOption(const s32 index); 00055 00059 virtual void removeAllOptions(); 00060 00073 virtual void addOption(const WoopsiString& text, const u32 value, const u16 normalTextColour, const u16 normalBackColour, const u16 selectedTextColour, const u16 selectedBackColour); 00074 00080 virtual void selectOption(const s32 index); 00081 00087 virtual void deselectOption(const s32 index); 00088 00094 virtual void selectAllOptions(); 00095 00100 virtual void deselectAllOptions(); 00101 00108 virtual const s32 getSelectedIndex() const; 00109 00116 virtual void setSelectedIndex(const s32 index); 00117 00122 virtual const ListBoxDataItem* getSelectedOption() const; 00123 00128 virtual inline void setAllowMultipleSelections(const bool allowMultipleSelections) { _options.setAllowMultipleSelections(allowMultipleSelections); }; 00129 00134 virtual inline const bool allowsMultipleSelections() const { return _options.allowsMultipleSelections(); }; 00135 00139 virtual void resizeCanvas(); 00140 00145 virtual inline const ListBoxDataItem* getOption(const s32 index) { 00146 return (const ListBoxDataItem*)_options.getItem(index); 00147 }; 00148 00152 virtual void sort(); 00153 00158 virtual inline const s32 getOptionCount() const { 00159 return _options.getItemCount(); 00160 }; 00161 00166 virtual const u16 getOptionHeight() const; 00167 00173 virtual inline void setSortInsertedItems(const bool sortInsertedItems) { 00174 _options.setSortInsertedItems(sortInsertedItems); 00175 }; 00176 00181 virtual void handleListDataChangedEvent(const ListDataEventArgs& e); 00182 00187 virtual void handleListDataSelectionChangedEvent(const ListDataEventArgs& e); 00188 00196 virtual void getPreferredDimensions(Rect& rect) const; 00197 00204 virtual bool isDoubleClick(s16 x, s16 y); 00205 00206 protected: 00207 ListData _options; 00208 u8 _optionPadding; 00209 s32 _lastSelectedIndex; 00217 virtual void drawContents(GraphicsPort* port); 00218 00225 virtual void drawBorder(GraphicsPort* port); 00226 00233 virtual void onClick(s16 x, s16 y); 00234 00240 virtual void onDoubleClick(s16 x, s16 y); 00241 00245 virtual ~ListBox(); 00246 00254 virtual void setOptionSelected(const s32 index, const bool selected); 00255 00259 inline ListBox(const ListBox& listBox) : ScrollingPanel(listBox) { }; 00260 }; 00261 } 00262 00263 #endif