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/check2.c,v 1.6 2000/01/10 11:52:02 phantom Exp $
29 getBool(dialogMenuItem *self)
31 if (self->data && *((int *)self->data))
37 setBool(dialogMenuItem *self)
40 *((int *)self->data) = !*((int *)self->data);
46 static int german_book, italian_book, slang_book;
49 clearBooks(dialogMenuItem *self)
51 german_book = italian_book = slang_book = FALSE;
52 return DITEM_SUCCESS | DITEM_REDRAW;
56 buyBooks(dialogMenuItem *self)
60 if (german_book || italian_book || slang_book) {
61 strcpy(foo, "Ok, you're buying books on");
63 strcat(foo, " german");
65 strcat(foo, " italian");
67 strcat(foo, " slang");
70 strcpy(foo, "You're not buying any books?");
71 dialog_mesgbox("This is a direct callback for the `Buy' button", foo, -1, -1);
75 /* menu3 - Look mom! We can finally use our own OK and Cancel buttons! */
76 /* prompt title checked fire sel data */
77 static dialogMenuItem menu3[] = {
78 { "Buy!", NULL, NULL, buyBooks }, /* New "OK" button */
79 { "No Way!", NULL, NULL, NULL }, /* New "Cancel" button */
80 { "German", "Buy books on learning German", getBool, setBool, NULL, &german_book },
81 { "Italian", "Buy books on learning Italian", getBool, setBool, NULL, &italian_book },
82 { "Slang", "Buy books on commonly used insults", getBool, setBool, NULL, &slang_book },
83 { "Clear", "Clear book list", NULL, clearBooks, NULL, NULL, ' ', ' ', ' ' },
86 /* End of hook functions */
88 /* Kick it off, James! */
90 main(int argc, char **argv)
96 retval = dialog_checklist("this is dialog_checklist() in action, test #2",
97 "Same as before, but now we relabel the buttons and override the OK action.",
98 -1, -1, 4, -4, menu3 + 2, (char *)TRUE);
100 fprintf(stderr, "returned value for dialog_checklist was %d\n", retval);