]> git.ipfire.org Git - thirdparty/newt.git/commitdiff
added newtFormSetCurrent(), newtListboxSetCurrent() 0-1
authorewt <ewt>
Thu, 20 Jun 1996 02:49:26 +0000 (02:49 +0000)
committerewt <ewt>
Thu, 20 Jun 1996 02:49:26 +0000 (02:49 +0000)
form.c
listbox.c
newt.h

diff --git a/form.c b/form.c
index bf355f9f37e922be45dc30d160353ea4fc1c132f..4f8577cf06eafb8bb5b4d6e46ffb8b55e8ef39a8 100644 (file)
--- a/form.c
+++ b/form.c
@@ -88,6 +88,25 @@ newtComponent newtFormGetCurrent(newtComponent co) {
     return form->elements[form->currComp].co;
 }
 
+void newtFormSetCurrent(newtComponent co, newtComponent subco) {
+    struct form * form = co->data;
+    int i, new;
+
+    for (i = 0; i < form->numComps; i++) {
+        if (form->elements[i].co == subco) break;
+    }
+
+    if (form->elements[i].co != subco) return;
+    new = i;
+
+    if (!componentFits(co, new)) {
+       gotoComponent(form, -1);
+       form->vertOffset = form->elements[new].top - co->top - 1;
+    }
+
+    gotoComponent(form, new);
+}
+
 void newtFormSetHeight(newtComponent co, int height) {
     struct form * form = co->data;
 
index 383aea6bd130b02b1bb47c0844fb3e9e7ef464af..fb3a860bb71f983ff10d61e17c8b5972dc05beca 100644 (file)
--- a/listbox.c
+++ b/listbox.c
@@ -59,6 +59,12 @@ newtComponent newtListbox(int left, int top, int height, int flags) {
     return co;
 }
 
+void newtListboxSetCurrent(newtComponent co, int num) {
+    struct listbox * li = co->data;
+
+    newtFormSetCurrent(li->form, li->items[num]);
+}
+
 void * newtListboxGetCurrent(newtComponent co) {
     struct listbox * li = co->data;
     newtComponent curr;
diff --git a/newt.h b/newt.h
index ec1c9322cff3fdfb3e69ee9c49b778d5a0374985..ff05892075380a0fc65b6eed370273dffba1bd9d 100644 (file)
--- a/newt.h
+++ b/newt.h
@@ -61,6 +61,7 @@ void newtScrollbarSet(newtComponent co, int where, int total);
 newtComponent newtListbox(int left, int top, int height, int flags);
 /* return the data passed to AddEntry */
 void * newtListboxGetCurrent(newtComponent co);
+void newtListboxSetCurrent(newtComponent co, int num);
 void newtListboxAddEntry(newtComponent co, char * text, void * data);
 void newtListboxSetEntry(newtComponent co, int num, char * text);
 
@@ -72,6 +73,7 @@ void newtTextboxSetText(newtComponent co, const char * text);
 
 newtComponent newtForm(newtComponent vertBar);
 newtComponent newtFormGetCurrent(newtComponent co);
+void newtFormSetCurrent(newtComponent co, newtComponent subco);
 void newtFormAddComponent(newtComponent form, newtComponent co);
 void newtFormAddComponents(newtComponent form, ...);
 void newtFormSetHeight(newtComponent co, int height);