Added gwinListSetScroll()

This commit is contained in:
Joel Bodenmann 2013-10-23 16:26:34 +02:00
parent 2e64bddee5
commit 1244fd9e85
3 changed files with 40 additions and 1 deletions

View File

@ -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
@ -85,6 +92,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
*

View File

@ -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 ***

View File

@ -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;