00001 #ifndef _SCROLLING_LISTBOX_H_
00002 #define _SCROLLING_LISTBOX_H_
00003
00004 #include "gadget.h"
00005 #include "listbox.h"
00006 #include "gadgeteventhandler.h"
00007 #include "listdata.h"
00008 #include "listboxdataitem.h"
00009 #include "gadgetstyle.h"
00010 #include "listboxbase.h"
00011
00012 namespace WoopsiUI {
00013
00014 class ScrollbarVertical;
00015
00021 class ScrollingListBox : public ListBoxBase, public Gadget, public GadgetEventHandler {
00022 public:
00023
00035 ScrollingListBox(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
00059 virtual void addOption(const WoopsiString& text, const u32 value, const u16 normalTextColour, const u16 normalBackColour, const u16 selectedTextColour, const u16 selectedBackColour);
00060
00065 virtual void removeOption(const s32 index);
00066
00070 virtual void removeAllOptions();
00071
00077 virtual inline void selectOption(const s32 index) {
00078 _listbox->selectOption(index);
00079 };
00080
00086 virtual inline void deselectOption(const s32 index) {
00087 _listbox->deselectOption(index);
00088 };
00089
00094 virtual inline void selectAllOptions() {
00095 _listbox->selectAllOptions();
00096 };
00097
00102 virtual inline void deselectAllOptions() {
00103 _listbox->deselectAllOptions();
00104 };
00105
00111 virtual inline const s32 getSelectedIndex() const {
00112 return _listbox->getSelectedIndex();
00113 };
00114
00121 virtual inline void setSelectedIndex(const s32 index) {
00122 _listbox->setSelectedIndex(index);
00123 };
00124
00129 virtual inline const ListBoxDataItem* getSelectedOption() const {
00130 return _listbox->getSelectedOption();
00131 };
00132
00137 virtual inline void setAllowMultipleSelections(const bool allowMultipleSelections) {
00138 _listbox->setAllowMultipleSelections(allowMultipleSelections);
00139 };
00140
00145 virtual inline const bool allowsMultipleSelections() const {
00146 return _listbox->allowsMultipleSelections();
00147 };
00148
00152 virtual inline void resizeCanvas() {
00153 _listbox->resizeCanvas();
00154 };
00155
00160 virtual inline const ListBoxDataItem* getOption(const s32 index) {
00161 return _listbox->getOption(index);
00162 };
00163
00168 virtual inline const ListBoxDataItem* getOption(const s32 index) const {
00169 return _listbox->getOption(index);
00170 };
00171
00175 virtual inline void sort() {
00176 _listbox->sort();
00177 };
00178
00183 virtual inline const s32 getOptionCount() const {
00184 return _listbox->getOptionCount();
00185 };
00186
00191 virtual inline const u16 getOptionHeight() const {
00192 return _listbox->getOptionHeight();
00193 };
00194
00199 virtual void handleValueChangeEvent(const GadgetEventArgs& e);
00200
00205 virtual void handleActionEvent(const GadgetEventArgs& e);
00206
00211 virtual void handleScrollEvent(const GadgetEventArgs& e);
00212
00217 virtual void handleClickEvent(const GadgetEventArgs& e);
00218
00223 virtual void handleDoubleClickEvent(const GadgetEventArgs& e);
00224
00230 virtual void handleReleaseEvent(const GadgetEventArgs& e);
00231
00237 virtual void handleReleaseOutsideEvent(const GadgetEventArgs& e);
00238
00243 virtual void setFont(FontBase* font);
00244
00249 virtual inline void setSortInsertedItems(const bool sortInsertedItems) { _listbox->setSortInsertedItems(sortInsertedItems); };
00250
00258 virtual void getPreferredDimensions(Rect& rect) const;
00259
00260 protected:
00261 ListBox* _listbox;
00262 ScrollbarVertical* _scrollbar;
00263 u8 _scrollbarWidth;
00271 virtual void drawContents(GraphicsPort* port);
00272
00278 virtual void onResize(u16 width, u16 height);
00279
00283 virtual inline ~ScrollingListBox() { };
00284
00288 inline ScrollingListBox(const ScrollingListBox& scrollingListBox) : Gadget(scrollingListBox) { };
00289 };
00290 }
00291
00292 #endif