From: ewt Date: Mon, 17 Feb 1997 16:59:10 +0000 (+0000) Subject: cleanups from sopwith X-Git-Tag: v0-9~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b38669d173b377da1c9349db1fe4d7f70fddc68;p=thirdparty%2Fnewt.git cleanups from sopwith --- diff --git a/listbox.c b/listbox.c index b8a2718..7f439ac 100644 --- a/listbox.c +++ b/listbox.c @@ -1,4 +1,7 @@ -/* This goofed-up box whacked into shape by Elliot Lee */ +/* This goofed-up box whacked into shape by Elliot Lee + (from the original listbox by Erik Troan ) + and contributed to newt for use under the LGPL license. + Copyright Elliot Lee 1996 */ #include #include @@ -287,16 +290,15 @@ static void listboxDraw(newtComponent co) struct items *item; int i, j; - SLsmg_set_color(NEWT_COLORSET_LISTBOX); - if(li->sb) li->sb->ops->draw(li->sb); + SLsmg_set_color(NEWT_COLORSET_LISTBOX); + for(i = 0, item = li->boxItems; item != NULL && i < li->startShowItem; i++, item = item->next); j = i; - newtGotorc(co->top - 1, co->left); for (i = 0; item != NULL && i < co->height; i++, item = item->next) { if (!item->key) continue; @@ -310,6 +312,7 @@ static void listboxDraw(newtComponent co) if(j + i == li->currItem) SLsmg_set_color(NEWT_COLORSET_LISTBOX); } + newtGotorc(co->top + (li->currItem - li->startShowItem), co->left); } static struct eventResult listboxEvent(newtComponent co, struct event ev) { @@ -318,6 +321,10 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) { er.result = ER_IGNORED; + if(ev.when == EV_EARLY || ev.when == EV_LATE) { + return er; + } + switch(ev.event) { case EV_KEYPRESS: if (!li->isActive) break; @@ -333,12 +340,9 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) { li->currItem--; if(li->currItem < li->startShowItem) li->startShowItem = li->currItem; + newtScrollbarSet(li->sb, li->currItem + 1, li->numItems); listboxDraw(co); } - - newtGotorc(co->top + li->currItem - li->startShowItem, - co->left); - newtScrollbarSet(li->sb, li->currItem + 1, li->numItems); er.result = ER_SWALLOWED; break; @@ -350,12 +354,9 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) { if(li->startShowItem + co->height > li->numItems) li->startShowItem = li->numItems - co->height; } + newtScrollbarSet(li->sb, li->currItem + 1, li->numItems); listboxDraw(co); } - - newtGotorc(co->top + li->currItem - li->startShowItem, - co->left); - newtScrollbarSet(li->sb, li->currItem + 1, li->numItems); er.result = ER_SWALLOWED; break; @@ -375,8 +376,8 @@ static struct eventResult listboxEvent(newtComponent co, struct event ev) { break; case EV_FOCUS: - newtGotorc(co->top + li->currItem - li->startShowItem, co->left); li->isActive = 1; + listboxDraw(co); er.result = ER_SWALLOWED; break;