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 /* This demo shows the use of a browser and fl_call_object_callback.  */
22 
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26 
27 #include <stdio.h>
28 #include "include/forms.h"
29 
30 FL_FORM *form;
31 FL_OBJECT *br, *but;
32 
33 
34 /***************************************
35  ***************************************/
36 
37 void
load_file(FL_OBJECT * ob FL_UNUSED_ARG,long arg FL_UNUSED_ARG)38 load_file( FL_OBJECT * ob   FL_UNUSED_ARG,
39            long        arg  FL_UNUSED_ARG )
40 {
41   if ( ! fl_load_browser( br, fl_show_input( "Filename to load", "" ) ) )
42       fl_add_browser_line( br, "NO SUCH FILE!" );
43 }
44 
45 
46 /***************************************
47  ***************************************/
48 
49 void
set_size(FL_OBJECT * ob FL_UNUSED_ARG,long arg)50 set_size( FL_OBJECT * ob  FL_UNUSED_ARG,
51           long        arg )
52 {
53   fl_set_browser_fontsize( br, arg );
54 }
55 
56 
57 /***************************************
58  ***************************************/
59 
60 int
main(int argc,char * argv[])61 main( int    argc,
62       char * argv[ ] )
63 {
64     FL_OBJECT *obj;
65 
66     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
67 
68     form = fl_bgn_form( FL_UP_BOX, 130, 100 );
69 
70     br = fl_add_browser( FL_NORMAL_BROWSER, 5, 5, 95, 90, "" );
71 
72     but = fl_add_button( FL_NORMAL_BUTTON, 105, 5, 20, 8, "Exit" );
73 
74     obj = fl_add_button( FL_NORMAL_BUTTON, 105, 75, 20, 8, "Load" );
75     fl_set_object_callback( obj, load_file, 0 );
76 
77     obj = fl_add_lightbutton( FL_RADIO_BUTTON, 105, 60, 20, 8, "Small" );
78     fl_set_object_callback( obj, set_size, FL_SMALL_SIZE );
79     fl_call_object_callback( obj );
80     fl_set_button( obj, 1 );
81 
82     obj = fl_add_lightbutton( FL_RADIO_BUTTON, 105, 50, 20, 8, "Normal" );
83     fl_set_object_callback( obj, set_size, FL_NORMAL_SIZE );
84     obj = fl_add_lightbutton( FL_RADIO_BUTTON, 105, 40, 20, 8, "Large" );
85 
86     fl_set_object_callback( obj, set_size, FL_LARGE_SIZE );
87 
88     fl_end_form( );
89 
90     fl_scale_form( form, 4.0, 4.0 );
91     fl_adjust_form_size( form );
92 
93     fl_clear_browser( br );
94     fl_add_browser_line( br,"LOAD A FILE." );
95 
96     fl_show_form( form,FL_PLACE_FREE, FL_FULLBORDER, "Browser" );
97 
98     do
99         obj = fl_do_forms( );
100     while ( obj != but );
101 
102     fl_hide_form( form );
103     fl_finish( );
104 
105     return 0;
106 }
107 
108 
109 /*
110  * Local variables:
111  * tab-width: 4
112  * indent-tabs-mode: nil
113  * End:
114  */
115