- Main Page
- Classes
- Files

- File List

# listdata.h

    00001 #ifndef _LIST_BASE_H_
    00002 #define _LIST_BASE_H_
    00003
    00004 #include "woopsiarray.h"
    00005 #include "listdataeventhandler.h"
    00006 #include "listdataitem.h"
    00007 #include "woopsistring.h"
    00008
    00009 namespace WoopsiUI {
    00010
    00016         class ListData {
    00017         public:
    00018
    00022                 ListData();
    00023
    00027                 virtual ~ListData();
    00028
    00034                 virtual void addItem(const WoopsiString& text, const u32 value);
    00035
    00041                 virtual void addItem(ListDataItem* item);
    00042
    00043
    00048                 virtual void removeItem(const s32 index);
    00049
    00054                 virtual void selectItem(const s32 index);
    00055
    00060                 virtual void deselectItem(const s32 index);
    00061
    00065                 virtual void removeAllItems();
    00066
    00072                 virtual const s32 getSelectedIndex() const;
    00073
    00079                 virtual void setSelectedIndex(const s32 index);
    00080
    00085                 virtual const ListDataItem* getSelectedItem() const;
    00086
    00091                 virtual inline void setAllowMultipleSelections(const bool allowMultipleSelections) { _allowMultipleSelections = allowMultipleSelections; };
    00092
    00097                 virtual inline const ListDataItem* getItem(const s32 index) const { return _items[index]; };
    00098
    00102                 virtual void sort();
    00103
    00108                 virtual inline const s32 getItemCount() const { return _items.size(); };
    00109
    00113                 virtual void selectAllItems();
    00114
    00118                 virtual void deselectAllItems();
    00119
    00126                 virtual void setItemSelected(const s32 index, const bool selected);
    00127
    00132                 virtual inline const bool allowsMultipleSelections() const { return _allowMultipleSelections; };
    00133
    00138                 virtual inline void setSortInsertedItems(const bool sortInsertedItems) { _sortInsertedItems = sortInsertedItems; };
    00139
    00144                 inline void addListDataEventHandler(ListDataEventHandler* eventHandler) {
    00145                         _listDataEventhandlers.push_back(eventHandler);
    00146                 }
    00147
    00152                 void removeListDataEventHandler(ListDataEventHandler* eventHandler);
    00153
    00154         protected:
    00155                 WoopsiArray<ListDataItem*> _items;
    00156                 WoopsiArray<ListDataEventHandler*> _listDataEventhandlers;
    00157                 bool _allowMultipleSelections;
    00158                 bool _sortInsertedItems;
    00165                 virtual void quickSort(const s32 start, const s32 end);
    00166
    00172                 virtual void swapItems(const s32 index1, const s32 index2);
    00173
    00179                 const s32 getSortedInsertionIndex(const ListDataItem* item) const;
    00180
    00184                 void raiseDataChangedEvent();
    00185
    00189                 void raiseSelectionChangedEvent();
    00190         };
    00191 }
    00192
    00193 #endif