]>
git.ipfire.org Git - thirdparty/newt.git/blob - testgrid.c
9 newtComponent b1
, b2
, b3
, b4
;
10 newtComponent answer
, f
, t
;
11 newtGrid grid
, subgrid
;
13 int textWidth
, textHeight
, rc
;
14 char * menuContents
[] = { "One", "Two", "Three", "Four", "Five", NULL
};
19 newtOpenWindow(2, 2, 40, 15, "first window");
21 b1
= newtButton(-1, -1, "Button 1");
22 b2
= newtButton(-1, -1, "Another Button");
23 b3
= newtButton(-1, -1, "But, but");
24 b4
= newtButton(-1, -1, "But what?");
26 f
= newtForm(NULL
, NULL
, 0);
28 grid
= newtCreateGrid(2, 2);
29 newtGridSetField(grid
, 0, 0, NEWT_GRID_COMPONENT
, b1
, 0, 0, 0, 0,
30 NEWT_ANCHOR_RIGHT
, 0);
31 newtGridSetField(grid
, 0, 1, NEWT_GRID_COMPONENT
, b2
, 0, 0, 0, 0, 0, 0);
32 newtGridSetField(grid
, 1, 0, NEWT_GRID_COMPONENT
, b3
, 0, 0, 0, 0, 0, 0);
33 newtGridSetField(grid
, 1, 1, NEWT_GRID_COMPONENT
, b4
, 0, 0, 0, 0, 0, 0);
36 newtFormAddComponents(f
, b1
, b2
, b3
, b4
, NULL
);
38 newtGridPlace(grid
, 1, 1);
40 answer
= newtRunForm(f
);
46 flowedText
= newtReflowText("This is a quite a bit of text. It is 40 "
47 "columns long, so some wrapping should be "
48 "done. Did you know that the quick, brown "
49 "fox jumped over the lazy dog?\n\n"
50 "In other news, it's pretty important that we "
51 "can properly force a line break.",
52 40, 5, 5, &textWidth
, &textHeight
);
53 t
= newtTextbox(-1, -1, textWidth
, textHeight
, NEWT_FLAG_WRAP
);
54 newtTextboxSetText(t
, flowedText
);
58 b1
= newtButton(-1, -1, "Okay");
59 b2
= newtButton(-1, -1, "Cancel");
61 grid
= newtCreateGrid(1, 2);
62 subgrid
= newtCreateGrid(2, 1);
64 newtGridSetField(subgrid
, 0, 0, NEWT_GRID_COMPONENT
, b1
, 0, 0, 0, 0, 0, 0);
65 newtGridSetField(subgrid
, 1, 0, NEWT_GRID_COMPONENT
, b2
, 0, 0, 0, 0, 0, 0);
67 newtGridSetField(grid
, 0, 0, NEWT_GRID_COMPONENT
, t
, 0, 0, 0, 1, 0, 0);
68 newtGridSetField(grid
, 0, 1, NEWT_GRID_SUBGRID
, subgrid
, 0, 0, 0, 0, 0,
69 NEWT_GRID_FLAG_GROWX
);
70 newtGridWrappedWindow(grid
, "another example");
72 f
= newtForm(NULL
, NULL
, 0);
73 newtFormAddComponents(f
, b1
, t
, b2
, NULL
);
74 answer
= newtRunForm(f
);
78 newtWinMessage("Simple", "Ok", "This is a simple message window");
79 newtWinChoice("Simple", "Ok", "Cancel", "This is a simple choice window");
82 rc
= newtWinMenu("Test Menu", "This is a sample invovation of the "
83 "newtWinMenu() call. It may or may not have a scrollbar, "
84 "depending on the need for one.", 50, 5, 5, 3,
85 menuContents
, &textWidth
, "Ok", "Cancel", NULL
);
88 printf("rc = 0x%x item = %d\n", rc
, textWidth
);