- Main Page
- Classes
- Files

- File List

# listbox.h

    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
    00070                 virtual void addOption(const WoopsiString& text, const u32 value, const u16 normalTextColour, const u16 normalBackColour, const u16 selectedTextColour, const u16 selectedBackColour);
    00071
    00077                 virtual void selectOption(const s32 index);
    00078
    00084                 virtual void deselectOption(const s32 index);
    00085
    00090                 virtual void selectAllOptions();
    00091
    00096                 virtual void deselectAllOptions();
    00097
    00103                 virtual const s32 getSelectedIndex() const;
    00104
    00111                 virtual void setSelectedIndex(const s32 index);
    00112
    00117                 virtual const ListBoxDataItem* getSelectedOption() const;
    00118
    00123                 virtual inline void setAllowMultipleSelections(const bool allowMultipleSelections) { _options.setAllowMultipleSelections(allowMultipleSelections); };
    00124
    00129                 virtual inline const bool allowsMultipleSelections() const { return _options.allowsMultipleSelections(); };
    00130
    00134                 virtual void resizeCanvas();
    00135
    00140                 virtual inline const ListBoxDataItem* getOption(const s32 index) {
    00141                         return (const ListBoxDataItem*)_options.getItem(index);
    00142                 };
    00143
    00147                 virtual void sort();
    00148
    00153                 virtual inline const s32 getOptionCount() const {
    00154                         return _options.getItemCount();
    00155                 };
    00156
    00161                 virtual const u16 getOptionHeight() const;
    00162
    00167                 virtual inline void setSortInsertedItems(const bool sortInsertedItems) {
    00168                         _options.setSortInsertedItems(sortInsertedItems);
    00169                 };
    00170
    00175                 virtual void handleListDataChangedEvent(const ListDataEventArgs& e);
    00176
    00181                 virtual void handleListDataSelectionChangedEvent(const ListDataEventArgs& e);
    00182
    00190                 virtual void getPreferredDimensions(Rect& rect) const;
    00191
    00198                 virtual bool isDoubleClick(s16 x, s16 y);
    00199
    00200         protected:
    00201                 ListData _options;
    00202                 u8 _optionPadding;
    00203                 s32 _lastSelectedIndex;
    00211                 virtual void drawContents(GraphicsPort* port);
    00212
    00219                 virtual void drawBorder(GraphicsPort* port);
    00220
    00227                 virtual void onClick(s16 x, s16 y);
    00228
    00234                 virtual void onDoubleClick(s16 x, s16 y);
    00235
    00239                 virtual ~ListBox();
    00240
    00248                 virtual void setOptionSelected(const s32 index, const bool selected);
    00249
    00253                 inline ListBox(const ListBox& listBox) : ScrollingPanel(listBox) { };
    00254         };
    00255 }
    00256
    00257 #endif