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 From 92883c795ee27ededc68b7ee89bfa314987598b3 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Mon, 20 May 2013 16:04:38 +0200 Subject: button fix --- include/gwin/button.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/gwin/button.h b/include/gwin/button.h index bcf9be04..7108cb83 100644 --- a/include/gwin/button.h +++ b/include/gwin/button.h @@ -244,19 +244,19 @@ void gwinSetButtonCustom(GHandle gh, GButtonDrawFunction fn, void *param); * @api * @{ */ -void gwinButtonDraw_3D(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); -void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); +void gwinButtonDraw_3D(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); +void gwinButtonDraw_Square(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); #if GDISP_NEED_ARC || defined(__DOXYGEN__) - void gwinButtonDraw_Rounded(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); + void gwinButtonDraw_Rounded(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); #endif #if GDISP_NEED_ELLIPSE || defined(__DOXYGEN__) - void gwinButtonDraw_Ellipse(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); + void gwinButtonDraw_Ellipse(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); #endif #if GDISP_NEED_CONVEX_POLYGON || defined(__DOXYGEN__) - void gwinButtonDraw_ArrowUp(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); - void gwinButtonDraw_ArrowDown(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); - void gwinButtonDraw_ArrowLeft(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); - void gwinButtonDraw_ArrowRight(GHandle gh, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); + void gwinButtonDraw_ArrowUp(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); + void gwinButtonDraw_ArrowDown(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); + void gwinButtonDraw_ArrowLeft(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); + void gwinButtonDraw_ArrowRight(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param); #endif /** @} */ -- cgit v1.2.3 From 757b28531f944a01edf3d64bf9608cde8ffeffba Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Mon, 20 May 2013 16:18:10 +0200 Subject: added enable and disable APIs to high level GWIN code --- include/gwin/gwin.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h index c7b20008..d1192bc7 100644 --- a/include/gwin/gwin.h +++ b/include/gwin/gwin.h @@ -87,6 +87,15 @@ GHandle gwinCreateWindow(GWindowObject *gw, coord_t x, coord_t y, coord_t width, */ void gwinDestroyWindow(GHandle gh); +/** + * @brief Enable or disable a widget (of any type). + * + * @param[in] gh The window handle + * + * @api + */ +void gwinSetEnabled(GHandle gh, bool_t enabled); + /** * @brief Get the X coordinate of the window * @details Returns the X coordinate of the origin of the window. @@ -138,6 +147,20 @@ void gwinDestroyWindow(GHandle gh); */ #define gwinSetBgColor(gh, bgclr) (gh)->bgcolor = (bgclr) +/** + * @brief Enable a window of any type + * + * @param[in] gh The window handle + */ +#define gwinEnable(gh) gwinSetEnabled(gh, TRUE) + +/** + * @brief Disable a window of any type + * + * @param[in] gh The window handle + */ +#define gwinDisable(gh) gwinSetEnabled(gh, FALSE) + /* Set up for text */ #if GDISP_NEED_TEXT || defined(__DOXYGEN__) -- cgit v1.2.3 From fefdd42d7d2bd0231b391c30b8edb4caba5b9b85 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Mon, 20 May 2013 16:43:40 +0200 Subject: doxygen fix --- include/gwin/button.h | 1 + include/gwin/gwin.h | 1 + 2 files changed, 2 insertions(+) (limited to 'include') diff --git a/include/gwin/button.h b/include/gwin/button.h index 7108cb83..ed74a80d 100644 --- a/include/gwin/button.h +++ b/include/gwin/button.h @@ -228,6 +228,7 @@ void gwinSetButtonCustom(GHandle gh, GButtonDrawFunction fn, void *param); * @details These routines are called to draw the standard button styles. * * @param[in] gh The button handle + * @param[in] enabled Is the button currently enabled or disabled * @param[in] isdown Is the button currently down (depressed) * @param[in] txt The text to be display inside the button * @param[in] pstyle The current drawing style for the state we are in diff --git a/include/gwin/gwin.h b/include/gwin/gwin.h index d1192bc7..710c86ba 100644 --- a/include/gwin/gwin.h +++ b/include/gwin/gwin.h @@ -91,6 +91,7 @@ void gwinDestroyWindow(GHandle gh); * @brief Enable or disable a widget (of any type). * * @param[in] gh The window handle + * @param[in] enabled Enable or disable the widget * * @api */ -- cgit v1.2.3 From 8d5fa39dd9b1f7f4016841e69b9e9b9e3772b2f5 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Mon, 20 May 2013 19:15:20 +0200 Subject: docs --- include/gdisp/fonts.h | 123 +++++++++++++++++++++++++------------------------- include/gdisp/image.h | 3 +- 2 files changed, 64 insertions(+), 62 deletions(-) (limited to 'include') diff --git a/include/gdisp/fonts.h b/include/gdisp/fonts.h index f4e6f5dd..ca175b77 100644 --- a/include/gdisp/fonts.h +++ b/include/gdisp/fonts.h @@ -4,64 +4,65 @@ * * http://chibios-gfx.com/license.html */ - -/** - * @file include/gdisp/fonts.h - * @brief GDISP internal font definitions. - * @details This is not generally needed by an application. It is used - * by the low level drivers that need to understand a font. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_FONTS_H -#define _GDISP_FONTS_H - -/* Don't test against GFX_USE_GDISP as we may want to use this in other non-GDISP utilities. */ - -/** - * @brief The type of a font column. - * @note Set by defining @p GDISP_MAX_FNT_HEIGHT appropriately. - */ -#if GDISP_MAX_FONT_HEIGHT == 16 - typedef uint16_t fontcolumn_t; -#elif GDISP_MAX_FONT_HEIGHT == 32 - typedef uint32_t fontcolumn_t; -#else - #error "GDISP: GDISP_MAX_FONT_HEIGHT must be either 16 or 32" -#endif - -/** - * @brief Internal font structure. - * @note This structure is followed by: - * 1. An array of character widths (uint8_t) - * 2. An array of column data offsets (relative to the font structure) - * 3. Each characters array of column data (fontcolumn_t) - * Each sub-structure must be padded to a multiple of 8 bytes - * to allow the tables to work across many different compilers. - */ -struct font { - const char * name; - uint8_t height; - uint8_t charPadding; - uint8_t lineSpacing; - uint8_t descenderHeight; - uint8_t minWidth; - uint8_t maxWidth; - char minChar; - char maxChar; - uint8_t xscale; - uint8_t yscale; - const uint8_t *widthTable; - const uint16_t *offsetTable; - const fontcolumn_t *dataTable; -}; - -#define _getCharWidth(f,c) (((c) < (f)->minChar || (c) > (f)->maxChar) ? 0 : (f)->widthTable[(c) - (f)->minChar]) -#define _getCharOffset(f,c) ((f)->offsetTable[(c) - (f)->minChar]) -#define _getCharData(f,c) (&(f)->dataTable[_getCharOffset(f, c)]) - -#endif /* _GDISP_FONTS_H */ -/** @} */ - + +/** + * @file include/gdisp/fonts.h + * @brief GDISP internal font definitions. + * @details This is not generally needed by an application. It is used + * by the low level drivers that need to understand a font. + * + * @addtogroup GDISP + * + * @{ + */ + +#ifndef _GDISP_FONTS_H +#define _GDISP_FONTS_H + +/* Don't test against GFX_USE_GDISP as we may want to use this in other non-GDISP utilities. */ + +/** + * @brief The type of a font column. + * @note Set by defining @p GDISP_MAX_FNT_HEIGHT appropriately. + */ +#if GDISP_MAX_FONT_HEIGHT == 16 + typedef uint16_t fontcolumn_t; +#elif GDISP_MAX_FONT_HEIGHT == 32 + typedef uint32_t fontcolumn_t; +#else + #error "GDISP: GDISP_MAX_FONT_HEIGHT must be either 16 or 32" +#endif + +/** + * @brief Internal font structure. + * @note This structure is followed by: + * 1. An array of character widths (uint8_t) + * 2. An array of column data offsets (relative to the font structure) + * 3. Each characters array of column data (fontcolumn_t) + * Each sub-structure must be padded to a multiple of 8 bytes + * to allow the tables to work across many different compilers. + */ +struct font { + const char * name; + uint8_t height; + uint8_t charPadding; + uint8_t lineSpacing; + uint8_t descenderHeight; + uint8_t minWidth; + uint8_t maxWidth; + char minChar; + char maxChar; + uint8_t xscale; + uint8_t yscale; + const uint8_t *widthTable; + const uint16_t *offsetTable; + const fontcolumn_t *dataTable; +}; + +#define _getCharWidth(f,c) (((c) < (f)->minChar || (c) > (f)->maxChar) ? 0 : (f)->widthTable[(c) - (f)->minChar]) +#define _getCharOffset(f,c) ((f)->offsetTable[(c) - (f)->minChar]) +#define _getCharData(f,c) (&(f)->dataTable[_getCharOffset(f, c)]) + +#endif /* _GDISP_FONTS_H */ +/** @} */ + diff --git a/include/gdisp/image.h b/include/gdisp/image.h index d0339e0e..f169a0f1 100644 --- a/include/gdisp/image.h +++ b/include/gdisp/image.h @@ -9,7 +9,8 @@ * @file include/gdisp/image.h * @brief GDISP image header file. * - * @addtogroup GDISP + * @defgroup Image Image + * @ingroup GDISP * @{ */ -- cgit v1.2.3