el h / SimpleGUI

Fork of SimpleGUI by Duncan McIntyre

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SpinnerWidget.h Source File

SpinnerWidget.h

00001 #ifndef SIMPLEGUI_SPINNER_WIDGET_H
00002 #define SIMPLEGUI_SPINNER_WIDGET_H
00003 
00004 #include "BitmapWidget.h"
00005 #include "TextWidget.h"
00006 #include "ContainerWidget.h"
00007 #include "GUI.h"
00008 
00009 /**
00010 * A spinner widget shows up and down arrows to set a value
00011 * It automatically sizes itself to fit the screen dimensions when created
00012 **/
00013 class SpinnerWidget : public ContainerWidget
00014 {
00015 
00016 public:
00017 
00018     SpinnerWidget(GraphicsContext *context);
00019     
00020     TextWidget *getTextWidget();
00021 
00022     void setMin(float min);
00023     void setMax(float max);
00024     void setIncrement(float increment);
00025     void setValue(float value);
00026     void setFormat(const char* format);
00027 
00028     float getMin();
00029     float getMax();
00030     float getIncrement();
00031     float getValue();
00032     const char* getFormat();
00033 
00034     template<typename T>
00035     void onChange(T* tptr, void (T::*mptr)(Event e));
00036 
00037     // Overrides
00038     virtual void setSize(int width, int height);
00039 
00040 protected:
00041 
00042     BitmapWidget _upArrow;
00043     TextWidget _text;
00044     BitmapWidget _downArrow;
00045 
00046     float _min, _max, _increment, _value;
00047 
00048     const char* _format;
00049     char _buf[64];
00050 
00051     FunctionPointerArg1<void,Event> _onChange;
00052 
00053     virtual void _onUpClick(Event e);
00054     virtual void _onDownClick(Event e);
00055 
00056     /**
00057     * Overrides
00058     **/
00059     virtual void _dirty();
00060 };
00061 #endif