]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
Added patches from Clarence for constant sized listboxes, changed vesrion v0-9
authorewt <ewt>
Mon, 2 Jun 1997 16:27:33 +0000 (16:27 +0000)
committerewt <ewt>
Mon, 2 Jun 1997 16:27:33 +0000 (16:27 +0000)
numbers to 0.9

Makefile
listbox.c
newt.h
newt.spec

index 8156f4f748802d0342724a3da797652448c8d772..b2defb5b97e1104440dc876dfa27f1a1cd1f4b3d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -103,7 +103,7 @@ archive:
        @rm -f /tmp/newt-$(VERSION).tar.gz 
        @echo " "
        @echo "The final archive is ./newt-$(VERSION).tar.gz. You should run"
-       @echo "-n$(VERSION): RCS/*,v on all of the directories btw."
+       @echo "cvs tag v$(VERSION) now."
 
 ifeq (.depend,$(wildcard .depend))
 include .depend
index 17276e0040ae63be59f71ea6d28aa465aa52993e..7e26c9958a448a8acacb9adb8884b683dc8ab7f1 100644 (file)
--- a/listbox.c
+++ b/listbox.c
@@ -22,6 +22,7 @@ struct items {
 struct listbox {
     newtComponent sb; /* Scrollbar on right side of listbox */
     int numItems, curWidth;
+    int userHasSetWidth;
     int currItem, startShowItem; /* startShowItem is the first item displayed
                                   on the screen */
     int isActive; /* If we handle key events all the time, it seems
@@ -59,6 +60,7 @@ newtComponent newtListbox(int left, int top, int height, int flags) {
     li->numItems = 0;
     li->currItem = 0;
     li->isActive = 0;
+    li->userHasSetWidth = 0;
     li->startShowItem = 0;
     li->flags = flags & (NEWT_FLAG_RETURNEXIT|NEWT_FLAG_DOBORDER);
 
@@ -108,6 +110,16 @@ void newtListboxSetCurrent(newtComponent co, int num) {
     listboxDraw(co);
 }
 
+
+void newtListboxSetWidth(newtComponent co , int width) {
+    struct listbox * li = co->data;
+    
+    li->curWidth = co->width = width;
+    li->userHasSetWidth = 1;
+    li->sb->left = width + co->left + 2;
+    listboxDraw(co);
+}
+
 void * newtListboxGetCurrent(newtComponent co) {
     struct listbox * li = co->data;
     int i;
@@ -136,7 +148,8 @@ void newtListboxSetText(newtComponent co, int num, char * text) {
        free(item->key);
        item->key = strdup(text);
     }
-    if (strlen(text) > li->curWidth) {
+    if (li->userHasSetWidth == 0
+       && strlen(text) > li->curWidth) {
        co->width = li->curWidth = strlen(text);
        if (li->sb)
            li->sb->left = co->left + co->width + 2;
@@ -173,7 +186,8 @@ int newtListboxAddEntry(newtComponent co, char * text, void * data) {
        item = li->boxItems = malloc(sizeof(struct items));
     }
 
-    if (text && (strlen(text) > li->curWidth))
+    if (li->userHasSetWidth == 0
+       && text && (strlen(text) > li->curWidth))
        li->curWidth = strlen(text) ;
 
     item->key = strdup(text); item->data = data; item->next = NULL;
@@ -183,8 +197,8 @@ int newtListboxAddEntry(newtComponent co, char * text, void * data) {
 
     if (li->grow)
        co->height++;
-
-    co->width = li->curWidth;
+    if(li->userHasSetWidth == 0)
+       co->width = li->curWidth;
     li->numItems++;
 
     return li->numItems;
@@ -216,15 +230,16 @@ int newtListboxInsertEntry(newtComponent co, char * text, void * data,
        item->next = NULL;
     }
 
-    if (text && (strlen(text) > li->curWidth))
+    if (li->userHasSetWidth == 0
+       && text && (strlen(text) > li->curWidth))
        li->curWidth = strlen(text);
 
     item->key = strdup(text?text:"(null)"); item->data = data;
 
     if (li->sb)
        li->sb->left = co->left + li->curWidth + 2;
-
-    co->width = li->curWidth;
+    if (li->userHasSetWidth == 0)
+       co->width = li->curWidth;
     li->numItems++;
     listboxDraw(co);
 
@@ -270,9 +285,11 @@ int newtListboxDeleteEntry(newtComponent co, int num) {
        if((t = strlen(item->key)) > widest) widest = t;
 
     /* Adjust the listbox width */
-    co->width = li->curWidth = widest;
-    if (li->sb)
-       li->sb->left = co->left + widest + 2;
+    if (li->userHasSetWidth == 0) {
+       co->width = li->curWidth = widest;
+       if (li->sb)
+               li->sb->left = co->left + widest + 2;
+    }
 
     listboxDraw(co);
 
diff --git a/newt.h b/newt.h
index d8c414a9c613eb05001f2b1905af672aa084440a..a9628fe49abd27ff31349df9a8a3ed875b4dcf12 100644 (file)
--- a/newt.h
+++ b/newt.h
@@ -124,6 +124,7 @@ void * newtListboxGetCurrent(newtComponent co);
 void newtListboxSetCurrent(newtComponent co, int num);
 void newtListboxSetText(newtComponent co, int num, char * text);
 void newtListboxSetEntry(newtComponent co, int num, char * text);
+void newtListboxSetWidth(newtComponent co, int width);
 /* return the data passed to AddEntry */
 void newtListboxSetData(newtComponent co, int num, void * data);
 int newtListboxAddEntry(newtComponent co, char * text, void * data);
index 75179900dd7cf0213433a9955af34d3dc7e617f7..3e394312b626ce2c8e747a88315f7458360b7ccd 100644 (file)
--- a/newt.spec
+++ b/newt.spec
@@ -1,10 +1,10 @@
 Summary: Not Erik's Windowing Toolkit - text mode windowing with slang
 Name: newt
-Version: 0.8
+Version: 0.9
 Release: 1
 Copyright: LGPL
 Group: Libraries
-Source: ftp://ftp.redhat.com/pub/redhat/code/newt/newt-0.8.tar.gz
+Source: ftp://ftp.redhat.com/pub/redhat/code/newt/newt-0.9.tar.gz
 Requires: slang
 %package devel
 Summary: Developer's toolkit for newt windowing library
@@ -45,6 +45,11 @@ make install-sh
 
 %changelog
 
+* Mon Jun 02 1997 Erik Troan <ewt@redhat.com>
+
+- Added patched from Clarence Smith for setting the size of a listbox
+- Version 0.9
+
 * Tue May 28 1997 Elliot Lee <sopwith@redhat.com> 0.8-2
 - Touchups on Makefile
 - Cleaned up NEWT_FLAGS_*