From d4e0ce8b70d58e1e39cf58d681486b4d8657820b Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Mon, 20 May 2013 07:01:20 +0200 Subject: added gwin enabled parameter and implemented button enable/disable functions --- include/gwin/button.h | 33 ++++++++++++++++++++++++++++++++- include/gwin/gwin.h | 1 + 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/gwin/button.h b/include/gwin/button.h index b96cb83e..bcf9be04 100644 --- a/include/gwin/button.h +++ b/include/gwin/button.h @@ -63,7 +63,7 @@ typedef enum GButtonState_e { GBTN_UP, GBTN_DOWN } GButtonState; -typedef void (*GButtonDrawFunction)(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); +typedef void (*GButtonDrawFunction)(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); // A button window typedef struct GButtonObject_t { @@ -145,6 +145,16 @@ void gwinSetButtonText(GHandle gh, const char *txt, bool_t useAlloc); */ void gwinButtonDraw(GHandle gh); +/** + * @brief Enable or disable a button + * + * @param[in] gh The window handle (must be a button window) + * @param[in] enabled Enable or disable the button + * + * @api + */ +void gwinButtonSetEnabled(GHandle gh, bool_t enabled); + /** * @brief Set the callback routine to perform a custom button drawing. * @@ -156,6 +166,27 @@ void gwinButtonDraw(GHandle gh); */ void gwinSetButtonCustom(GHandle gh, GButtonDrawFunction fn, void *param); +/** + * @brief Enable a button + * + * @api + */ +#define gwinEnableButton(gh) gwinButtonSetEnabled( ((GButtonObject *)(gh)), TRUE) + +/** + * @brief Disable a button + * + * @api + */ +#define gwinDisableButton(gh) gwinButtonSetEnabled( ((GButtonObject *)(gh)), FALSE) + +/** + * @brief Get the state of a button + * + * @param[in] gh The window handle (must be a button window) + * + * @api + */ #define gwinGetButtonState(gh) (((GButtonObject *)(gh))->state) /** diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h index 43095643..c7b20008 100644 --- a/include/gwin/gwin.h +++ b/include/gwin/gwin.h @@ -45,6 +45,7 @@ typedef struct GWindowObject_t { coord_t x, y; // Screen relative position coord_t width, height; // Dimensions of this window color_t color, bgcolor; // Current drawing colors + bool_t enabled; // Enabled/Disabled state #if GDISP_NEED_TEXT font_t font; // Current font #endif -- cgit v1.2.3