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 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include "include/forms.h"
26
27 FL_FORM *form;
28 FL_OBJECT *readyobj;
29
30
31 /***************************************
32 ***************************************/
33
34 static int
cb(FL_POPUP_RETURN * r)35 cb( FL_POPUP_RETURN *r )
36 {
37 fprintf( stderr, "CallBack: %s\n", r->label );
38 return 0;
39 }
40
41
42 /***************************************
43 ***************************************/
44
45 void
create_form(void)46 create_form( void )
47 {
48 FL_OBJECT *sexobj,
49 *childobj,
50 *licenceobj,
51 *marriedobj;
52 FL_POPUP_ITEM items[ ] = { { "Male%SM", cb, "M", 0, 0 },
53 { "Female%SF", cb, "F", 0, 0 },
54 { NULL, NULL, NULL, 0, 0 } };
55
56 form = fl_bgn_form( FL_NO_BOX, 420, 360 );
57
58 fl_add_box( FL_UP_BOX, 0, 0, 420, 360, "" );
59
60 fl_add_input( FL_NORMAL_INPUT, 70, 300, 320, 30, "Name" );
61
62 fl_add_input( FL_NORMAL_INPUT, 70, 260, 320, 30, "Address" );
63
64 fl_add_input( FL_NORMAL_INPUT, 70, 220, 320, 30, "City" );
65
66 fl_add_input( FL_NORMAL_INPUT, 70, 180, 320, 30, "Country" );
67
68 sexobj = fl_add_select( FL_NORMAL_SELECT, 70, 130, 110, 30, "Sex");
69 fl_set_select_items( sexobj, items );
70 fl_set_object_shortcut( sexobj, "S", 1 );
71
72 childobj = fl_add_select( FL_MENU_SELECT, 280, 130, 110, 30,
73 "Children" );
74 fl_add_select_items( childobj, "Zero|One|Two|Three|Four|Many" );
75 fl_set_object_shortcut( childobj, "C", 1 );
76 fl_popup_set_title( fl_get_select_popup( childobj ), "Kids" );
77
78 licenceobj = fl_add_select( FL_NORMAL_SELECT, 280, 80, 110, 30, "Licence" );
79 fl_add_select_items( licenceobj, "Yes|No" );
80 fl_set_select_policy( licenceobj, FL_POPUP_DRAG_SELECT );
81
82 marriedobj = fl_add_select( FL_DROPLIST_SELECT, 70, 80, 110, 27,
83 "Married" );
84 fl_add_select_items( marriedobj, "Yes|No" );
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
104 fl_show_form( form, FL_PLACE_CENTER | FL_FREE_SIZE, FL_TRANSIENT,
105 "Select Object Demo" );
106
107 while ( fl_do_forms( ) != readyobj )
108 /* empty */ ;
109
110 fl_hide_form( form );
111 fl_finish( );
112
113 return 0;
114 }
115
116
117 /*
118 * Local variables:
119 * tab-width: 4
120 * indent-tabs-mode: nil
121 * End:
122 */
123