aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2014-04-30 13:41:34 +0200
committerJoel Bodenmann <joel@unormal.org>2014-04-30 13:41:34 +0200
commit33c721c009465dd30d4e96e055a051480c567b57 (patch)
tree5a6744a79b7469d80bae474d4314b47d4cd6d44d /src/gwin
parent58cf2d2b35542166f1a4e50a83bcf28ff33574a5 (diff)
parenta394e2c35dde67241bea69409bcae9f46dcfc089 (diff)
downloaduGFX-33c721c009465dd30d4e96e055a051480c567b57.tar.gz
uGFX-33c721c009465dd30d4e96e055a051480c567b57.tar.bz2
uGFX-33c721c009465dd30d4e96e055a051480c567b57.zip
Merge branch 'master' into freertos
Diffstat (limited to 'src/gwin')
-rw-r--r--src/gwin/button.h2
-rw-r--r--src/gwin/checkbox.h2
-rw-r--r--src/gwin/class_gwin.h2
-rw-r--r--src/gwin/console.h2
-rw-r--r--src/gwin/graph.h2
-rw-r--r--src/gwin/gwidget.h2
-rw-r--r--src/gwin/image.h2
-rw-r--r--src/gwin/label.c45
-rw-r--r--src/gwin/label.h34
-rw-r--r--src/gwin/list.c22
-rw-r--r--src/gwin/list.h16
-rw-r--r--src/gwin/progressbar.c56
-rw-r--r--src/gwin/progressbar.h20
-rw-r--r--src/gwin/radio.h2
-rw-r--r--src/gwin/slider.h2
-rw-r--r--src/gwin/sys_defs.h2
-rw-r--r--src/gwin/sys_options.h2
17 files changed, 186 insertions, 29 deletions
diff --git a/src/gwin/button.h b/src/gwin/button.h
index d11764d6..dad0cc91 100644
--- a/src/gwin/button.h
+++ b/src/gwin/button.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/button.h
+ * @file src/gwin/button.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Button Button
diff --git a/src/gwin/checkbox.h b/src/gwin/checkbox.h
index 946f7e4a..529fc757 100644
--- a/src/gwin/checkbox.h
+++ b/src/gwin/checkbox.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/checkbox.h
+ * @file src/gwin/checkbox.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Checkbox Checkbox
diff --git a/src/gwin/class_gwin.h b/src/gwin/class_gwin.h
index ae5ac756..49fc6084 100644
--- a/src/gwin/class_gwin.h
+++ b/src/gwin/class_gwin.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/class_gwin.h
+ * @file src/gwin/class_gwin.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Internal Internal
diff --git a/src/gwin/console.h b/src/gwin/console.h
index 14bc7eb3..3fca6aa4 100644
--- a/src/gwin/console.h
+++ b/src/gwin/console.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/console.h
+ * @file src/gwin/console.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Console Console
diff --git a/src/gwin/graph.h b/src/gwin/graph.h
index 65a64126..69dbb617 100644
--- a/src/gwin/graph.h
+++ b/src/gwin/graph.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/graph.h
+ * @file src/gwin/graph.h
* @brief GWIN GRAPH module header file.
*
* @defgroup Graph Graph
diff --git a/src/gwin/gwidget.h b/src/gwin/gwidget.h
index 4eaf6c81..96832fe3 100644
--- a/src/gwin/gwidget.h
+++ b/src/gwin/gwidget.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/gwidget.h
+ * @file src/gwin/gwidget.h
* @brief GWIN Widgets header file.
*/
diff --git a/src/gwin/image.h b/src/gwin/image.h
index 66aba3d1..fdaabc92 100644
--- a/src/gwin/image.h
+++ b/src/gwin/image.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/image.h
+ * @file src/gwin/image.h
* @brief GWIN image widget header file.
*
* @defgroup Image Image
diff --git a/src/gwin/label.c b/src/gwin/label.c
index 97588a27..574dc8b7 100644
--- a/src/gwin/label.c
+++ b/src/gwin/label.c
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/label.h
+ * @file src/gwin/label.c
* @brief GWIN label widget header file.
*
* @defgroup Label Label
@@ -23,6 +23,7 @@
// macros to assist in data type conversions
#define gh2obj ((GLabelObject *)gh)
+#define gw2obj ((GLabelObject *)gw)
// flags for the GLabelObject
#define GLABEL_FLG_WAUTO (GWIN_FIRST_CONTROL_FLAG << 0)
@@ -57,10 +58,26 @@ static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) {
return;
}
- // render the text
- gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
- (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
- justifyLeft);
+ #if GWIN_LABEL_ATTRIBUTE
+ if (gw2obj->attr != 0) {
+ gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw2obj->attr, gw->g.font,
+ (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
+ justifyLeft);
+
+ gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
+ (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
+ justifyLeft);
+ } else {
+ gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
+ (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
+ justifyLeft);
+
+ }
+ #else
+ gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
+ (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
+ justifyLeft);
+ #endif
// render the border (if any)
if (gw->g.flags & GLABEL_FLG_BORDER)
@@ -124,6 +141,11 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit)
// no borders by default
flags &=~ GLABEL_FLG_BORDER;
+ #if GWIN_LABEL_ATTRIBUTE
+ widget->tab = 0;
+ widget->attr = 0;
+ #endif
+
widget->w.g.flags |= flags;
gwinSetVisible(&widget->w.g, pInit->g.show);
@@ -141,6 +163,19 @@ void gwinLabelSetBorder(GHandle gh, bool_t border) {
gh2obj->w.g.flags &=~ GLABEL_FLG_BORDER;
}
+#if GWIN_LABEL_ATTRIBUTE
+ void gwinLabelSetAttribute(GHandle gh, coord_t tab, const char* attr) {
+ // is it a valid handle?
+ if (gh->vmt != (gwinVMT *)&labelVMT)
+ return;
+
+ gh2obj->tab = tab;
+ gh2obj->attr = attr;
+
+ gwinRedraw(gh);
+ }
+#endif // GWIN_LABEL_ATTRIBUTE
+
#endif // GFX_USE_GWIN && GFX_NEED_LABEL
/** @} */
diff --git a/src/gwin/label.h b/src/gwin/label.h
index 3fe0f3d7..b7218193 100644
--- a/src/gwin/label.h
+++ b/src/gwin/label.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/label.h
+ * @file src/gwin/label.h
* @brief GWIN label widget header file.
*
* @defgroup Label Label
@@ -32,6 +32,11 @@
// An label window
typedef struct GLabelObject {
GWidgetObject w;
+
+ #if GWIN_LABEL_ATTRIBUTE
+ coord_t tab;
+ const char* attr;
+ #endif
} GLabelObject;
#ifdef __cplusplus
@@ -63,6 +68,33 @@ GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit);
*/
void gwinLabelSetBorder(GHandle gh, bool_t border);
+#if GWIN_LABEL_ATTRIBUTE || defined(__DOXYGEN__)
+ /**
+ * @brief Add an text attribute in front of the normal label text
+ * @details Often you want to display a text like this:
+ * Current IP: 192.168.1.42
+ * In that case, the actual IP will be variable, the text in front of it
+ * always remains the same. The static text is called the attribute and can be
+ * set using this function.
+ * Furthermore, the tab can be set in order to vertically align multiple labels.
+ * Please check out the website for further explanation, illustraions and usage
+ * examples.
+ *
+ * @note The attribute text is not copied into private memory and so it
+ * must be a constant string, not one allocated in a stack buffer.
+ * @note Use of this construct is discouraged. The appropriate way is to
+ * create two labels - one for the static text and one for the
+ * dynamic text.
+ *
+ * @param[in] gh The widget handle (must be a label handle)
+ * @param[in] tab The distance of the label text from the left widget edge
+ * @param[in] attr The attribute to be displayed
+ *
+ * @api
+ */
+ void gwinLabelSetAttribute(GHandle gh, coord_t tab, const char* attr);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gwin/list.c b/src/gwin/list.c
index 5b49811c..50c669f0 100644
--- a/src/gwin/list.c
+++ b/src/gwin/list.c
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/list.h
+ * @file src/gwin/list.c
* @brief GWIN list widget header file.
*
* @defgroup List List
@@ -41,6 +41,7 @@
#define GLIST_FLG_HASIMAGES (GWIN_FIRST_CONTROL_FLAG << 1)
#define GLIST_FLG_SCROLLALWAYS (GWIN_FIRST_CONTROL_FLAG << 2)
#define GLIST_FLG_SCROLLSMOOTH (GWIN_FIRST_CONTROL_FLAG << 3)
+#define GLIST_FLG_ENABLERENDER (GWIN_FIRST_CONTROL_FLAG << 4)
// Flags on a ListItem.
#define GLIST_FLG_SELECTED 0x0001
@@ -92,6 +93,11 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
coord_t sy;
#endif
+ // dont render if render has been disabled
+ if (!(gw->g.flags & GLIST_FLG_ENABLERENDER)) {
+ return;
+ }
+
ps = (gw->g.flags & GWIN_FLG_ENABLED) ? &gw->pstyle->enabled : &gw->pstyle->disabled;
iheight = gdispGetFontMetric(gw->g.font, fontHeight) + VERTICAL_PADDING;
x = 1;
@@ -401,12 +407,26 @@ GHandle gwinGListCreate(GDisplay *g, GListObject* gobj, GWidgetInit* pInit, bool
if (multiselect)
gobj->w.g.flags |= GLIST_FLG_MULTISELECT;
gobj->w.g.flags |= GLIST_FLG_SCROLLALWAYS;
+ gobj->w.g.flags |= GLIST_FLG_ENABLERENDER;
gwinSetVisible(&gobj->w.g, pInit->g.show);
return (GHandle)gobj;
}
+void gwinListEnableRender(GHandle gh, bool_t ena) {
+ // is it a valid handle?
+ if (gh->vmt != (gwinVMT *)&listVMT)
+ return;
+
+ if (ena) {
+ gh->flags |= GLIST_FLG_ENABLERENDER;
+ gwinRedraw(gh);
+ } else {
+ gh->flags &=~ GLIST_FLG_ENABLERENDER;
+ }
+}
+
void gwinListSetScroll(GHandle gh, scroll_t flag) {
// is it a valid handle?
if (gh->vmt != (gwinVMT *)&listVMT)
diff --git a/src/gwin/list.h b/src/gwin/list.h
index cfe6aeb2..2cc525a2 100644
--- a/src/gwin/list.h
+++ b/src/gwin/list.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/list.h
+ * @file src/gwin/list.h
* @brief GWIN list widget header file
*
* @defgroup List List
@@ -103,6 +103,20 @@ GHandle gwinGListCreate(GDisplay *g, GListObject *widget, GWidgetInit *pInit, bo
#define gwinListCreate(w, pInit, m) gwinGListCreate(GDISP, w, pInit, m)
/**
+ * @brief Enable or disable the rendering of the list
+ *
+ * @details Usually the list is being re-rendered when an item is added to the list. This can cause
+ * flickering and performance issues when many items are added at once. This can be prevented
+ * by temporarely disabling the render using this function.
+ *
+ * @param[in] gh The widget handle (must be a list handle)
+ * @param[in] ena TRUE or FALSE
+ *
+ * @api
+ */
+void gwinListEnableRender(GHandle gh, bool_t ena);
+
+/**
* @brief Change the behaviour of the scroll bar
*
* @note Current possible values: @p scrollAlways, @p scrollAuto and @p scrollSmooth
diff --git a/src/gwin/progressbar.c b/src/gwin/progressbar.c
index 37bad3c8..7c34607f 100644
--- a/src/gwin/progressbar.c
+++ b/src/gwin/progressbar.c
@@ -29,12 +29,21 @@ static void ResetDisplayPos(GProgressbarObject *gsw) {
gsw->dpos = ((gsw->w.g.width-1)*(gsw->pos-gsw->min))/(gsw->max-gsw->min);
}
+// We have to deinitialize the timer which auto updates the progressbar if any
+static void _destroy(GHandle gh) {
+ #if GFX_USE_GTIMER
+ gtimerDeinit( &((GProgressbarObject *)gh)->gt );
+ #endif
+
+ _gwidgetDestroy(gh);
+}
+
// The progressbar VMT table
static const gwidgetVMT progressbarVMT = {
{
"Progressbar", // The classname
sizeof(GProgressbarObject), // The object size
- _gwidgetDestroy, // The destroy routine
+ _destroy, // The destroy routine
_gwidgetRedraw, // The redraw routine
0, // The after-clear routine
},
@@ -197,6 +206,23 @@ void gwinProgressbarStart(GHandle gh, delaytime_t delay) {
gtimerInit(&(gsw->gt));
gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay);
+ // if this is not made, the progressbar will not start when the it's already visible
+ if (gsw->w.g.flags & GWIN_FLG_VISIBLE) {
+ gwinSetVisible(gh, FALSE);
+ gwinSetVisible(gh, TRUE);
+ }
+
+ #undef gsw
+}
+
+void gwinProgressbarStop(GHandle gh) {
+ #define gsw ((GProgressbarObject *)gh)
+
+ if (gh->vmt != (gwinVMT *)&progressbarVMT)
+ return;
+
+ gtimerStop(&(gsw->gt));
+
#undef gsw
}
@@ -206,33 +232,43 @@ void gwinProgressbarStart(GHandle gh, delaytime_t delay) {
void gwinProgressbarDraw_Std(GWidgetObject *gw, void *param) {
#define gsw ((GProgressbarObject *)gw)
+
const GColorSet * pcol;
(void) param;
if (gw->g.vmt != (gwinVMT *)&progressbarVMT)
return;
- if ((gw->g.flags & GWIN_FLG_ENABLED))
+ // disable the auto-update timer if any
+ #if GFX_USE_GTIMER
+ if (gtimerIsActive(&(gsw->gt)) && !(gw->g.flags & GWIN_FLG_ENABLED)) {
+ gtimerStop(&(gsw->gt));
+ }
+ #endif
+
+ // get the colors right
+ if ((gw->g.flags & GWIN_FLG_ENABLED))
pcol = &gw->pstyle->pressed;
else
pcol = &gw->pstyle->disabled;
- if (gw->g.width < gw->g.height) { // Vertical progressbar
+ // Vertical progressbar
+ if (gw->g.width < gw->g.height) {
if (gsw->dpos != gw->g.height-1)
- gdispGFillArea(gw->g.display, gw->g.x, gw->g.y+gsw->dpos, gw->g.width, gw->g.height - gsw->dpos, pcol->progress); // Active Area
+ gdispGFillArea(gw->g.display, gw->g.x, gw->g.y+gsw->dpos, gw->g.width, gw->g.height - gsw->dpos, pcol->progress); // Active Area
if (gsw->dpos != 0)
- gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gsw->dpos, gw->pstyle->enabled.progress); // Inactive area
- gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge); // Edge
- gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gsw->dpos, gw->g.x+gw->g.width-1, gw->g.y+gsw->dpos, pcol->edge); // Thumb
+ gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gsw->dpos, gw->pstyle->enabled.progress); // Inactive area
+ gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge); // Edge
+ gdispGDrawLine(gw->g.display, gw->g.x, gw->g.y+gsw->dpos, gw->g.x+gw->g.width-1, gw->g.y+gsw->dpos, pcol->edge); // Thumb
// Horizontal progressbar
} else {
if (gsw->dpos != gw->g.width-1)
gdispGFillArea(gw->g.display, gw->g.x+gsw->dpos, gw->g.y, gw->g.width-gsw->dpos, gw->g.height, gw->pstyle->enabled.progress); // Inactive area
if (gsw->dpos != 0)
- gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gsw->dpos, gw->g.height, pcol->progress); // Active Area
- gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge); // Edge
- gdispGDrawLine(gw->g.display, gw->g.x+gsw->dpos, gw->g.y, gw->g.x+gsw->dpos, gw->g.y+gw->g.height-1, pcol->edge); // Thumb
+ gdispGFillArea(gw->g.display, gw->g.x, gw->g.y, gsw->dpos, gw->g.height, pcol->progress); // Active Area
+ gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, pcol->edge); // Edge
+ gdispGDrawLine(gw->g.display, gw->g.x+gsw->dpos, gw->g.y, gw->g.x+gsw->dpos, gw->g.y+gw->g.height-1, pcol->edge); // Thumb
}
gdispGDrawStringBox(gw->g.display, gw->g.x+1, gw->g.y+1, gw->g.width-2, gw->g.height-2, gw->text, gw->g.font, pcol->text, justifyCenter);
diff --git a/src/gwin/progressbar.h b/src/gwin/progressbar.h
index c9efe46b..fcf76b12 100644
--- a/src/gwin/progressbar.h
+++ b/src/gwin/progressbar.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/progressbar.h
+ * @file src/gwin/progressbar.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Progressbar Progressbar
@@ -138,6 +138,15 @@ void gwinProgressbarDecrement(GHandle gh);
*/
#define gwinProgressbarGetPosition(gh) (((GProgressbarObject *)(gh))->pos)
+ /**
+ * @brief Reset the progressbar to the minimum position
+ *
+ * @param[in] gh The window handle (must be a progressbar window)
+ *
+ * @api
+ */
+#define gwinProgressbarReset(gh) gwinProgressbarSetPosition(gh, ((GProgressbarObject *)(gh))->min)
+
/**
* @brief Automatically increments the progress bar
*
@@ -156,6 +165,15 @@ void gwinProgressbarDecrement(GHandle gh);
void gwinProgressbarStart(GHandle gh, delaytime_t delay);
/**
+ * @brief Stop the timer which is started by @p gwinProgressbarStart()
+ *
+ * @param[in] gh The window handle (must be a progressbar window)
+ *
+ * @api
+ */
+void gwinProgressbarStop(GHandle gh);
+
+/**
* @brief Some custom progressbar drawing routines
* @details These function may be passed to @p gwinSetCustomDraw() to get different progressbar drawing styles
*
diff --git a/src/gwin/radio.h b/src/gwin/radio.h
index 3ee2918f..f2bd7f35 100644
--- a/src/gwin/radio.h
+++ b/src/gwin/radio.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/radio.h
+ * @file src/gwin/radio.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup RadioButton RadioButton
diff --git a/src/gwin/slider.h b/src/gwin/slider.h
index 8f87745c..8c5bd9ca 100644
--- a/src/gwin/slider.h
+++ b/src/gwin/slider.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/slider.h
+ * @file src/gwin/slider.h
* @brief GWIN Graphic window subsystem header file.
*
* @defgroup Slider Slider
diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h
index 10b5b564..ac2c98c7 100644
--- a/src/gwin/sys_defs.h
+++ b/src/gwin/sys_defs.h
@@ -439,6 +439,8 @@ extern "C" {
*
* @param[in] gh The window
*
+ * @return GWIN_NORMAL, GWIN_MAXIMIZE or GWIN_MINIMIZE
+ *
* @api
*/
GWindowMinMax gwinGetMinMax(GHandle gh);
diff --git a/src/gwin/sys_options.h b/src/gwin/sys_options.h
index e7bb93b4..656e0e3f 100644
--- a/src/gwin/sys_options.h
+++ b/src/gwin/sys_options.h
@@ -6,7 +6,7 @@
*/
/**
- * @file include/gwin/sys_options.h
+ * @file src/gwin/sys_options.h
* @brief GWIN sub-system options header file.
*
* @addtogroup GWIN