]> git.ipfire.org Git - thirdparty/newt.git/blob - test.c
changed for new newtForm() call
[thirdparty/newt.git] / test.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #include "newt.h"
6
7 void main(void) {
8 newtComponent b1, b2, r1, r2, r3, e1, e2, e3, l1, l2, l3;
9 newtComponent lb, t;
10 newtComponent cs[10];
11 newtComponent f, chklist;
12 char results[10];
13 char * enr1, * enr2, * enr3;
14 int i;
15 char buf[20];
16
17 newtInit();
18 newtCls();
19
20 newtOpenWindow(2, 2, 30, 10, "first window");
21 newtOpenWindow(10, 5, 65, 16, "window 2");
22
23 f = newtForm(NULL, NULL, 0);
24 chklist = newtForm(NULL, NULL, 0);
25
26 b1 = newtButton(3, 1, "Push me");
27 b2 = newtButton(18, 1, "Not me");
28 r1 = newtRadiobutton(20, 6, "Choice 1", 0, NULL);
29 r2 = newtRadiobutton(20, 7, "Choice 2", 1, r1);
30 r3 = newtRadiobutton(20, 8, "Choice 3", 0, r2);
31
32 for (i = 0; i < 10; i++) {
33 sprintf(buf, "Check %d", i);
34 cs[i] = newtCheckbox(3, 6 + i, buf, ' ', NULL, &results[i]);
35 newtFormAddComponent(chklist, cs[i]);
36 }
37
38 l1 = newtLabel(3, 10, "Fixed:");
39 l2 = newtLabel(3, 11, "Scrolls:");
40 l3 = newtLabel(3, 12, "Hidden:");
41 e1 = newtEntry(12, 10, "", 20, &enr1, 0);
42 e2 = newtEntry(12, 11, "Default", 20, &enr2, NEWT_ENTRY_SCROLL);
43 e3 = newtEntry(12, 12, NULL, 20, &enr3, NEWT_ENTRY_HIDDEN);
44
45 newtFormSetHeight(chklist, 3);
46
47 newtFormAddComponents(f, b1, b2, chklist, NULL);
48 newtFormAddComponents(f, r1, r2, r3, l1, l2, l3, e1, e2, e3, NULL);
49
50 lb = newtListbox(45, 3, 4, 0);
51 newtListboxAddEntry(lb, "First", NULL);
52 newtListboxAddEntry(lb, "Second", NULL);
53 newtListboxAddEntry(lb, "Third", NULL);
54 newtListboxAddEntry(lb, "Fourth", NULL);
55 newtListboxAddEntry(lb, "Fifth", NULL);
56 newtListboxAddEntry(lb, "Sixth", NULL);
57 newtListboxAddEntry(lb, "Seventh", NULL);
58 newtListboxAddEntry(lb, "Eighth", NULL);
59 newtListboxAddEntry(lb, "Ninth", NULL);
60 newtListboxAddEntry(lb, "Tenth", NULL);
61
62 t = newtTextbox(45, 10, 17, 5, NEWT_TEXTBOX_WRAP);
63 newtTextboxSetText(t, "This is some text does it look okay?\nThis should be alone.\nThis shouldn't be printed");
64
65 newtFormAddComponents(f, lb, t, NULL);
66
67 newtRunForm(f);
68
69 enr1 = strdup(enr1);
70 enr2 = strdup(enr2);
71 enr3 = strdup(enr3);
72
73 newtFormDestroy(f);
74
75 newtPopWindow();
76 newtPopWindow();
77 newtFinished();
78
79 printf("got string 1: %s\n", enr1);
80 printf("got string 2: %s\n", enr2);
81 printf("got string 3: %s\n", enr3);
82 }