Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: app_emwin1 app_emwin2_pos lpc4088_ebb_gui_emwin
EwCheckBox.h
00001 00002 #ifndef EWCHECKBOX_H 00003 #define EWCHECKBOX_H 00004 00005 #include "EwPainter.h" 00006 #include "EwWindow.h" 00007 #include "EwFunctionPointer.h" 00008 00009 #include "CHECKBOX.h" 00010 00011 enum ewCheckBoxColorIndex_t { 00012 CheckBoxColorIndexDisabled = CHECKBOX_CI_DISABLED, 00013 CheckBoxColorIndexEnabled = CHECKBOX_CI_ENABLED, 00014 }; 00015 00016 enum ewCheckBoxBitmapIndex_t { 00017 CheckBoxBitmapInactiveUnchecked = CHECKBOX_BI_INACTIV_UNCHECKED, 00018 CheckBoxBitmapActiveUnchecked = CHECKBOX_BI_ACTIV_UNCHECKED, 00019 CheckBoxBitmapInactiveChecked = CHECKBOX_BI_INACTIV_CHECKED, 00020 CheckBoxBitmapActiveChecked = CHECKBOX_BI_ACTIV_CHECKED, 00021 CheckBoxBitmapInactive3State = CHECKBOX_BI_INACTIV_3STATE, 00022 CheckBoxBitmapActive3State = CHECKBOX_BI_ACTIV_3STATE 00023 }; 00024 00025 enum ewCheckBoxState_t { 00026 CheckBoxStateUnchecked = 0, 00027 CheckBoxStateChecked, 00028 CheckBoxStateTristate 00029 }; 00030 00031 /** 00032 * This is wrapper class for the emwin CHECKBOX interface. 00033 */ 00034 class EwCheckBox : public EwWindow { 00035 public: 00036 00037 EwCheckBox(EwWindow* parent = 0); 00038 EwCheckBox(int x, int y, int width, int height, EwWindow* parent = 0); 00039 00040 00041 00042 00043 ewCheckBoxState_t getState(); 00044 void setState(ewCheckBoxState_t state); 00045 00046 void setTristate(bool on = true); 00047 bool isTristate(); 00048 00049 void setText(const char* text); 00050 void getText(char* pBuf, int bufSz); 00051 00052 void setBackgroundColor(ewColor_t c); 00053 void setBoxBackgroundColor(ewColor_t c, ewCheckBoxColorIndex_t idx); 00054 void setFont(const ewFont_t* pFont); 00055 00056 void setTextAlign(ewTextAlign_t align); 00057 void setTextColor(ewColor_t c); 00058 00059 void setFocusColor(ewColor_t c); 00060 00061 void setImage(ewBitmap_t* pBitmap, ewCheckBoxBitmapIndex_t idx); 00062 void setSpacing(int32_t spacing); 00063 00064 /** 00065 * Register a member function that will called when the checkbox 00066 * state has changed 00067 * 00068 * @param tptr pointer to the object to call the member function on 00069 * @param mptr pointer to the member function to be called 00070 */ 00071 template<typename T> 00072 void setChangedListener(T* tptr, void (T::*mptr)(EwWindow* w)) { 00073 if((mptr != NULL) && (tptr != NULL)) { 00074 _changedListener.attach(tptr, mptr); 00075 } 00076 } 00077 00078 /** 00079 * Register a function that will called when the checkbox 00080 * state has changed 00081 * 00082 * @param fptr A pointer to a void function that will be called 00083 * when the checkbox state has changed 00084 */ 00085 void setChangedListener(void (*fptr)(EwWindow* w)); 00086 00087 00088 static ewColor_t getDefaultBackgroundColor(); 00089 static void setDefaultBackgroundColor(ewColor_t c); 00090 static const ewFont_t* getDefaultFont(); 00091 static void setDefaultFont(const ewFont_t* pFont); 00092 static ewColor_t getDefaultTextColor(); 00093 static void setDefaultTextColor(ewColor_t c); 00094 static void setDefaultFocusColor(ewColor_t c); 00095 00096 static int32_t getDefaultSpacing(); 00097 static void setDefaultSpacing(int32_t spacing); 00098 00099 static void setDefaultImage(ewBitmap_t* pBitmap, ewCheckBoxBitmapIndex_t idx); 00100 00101 00102 private: 00103 00104 00105 bool _isTristate; 00106 EwFunctionPointer _changedListener; 00107 00108 void init(int x, int y, int width, int height, EwWindow* parent); 00109 void handleStateChanged(); 00110 00111 static void _callback(WM_MESSAGE* pMsg, EwWindow* w); 00112 00113 00114 }; 00115 00116 #endif
Generated on Tue Jul 12 2022 19:57:49 by
