1 /*
2  *  This file is part of XForms.
3  *
4  *  XForms is free software; you can redistribute it and/or modify it
5  *  under the terms of the GNU Lesser General Public License as
6  *  published by the Free Software Foundation; either version 2.1, or
7  *  (at your option) any later version.
8  *
9  *  XForms is distributed in the hope that it will be useful, but
10  *  WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public
15  *  License along with XForms; see the file COPYING.  If not, write to
16  *  the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
17  *  MA 02111-1307, USA.
18  */
19 
20 
21 /*
22  * same functionality as yesno.c, but with callbacks.
23  */
24 
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28 
29 #include <stdlib.h>
30 #include "include/forms.h"
31 
32 
33 /***************************************
34  ***************************************/
35 
36 void
yes_push(FL_OBJECT * ob FL_UNUSED_ARG,long data FL_UNUSED_ARG)37 yes_push( FL_OBJECT * ob    FL_UNUSED_ARG,
38           long        data  FL_UNUSED_ARG )
39 {
40     fprintf( stderr, "Yes is pushed\n" );
41     fl_finish( );
42     exit( 0 );
43 }
44 
45 
46 /***************************************
47  ***************************************/
48 
49 void
no_push(FL_OBJECT * ob FL_UNUSED_ARG,long data FL_UNUSED_ARG)50 no_push( FL_OBJECT * ob    FL_UNUSED_ARG,
51          long        data  FL_UNUSED_ARG )
52 {
53     fprintf( stderr, "No is pushed\n" );
54 }
55 
56 
57 /***************************************
58  ***************************************/
59 
60 int
main(int argc,char * argv[])61 main( int    argc,
62       char * argv[ ] )
63 {
64     FL_FORM *form;
65     FL_OBJECT *obj;
66 
67     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
68 
69     form = fl_bgn_form( FL_UP_BOX, 320, 120 );
70 
71     fl_add_box( FL_NO_BOX, 80, 20, 160, 40, "Do you want to quit?" );
72 
73     obj = fl_add_button( FL_NORMAL_BUTTON, 40, 70, 80, 30, "Yes" );
74     fl_set_object_callback( obj, yes_push, 0 );
75 
76     obj  = fl_add_button( FL_NORMAL_BUTTON, 200, 70, 80, 30, "No" );
77     fl_set_object_callback( obj, no_push, 0 );
78 
79     fl_end_form( );
80 
81     fl_show_form( form,FL_PLACE_MOUSE, FL_TRANSIENT, "Question" );
82 
83     fl_do_forms( );
84 
85     /* We'll never get here since all objects have callback
86        functions and thus fl_do_forms() never returns */
87 
88     return 0;
89 }
90 
91 
92 /*
93  * Local variables:
94  * tab-width: 4
95  * indent-tabs-mode: nil
96  * End:
97  */
98