/* 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 */
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;
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;
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;
#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