Foundation classes for a basic GUI implementing simple widgets and events. (Fork for custom changes.)
Fork of SimpleGUI by
Dialogs/OKCancelDialog.h@20:ef07d42ea062, 2016-10-18 (annotated)
- Committer:
- elh
- Date:
- Tue Oct 18 19:43:15 2016 +0000
- Revision:
- 20:ef07d42ea062
- Parent:
- 16:e9a771ecfdbe
Initialize Textwidgets _text to NULL preventing crash if widget is draw until a text was set.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
duncanFrance | 14:e6515b19f5a0 | 1 | #ifndef SIMPLEGUI_OK_CANCEL_DIALOG_H |
duncanFrance | 14:e6515b19f5a0 | 2 | #define SIMPLEGUI_OK_CANCEL_DIALOG_H |
duncanFrance | 14:e6515b19f5a0 | 3 | #include "ContainerWidget.h" |
duncanFrance | 14:e6515b19f5a0 | 4 | /** |
duncanFrance | 14:e6515b19f5a0 | 5 | * A Dialog takes over the whole screen and offers some sort of control |
duncanFrance | 14:e6515b19f5a0 | 6 | * together with apply and cancel buttons |
duncanFrance | 14:e6515b19f5a0 | 7 | **/ |
duncanFrance | 14:e6515b19f5a0 | 8 | class OKCancelDialog : public ContainerWidget |
duncanFrance | 14:e6515b19f5a0 | 9 | { |
duncanFrance | 14:e6515b19f5a0 | 10 | public: |
duncanFrance | 14:e6515b19f5a0 | 11 | |
duncanFrance | 14:e6515b19f5a0 | 12 | OKCancelDialog(GraphicsContext *context); |
duncanFrance | 14:e6515b19f5a0 | 13 | |
duncanFrance | 15:e69fd74d42e4 | 14 | void onOK(void(* fn)(Event e)) { |
duncanFrance | 15:e69fd74d42e4 | 15 | _onOK.attach(fn); |
duncanFrance | 15:e69fd74d42e4 | 16 | } |
duncanFrance | 15:e69fd74d42e4 | 17 | |
duncanFrance | 15:e69fd74d42e4 | 18 | void onCancel(void(* fn)(Event e)) { |
duncanFrance | 15:e69fd74d42e4 | 19 | _onCancel.attach(fn); |
duncanFrance | 15:e69fd74d42e4 | 20 | } |
duncanFrance | 15:e69fd74d42e4 | 21 | |
duncanFrance | 14:e6515b19f5a0 | 22 | template<typename T> |
duncanFrance | 14:e6515b19f5a0 | 23 | void onOK(T* tptr, void (T::*mptr)(Event e)) { |
duncanFrance | 16:e9a771ecfdbe | 24 | _onOK.attach(tptr, mptr); |
duncanFrance | 14:e6515b19f5a0 | 25 | } |
duncanFrance | 14:e6515b19f5a0 | 26 | |
duncanFrance | 14:e6515b19f5a0 | 27 | template<typename T> |
duncanFrance | 14:e6515b19f5a0 | 28 | void onCancel(T* tptr, void (T::*mptr)(Event e)) { |
duncanFrance | 16:e9a771ecfdbe | 29 | _onCancel.attach(tptr, mptr); |
duncanFrance | 14:e6515b19f5a0 | 30 | } |
duncanFrance | 14:e6515b19f5a0 | 31 | |
duncanFrance | 14:e6515b19f5a0 | 32 | private: |
duncanFrance | 14:e6515b19f5a0 | 33 | |
duncanFrance | 14:e6515b19f5a0 | 34 | FunctionPointerArg1<void,Event> _onOK; |
duncanFrance | 14:e6515b19f5a0 | 35 | FunctionPointerArg1<void,Event> _onCancel; |
duncanFrance | 14:e6515b19f5a0 | 36 | |
duncanFrance | 14:e6515b19f5a0 | 37 | void _handleOK(Event e); |
duncanFrance | 14:e6515b19f5a0 | 38 | void _handleCancel(Event e); |
duncanFrance | 14:e6515b19f5a0 | 39 | |
duncanFrance | 14:e6515b19f5a0 | 40 | |
duncanFrance | 14:e6515b19f5a0 | 41 | }; |
duncanFrance | 14:e6515b19f5a0 | 42 | |
duncanFrance | 14:e6515b19f5a0 | 43 | #endif |