Woopsi 1.3
Nintendo DS Gui Framework
libwoopsi/include/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 
00073         virtual const s32 getSelectedIndex() const;
00074 
00080         virtual void setSelectedIndex(const s32 index);
00081 
00086         virtual const ListDataItem* getSelectedItem() const;
00087 
00092         virtual inline void setAllowMultipleSelections(const bool allowMultipleSelections) { _allowMultipleSelections = allowMultipleSelections; };
00093 
00098         virtual inline const ListDataItem* getItem(const s32 index) const { return _items[index]; };
00099 
00103         virtual void sort();
00104 
00109         virtual inline const s32 getItemCount() const { return _items.size(); };
00110 
00115         virtual void selectAllItems();
00116 
00120         virtual void deselectAllItems();
00121 
00128         virtual void setItemSelected(const s32 index, const bool selected);
00129 
00134         virtual inline const bool allowsMultipleSelections() const { return _allowMultipleSelections; };
00135 
00141         virtual inline void setSortInsertedItems(const bool sortInsertedItems) { _sortInsertedItems = sortInsertedItems; };
00142 
00147         inline void addListDataEventHandler(ListDataEventHandler* eventHandler) {
00148             _listDataEventhandlers.push_back(eventHandler);
00149         }
00150 
00155         void removeListDataEventHandler(ListDataEventHandler* eventHandler);
00156 
00157     protected:
00158         WoopsiArray<ListDataItem*> _items;                          
00159         WoopsiArray<ListDataEventHandler*> _listDataEventhandlers;  
00160         bool _allowMultipleSelections;                              
00161         bool _sortInsertedItems;                                    
00168         virtual void quickSort(const s32 start, const s32 end);
00169 
00175         virtual void swapItems(const s32 index1, const s32 index2);
00176 
00183         const s32 getSortedInsertionIndex(const ListDataItem* item) const;
00184 
00188         void raiseDataChangedEvent();
00189 
00193         void raiseSelectionChangedEvent();
00194     };
00195 }
00196 
00197 #endif
 All Classes Functions Variables Enumerations Enumerator