From: ewt Date: Mon, 2 Jun 1997 16:27:33 +0000 (+0000) Subject: Added patches from Clarence for constant sized listboxes, changed vesrion X-Git-Tag: v0-9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=babcb349683b2f9f2730d832ffe317ebbbaee43b;p=thirdparty%2Fnewt.git Added patches from Clarence for constant sized listboxes, changed vesrion numbers to 0.9 --- diff --git a/Makefile b/Makefile index 8156f4f..b2defb5 100644 --- 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 diff --git a/listbox.c b/listbox.c index 17276e0..7e26c99 100644 --- 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 d8c414a..a9628fe 100644 --- 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); diff --git a/newt.spec b/newt.spec index 7517990..3e39431 100644 --- 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 + +- Added patched from Clarence Smith for setting the size of a listbox +- Version 0.9 + * Tue May 28 1997 Elliot Lee 0.8-2 - Touchups on Makefile - Cleaned up NEWT_FLAGS_*