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  *  This demo shows the use of choice objects.
23  *
24  *  This file is part of xforms package
25  *  M. Overmars and T.C. Zhao    (1997)
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31 
32 #include "include/forms.h"
33 
34 FL_FORM *form;
35 FL_OBJECT *sexobj,
36           *childobj,
37           *licenceobj,
38           *marriedobj,
39           *readyobj;
40 
41 
42 /***************************************
43  ***************************************/
44 
45 static void
cb(FL_OBJECT * ob,long data FL_UNUSED_ARG)46 cb( FL_OBJECT * ob,
47     long        data  FL_UNUSED_ARG )
48 {
49     fprintf( stderr, "CallBack: %d\n", fl_get_choice( ob ) );
50 }
51 
52 
53 /***************************************
54  ***************************************/
55 
56 void
create_form(void)57 create_form( void )
58 {
59     form = fl_bgn_form( FL_NO_BOX, 420, 360 );
60 
61     fl_add_box( FL_UP_BOX, 0, 0, 420, 360, "" );
62 
63     fl_add_input( FL_NORMAL_INPUT, 70, 300, 320, 30, "Name" );
64 
65     fl_add_input( FL_NORMAL_INPUT, 70, 260, 320, 30, "Address" );
66 
67     fl_add_input( FL_NORMAL_INPUT, 70, 220, 320, 30, "City" );
68 
69     fl_add_input( FL_NORMAL_INPUT, 70, 180, 320, 30, "Country" );
70 
71     sexobj = fl_add_choice( FL_NORMAL_CHOICE, 70, 130, 110, 30, "Sex");
72     fl_set_choice_notitle( sexobj, 1 );
73     fl_set_object_shortcut( sexobj, "S", 1 );
74 
75     childobj = fl_add_choice( FL_NORMAL_CHOICE2, 280, 130, 110, 30,
76                               "Children" );
77 
78     licenceobj = fl_add_choice( FL_NORMAL_CHOICE, 280, 80, 110, 30, "Licence" );
79     fl_set_choice_align_bottom( licenceobj, 1 );
80 
81     marriedobj = fl_add_choice( FL_DROPLIST_CHOICE, 70, 80, 110, 27,
82                                 "Married" );
83     fl_set_object_callback( marriedobj, cb, 0 );
84     fl_set_object_boxtype( marriedobj, FL_UP_BOX );
85 
86     readyobj = fl_add_button( FL_NORMAL_BUTTON, 150, 20, 140, 30, "Quit" );
87 
88     fl_end_form( );
89 }
90 
91 
92 /***************************************
93  ***************************************/
94 
95 int
main(int argc,char * argv[])96 main( int    argc,
97       char * argv[ ] )
98 {
99     fl_flip_yorigin( );
100     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
101 
102     create_form( );
103     fl_addto_choice( sexobj,"Male" );
104     fl_addto_choice( sexobj,"Female" );
105     fl_addto_choice( childobj, "Zero|One|Two|Three|Four|Many" );
106     fl_addto_choice( licenceobj, "Yes|No" );
107     fl_addto_choice( marriedobj, "Yes" );
108     fl_addto_choice( marriedobj, "No" );
109 
110     fl_show_form( form, FL_PLACE_CENTER | FL_FREE_SIZE, FL_TRANSIENT,
111                   "ChoiceDemo" );
112 
113     while ( fl_do_forms( ) != readyobj )
114         /* empty */ ;
115 
116 	fl_finish( );
117     return 0;
118 }
119 
120 
121 /*
122  * Local variables:
123  * tab-width: 4
124  * indent-tabs-mode: nil
125  * End:
126  */
127