2 * small test-driver for new dialog functionality
4 * Copyright (c) 1995, Jordan Hubbard
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
16 * $FreeBSD: src/gnu/lib/libdialog/TESTS/check3.c,v 1.6 2000/01/10 11:52:03 phantom Exp $
17 * $DragonFly: src/gnu/lib/libdialog/TESTS/check3.c,v 1.2 2003/06/17 04:25:43 dillon Exp $
27 getBool(dialogMenuItem
*self
)
29 if (self
->data
&& *((int *)self
->data
))
35 setBool(dialogMenuItem
*self
)
38 *((int *)self
->data
) = !*((int *)self
->data
);
44 static int german_book
, italian_book
, slang_book
;
48 check(dialogMenuItem
*self
)
50 return ((int)self
->data
== spending
);
54 spend(dialogMenuItem
*self
)
56 spending
= (int)self
->data
;
57 return DITEM_SUCCESS
| DITEM_REDRAW
;
60 /* menu4 - Show off a simulated compound menu (group at top is checklist, group at bottom radio) */
61 /* prompt title checked fire sel, data lbra mark rbra */
62 static dialogMenuItem menu4
[] = {
63 { "German", "Buy books on learning German", getBool
, setBool
, NULL
, &german_book
},
64 { "Italian","Buy books on learning Italian", getBool
, setBool
, NULL
, &italian_book
},
65 { "Slang", "Buy books on commonly used insults", getBool
, setBool
, NULL
, &slang_book
},
66 { "-----", "----------------------------------", NULL
, NULL
, NULL
, NULL
, ' ', ' ', ' ' },
67 { "1000", "Spend $1,000", check
, spend
, NULL
, (void *)1000, '(', '*', ')' },
68 { "500", "Spend $500", check
, spend
, NULL
, (void *)500, '(', '*', ')' },
69 { "100", "Spend $100", check
, spend
, NULL
, (void *)100, '(', '*', ')' },
72 /* End of hook functions */
74 /* Kick it off, James! */
76 main(int argc
, char **argv
)
83 retval
= dialog_checklist("this is dialog_checklist() in action, test #3",
84 "Now we show off some of the button 'styles' one can create.",
85 -1, -1, 7, -7, menu4
, NULL
);
87 fprintf(stderr
, "spent $%d on %s%s%s books\n", spending
, german_book
? " german" : "",
88 italian_book
? " italian" : "", slang_book
? " slang" : "");