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/check1.c,v 1.7 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;
55 /* menu2 - A more advanced way of using checked and fire hooks to manipulate the backing-variables directly */
56 /* prompt title checked fire sel data */
57 static dialogMenuItem menu2[] = {
58 { "German", "Buy book on learning German", getBool, setBool, NULL, &german_book},
59 { "Italian", "Buy book on learning Italian", getBool, setBool, NULL, &italian_book },
60 { "Slang", "Buy book on commonly used insults", getBool, setBool, NULL, &slang_book },
61 { "Clear", "Clear book list", NULL, clearBooks, NULL, NULL, ' ', ' ', ' ' },
64 /* End of hook functions */
66 /* Kick it off, James! */
68 main(int argc, char **argv)
74 retval = dialog_checklist("this is a dialog_checklist() in action, test #1",
75 "this checklist menu shows off some of the straight-forward features\n"
76 "of the new menu system's check & fire dispatch hooks", -1, -1, 4, -4, menu2, NULL);
78 fprintf(stderr, "returned value for dialog_checklist was %d (%d %d %d)\n", retval, german_book, italian_book, slang_book);