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