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
li->numItems = 0;
li->currItem = 0;
li->isActive = 0;
+ li->userHasSetWidth = 0;
li->startShowItem = 0;
li->flags = flags & (NEWT_FLAG_RETURNEXIT|NEWT_FLAG_DOBORDER);
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;
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;
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;
if (li->grow)
co->height++;
-
- co->width = li->curWidth;
+ if(li->userHasSetWidth == 0)
+ co->width = li->curWidth;
li->numItems++;
return li->numItems;
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);
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);
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);
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
%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_*