1/*
2 * small test-driver for new dialog functionality
3 *
4 * Copyright (c) 1995, Jordan Hubbard
5 *
6 * All rights reserved.
7 *
8 * This source code may be used, modified, copied, distributed, and
9 * sold, in both source and binary form provided that the above
10 * copyright and these terms are retained, verbatim, as the first
11 * lines of this file.  Under no circumstances is the author
12 * responsible for the proper functioning of the software nor does
13 * the author assume any responsibility for damages incurred with
14 * its use.
15 */
16
17#include <sys/cdefs.h>
18__FBSDID("$FreeBSD$");
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <unistd.h>
24#include <sys/wait.h>
25#include <dialog.h>
26
27/* Hook functions */
28
29static int spending;
30
31static int
32check(dialogMenuItem *self)
33{
34    return ((int)(intptr_t)self->data == spending);
35}
36
37static int
38spend(dialogMenuItem *self)
39{
40    spending = (int)(intptr_t)self->data;
41    return DITEM_SUCCESS | DITEM_REDRAW;
42}
43
44/* menu5 - Show a simple radiolist menu that inherits the radio appearance by default */
45/* prompt	title			checked		fire		sel   data */
46static dialogMenuItem menu5[] = {
47    { "1000",	"Spend $1,000",		check,		spend,		NULL, (void *)1000 },
48    { "500",	"Spend $500",		check,		spend,		NULL, (void *)500 },
49    { "100",	"Spend $100",		check,		spend, 		NULL, (void *)100 },
50};
51
52/* End of hook functions */
53
54/* Kick it off, James! */
55int
56main(int argc, char **argv)
57{
58    int retval;
59
60    init_dialog();
61
62
63    retval = dialog_radiolist("this is dialog_radiolist() in action, test #1",
64			      "this radio menu shows off some of the straight-forward features\n"
65			      "of the new menu system's check & fire dispatch hooks", -1, -1, 3, -3, menu5, NULL);
66    dialog_clear();
67    fprintf(stderr, "returned value for dialog_radiolist was %d (money set to %d)\n", retval, spending);
68
69    end_dialog();
70    return 0;
71}
72