4
char *XCursesProgramName="buttonbox_ex";
7
static BINDFN_PROTO(entryCB);
10
* This program demonstrates the Cdk buttonbox widget.
14
/* Declare variables. */
15
CDKSCREEN *cdkscreen = 0;
16
CDKBUTTONBOX *buttonWidget = 0;
18
WINDOW *cursesWin = 0;
19
char *buttons[] = {" OK ", " Cancel "};
25
cursesWin = initscr();
26
cdkscreen = initCDKScreen (cursesWin);
31
/* Create the entry widget. */
32
entry = newCDKEntry (cdkscreen, CENTER, CENTER,
33
"<C>Enter a name\n<R>This is an entry box!\n<L>This is an entry box!", "Name:", A_NORMAL, '.', vMIXED,
34
40, 0, 256, TRUE, FALSE);
36
/* Create the button box widget. */
37
buttonWidget = newCDKButtonbox (cdkscreen,
39
getbegy(entry->win) + entry->boxHeight - 1,
41
"<R>This is a button box!\n<L>This is a button box!", 1, 2,
42
buttons, 2, A_REVERSE,
45
/* Set the lower left and right characters of the box. */
46
setCDKEntryLLChar (entry, ACS_LTEE);
47
setCDKEntryLRChar (entry, ACS_RTEE);
48
setCDKButtonboxULChar (buttonWidget, ACS_LTEE);
49
setCDKButtonboxURChar (buttonWidget, ACS_RTEE);
52
* Bind the Tab key in the entry field to send a
53
* Tab key to the button box widget.
55
bindCDKObject (vENTRY, entry, KEY_TAB, entryCB, buttonWidget);
57
/* Activate the entry field. */
58
drawCDKButtonbox (buttonWidget, TRUE);
59
activateCDKEntry (entry, 0);
60
exitType = entry->exitType;
61
selection = buttonWidget->currentButton;
62
if (exitType == vNORMAL)
64
info = copyChar (entry->info);
68
destroyCDKButtonbox (buttonWidget);
69
destroyCDKEntry (entry);
70
destroyCDKScreen (cdkscreen);
74
/* Spit out some info. */
75
if (exitType == vESCAPE_HIT)
77
printf ("You pressed escape.\n");
79
else if (exitType == vNORMAL)
81
printf ("You typed in (%s) and selected button (%s)\n", info, buttons[selection]);
87
static void entryCB (EObjectType cdktype GCC_UNUSED, void *object GCC_UNUSED, void *clientData, chtype key)
89
CDKBUTTONBOX *buttonbox = (CDKBUTTONBOX *)clientData;
91
injectCDKButtonbox (buttonbox, key);