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 #include "include/forms.h"
25 
26 
27 
28 static FL_OBJECT *sl,
29                  *but1,
30                  *but2,
31                  *but3;
32 
33 
34 /***************************************
35  ***************************************/
36 
37 static void
slider_callback(FL_OBJECT * a,long b FL_UNUSED_ARG)38 slider_callback( FL_OBJECT * a,
39                  long        b  FL_UNUSED_ARG )
40 
41 {
42     double val = fl_get_slider_value( a );
43 
44     fl_set_button( but1, 0 );
45     fl_set_button( but2, 0 );
46     fl_set_button( but3, 0 );
47 
48     if ( val <= 0.01 )
49         fl_set_button( but1, 1 );
50     else if ( val >= 0.49 && val <= 0.51 )
51         fl_set_button( but2, 1 );
52     else if ( val >= 0.99 )
53         fl_set_button( but3, 1 );
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 *but,
66               *obj;
67 
68     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
69     form = fl_bgn_form( FL_UP_BOX, 300, 300 );
70     sl = fl_add_slider( FL_VERT_SLIDER, 40, 40, 60, 220, "X" );
71     fl_set_slider_value( sl, 0.5 );
72     fl_set_object_callback( sl, slider_callback, 0 );
73     but1 = fl_add_lightbutton( FL_PUSH_BUTTON, 140, 220, 120, 40, "0.0" );
74     but2 = fl_add_lightbutton( FL_PUSH_BUTTON, 140, 160, 120, 40, "0.5" );
75     fl_set_button( but2, 1 );
76     but3 = fl_add_lightbutton( FL_PUSH_BUTTON, 140, 100, 120, 40, "1.0" );
77     but = fl_add_button( FL_NORMAL_BUTTON, 140, 40, 120, 40, "Exit" );
78     fl_end_form();
79 
80     fl_show_form( form, FL_PLACE_CENTER, FL_NOBORDER, "slRadio" );
81 
82     while ( ( obj = fl_do_forms( ) ) != but )
83         if ( obj == but1 )
84         {
85             if ( fl_get_button( but1 ) )
86             {
87                 fl_set_slider_value( sl, 0.0 );
88                 fl_set_button( but2, 0 );
89                 fl_set_button( but3, 0 );
90             }
91             else
92                 fl_set_button( but1, 1 );
93         }
94         else if ( obj == but2 )
95         {
96             if ( fl_get_button( but2 ) )
97             {
98                 fl_set_slider_value( sl, 0.5 );
99                 fl_set_button( but1, 0 );
100                 fl_set_button( but3, 0 );
101             }
102             else
103                 fl_set_button( but2, 1 );
104         }
105         else if ( obj == but3 )
106         {
107             if ( fl_get_button( but3 ) )
108             {
109                 fl_set_slider_value( sl, 1.0 );
110                 fl_set_button( but1, 0 );
111                 fl_set_button( but2, 0 );
112             }
113             else
114                 fl_set_button( but3, 1 );
115         }
116 
117     fl_finish( );
118 
119     return 0;
120 }
121 
122 
123 /*
124  * Local variables:
125  * tab-width: 4
126  * indent-tabs-mode: nil
127  * End:
128  */
129