Woopsi 1.0
GUI Framework for Nintendo DS Homebrew

cyclebutton.h

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 
00065                 virtual const s32 getSelectedIndex() const;
00066 
00073                 virtual void setSelectedIndex(const s32 index);
00074 
00079                 virtual const ListDataItem* getSelectedOption() const;
00080 
00085                 inline const u32 getValue() const { return getSelectedOption()->getValue(); };
00086 
00091                 virtual inline const ListDataItem* getOption(const s32 index) {
00092                         return _options.getItem(index);
00093                 };
00094 
00098                 virtual void sort();
00099 
00104                 virtual inline const s32 getOptionCount() const {
00105                         return _options.getItemCount();
00106                 };
00107 
00113                 virtual inline void setSortInsertedItems(const bool sortInsertedItems) {
00114                         _options.setSortInsertedItems(sortInsertedItems);
00115                 };
00116 
00121                 virtual void handleListDataChangedEvent(const ListDataEventArgs& e);
00122 
00127                 virtual void handleListDataSelectionChangedEvent(const ListDataEventArgs& e);
00128 
00136                 virtual void getPreferredDimensions(Rect& rect) const;
00137 
00138         protected:
00139                 ListData _options;                                                      
00147                 virtual void drawContents(GraphicsPort* port);
00148 
00155                 virtual void drawBorder(GraphicsPort* port);
00156 
00161                 virtual void drawOutline(GraphicsPort* port);
00162 
00168                 virtual void onRelease(s16 x, s16 y);
00169                 
00175                 virtual void onReleaseOutside(s16 x, s16 y);
00176 
00183                 virtual inline void onResize(u16 width, u16 height) { };
00184 
00189                 virtual inline void calculateTextPosition() { };
00190 
00194                 virtual ~CycleButton() { };
00195 
00199                 inline CycleButton(const CycleButton& cycleButton) : Button(cycleButton) { };
00200         };
00201 }
00202 
00203 #endif