]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
make listboxes work properly with borders
authorewt <ewt>
Sat, 1 Aug 1998 16:05:20 +0000 (16:05 +0000)
committerewt <ewt>
Sat, 1 Aug 1998 16:05:20 +0000 (16:05 +0000)
listbox.c

index 83a3f0c8956c689485ab70b33c7d403a6569c02c..051c7a6ee42a3866d84790f120d096b10778d0d1 100644 (file)
--- 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;