aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2013-10-23 16:26:34 +0200
committerJoel Bodenmann <joel@unormal.org>2013-10-23 16:26:34 +0200
commit1244fd9e8593eaa84c537ea7749a7c4493bf1513 (patch)
treeb03e03ae37fe889235cc4cf041c547d2d0ae6c77
parent2e64bddee588c4a3ee7ba89e7257b8828b399cc4 (diff)
downloaduGFX-1244fd9e8593eaa84c537ea7749a7c4493bf1513.tar.gz
uGFX-1244fd9e8593eaa84c537ea7749a7c4493bf1513.tar.bz2
uGFX-1244fd9e8593eaa84c537ea7749a7c4493bf1513.zip
Added gwinListSetScroll()
-rw-r--r--include/gwin/list.h19
-rw-r--r--releases.txt2
-rw-r--r--src/gwin/list.c20
3 files changed, 40 insertions, 1 deletions
diff --git a/include/gwin/list.h b/include/gwin/list.h
index 05433e87..cba5b137 100644
--- a/include/gwin/list.h
+++ b/include/gwin/list.h
@@ -56,6 +56,13 @@ typedef struct GListObject {
gfxQueueASync list_head; // The list of items
} GListObject;
+/**
+ * @brief Enum to change the behaviour of the scroll area
+ *
+ * @note This might be used with @p gwinListSetScroll()
+ */
+typedef enum scroll_t { scrollAlways, scrollAuto } scroll_t;
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -86,6 +93,18 @@ extern "C" {
GHandle gwinListCreate(GListObject *widget, GWidgetInit *pInit, bool_t multiselect);
/**
+ * @brief Change the behaviour of the scroll area
+ *
+ * @note Current possible values: @p scrollAlways and @p scrollAuto
+ *
+ * @param[in] gh The widget handle (must be a list handle)
+ * @param[in] flag The behaviour to be set
+ *
+ * @api
+ */
+void gwinListSetScroll(GHandle gh, scroll_t flag);
+
+/**
* @brief Add an item to the list
*
* @note The ID you get returned is not static. If items get removed from the list, the list items get
diff --git a/releases.txt b/releases.txt
index e8301b41..20e34b4d 100644
--- a/releases.txt
+++ b/releases.txt
@@ -13,6 +13,8 @@ FEATURE: SSD1306 driver by user goeck
FEATURE: ST7565 driver by user sam0737
FEATURE: ED060SC4 driver by user jpa-
FIX: SSD1289 area filling bug fix by user samofab
+FEATURE: Added gwinListGetSelectedText()
+FEATURE: Added gwinListSetScroll()
*** changes after 1.7 ***
diff --git a/src/gwin/list.c b/src/gwin/list.c
index cf0bebc4..fe903c16 100644
--- a/src/gwin/list.c
+++ b/src/gwin/list.c
@@ -37,6 +37,7 @@
// Flags for the GListObject
#define GLIST_FLG_MULTISELECT (GWIN_FIRST_CONTROL_FLAG << 0)
#define GLIST_FLG_HASIMAGES (GWIN_FIRST_CONTROL_FLAG << 1)
+#define GLIST_FLG_SCROLLALWAYS (GWIN_FIRST_CONTROL_FLAG << 2)
// Flags on a ListItem.
#define GLIST_FLG_SELECTED 0x0001
@@ -93,7 +94,7 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
x = 1;
// the scroll area
- if (gw2obj->cnt > (gw->g.height-2) / iheight) {
+ if (gw2obj->cnt > (gw->g.height-2) / iheight || gw->g.flags & GLIST_FLG_SCROLLALWAYS) {
iwidth = gw->g.width - (SCROLLWIDTH+3);
gdispFillArea(gw->g.x+iwidth+2, gw->g.y+1, SCROLLWIDTH, gw->g.height-2, gdispBlendColor(ps->fill, gw->pstyle->background, 128));
gdispDrawLine(gw->g.x+iwidth+1, gw->g.y+1, gw->g.x+iwidth+1, gw->g.y+gw->g.height-2, ps->edge);
@@ -327,12 +328,29 @@ GHandle gwinListCreate(GListObject* gobj, GWidgetInit* pInit, bool_t multiselect
gobj->top = 0;
if (multiselect)
gobj->w.g.flags |= GLIST_FLG_MULTISELECT;
+ gobj->w.g.flags |= GLIST_FLG_SCROLLALWAYS;
gwinSetVisible(&gobj->w.g, pInit->g.show);
return (GHandle)gobj;
}
+void gwinListSetScroll(GHandle gh, scroll_t flag) {
+ // is it a valid handle?
+ if (gh->vmt != (gwinVMT *)&listVMT)
+ return 0;
+
+ switch (flag) {
+ case scrollAlways:
+ ((GListObject*)gh)->w.g.flags |= GLIST_FLG_SCROLLALWAYS;
+ break;
+
+ case scrollAuto:
+ ((GListObject*)gh)->w.g.flags &=~ GLIST_FLG_SCROLLALWAYS;
+ break;
+ }
+}
+
int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) {
ListItem *newItem;