]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
Few more changes.
authorsopwith <sopwith>
Tue, 22 Jul 1997 18:22:18 +0000 (18:22 +0000)
committersopwith <sopwith>
Tue, 22 Jul 1997 18:22:18 +0000 (18:22 +0000)
listbox.c
newt.c
newt.h

index 39e6aceb696dad9802b4ff4622fc01964ac898b8..fb0c4d971e695bc6f0a3dd2ca857cc1bd569b4df 100644 (file)
--- a/listbox.c
+++ b/listbox.c
 /* 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 1c23e9c6917bb8ce521b6995cb70af1527b90a23..112668ce999c5022d6c139895ec57b99aeabe710 100644 (file)
--- 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 a9628fe49abd27ff31349df9a8a3ed875b4dcf12..aab64d42eb625d3098f5821e4959618eb4735ba9 100644 (file)
--- 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