Foundation classes for a basic GUI implementing simple widgets and events
Dependents: TouchScreenGUIDemo
Widgets/SpinnerWidget.h@12:63db16fea709, 2016-05-08 (annotated)
- Committer:
- duncanFrance
- Date:
- Sun May 08 14:42:08 2016 +0000
- Revision:
- 12:63db16fea709
- Parent:
- 11:b485561aa112
- Child:
- 13:6714534e7974
Update to handle dirty pixels and geometric change/damage
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
duncanFrance | 11:b485561aa112 | 1 | #ifndef SIMPLEGUI_SPINNER_WIDGET_H |
duncanFrance | 11:b485561aa112 | 2 | #define SIMPLEGUI_SPINNER_WIDGET_H |
duncanFrance | 11:b485561aa112 | 3 | |
duncanFrance | 11:b485561aa112 | 4 | #include "BitmapWidget.h" |
duncanFrance | 11:b485561aa112 | 5 | #include "TextWidget.h" |
duncanFrance | 11:b485561aa112 | 6 | #include "ContainerWidget.h" |
duncanFrance | 11:b485561aa112 | 7 | #include "GUI.h" |
duncanFrance | 11:b485561aa112 | 8 | |
duncanFrance | 11:b485561aa112 | 9 | /** |
duncanFrance | 11:b485561aa112 | 10 | * A spinner widget shows up and down arrows to set a value |
duncanFrance | 11:b485561aa112 | 11 | **/ |
duncanFrance | 12:63db16fea709 | 12 | class SpinnerWidget : public ContainerWidget |
duncanFrance | 12:63db16fea709 | 13 | { |
duncanFrance | 12:63db16fea709 | 14 | |
duncanFrance | 11:b485561aa112 | 15 | public: |
duncanFrance | 11:b485561aa112 | 16 | |
duncanFrance | 12:63db16fea709 | 17 | SpinnerWidget(GraphicsContext *context); |
duncanFrance | 11:b485561aa112 | 18 | |
duncanFrance | 11:b485561aa112 | 19 | void setMin(float min); |
duncanFrance | 11:b485561aa112 | 20 | void setMax(float max); |
duncanFrance | 11:b485561aa112 | 21 | void setIncrement(float increment); |
duncanFrance | 11:b485561aa112 | 22 | void setValue(float value); |
duncanFrance | 12:63db16fea709 | 23 | void setFormat(const char* format); |
duncanFrance | 12:63db16fea709 | 24 | |
duncanFrance | 12:63db16fea709 | 25 | float getMin(); |
duncanFrance | 12:63db16fea709 | 26 | float getMax(); |
duncanFrance | 12:63db16fea709 | 27 | float getIncrement(); |
duncanFrance | 12:63db16fea709 | 28 | float getValue(); |
duncanFrance | 12:63db16fea709 | 29 | const char* getFormat(); |
duncanFrance | 12:63db16fea709 | 30 | |
duncanFrance | 11:b485561aa112 | 31 | template<typename T> |
duncanFrance | 12:63db16fea709 | 32 | void onChange(T* tptr, void (T::*mptr)(Event e)); |
duncanFrance | 12:63db16fea709 | 33 | |
duncanFrance | 12:63db16fea709 | 34 | // Overrides |
duncanFrance | 12:63db16fea709 | 35 | virtual void setSize(int width, int height); |
duncanFrance | 11:b485561aa112 | 36 | |
duncanFrance | 11:b485561aa112 | 37 | protected: |
duncanFrance | 11:b485561aa112 | 38 | |
duncanFrance | 12:63db16fea709 | 39 | BitmapWidget _upArrow; |
duncanFrance | 12:63db16fea709 | 40 | TextWidget _text; |
duncanFrance | 12:63db16fea709 | 41 | BitmapWidget _downArrow; |
duncanFrance | 11:b485561aa112 | 42 | |
duncanFrance | 12:63db16fea709 | 43 | float _min, _max, _increment, _value; |
duncanFrance | 12:63db16fea709 | 44 | |
duncanFrance | 12:63db16fea709 | 45 | const char* _format; |
duncanFrance | 12:63db16fea709 | 46 | char _buf[64]; |
duncanFrance | 11:b485561aa112 | 47 | |
duncanFrance | 12:63db16fea709 | 48 | FunctionPointerArg1<void,Event> _onChange; |
duncanFrance | 12:63db16fea709 | 49 | |
duncanFrance | 12:63db16fea709 | 50 | virtual void _onUpClick(Event e); |
duncanFrance | 12:63db16fea709 | 51 | virtual void _onDownClick(Event e); |
duncanFrance | 12:63db16fea709 | 52 | |
duncanFrance | 12:63db16fea709 | 53 | /** |
duncanFrance | 12:63db16fea709 | 54 | * Overrides |
duncanFrance | 12:63db16fea709 | 55 | **/ |
duncanFrance | 12:63db16fea709 | 56 | virtual void _dirty(); |
duncanFrance | 11:b485561aa112 | 57 | }; |
duncanFrance | 11:b485561aa112 | 58 | #endif |