1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/* $Id: radio1_ex.c,v 1.14 2016/12/04 15:22:16 tom Exp $ */
#include <cdk_test.h>
#ifdef HAVE_XCURSES
char *XCursesProgramName = "radio_ex";
#endif
/*
* This program demonstrates the Cdk radio widget.
*/
int main (int argc, char **argv)
{
CDKSCREEN *cdkscreen;
CDKRADIO *radio;
const char *item[5] =
{
"Choice A",
"Choice B",
"Choice C"
};
const char *mesg[5];
char temp[100];
int selection;
CDK_PARAMS params;
CDKparseParams (argc, argv, ¶ms, "s:t:" CDK_CLI_PARAMS);
cdkscreen = initCDKScreen (NULL);
/* Set up CDK Colors. */
initCDKColor ();
/* Create the radio list. */
radio = newCDKRadio (cdkscreen,
CDKparamValue (¶ms, 'X', CENTER),
CDKparamValue (¶ms, 'Y', CENTER),
CDKparsePosition (CDKparamString2 (¶ms, 's',
"NONE")),
CDKparamValue (¶ms, 'H', 5),
CDKparamValue (¶ms, 'W', 20),
CDKparamString (¶ms, 't'),
(CDK_CSTRING2)item, 3,
'#' | A_REVERSE, 1,
A_REVERSE,
CDKparamValue (¶ms, 'N', TRUE),
CDKparamValue (¶ms, 'S', FALSE));
/* Check if the radio list is NULL. */
if (radio == (CDKRADIO *)NULL)
{
/* Exit CDK. */
destroyCDKScreen (cdkscreen);
endCDK ();
printf ("Cannot create the radio widget. ");
printf ("Is the window too small?\n");
ExitProgram (EXIT_FAILURE);
}
/* Activate the radio list. */
selection = activateCDKRadio (radio, (chtype *)NULL);
/* Check the exit status of the widget. */
if (radio->exitType == vESCAPE_HIT)
{
mesg[0] = "<C>You hit escape. No item selected.";
mesg[1] = "",
mesg[2] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 3);
}
else if (radio->exitType == vNORMAL)
{
mesg[0] = "<C>You selected the filename";
sprintf (temp, "<C>%.*s", (int)(sizeof (temp) - 20), item[selection]);
mesg[1] = temp;
mesg[2] = "";
mesg[3] = "<C>Press any key to continue.";
popupLabel (cdkscreen, (CDK_CSTRING2)mesg, 4);
}
destroyCDKRadio (radio);
destroyCDKScreen (cdkscreen);
endCDK ();
ExitProgram (EXIT_SUCCESS);
}
|