00001 #ifndef _CYCLE_BUTTON_H_ 00002 #define _CYCLE_BUTTON_H_ 00003 00004 #include <nds.h> 00005 #include "button.h" 00006 #include "listdataeventhandler.h" 00007 #include "listdata.h" 00008 #include "listdataitem.h" 00009 #include "gadgetstyle.h" 00010 #include "woopsistring.h" 00011 00012 namespace WoopsiUI { 00013 00018 class CycleButton : public Button, public ListDataEventHandler { 00019 public: 00020 00032 CycleButton(s16 x, s16 y, u16 width, u16 height, GadgetStyle* style = NULL); 00033 00039 void addOption(const WoopsiString& text, const u32 value); 00040 00045 virtual void removeOption(const s32 index); 00046 00050 virtual void removeAllOptions(); 00051 00057 virtual void selectOption(const s32 index); 00058 00064 virtual const s32 getSelectedIndex() const; 00065 00072 virtual void setSelectedIndex(const s32 index); 00073 00078 virtual const ListDataItem* getSelectedOption() const; 00079 00084 inline const u32 getValue() const { return getSelectedOption()->getValue(); }; 00085 00090 virtual inline const ListDataItem* getOption(const s32 index) { 00091 return _options.getItem(index); 00092 }; 00093 00097 virtual void sort(); 00098 00103 virtual inline const s32 getOptionCount() const { 00104 return _options.getItemCount(); 00105 }; 00106 00111 virtual inline void setSortInsertedItems(const bool sortInsertedItems) { 00112 _options.setSortInsertedItems(sortInsertedItems); 00113 }; 00114 00119 virtual void handleListDataChangedEvent(const ListDataEventArgs& e); 00120 00125 virtual void handleListDataSelectionChangedEvent(const ListDataEventArgs& e); 00126 00134 virtual void getPreferredDimensions(Rect& rect) const; 00135 00136 protected: 00137 ListData _options; 00145 virtual void drawContents(GraphicsPort* port); 00146 00153 virtual void drawBorder(GraphicsPort* port); 00154 00159 virtual void drawOutline(GraphicsPort* port); 00160 00166 virtual void onRelease(s16 x, s16 y); 00167 00173 virtual void onReleaseOutside(s16 x, s16 y); 00174 00181 virtual inline void onResize(u16 width, u16 height) { }; 00182 00186 virtual inline void calculateTextPosition() { }; 00187 00191 virtual ~CycleButton() { }; 00192 00196 inline CycleButton(const CycleButton& cycleButton) : Button(cycleButton) { }; 00197 }; 00198 } 00199 00200 #endif