10
newtComponent b1, b2, b3, b4;
11
newtComponent answer, f, t;
12
newtGrid grid, subgrid;
14
int textWidth, textHeight, rc;
15
char * menuContents[] = { "One", "Two", "Three", "Four", "Five", NULL };
17
struct newtWinEntry autoEntries[] = {
18
{ "An entry", entries + 0, 0 },
19
{ "Another entry", entries + 1, 0 },
20
{ "Third entry", entries + 2, 0 },
21
{ "Fourth entry", entries + 3, 0 },
24
setlocale(LC_ALL, "");
26
memset(entries, 0, sizeof(entries));
31
b1 = newtCheckbox(-1, -1, "An pretty long checkbox for testing", ' ', NULL, NULL);
32
b2 = newtButton(-1, -1, "Another Button");
33
b3 = newtButton(-1, -1, "But, but");
34
b4 = newtButton(-1, -1, "But what?");
36
f = newtForm(NULL, NULL, 0);
38
grid = newtCreateGrid(2, 2);
39
newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, b1, 0, 0, 0, 0,
40
NEWT_ANCHOR_RIGHT, 0);
41
newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0);
42
newtGridSetField(grid, 1, 0, NEWT_GRID_COMPONENT, b3, 0, 0, 0, 0, 0, 0);
43
newtGridSetField(grid, 1, 1, NEWT_GRID_COMPONENT, b4, 0, 0, 0, 0, 0, 0);
46
newtFormAddComponents(f, b1, b2, b3, b4, NULL);
48
newtGridWrappedWindow(grid, "first window");
49
newtGridFree(grid, 1);
51
answer = newtRunForm(f);
56
flowedText = newtReflowText("This is a quite a bit of text. It is 40 "
57
"columns long, so some wrapping should be "
58
"done. Did you know that the quick, brown "
59
"fox jumped over the lazy dog?\n\n"
60
"In other news, it's pretty important that we "
61
"can properly force a line break.",
62
40, 5, 5, &textWidth, &textHeight);
63
t = newtTextbox(-1, -1, textWidth, textHeight, NEWT_FLAG_WRAP);
64
newtTextboxSetText(t, flowedText);
68
b1 = newtButton(-1, -1, "Okay");
69
b2 = newtButton(-1, -1, "Cancel");
71
grid = newtCreateGrid(1, 2);
72
subgrid = newtCreateGrid(2, 1);
74
newtGridSetField(subgrid, 0, 0, NEWT_GRID_COMPONENT, b1, 0, 0, 0, 0, 0, 0);
75
newtGridSetField(subgrid, 1, 0, NEWT_GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0);
77
newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, t, 0, 0, 0, 1, 0, 0);
78
newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid, 0, 0, 0, 0, 0,
79
NEWT_GRID_FLAG_GROWX);
80
newtGridWrappedWindow(grid, "another example");
81
newtGridDestroy(grid, 1);
83
f = newtForm(NULL, NULL, 0);
84
newtFormAddComponents(f, b1, t, b2, NULL);
85
answer = newtRunForm(f);
90
newtWinMessage("Simple", "Ok", "This is a simple message window");
91
newtWinChoice("Simple", "Ok", "Cancel", "This is a simple choice window");
94
rc = newtWinMenu("Test Menu", "This is a sample invovation of the "
95
"newtWinMenu() call. It may or may not have a scrollbar, "
96
"depending on the need for one.", 50, 5, 5, 3,
97
menuContents, &textWidth, "Ok", "Cancel", NULL);
99
rc = newtWinEntries("Text newtWinEntries()", "This is a sample invovation of "
100
"newtWinEntries() call. It lets you get a lot of input "
101
"quite easily.", 50, 5, 5, 20, autoEntries, "Ok",
106
printf("rc = 0x%x item = %d\n", rc, textWidth);