aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/modules/gadc/main.c4
-rw-r--r--demos/modules/gaudio/oscilloscope/main.c1
-rw-r--r--demos/modules/gwin/basic/main.c1
-rw-r--r--demos/modules/gwin/button/main.c4
-rw-r--r--demos/modules/gwin/checkbox/main.c4
-rw-r--r--demos/modules/gwin/console/main.c1
-rw-r--r--demos/modules/gwin/graph/main.c1
-rw-r--r--demos/modules/gwin/list/main.c4
-rw-r--r--demos/modules/gwin/progressbar/main.c4
-rw-r--r--demos/modules/gwin/radio/main.c4
-rw-r--r--demos/modules/gwin/slider/main.c4
-rw-r--r--demos/modules/gwin/widgets/main.c2
-rw-r--r--src/gwin/gwidget.c8
-rw-r--r--src/gwin/gwidget.h16
-rw-r--r--src/gwin/gwin.c8
-rw-r--r--src/gwin/sys_defs.h18
-rw-r--r--tools/touch_driver_test/main.c1
17 files changed, 65 insertions, 20 deletions
diff --git a/demos/modules/gadc/main.c b/demos/modules/gadc/main.c
index 7db14c82..ae508278 100644
--- a/demos/modules/gadc/main.c
+++ b/demos/modules/gadc/main.c
@@ -152,6 +152,8 @@ int main(void) {
gwinSetDefaultFont(font);
{
GWindowInit wi;
+
+ gwinClearInit(&wi);
wi.show = TRUE;
wi.x = wi.y = 0;
wi.width = swidth-SCOPE_CX;
@@ -184,6 +186,8 @@ int main(void) {
/* Set up the scope window in the top right on the screen */
{
GWindowInit wi;
+
+ gwinClearInit(&wi);
wi.show = TRUE;
wi.x = swidth-SCOPE_CX;
wi.y = 0;
diff --git a/demos/modules/gaudio/oscilloscope/main.c b/demos/modules/gaudio/oscilloscope/main.c
index 3636e8f9..b544016e 100644
--- a/demos/modules/gaudio/oscilloscope/main.c
+++ b/demos/modules/gaudio/oscilloscope/main.c
@@ -73,6 +73,7 @@ int main(void) {
{
GWindowInit wi;
+ gwinClearInit(&wi);
wi.show = TRUE;
wi.x = wi.y = 0;
wi.width = swidth; wi.height = sheight;
diff --git a/demos/modules/gwin/basic/main.c b/demos/modules/gwin/basic/main.c
index 4d8fa33c..fca150c9 100644
--- a/demos/modules/gwin/basic/main.c
+++ b/demos/modules/gwin/basic/main.c
@@ -43,6 +43,7 @@ int main(void) {
{
GWindowInit wi;
+ gwinClearInit(&wi);
wi.show = TRUE; wi.x = 20; wi.y = 10; wi.width = 200; wi.height = 150;
GW1 = gwinWindowCreate(0, &wi);
wi.show = TRUE; wi.x = 50; wi.y = 190; wi.width = 150; wi.height = 100;
diff --git a/demos/modules/gwin/button/main.c b/demos/modules/gwin/button/main.c
index 6349ca09..156e929e 100644
--- a/demos/modules/gwin/button/main.c
+++ b/demos/modules/gwin/button/main.c
@@ -36,9 +36,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
- wi.customDraw = 0;
- wi.customParam = 0;
- wi.customStyle = 0;
+ gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// Apply the button parameters
diff --git a/demos/modules/gwin/checkbox/main.c b/demos/modules/gwin/checkbox/main.c
index b6cef40b..2a2df2fb 100644
--- a/demos/modules/gwin/checkbox/main.c
+++ b/demos/modules/gwin/checkbox/main.c
@@ -36,9 +36,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
- wi.customDraw = 0;
- wi.customParam = 0;
- wi.customStyle = 0;
+ gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// Apply the checkbox parameters
diff --git a/demos/modules/gwin/console/main.c b/demos/modules/gwin/console/main.c
index 14f68cd4..0e9000b5 100644
--- a/demos/modules/gwin/console/main.c
+++ b/demos/modules/gwin/console/main.c
@@ -48,6 +48,7 @@ int main(void) {
{
GWindowInit wi;
+ gwinClearInit(&wi);
wi.show = TRUE;
wi.x = 0; wi.y = 0; wi.width = gdispGetWidth(); wi.height = gdispGetHeight()/2;
GW1 = gwinConsoleCreate(0, &wi);
diff --git a/demos/modules/gwin/graph/main.c b/demos/modules/gwin/graph/main.c
index 4dd67ae8..7a496fae 100644
--- a/demos/modules/gwin/graph/main.c
+++ b/demos/modules/gwin/graph/main.c
@@ -69,6 +69,7 @@ int main(void) {
{
GWindowInit wi;
+ gwinClearInit(&wi);
wi.show = TRUE;
wi.x = wi.y = 0;
wi.width = gdispGetWidth();
diff --git a/demos/modules/gwin/list/main.c b/demos/modules/gwin/list/main.c
index 3811c36f..6d469626 100644
--- a/demos/modules/gwin/list/main.c
+++ b/demos/modules/gwin/list/main.c
@@ -37,9 +37,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
- wi.customDraw = 0;
- wi.customParam = 0;
- wi.customStyle = 0;
+ gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// Create the label for the first list
diff --git a/demos/modules/gwin/progressbar/main.c b/demos/modules/gwin/progressbar/main.c
index 960a3293..6fb53c2e 100644
--- a/demos/modules/gwin/progressbar/main.c
+++ b/demos/modules/gwin/progressbar/main.c
@@ -5,9 +5,7 @@ GHandle ghProgressbar;
static void _createWidget(void) {
GWidgetInit wi;
- wi.customDraw = 0;
- wi.customParam = 0;
- wi.customStyle = 0;
+ gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
wi.g.y = 10; wi.g.x = 10; wi.g.width = 200; wi.g.height = 20; wi.text = "Progress 1";
diff --git a/demos/modules/gwin/radio/main.c b/demos/modules/gwin/radio/main.c
index a3c493c3..60bf206f 100644
--- a/demos/modules/gwin/radio/main.c
+++ b/demos/modules/gwin/radio/main.c
@@ -40,9 +40,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
- wi.customDraw = 0;
- wi.customParam = 0;
- wi.customStyle = 0;
+ gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// create Radio11
diff --git a/demos/modules/gwin/slider/main.c b/demos/modules/gwin/slider/main.c
index 0897f1f3..475f68cf 100644
--- a/demos/modules/gwin/slider/main.c
+++ b/demos/modules/gwin/slider/main.c
@@ -36,9 +36,7 @@ static void createWidgets(void) {
GWidgetInit wi;
// Apply some default values for GWIN
- wi.customDraw = 0;
- wi.customParam = 0;
- wi.customStyle = 0;
+ gwinWidgetClearInit(&wi);
wi.g.show = TRUE;
// create Slider1
diff --git a/demos/modules/gwin/widgets/main.c b/demos/modules/gwin/widgets/main.c
index 17f87d46..9742a027 100644
--- a/demos/modules/gwin/widgets/main.c
+++ b/demos/modules/gwin/widgets/main.c
@@ -113,7 +113,7 @@ static gdispImage imgYesNo;
static void createWidgets(void) {
GWidgetInit wi;
- wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0;
+ gwinWidgetClearInit(&wi);
// Create the Tabs
wi.g.show = TRUE; wi.customDraw = gwinRadioDraw_Tab;
diff --git a/src/gwin/gwidget.c b/src/gwin/gwidget.c
index 181b7425..c46520ea 100644
--- a/src/gwin/gwidget.c
+++ b/src/gwin/gwidget.c
@@ -297,6 +297,14 @@ void _gwidgetRedraw(GHandle gh) {
gw->fnDraw(gw, gw->fnParam);
}
+void gwinWidgetClearInit(GWidgetInit *pwi) {
+ char *p;
+ unsigned len;
+
+ for(p = (char *)pwi, len = sizeof(GWidgetInit); len; len--)
+ *p++ = 0;
+}
+
void gwinSetDefaultStyle(const GWidgetStyle *pstyle, bool_t updateAll) {
if (!pstyle)
pstyle = &BlackWidgetStyle;
diff --git a/src/gwin/gwidget.h b/src/gwin/gwidget.h
index 96832fe3..8373e2d0 100644
--- a/src/gwin/gwidget.h
+++ b/src/gwin/gwidget.h
@@ -78,6 +78,10 @@ typedef void (*CustomWidgetDrawFunction)(struct GWidgetObject *gw, void *param);
* @brief The structure to initialise a widget.
*
* @note Some widgets may have extra parameters.
+ * @note If you create this structure on the stack, you should always memset
+ * it to all zero's first in case a future version of the software
+ * add's extra fields. Alternatively you can use @p gwinWidgetClearInit()
+ * to clear it.
* @note The text element must be static string (not stack allocated). If you want to use
* a dynamic string (eg a stack allocated string) use NULL for this member and then call
* @p gwinSetText() with useAlloc set to TRUE.
@@ -127,6 +131,18 @@ extern "C" {
#endif
/**
+ * @brief Clear a GWidgetInit structure to all zero's
+ * @note This function is provided just to prevent problems
+ * on operating systems where using memset() causes issues
+ * in the users application.
+ *
+ * @param[in] pwi The GWidgetInit structure to clear
+ *
+ * @api
+ */
+void gwinWidgetClearInit(GWidgetInit *pwi);
+
+/**
* @brief Set the default style for widgets created hereafter.
*
* @param[in] pstyle The default style. Passing NULL uses the system compiled style.
diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c
index 54f42077..93c17f3a 100644
--- a/src/gwin/gwin.c
+++ b/src/gwin/gwin.c
@@ -149,6 +149,14 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit
* Routines that affect all windows
*-----------------------------------------------*/
+void gwinClearInit(GWindowInit *pwi) {
+ char *p;
+ unsigned len;
+
+ for(p = (char *)pwi, len = sizeof(GWindowInit); len; len--)
+ *p++ = 0;
+}
+
void gwinSetDefaultColor(color_t clr) {
defaultFgColor = clr;
}
diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h
index f4e1c2f7..fa5084a3 100644
--- a/src/gwin/sys_defs.h
+++ b/src/gwin/sys_defs.h
@@ -34,7 +34,7 @@
*/
typedef struct GWindowObject {
#if GWIN_NEED_WINDOWMANAGER
- // This MUST be the first member of the struct
+ // This MUST be the first member of the structure
gfxQueueASyncItem wmq; // @< The next window (for the window manager)
#endif
const struct gwinVMT *vmt; // @< The VMT for this GWIN
@@ -54,6 +54,10 @@ typedef struct GWindowObject {
*
* @note Some gwin's will need extra parameters.
* @note The dimensions and position may be changed to fit on the real screen.
+ * @note If you create this structure on the stack, you should always memset
+ * it to all zero's first in case a future version of the software
+ * add's extra fields. Alternatively you can use @p gwinClearInit()
+ * to clear it.
*
* @{
*/
@@ -103,6 +107,18 @@ extern "C" {
*-------------------------------------------------*/
/**
+ * @brief Clear a GWindowInit structure to all zero's
+ * @note This function is provided just to prevent problems
+ * on operating systems where using memset() causes issues
+ * in the users application.
+ *
+ * @param[in] pwi The GWindowInit structure to clear
+ *
+ * @api
+ */
+ void gwinClearInit(GWindowInit *pwi);
+
+ /**
* @brief Set the default foreground color for all new GWIN windows
*
* @param[in] clr The color to be set
diff --git a/tools/touch_driver_test/main.c b/tools/touch_driver_test/main.c
index adfafa0f..a8318edd 100644
--- a/tools/touch_driver_test/main.c
+++ b/tools/touch_driver_test/main.c
@@ -66,6 +66,7 @@ int main(void) {
{
GWindowInit wi;
+ gwinClearInit(&wi);
wi.show = TRUE; wi.x = 0; wi.y = bHeight; wi.width = swidth; wi.height = sheight-bHeight;
ghc = gwinConsoleCreate(&gc, &wi);
}