From: ewt Date: Sat, 1 Aug 1998 16:05:20 +0000 (+0000) Subject: make listboxes work properly with borders X-Git-Tag: r0-30~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa564c1de5d8647c67a2273b074e127dcc3ab850;p=thirdparty%2Fnewt.git make listboxes work properly with borders --- diff --git a/listbox.c b/listbox.c index 83a3f0c..051c7a6 100644 --- a/listbox.c +++ b/listbox.c @@ -72,7 +72,8 @@ static void listboxPlace(newtComponent co, int newLeft, int newTop) { co->left = newLeft; if (li->sb) - li->sb->ops->place(li->sb, co->left + co->width - 1, co->top); + li->sb->ops->place(li->sb, co->left + co->width - li->bdxAdjust - 1, + co->top); } newtComponent newtListbox(int left, int top, int height, int flags) { @@ -105,20 +106,22 @@ newtComponent newtListbox(int left, int top, int height, int flags) { li->bdyAdjust = 1; } + co->height = height; + li->curHeight = co->height - (2 * li->bdyAdjust); + if (height) { li->grow = 0; if (flags & NEWT_FLAG_SCROLL) { - sb = newtVerticalScrollbar(left, top, height, COLORSET_LISTBOX, - COLORSET_ACTLISTBOX); + sb = newtVerticalScrollbar(left, top + li->bdyAdjust, + li->curHeight, + COLORSET_LISTBOX, COLORSET_ACTLISTBOX); li->sbAdjust = 3; } else { sb = NULL; } - co->height = height; } else { li->grow = 1; sb = NULL; - co->height = 2 * li->bdyAdjust; } li->sb = sb; @@ -131,7 +134,6 @@ newtComponent newtListbox(int left, int top, int height, int flags) { co->callback = NULL; updateWidth(co, li, 5); - li->curHeight = co->height - (2 * li->bdyAdjust); return co; } @@ -142,7 +144,7 @@ static inline void updateWidth(newtComponent co, struct listbox * li, co->width = li->curWidth + li->sbAdjust + 2 * li->bdxAdjust; if (li->sb) - li->sb->left = co->left + co->width - 1; + li->sb->left = co->left + co->width - li->bdxAdjust - 1; } void newtListboxSetCurrentByKey(newtComponent co, void * key) { @@ -373,7 +375,7 @@ int newtListboxInsertEntry(newtComponent co, const char * text, item->isSelected = 0; if (li->sb) - li->sb->left = co->left + co->width - 1; + li->sb->left = co->left + co->width - li->bdxAdjust - 1; li->numItems++; listboxDraw(co); @@ -483,9 +485,6 @@ static void listboxDraw(newtComponent co) if (!co->isMapped) return ; - if(li->sb) - li->sb->ops->draw(li->sb); - if(li->flags & NEWT_FLAG_BORDER) { if(li->isActive) SLsmg_set_color(NEWT_COLORSET_ACTLISTBOX); @@ -495,6 +494,9 @@ static void listboxDraw(newtComponent co) newtDrawBox(co->left, co->top, co->width, co->height, 0); } + 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;