1
/* $Id: fslider_ex.c,v 1.1 2005/12/27 19:16:29 tom Exp $ */
6
char *XCursesProgramName = "slider_ex";
10
* This program demonstrates the Cdk slider widget.
12
int main (int argc, char **argv)
14
/* Declare variables. */
15
CDKSCREEN *cdkscreen = 0;
16
CDKFSLIDER *widget = 0;
17
WINDOW *cursesWin = 0;
18
char *title = "<C></U>Enter a value:";
19
char *label = "</B>Current Value:";
20
char temp[256], *mesg[5];
31
CDKparseParams(argc, argv, ¶ms, "h:i:l:w:p:" CDK_MIN_PARAMS);
32
digits = CDKparamNumber2(¶ms, 'p', 0);
35
for (n = 0; n < digits; ++n) {
39
high = CDKparamNumber2(¶ms, 'h', 100) / scale;
40
inc = CDKparamNumber2(¶ms, 'i', 1) / scale;
41
low = CDKparamNumber2(¶ms, 'l', 1) / scale;
44
cursesWin = initscr();
45
cdkscreen = initCDKScreen (cursesWin);
47
/* Start CDK Colors. */
50
/* Create the widget. */
51
widget = newCDKFSlider (cdkscreen,
52
CDKparamValue(¶ms, 'X', CENTER),
53
CDKparamValue(¶ms, 'Y', CENTER),
55
A_REVERSE | COLOR_PAIR (29) | ' ',
56
CDKparamNumber2(¶ms, 'w', 50),
60
CDKparamValue(¶ms, 'N', TRUE),
61
CDKparamValue(¶ms, 'S', FALSE));
63
/* Is the widget null? */
67
destroyCDKScreen (cdkscreen);
70
/* Print out a message. */
71
printf ("Oops. Can't make the widget. Is the window too small?\n");
72
ExitProgram (EXIT_FAILURE);
75
/* Activate the widget. */
76
selection = activateCDKFSlider (widget, 0);
78
/* Check the exit value of the widget. */
79
if (widget->exitType == vESCAPE_HIT)
81
mesg[0] = "<C>You hit escape. No value selected.";
83
mesg[2] = "<C>Press any key to continue.";
84
popupLabel (cdkscreen, mesg, 3);
86
else if (widget->exitType == vNORMAL)
88
sprintf (temp, "<C>You selected %.*f", digits, selection);
89
mesg[0] = copyChar (temp);
91
mesg[2] = "<C>Press any key to continue.";
92
popupLabel (cdkscreen, mesg, 3);
97
destroyCDKFSlider (widget);
98
destroyCDKScreen (cdkscreen);
100
ExitProgram (EXIT_SUCCESS);