00001 #ifndef _LISTBOX_H_
00002 #define _LISTBOX_H_
00003
00004 #include "scrollingpanel.h"
00005 #include "listdataeventhandler.h"
00006 #include "listdata.h"
00007
00008 namespace WoopsiUI {
00009
00018 class ListBox : public ScrollingPanel, public ListDataEventHandler {
00019 public:
00020
00029 ListBox(s16 x, s16 y, u16 width, u16 height, FontBase* font = NULL);
00030
00036 virtual void addOption(const char* text, const u32 value);
00037
00042 virtual void removeOption(const s32 index);
00043
00047 virtual void removeAllOptions();
00048
00058 virtual void addOption(const char* text, const u32 value, const u16 normalTextColour, const u16 normalBackColour, const u16 selectedTextColour, const u16 selectedBackColour);
00059
00065 virtual void selectOption(const s32 index);
00066
00072 virtual void deselectOption(const s32 index);
00073
00078 virtual void selectAllOptions();
00079
00084 virtual void deselectAllOptions();
00085
00090 virtual void draw(Rect clipRect);
00091
00097 virtual const s32 getSelectedIndex() const;
00098
00105 virtual void setSelectedIndex(const s32 index);
00106
00111 virtual const ListData::ListDataItem* getSelectedOption() const;
00112
00119 virtual bool click(s16 x, s16 y);
00120
00127 virtual bool doubleClick(s16 x, s16 y);
00128
00134 virtual inline void setAllowMultipleSelections(const bool allowMultipleSelections) { _options.setAllowMultipleSelections(allowMultipleSelections); };
00135
00141 virtual inline const bool allowsMultipleSelections() const { return _options.allowsMultipleSelections(); };
00142
00147 virtual void resizeCanvas();
00148
00153 virtual inline ListData::ListDataItem* getOption(const s32 index) { return _options.getItem(index); };
00154
00158 virtual void sort();
00159
00164 virtual inline const s32 getOptionCount() const { return _options.getItemCount(); };
00165
00170 virtual const u16 getOptionHeight() const;
00171
00176 virtual inline void setSortInsertedItems(const bool sortInsertedItems) { _options.setSortInsertedItems(sortInsertedItems); };
00177
00182 virtual void handleListDataChangedEvent(const ListDataEventArgs& e);
00183
00188 virtual void handleListDataSelectionChangedEvent(const ListDataEventArgs& e);
00189
00190 protected:
00191 ListData _options;
00192 u8 _optionPadding;
00197 virtual ~ListBox();
00198
00206 virtual void setOptionSelected(const s32 index, const bool selected);
00207
00211 inline ListBox(const ListBox& listBox) : ScrollingPanel(listBox) { };
00212 };
00213 }
00214
00215 #endif