From: sopwith Date: Tue, 22 Jul 1997 18:22:18 +0000 (+0000) Subject: Few more changes. X-Git-Tag: r0-12~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2dbc072e5ecaba76ee2211eaf9d7ce94bc8666ea;p=thirdparty%2Fnewt.git Few more changes. --- diff --git a/listbox.c b/listbox.c index 39e6ace..fb0c4d9 100644 --- a/listbox.c +++ b/listbox.c @@ -15,13 +15,14 @@ /* Linked list of items in the listbox */ struct items { void *key, *data; + unsigned char isSelected; struct items *next; }; /* Holds all the relevant information for this listbox */ struct listbox { newtComponent sb; /* Scrollbar on right side of listbox */ - int numItems, curWidth; + int numItems, curWidth, numSelected; int userHasSetWidth; int currItem, startShowItem; /* startShowItem is the first item displayed on the screen */ @@ -60,10 +61,11 @@ newtComponent newtListbox(int left, int top, int height, int flags) { li->boxItems = NULL; li->numItems = 0; li->currItem = 0; + li->numSelected = 0; li->isActive = 0; li->userHasSetWidth = 0; li->startShowItem = 0; - li->flags = flags & (NEWT_FLAG_RETURNEXIT|NEWT_FLAG_DOBORDER); + li->flags = flags & (NEWT_FLAG_RETURNEXIT|NEWT_FLAG_DOBORDER|NEWT_FLAG_MULTIPLE); if (height) { li->grow = 0; @@ -144,6 +146,27 @@ void * newtListboxGetCurrent(newtComponent co) { return NULL; } +/* Free the returned array after use, but NOT the values in the array */ +void ** newtListboxGetSelected(newtComponent co) +{ + struct listbox * li; + int i; + void **retval; + struct items *item; + + if(!co) return NULL; + + li = co->data; + if(!li || !li->numSelected) return NULL; + + retval = malloc(li->numSelected * sizeof(void *)); + for(i = 0, item = li->boxItems; item != NULL; + item = item->next) + if(item->isSelected) + retval[i++] = item->data; + return retval; +} + void newtListboxSetText(newtComponent co, int num, char * text) { struct listbox * li = co->data; int i; diff --git a/newt.c b/newt.c index 1c23e9c..112668c 100644 --- a/newt.c +++ b/newt.c @@ -338,6 +338,8 @@ int newtOpenWindow(int left, int top, int width, int height, return 0; } +/* XXX hack to allow newtDrawForm() to redraw the current window. + Need to find out what the real problem is */ void newtDrawCurrentWindow(void) { int i; diff --git a/newt.h b/newt.h index a9628fe..aab64d4 100644 --- a/newt.h +++ b/newt.h @@ -60,6 +60,7 @@ enum newtFlagsSense { NEWT_FLAGS_SET, NEWT_FLAGS_RESET }; #define NEWT_FLAG_DOBORDER (1 << 5) #define NEWT_FLAG_WRAP (1 << 6) #define NEWT_FLAG_NOF12 (1 << 7) +#define NEWT_FLAG_MULTIPLE (1 << 8) /* Backwards compatibility */ #define NEWT_LISTBOX_RETURNEXIT NEWT_FLAG_RETURNEXIT