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
17 #include <sys/cdefs.h>
18 __FBSDID("$FreeBSD$");
30 getBool(dialogMenuItem *self)
32 if (self->data && *((int *)self->data))
38 setBool(dialogMenuItem *self)
41 *((int *)self->data) = !*((int *)self->data);
47 static int german_book, italian_book, slang_book;
50 clearBooks(dialogMenuItem *self)
52 german_book = italian_book = slang_book = FALSE;
53 return DITEM_SUCCESS | DITEM_REDRAW;
57 buyBooks(dialogMenuItem *self)
61 if (german_book || italian_book || slang_book) {
62 strcpy(foo, "Ok, you're buying books on");
64 strcat(foo, " german");
66 strcat(foo, " italian");
68 strcat(foo, " slang");
71 strcpy(foo, "You're not buying any books?");
72 dialog_mesgbox("This is a direct callback for the `Buy' button", foo, -1, -1);
76 /* menu3 - Look mom! We can finally use our own OK and Cancel buttons! */
77 /* prompt title checked fire sel data */
78 static dialogMenuItem menu3[] = {
79 { "Buy!", NULL, NULL, buyBooks }, /* New "OK" button */
80 { "No Way!", NULL, NULL, NULL }, /* New "Cancel" button */
81 { "German", "Buy books on learning German", getBool, setBool, NULL, &german_book },
82 { "Italian", "Buy books on learning Italian", getBool, setBool, NULL, &italian_book },
83 { "Slang", "Buy books on commonly used insults", getBool, setBool, NULL, &slang_book },
84 { "Clear", "Clear book list", NULL, clearBooks, NULL, NULL, ' ', ' ', ' ' },
87 /* End of hook functions */
89 /* Kick it off, James! */
91 main(int argc, char **argv)
97 retval = dialog_checklist("this is dialog_checklist() in action, test #2",
98 "Same as before, but now we relabel the buttons and override the OK action.",
99 -1, -1, 4, -4, menu3 + 2, (char *)TRUE);
101 fprintf(stderr, "returned value for dialog_checklist was %d\n", retval);