From b0b35396395c3eadc5a656df995a17b266c4b374 Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 1 Aug 2013 14:54:25 +1000 Subject: [PATCH] Update GWIN list. Now supports item and page scrolling. A few bugs fixed. --- include/gwin/list.h | 3 +- src/gwin/list.c | 412 +++++++++++++++++++++++--------------------- 2 files changed, 213 insertions(+), 202 deletions(-) diff --git a/include/gwin/list.h b/include/gwin/list.h index d28206d9..99f5f532 100644 --- a/include/gwin/list.h +++ b/include/gwin/list.h @@ -52,6 +52,7 @@ typedef struct GListObject { #endif int cnt; // Number of items currently in the list (quicker than counting each time) + int top; // The element at the top of the visible list area gfxQueueASync list_head; // The list of items } GListObject; @@ -111,7 +112,7 @@ int gwinListAddItem(GHandle gh, const char* item, bool_t useAlloc); * * @api */ -char* gwinListItemGetText(GHandle gh, int item); +const char* gwinListItemGetText(GHandle gh, int item); /** * @brief Get the ID of an item with a given name diff --git a/src/gwin/list.c b/src/gwin/list.c index 2509260c..a938150f 100644 --- a/src/gwin/list.c +++ b/src/gwin/list.c @@ -23,11 +23,15 @@ #include // user for the default drawing routine -#define BORDER 3 // the border from the the text to the frame -#define BORDER_SCROLL 20 // the border from the scroll buttons to the frame +#define SCROLLWIDTH 16 // the border from the scroll buttons to the frame #define ARROW 10 // arrow side length +#define TEXTGAP 1 // extra vertical padding for text -#define widget(gh) ((GListObject *)gh) +#define gh2obj ((GListObject *)gh) +#define gw2obj ((GListObject *)gw) +#define qi2li ((ListItem *)qi) +#define qix2li ((ListItem *)qix) +#define ple ((GEventGWinList *)pe) #define GLIST_FLG_MULTISELECT (GWIN_FIRST_CONTROL_FLAG << 0) #define GLIST_FLG_HASIMAGES (GWIN_FIRST_CONTROL_FLAG << 1) @@ -40,67 +44,13 @@ typedef struct ListItem { uint16_t param; // A parameter the user can specify himself const char* text; #if GWIN_LIST_IMAGES - gdispImage* pimg; + gdispImage* pimg; #endif } ListItem; -// select the next item in the list -static int _selectDown(GWidgetObject *gw) { - #define gcw ((GListObject *)gw) - - gfxQueueASyncItem *qi; - uint16_t i; - - for (i = 0, qi = gfxQueueASyncPeek(&gcw->list_head); qi; qi = gfxQueueASyncNext(qi), i++) { - if (((ListItem*)qi)->flags & GLIST_FLG_SELECTED && i < gcw->cnt - 1) { - ((ListItem*)qi)->flags &=~ GLIST_FLG_SELECTED; - qi = gfxQueueASyncNext(qi); - ((ListItem*)qi)->flags |= GLIST_FLG_SELECTED; - - break; - } - } - - _gwidgetRedraw((GHandle)gw); - - return ++i; - - #undef gcw -} - -// select the previous item in the list -static int _selectUp(GWidgetObject *gw) { - #define gcw ((GListObject *)gw) - - gfxQueueASyncItem *qi; - gfxQueueASyncItem *qi2; - uint16_t i; - - qi = gfxQueueASyncPeek(&gcw->list_head); - qi2 = qi; - - for (i = 0; qi2; qi2 = gfxQueueASyncNext(qi), i++) { - if (((ListItem*)qi2)->flags & GLIST_FLG_SELECTED) { - ((ListItem*)qi2)->flags &=~ GLIST_FLG_SELECTED; - ((ListItem*)qi)->flags |= GLIST_FLG_SELECTED; - - break; - } - - qi = qi2; - } - - _gwidgetRedraw((GHandle)gw); - - return --i; - - #undef gcw -} - static void sendListEvent(GWidgetObject *gw, int item) { GSourceListener* psl; GEvent* pe; - #define pse ((GEventGWinList *)pe) // Trigger a GWIN list event psl = 0; @@ -109,128 +59,188 @@ static void sendListEvent(GWidgetObject *gw, int item) { if (!(pe = geventGetEventBuffer(psl))) continue; - pse->type = GEVENT_GWIN_LIST; - pse->list = (GHandle)gw; - pse->item = item; + ple->type = GEVENT_GWIN_LIST; + ple->list = (GHandle)gw; + ple->item = item; geventSendEvent(psl); } - - #undef pse } static void gwinListDefaultDraw(GWidgetObject* gw, void* param) { - #define gcw ((GListObject *)gw) (void)param; - uint16_t i, fheight; - const point upArrow[] = { {0, ARROW}, {ARROW, ARROW}, {ARROW/2, 0} }; - const point downArrow[] = { {0, 0}, {ARROW, 0}, {ARROW/2, ARROW} }; - const gfxQueueASyncItem* qi; + #if GDISP_NEED_CONVEX_POLYGON + static const point upArrow[] = { {0, ARROW}, {ARROW, ARROW}, {ARROW/2, 0} }; + static const point downArrow[] = { {0, 0}, {ARROW, 0}, {ARROW/2, ARROW} }; + #endif - fheight = gdispGetFontMetric(gwinGetDefaultFont(), fontHeight); + const gfxQueueASyncItem* qi; + int i; + coord_t y, iheight, iwidth; + const GColorSet * ps; - // the list frame - gdispDrawBox(gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->pstyle->enabled.edge); - gdispDrawLine(gw->g.x + gw->g.width - BORDER_SCROLL, gw->g.y, gw->g.x + gw->g.width - BORDER_SCROLL, gw->g.y + gw->g.height, gw->pstyle->enabled.edge); - gdispDrawLine(gw->g.x + gw->g.width - BORDER_SCROLL, gw->g.y + BORDER_SCROLL, gw->g.x + gw->g.width, gw->g.y + BORDER_SCROLL, gw->pstyle->enabled.edge); - gdispDrawLine(gw->g.x + gw->g.width - BORDER_SCROLL, gw->g.y + gw->g.height - BORDER_SCROLL, gw->g.x + gw->g.width, gw->g.y + gw->g.height - BORDER_SCROLL, gw->pstyle->enabled.edge); + ps = (gw->g.flags & GWIN_FLG_ENABLED) ? &gw->pstyle->enabled : &gw->pstyle->disabled; + iheight = gdispGetFontMetric(gwinGetDefaultFont(), fontHeight) + TEXTGAP; - // the up-button - gdispFillConvexPoly(gw->g.x + gw->g.width - BORDER_SCROLL + ARROW/2, gw->g.y + BORDER_SCROLL - ARROW - ARROW/2, upArrow, 3, gw->pstyle->enabled.edge); - - // the down-button - gdispFillConvexPoly(gw->g.x + gw->g.width - BORDER_SCROLL + ARROW/2, gw->g.y + gw->g.height - BORDER_SCROLL + ARROW/2, downArrow, 3, gw->pstyle->enabled.edge); + // the scroll area + if (gw2obj->cnt > (gw->g.height-2) / iheight) { + 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); + #if GDISP_NEED_CONVEX_POLYGON + gdispFillConvexPoly(gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+(ARROW/2+1), upArrow, 3, ps->fill); + gdispFillConvexPoly(gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+gw->g.height-(ARROW+ARROW/2+1), downArrow, 3, ps->fill); + #else + #warning "GWIN: Lists display better when GDISP_NEED_CONVEX_POLGON is turned on" + gdispFillArea(gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+(ARROW/2+1), ARROW, ARROW, ps->fill); + gdispFillArea(gw->g.x+iwidth+((SCROLLWIDTH-ARROW)/2+2), gw->g.y+gw->g.height-(ARROW+ARROW/2+1), ARROW, ARROW, ps->fill); + #endif + } else + iwidth = gw->g.width - 2; - for (qi = gfxQueueASyncPeek(&gcw->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i += fheight + 2*BORDER) { - if (((ListItem*)qi)->flags & GLIST_FLG_SELECTED) { - gdispFillStringBox(gw->g.x + BORDER, gw->g.y + BORDER + i, gw->g.width - 2*BORDER - BORDER_SCROLL, fheight, ((ListItem*)qi)->text, gwinGetDefaultFont(), gw->pstyle->background, gw->pstyle->enabled.text, justifyLeft); + + // Find the top item + for (qi = gfxQueueASyncPeek(&gw2obj->list_head), i = 0; i < gw2obj->top && qi; qi = gfxQueueASyncNext(qi), i++); + + // Draw until we run out of room or items + for (y=1; y+iheight < gw->g.height-1 && qi; qi = gfxQueueASyncNext(qi), y += iheight) { + if (qi2li->flags & GLIST_FLG_SELECTED) { + //gdispFillStringBox(gw->g.x+1, gw->g.y+y, iwidth, iheight, qi2li->text, gwinGetDefaultFont(), gw->pstyle->background, ps->text, justifyLeft); + gdispFillStringBox(gw->g.x+1, gw->g.y+y, iwidth, iheight, qi2li->text, gwinGetDefaultFont(), ps->text, ps->fill, justifyLeft); } else { - gdispFillStringBox(gw->g.x + BORDER, gw->g.y + BORDER + i, gw->g.width - 2*BORDER - BORDER_SCROLL, fheight, ((ListItem*)qi)->text, gwinGetDefaultFont(), gw->pstyle->enabled.text, gw->pstyle->background, justifyLeft); + gdispFillStringBox(gw->g.x+1, gw->g.y+y, iwidth, iheight, qi2li->text, gwinGetDefaultFont(), ps->text, gw->pstyle->background, justifyLeft); } } - #undef gcw + // Fill any remaining item space + if (y < gw->g.height-1) + gdispFillArea(gw->g.x+1, gw->g.y+y, iwidth, gw->g.height-1-y, gw->pstyle->background); + + // the list frame + gdispDrawBox(gw->g.x, gw->g.y, gw->g.width, gw->g.height, ps->edge); } #if GINPUT_NEED_MOUSE - // a mouse down has occured over the list area + // a mouse down has occurred over the list area static void MouseDown(GWidgetObject* gw, coord_t x, coord_t y) { - #define gcw ((GListObject *)gw) - #define li ((ListItem *)qi) - (void) x; + const gfxQueueASyncItem* qi; + int item, i, pgsz; + coord_t iheight; + (void) x; - uint16_t i, item_id, item_height; - const gfxQueueASyncItem* qi; + iheight = gdispGetFontMetric(gwinGetDefaultFont(), fontHeight) + TEXTGAP; + pgsz = (gw->g.height-2)/iheight; + if (pgsz < 1) pgsz = 1; - item_id = -1; - - if (x > gw->g.width - BORDER_SCROLL) { - if (y < BORDER_SCROLL) - item_id = _selectUp(gw); - else if (y > gw->g.height - BORDER_SCROLL) - item_id = _selectDown(gw); - } else if (x < gw->g.width - BORDER_SCROLL - BORDER) { - item_height = gdispGetFontMetric(gwinGetDefaultFont(), fontHeight) + 2*BORDER; - item_id = (y) / item_height; - - for(qi = gfxQueueASyncPeek(&gcw->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { - if (item_id == i) - li->flags |= GLIST_FLG_SELECTED; - else - li->flags &=~ GLIST_FLG_SELECTED; + // Handle click over the scroll bar + if (gw2obj->cnt > pgsz && x >= gw->g.width-(SCROLLWIDTH+2)) { + if (y < 2*ARROW) { + if (gw2obj->top > 0) { + gw2obj->top--; + _gwidgetRedraw(&gw->g); + } + } else if (y >= gw->g.height - 2*ARROW) { + if (gw2obj->top < gw2obj->cnt - pgsz) { + gw2obj->top++; + _gwidgetRedraw(&gw->g); + } + } else if (y < gw->g.height/2) { + if (gw2obj->top > 0) { + if (gw2obj->top > pgsz) + gw2obj->top -= pgsz; + else + gw2obj->top = 0; + _gwidgetRedraw(&gw->g); + } + } else { + if (gw2obj->top < gw2obj->cnt - pgsz) { + if (gw2obj->top < gw2obj->cnt - 2*pgsz) + gw2obj->top += pgsz; + else + gw2obj->top = gw2obj->cnt - pgsz; + _gwidgetRedraw(&gw->g); + } } + return; } - _gwidgetRedraw((GHandle)gw); + // Handle click over the list area + item = gw2obj->top + y / iheight; - // do not generate an event if an empty section of the list has has been selected - if (item_id < 0 || item_id > gcw->cnt - 1) + if (item < 0 || item >= gw2obj->cnt) return; - sendListEvent(gw, item_id); + for(qi = gfxQueueASyncPeek(&gw2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { + if (item == i) + qi2li->flags |= GLIST_FLG_SELECTED; + else + qi2li->flags &=~ GLIST_FLG_SELECTED; + } - #undef gcw - #undef li + _gwidgetRedraw(&gw->g); + sendListEvent(gw, item); } #endif #if GINPUT_NEED_TOGGLE // a toggle-on has occurred static void ToggleOn(GWidgetObject *gw, uint16_t role) { - #define gcw ((GListObject *)gw) + const gfxQueueASyncItem * qi; + const gfxQueueASyncItem * qix; + int i; switch (role) { // select down case 0: - _selectDown(gw); + for (i = 0, qi = gfxQueueASyncPeek(&gw2obj->list_head); qi; qi = gfxQueueASyncNext(qi), i++) { + if ((qi2li->flags & GLIST_FLG_SELECTED)) { + qix = gfxQueueASyncNext(qi); + if (qix) { + qi2li->flags &=~ GLIST_FLG_SELECTED; + qix2li->flags |= GLIST_FLG_SELECTED; + _gwidgetRedraw(&gw->g); + } + break; + } + } break; // select up case 1: - _selectUp(gw); + qi = gfxQueueASyncPeek(&gw2obj->list_head); + qix = 0; + + for (i = 0; qi; qix = qi, qi = gfxQueueASyncNext(qi), i++) { + if ((qi2li->flags & GLIST_FLG_SELECTED)) + if (qix) { + qi2li->flags &=~ GLIST_FLG_SELECTED; + qix2li->flags |= GLIST_FLG_SELECTED; + _gwidgetRedraw(&gw->g); + } + break; + } + } break; } - - #undef gcw } static void ToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) { if (role) - ((GListObject *)gw)->t_up = instance; + gw2obj->t_up = instance; else - ((GListObject *)gw)->t_dn = instance; + gw2obj->t_dn = instance; } static uint16_t ToggleGet(GWidgetObject *gw, uint16_t role) { - return role ? ((GListObject *)gw)->t_up : ((GListObject *)gw)->t_dn; + return role ? gw2obj->t_up : gw2obj->t_dn; } #endif static void _destroy(GHandle gh) { const gfxQueueASyncItem* qi; - while((qi = gfxQueueASyncGet(&((GListObject *)gh)->list_head))) + while((qi = gfxQueueASyncGet(&gh2obj->list_head))) gfxFree((void *)qi); _gwidgetDestroy(gh); @@ -271,31 +281,32 @@ static const gwidgetVMT listVMT = { #endif }; -GHandle gwinListCreate(GListObject* widget, GWidgetInit* pInit) { - if (!(widget = (GListObject *)_gwidgetCreate(&widget->w, pInit, &listVMT))) +GHandle gwinListCreate(GListObject* gobj, GWidgetInit* pInit) { + if (!(gobj = (GListObject *)_gwidgetCreate(&gobj->w, pInit, &listVMT))) return 0; // initialize the item queue - gfxQueueASyncInit(&(widget->list_head)); - widget->cnt = 0; + gfxQueueASyncInit(&gobj->list_head); + gobj->cnt = 0; + gobj->top = 0; - gwinSetVisible(&widget->w.g, pInit->g.show); + gwinSetVisible(&gobj->w.g, pInit->g.show); - return (GHandle)widget; + return (GHandle)gobj; } int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) { - size_t sz; ListItem *newItem; - sz = useAlloc ? sizeof(ListItem)+strlen(item_name)+1 : sizeof(ListItem); - - if (!(newItem = (ListItem *)gfxAlloc(sz))) - return -1; - if (useAlloc) { + if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem)+strlen(item_name)+1))) + return -1; + strcpy((char *)(newItem+1), item_name); item_name = (const char *)(newItem+1); + } else { + if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem)))) + return -1; } // the item is not selected when added @@ -304,43 +315,43 @@ int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) { newItem->text = item_name; // select the item if it's the first in the list - if (widget(gh)->cnt == 0) + if (gh2obj->cnt == 0) newItem->flags |= GLIST_FLG_SELECTED; // add the new item to the list - gfxQueueASyncPut(&widget(gh)->list_head, &newItem->q_item); + gfxQueueASyncPut(&gh2obj->list_head, &newItem->q_item); // increment the total amount of entries in the list widget - widget(gh)->cnt++; + gh2obj->cnt++; + + _gwidgetRedraw(gh); // return the position in the list (-1 because we start with index 0) - return widget(gh)->cnt-1; + return gh2obj->cnt-1; } -char* gwinListItemGetText(GHandle gh, int item) { - const gfxQueueASyncItem* qi; - uint16_t i; +const char* gwinListItemGetText(GHandle gh, int item) { + const gfxQueueASyncItem* qi; + int i; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) return 0; // watch out for an invalid item - if (item < 0 || item > (widget(gh)->cnt) - 1) + if (item < 0 || item >= gh2obj->cnt) return 0; - qi = gfxQueueASyncPeek(&widget(gh)->list_head); - - for (i = 0; i < item; i++) { - qi = gfxQueueASyncNext(qi); + for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { + if (i == item) + return qi2li->text; } - - return ((ListItem*)qi)->text; + return 0; } int gwinListFindText(GHandle gh, const char* text) { - const gfxQueueASyncItem* qi; - uint16_t i; + const gfxQueueASyncItem* qi; + int i; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) @@ -350,9 +361,7 @@ int gwinListFindText(GHandle gh, const char* text) { if (!text) return -1; - qi = gfxQueueASyncPeek(&widget(gh)->list_head); - - for(qi = gfxQueueASyncPeek(&widget(gh)->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { + for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { if (strcmp(((ListItem *)qi)->text, text) == 0) return i; } @@ -361,15 +370,15 @@ int gwinListFindText(GHandle gh, const char* text) { } int gwinListGetSelected(GHandle gh) { - const gfxQueueASyncItem *qi; - int i; + const gfxQueueASyncItem * qi; + int i; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) return -1; - for(qi = gfxQueueASyncPeek(&widget(gh)->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { - if (((ListItem*)qi)->flags & GLIST_FLG_SELECTED) + for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { + if (qi2li->flags & GLIST_FLG_SELECTED) return i; } @@ -377,99 +386,100 @@ int gwinListGetSelected(GHandle gh) { } void gwinListItemSetParam(GHandle gh, int item, uint16_t param) { - const gfxQueueASyncItem* qi; - uint16_t i; + const gfxQueueASyncItem * qi; + int i; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) return; // watch out for an invalid item - if (item < 0 || item > (widget(gh)->cnt) - 1) + if (item < 0 || item > (gh2obj->cnt) - 1) return; - qi = gfxQueueASyncPeek(&widget(gh)->list_head); - - for (i = 0; i < item; i++) { - ((ListItem*)qi)->param = param; + for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { + if (i == item) { + qi2li->param = param; + break; + } } - - return; } void gwinListDeleteAll(GHandle gh) { - const gfxQueueASyncItem* qi; + gfxQueueASyncItem* qi; - while((qi = gfxQueueASyncGet(&((GListObject *)gh)->list_head))) - gfxFree((void *)qi); + // is it a valid handle? + if (gh->vmt != (gwinVMT *)&listVMT) + return; + + while((qi = gfxQueueASyncGet(&gh2obj->list_head))) + gfxFree(qi); + + gh2obj->cnt = 0; + gh2obj->top = 0; + _gwidgetRedraw(gh); } void gwinListItemDelete(GHandle gh, int item) { - const gfxQueueASyncItem* qi; - uint16_t i; + const gfxQueueASyncItem * qi; + int i; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) return; // watch out for an invalid item - if (item < 0 || item > (widget(gh)->cnt) - 1) + if (item < 0 || item >= gh2obj->cnt) return; - qi = gfxQueueASyncPeek(&widget(gh)->list_head); - - // get our item pointer - for (i = 0; i < item; i++) { - qi = gfxQueueASyncNext(qi); + for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { + if (i == item) { + gfxQueueASyncRemove(&gh2obj->list_head, (gfxQueueASyncItem*)qi); + gfxFree((void *)qi); + if (gh2obj->top >= item && gh2obj->top) + gh2obj->top--; + _gwidgetRedraw(gh); + break; + } } - - gfxQueueASyncRemove(&widget(gh)->list_head, qi); - gfxFree((void*)qi); } uint16_t gwinListItemGetParam(GHandle gh, int item) { - const gfxQueueASyncItem* qi; - uint16_t i; + const gfxQueueASyncItem * qi; + int i; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) return 0; // watch out for an invalid item - if (item < 0 || item > (widget(gh)->cnt) - 1) + if (item < 0 || item > (gh2obj->cnt) - 1) return 0; - qi = gfxQueueASyncPeek(&widget(gh)->list_head); - - for (i = 0; i < item; i++) { - qi = gfxQueueASyncNext(qi); + for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { + if (i == item) + return qi2li->param; } - - return ((ListItem*)qi)->param; + return 0; } bool_t gwinListItemIsSelected(GHandle gh, int item) { - const gfxQueueASyncItem* qi; - uint16_t i; + const gfxQueueASyncItem * qi; + int i; // is it a valid handle? if (gh->vmt != (gwinVMT *)&listVMT) return FALSE; // watch out for an invalid item - if (item < 0 || item > (widget(gh)->cnt) - 1) + if (item < 0 || item > (gh2obj->cnt) - 1) return FALSE; - qi = gfxQueueASyncPeek(&widget(gh)->list_head); - - for (i = 0; i < item; i++) { - qi = gfxQueueASyncNext(qi); + for(qi = gfxQueueASyncPeek(&gh2obj->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { + if (i == item) + return (qi2li->flags & GLIST_FLG_SELECTED) ? TRUE : FALSE; } - - if (((ListItem*)qi)->flags & GLIST_FLG_SELECTED) - return TRUE; - else - return FALSE; + return FALSE; } int gwinListItemCount(GHandle gh) { @@ -477,7 +487,7 @@ int gwinListItemCount(GHandle gh) { if (gh->vmt != (gwinVMT *)&listVMT) return 0; - return widget(gh)->cnt; + return gh2obj->cnt; } #endif // GFX_USE_GWIN && GWIN_NEED_LIST