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 /* A demo that shows the use of push buttons.  */
22 
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26 
27 #include "include/forms.h"
28 
29 FL_FORM *form;
30 FL_OBJECT  *abox[ 8 ];
31 
32 
33 /***************************************
34  ***************************************/
35 
36 static void
push_cb(FL_OBJECT * ob,long n)37 push_cb( FL_OBJECT * ob,
38          long        n )
39 {
40     if ( fl_get_button( ob ) )
41         fl_show_object( abox[ n ] );
42     else
43         fl_hide_object( abox[ n ] );
44 }
45 
46 
47 /***************************************
48  ***************************************/
49 
50 static void
makeform(void)51 makeform( void )
52 {
53     int i;
54     FL_OBJECT *obj;
55 
56     form = fl_bgn_form( FL_UP_BOX, 400, 400 );
57 
58     for ( i = 0; i < 8; i++ )
59     {
60         obj = fl_add_button( FL_PUSH_BUTTON, 40, 310 - 40 * i, 80, 30, "" );
61         fl_set_object_color( obj, FL_BLACK + i + 1, FL_BLACK + i + 1 );
62         fl_set_object_callback( obj, push_cb, i );
63 
64         abox[ i ] = fl_add_box( FL_DOWN_BOX, 150 + 30 * i, 40, 25, 320, "" );
65         fl_set_object_color( abox[ i ], FL_BLACK + i + 1, FL_BLACK + i + 1 );
66         fl_hide_object( abox[ i ] );
67     }
68 
69     fl_add_button( FL_NORMAL_BUTTON, 40, 350, 80, 30, "Exit" );
70     fl_end_form( );
71 }
72 
73 
74 /***************************************
75  ***************************************/
76 
77 int
main(int argc,char * argv[])78 main( int    argc,
79       char * argv[ ] )
80 {
81     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
82     makeform( );
83 
84     fl_show_form( form, FL_PLACE_CENTER, FL_NOBORDER, "Push Buttons" );
85 
86     /* fl_do_forms will return only when Exit is pressed */
87 
88     fl_do_forms( );
89     fl_finish( );
90 
91     return 0;
92 }
93 
94 
95 /*
96  * Local variables:
97  * tab-width: 4
98  * indent-tabs-mode: nil
99  * End:
100  */
101