- Main Page
- Classes
- Files

- File List

# C:/Documents and Settings/Administrator/Desktop/woopsi-src-0.40/Woopsi/libwoopsi/include/listdata.h

    00001 #ifndef _LIST_DATA_H_
    00002 #define _LIST_DATA_H_
    00003
    00004 #include "woopsiarray.h"
    00005 #include "listdataeventhandler.h"
    00006
    00007 namespace WoopsiUI {
    00008
    00012         class ListData {
    00013         public:
    00014
    00018                 typedef struct {
    00019                         char* text;
    00020                         u32 value;
    00021                         u16 normalTextColour;
    00022                         u16 normalBackColour;
    00023                         u16 selectedTextColour;
    00024                         u16 selectedBackColour;
    00025                         bool selected;
    00026                 } ListDataItem;
    00027
    00031                 ListData();
    00032
    00036                 virtual ~ListData();
    00037
    00047                 virtual void addItem(const char* text, const u32 value, const u16 normalTextColour, const u16 normalBackColour, const u16 selectedTextColour, const u16 selectedBackColour);
    00048
    00053                 virtual void removeItem(const s32 index);
    00054
    00059                 virtual void selectItem(const s32 index);
    00060
    00065                 virtual void deselectItem(const s32 index);
    00066
    00070                 virtual void removeAllItems();
    00071
    00077                 virtual const s32 getSelectedIndex() const;
    00078
    00084                 virtual void setSelectedIndex(const s32 index);
    00085
    00090                 virtual const ListDataItem* getSelectedItem() const;
    00091
    00096                 virtual inline void setAllowMultipleSelections(const bool allowMultipleSelections) { _allowMultipleSelections = allowMultipleSelections; };
    00097
    00102                 virtual inline ListDataItem* getItem(const s32 index) { return _items[index]; };
    00103
    00107                 virtual void sort();
    00108
    00113                 virtual inline const s32 getItemCount() const {
    00114                         return _items.size();
    00115                 }
    00116
    00120                 virtual void selectAllItems();
    00121
    00125                 virtual void deselectAllItems();
    00126
    00133                 virtual void setItemSelected(const s32 index, const bool selected);
    00134
    00139                 virtual inline const bool allowsMultipleSelections() const { return _allowMultipleSelections; };
    00140
    00145                 virtual inline void setSortInsertedItems(const bool sortInsertedItems) { _sortInsertedItems = sortInsertedItems; };
    00146
    00151                 inline void addListDataEventHandler(ListDataEventHandler* eventHandler) {
    00152                         _listDataEventhandlers.push_back(eventHandler);
    00153                 }
    00154
    00159                 void removeListDataEventHandler(ListDataEventHandler* eventHandler);
    00160
    00161         protected:
    00162                 WoopsiArray<ListDataItem*> _items;
    00163                 WoopsiArray<ListDataEventHandler*> _listDataEventhandlers;
    00164                 bool _allowMultipleSelections;
    00165                 bool _sortInsertedItems;
    00172                 virtual void quickSort(const s32 start, const s32 end);
    00173
    00179                 virtual void swapItems(const s32 index1, const s32 index2);
    00180
    00187                 const s32 getInsertionIndex(const char* text) const;
    00188
    00192                 void raiseDataChangedEvent();
    00193
    00197                 void raiseSelectionChangedEvent();
    00198         };
    00199 }
    00200
    00201 #endif