Wrapper classes for the emwin library
Dependents: app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin
EwCheckBox.h@1:0b16165ada7c, 2014-04-14 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Apr 14 08:38:33 2014 +0000
- Revision:
- 1:0b16165ada7c
- Parent:
- 0:316c181e9b65
Initialize uninitialized touchState in EwGui
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:316c181e9b65 | 1 | |
embeddedartists | 0:316c181e9b65 | 2 | #ifndef EWCHECKBOX_H |
embeddedartists | 0:316c181e9b65 | 3 | #define EWCHECKBOX_H |
embeddedartists | 0:316c181e9b65 | 4 | |
embeddedartists | 0:316c181e9b65 | 5 | #include "EwPainter.h" |
embeddedartists | 0:316c181e9b65 | 6 | #include "EwWindow.h" |
embeddedartists | 0:316c181e9b65 | 7 | #include "EwFunctionPointer.h" |
embeddedartists | 0:316c181e9b65 | 8 | |
embeddedartists | 0:316c181e9b65 | 9 | #include "CHECKBOX.h" |
embeddedartists | 0:316c181e9b65 | 10 | |
embeddedartists | 0:316c181e9b65 | 11 | enum ewCheckBoxColorIndex_t { |
embeddedartists | 0:316c181e9b65 | 12 | CheckBoxColorIndexDisabled = CHECKBOX_CI_DISABLED, |
embeddedartists | 0:316c181e9b65 | 13 | CheckBoxColorIndexEnabled = CHECKBOX_CI_ENABLED, |
embeddedartists | 0:316c181e9b65 | 14 | }; |
embeddedartists | 0:316c181e9b65 | 15 | |
embeddedartists | 0:316c181e9b65 | 16 | enum ewCheckBoxBitmapIndex_t { |
embeddedartists | 0:316c181e9b65 | 17 | CheckBoxBitmapInactiveUnchecked = CHECKBOX_BI_INACTIV_UNCHECKED, |
embeddedartists | 0:316c181e9b65 | 18 | CheckBoxBitmapActiveUnchecked = CHECKBOX_BI_ACTIV_UNCHECKED, |
embeddedartists | 0:316c181e9b65 | 19 | CheckBoxBitmapInactiveChecked = CHECKBOX_BI_INACTIV_CHECKED, |
embeddedartists | 0:316c181e9b65 | 20 | CheckBoxBitmapActiveChecked = CHECKBOX_BI_ACTIV_CHECKED, |
embeddedartists | 0:316c181e9b65 | 21 | CheckBoxBitmapInactive3State = CHECKBOX_BI_INACTIV_3STATE, |
embeddedartists | 0:316c181e9b65 | 22 | CheckBoxBitmapActive3State = CHECKBOX_BI_ACTIV_3STATE |
embeddedartists | 0:316c181e9b65 | 23 | }; |
embeddedartists | 0:316c181e9b65 | 24 | |
embeddedartists | 0:316c181e9b65 | 25 | enum ewCheckBoxState_t { |
embeddedartists | 0:316c181e9b65 | 26 | CheckBoxStateUnchecked = 0, |
embeddedartists | 0:316c181e9b65 | 27 | CheckBoxStateChecked, |
embeddedartists | 0:316c181e9b65 | 28 | CheckBoxStateTristate |
embeddedartists | 0:316c181e9b65 | 29 | }; |
embeddedartists | 0:316c181e9b65 | 30 | |
embeddedartists | 0:316c181e9b65 | 31 | /** |
embeddedartists | 0:316c181e9b65 | 32 | * This is wrapper class for the emwin CHECKBOX interface. |
embeddedartists | 0:316c181e9b65 | 33 | */ |
embeddedartists | 0:316c181e9b65 | 34 | class EwCheckBox : public EwWindow { |
embeddedartists | 0:316c181e9b65 | 35 | public: |
embeddedartists | 0:316c181e9b65 | 36 | |
embeddedartists | 0:316c181e9b65 | 37 | EwCheckBox(EwWindow* parent = 0); |
embeddedartists | 0:316c181e9b65 | 38 | EwCheckBox(int x, int y, int width, int height, EwWindow* parent = 0); |
embeddedartists | 0:316c181e9b65 | 39 | |
embeddedartists | 0:316c181e9b65 | 40 | |
embeddedartists | 0:316c181e9b65 | 41 | |
embeddedartists | 0:316c181e9b65 | 42 | |
embeddedartists | 0:316c181e9b65 | 43 | ewCheckBoxState_t getState(); |
embeddedartists | 0:316c181e9b65 | 44 | void setState(ewCheckBoxState_t state); |
embeddedartists | 0:316c181e9b65 | 45 | |
embeddedartists | 0:316c181e9b65 | 46 | void setTristate(bool on = true); |
embeddedartists | 0:316c181e9b65 | 47 | bool isTristate(); |
embeddedartists | 0:316c181e9b65 | 48 | |
embeddedartists | 0:316c181e9b65 | 49 | void setText(const char* text); |
embeddedartists | 0:316c181e9b65 | 50 | void getText(char* pBuf, int bufSz); |
embeddedartists | 0:316c181e9b65 | 51 | |
embeddedartists | 0:316c181e9b65 | 52 | void setBackgroundColor(ewColor_t c); |
embeddedartists | 0:316c181e9b65 | 53 | void setBoxBackgroundColor(ewColor_t c, ewCheckBoxColorIndex_t idx); |
embeddedartists | 0:316c181e9b65 | 54 | void setFont(const ewFont_t* pFont); |
embeddedartists | 0:316c181e9b65 | 55 | |
embeddedartists | 0:316c181e9b65 | 56 | void setTextAlign(ewTextAlign_t align); |
embeddedartists | 0:316c181e9b65 | 57 | void setTextColor(ewColor_t c); |
embeddedartists | 0:316c181e9b65 | 58 | |
embeddedartists | 0:316c181e9b65 | 59 | void setFocusColor(ewColor_t c); |
embeddedartists | 0:316c181e9b65 | 60 | |
embeddedartists | 0:316c181e9b65 | 61 | void setImage(ewBitmap_t* pBitmap, ewCheckBoxBitmapIndex_t idx); |
embeddedartists | 0:316c181e9b65 | 62 | void setSpacing(int32_t spacing); |
embeddedartists | 0:316c181e9b65 | 63 | |
embeddedartists | 0:316c181e9b65 | 64 | /** |
embeddedartists | 0:316c181e9b65 | 65 | * Register a member function that will called when the checkbox |
embeddedartists | 0:316c181e9b65 | 66 | * state has changed |
embeddedartists | 0:316c181e9b65 | 67 | * |
embeddedartists | 0:316c181e9b65 | 68 | * @param tptr pointer to the object to call the member function on |
embeddedartists | 0:316c181e9b65 | 69 | * @param mptr pointer to the member function to be called |
embeddedartists | 0:316c181e9b65 | 70 | */ |
embeddedartists | 0:316c181e9b65 | 71 | template<typename T> |
embeddedartists | 0:316c181e9b65 | 72 | void setChangedListener(T* tptr, void (T::*mptr)(EwWindow* w)) { |
embeddedartists | 0:316c181e9b65 | 73 | if((mptr != NULL) && (tptr != NULL)) { |
embeddedartists | 0:316c181e9b65 | 74 | _changedListener.attach(tptr, mptr); |
embeddedartists | 0:316c181e9b65 | 75 | } |
embeddedartists | 0:316c181e9b65 | 76 | } |
embeddedartists | 0:316c181e9b65 | 77 | |
embeddedartists | 0:316c181e9b65 | 78 | /** |
embeddedartists | 0:316c181e9b65 | 79 | * Register a function that will called when the checkbox |
embeddedartists | 0:316c181e9b65 | 80 | * state has changed |
embeddedartists | 0:316c181e9b65 | 81 | * |
embeddedartists | 0:316c181e9b65 | 82 | * @param fptr A pointer to a void function that will be called |
embeddedartists | 0:316c181e9b65 | 83 | * when the checkbox state has changed |
embeddedartists | 0:316c181e9b65 | 84 | */ |
embeddedartists | 0:316c181e9b65 | 85 | void setChangedListener(void (*fptr)(EwWindow* w)); |
embeddedartists | 0:316c181e9b65 | 86 | |
embeddedartists | 0:316c181e9b65 | 87 | |
embeddedartists | 0:316c181e9b65 | 88 | static ewColor_t getDefaultBackgroundColor(); |
embeddedartists | 0:316c181e9b65 | 89 | static void setDefaultBackgroundColor(ewColor_t c); |
embeddedartists | 0:316c181e9b65 | 90 | static const ewFont_t* getDefaultFont(); |
embeddedartists | 0:316c181e9b65 | 91 | static void setDefaultFont(const ewFont_t* pFont); |
embeddedartists | 0:316c181e9b65 | 92 | static ewColor_t getDefaultTextColor(); |
embeddedartists | 0:316c181e9b65 | 93 | static void setDefaultTextColor(ewColor_t c); |
embeddedartists | 0:316c181e9b65 | 94 | static void setDefaultFocusColor(ewColor_t c); |
embeddedartists | 0:316c181e9b65 | 95 | |
embeddedartists | 0:316c181e9b65 | 96 | static int32_t getDefaultSpacing(); |
embeddedartists | 0:316c181e9b65 | 97 | static void setDefaultSpacing(int32_t spacing); |
embeddedartists | 0:316c181e9b65 | 98 | |
embeddedartists | 0:316c181e9b65 | 99 | static void setDefaultImage(ewBitmap_t* pBitmap, ewCheckBoxBitmapIndex_t idx); |
embeddedartists | 0:316c181e9b65 | 100 | |
embeddedartists | 0:316c181e9b65 | 101 | |
embeddedartists | 0:316c181e9b65 | 102 | private: |
embeddedartists | 0:316c181e9b65 | 103 | |
embeddedartists | 0:316c181e9b65 | 104 | |
embeddedartists | 0:316c181e9b65 | 105 | bool _isTristate; |
embeddedartists | 0:316c181e9b65 | 106 | EwFunctionPointer _changedListener; |
embeddedartists | 0:316c181e9b65 | 107 | |
embeddedartists | 0:316c181e9b65 | 108 | void init(int x, int y, int width, int height, EwWindow* parent); |
embeddedartists | 0:316c181e9b65 | 109 | void handleStateChanged(); |
embeddedartists | 0:316c181e9b65 | 110 | |
embeddedartists | 0:316c181e9b65 | 111 | static void _callback(WM_MESSAGE* pMsg, EwWindow* w); |
embeddedartists | 0:316c181e9b65 | 112 | |
embeddedartists | 0:316c181e9b65 | 113 | |
embeddedartists | 0:316c181e9b65 | 114 | }; |
embeddedartists | 0:316c181e9b65 | 115 | |
embeddedartists | 0:316c181e9b65 | 116 | #endif |