9
newtComponent b1, b2, b3, b4;
10
newtComponent answer, f, t;
11
newtGrid grid, subgrid;
13
int textWidth, textHeight, rc, i;
14
char * menuContents[] = { "One", "Two", "Three", "Four", "Five", NULL };
16
struct newtWinEntry autoEntries[] = {
17
{ "An entry", entries + 0, 0 },
18
{ "Another entry", entries + 1, 0 },
19
{ "Third entry", entries + 2, 0 },
20
{ "Fourth entry", entries + 3, 0 },
23
memset(entries, 0, sizeof(entries));
28
b1 = newtCheckbox(-1, -1, "An pretty long checkbox for testing", ' ', NULL, NULL);
29
b2 = newtButton(-1, -1, "Another Button");
30
b3 = newtButton(-1, -1, "But, but");
31
b4 = newtButton(-1, -1, "But what?");
33
f = newtForm(NULL, NULL, 0);
35
grid = newtCreateGrid(2, 2);
36
newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, b1, 0, 0, 0, 0,
37
NEWT_ANCHOR_RIGHT, 0);
38
newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0);
39
newtGridSetField(grid, 1, 0, NEWT_GRID_COMPONENT, b3, 0, 0, 0, 0, 0, 0);
40
newtGridSetField(grid, 1, 1, NEWT_GRID_COMPONENT, b4, 0, 0, 0, 0, 0, 0);
43
newtFormAddComponents(f, b1, b2, b3, b4, NULL);
45
newtGridWrappedWindow(grid, "first window");
46
newtGridFree(grid, 1);
48
answer = newtRunForm(f);
53
flowedText = newtReflowText("This is a quite a bit of text. It is 40 "
54
"columns long, so some wrapping should be "
55
"done. Did you know that the quick, brown "
56
"fox jumped over the lazy dog?\n\n"
57
"In other news, it's pretty important that we "
58
"can properly force a line break.",
59
40, 5, 5, &textWidth, &textHeight);
60
t = newtTextbox(-1, -1, textWidth, textHeight, NEWT_FLAG_WRAP);
61
newtTextboxSetText(t, flowedText);
65
b1 = newtButton(-1, -1, "Okay");
66
b2 = newtButton(-1, -1, "Cancel");
68
grid = newtCreateGrid(1, 2);
69
subgrid = newtCreateGrid(2, 1);
71
newtGridSetField(subgrid, 0, 0, NEWT_GRID_COMPONENT, b1, 0, 0, 0, 0, 0, 0);
72
newtGridSetField(subgrid, 1, 0, NEWT_GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0);
74
newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, t, 0, 0, 0, 1, 0, 0);
75
newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid, 0, 0, 0, 0, 0,
76
NEWT_GRID_FLAG_GROWX);
77
newtGridWrappedWindow(grid, "another example");
78
newtGridDestroy(grid, 1);
80
f = newtForm(NULL, NULL, 0);
81
newtFormAddComponents(f, b1, t, b2, NULL);
82
answer = newtRunForm(f);
87
newtWinMessage("Simple", "Ok", "This is a simple message window");
88
newtWinChoice("Simple", "Ok", "Cancel", "This is a simple choice window");
91
rc = newtWinMenu("Test Menu", "This is a sample invovation of the "
92
"newtWinMenu() call. It may or may not have a scrollbar, "
93
"depending on the need for one.", 50, 5, 5, 3,
94
menuContents, &textWidth, "Ok", "Cancel", NULL);
96
rc = newtWinEntries("Text newtWinEntries()", "This is a sample invovation of "
97
"newtWinEntries() call. It lets you get a lot of input "
98
"quite easily.", 50, 5, 5, 20, autoEntries, "Ok",
100
for (i = 0; i < sizeof (autoEntries) / sizeof (struct newtWinEntry) && autoEntries[i].value; i++)
101
free(*(autoEntries[i].value));
105
printf("rc = 0x%x item = %d\n", rc, textWidth);