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 slider. Every time the slider changes
22 position it is returned by do_forms() and the text field showing its
23 value is adapted.
24 */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29 #include <stdio.h>
30 #include "include/forms.h"
31
32
33 /***************************************
34 ***************************************/
35
36 void
slider_cb(FL_OBJECT * ob,long data)37 slider_cb( FL_OBJECT * ob,
38 long data )
39 {
40 char str[ 30 ];
41
42 sprintf( str, "%f", fl_get_slider_value( ob ) );
43 fl_set_object_label( ( FL_OBJECT * ) data, str );
44 }
45
46
47 /***************************************
48 ***************************************/
49
50 int
main(int argc,char * argv[])51 main( int argc,
52 char * argv[ ] )
53 {
54 FL_FORM *form;
55 FL_OBJECT *slider,
56 *value;
57
58 fl_initialize( &argc, argv, "FormDemo", 0, 0 );
59
60 form = fl_bgn_form( FL_UP_BOX, 240, 400 );
61
62 value = fl_add_box( FL_DOWN_BOX, 120, 180, 100, 30, "" );
63 fl_set_object_lalign( value, FL_ALIGN_CENTER );
64
65 slider = fl_add_slider( FL_VERT_SLIDER, 40, 40, 60, 320, "" );
66 fl_set_slider_bounds( slider, -1, 1 );
67 fl_set_slider_value( slider, 0 );
68 fl_set_object_color( slider, FL_SLIDER_COL1, FL_GREEN );
69 fl_set_object_callback( slider, slider_cb, ( long ) value );
70
71 fl_add_button( FL_RETURN_BUTTON, 120, 290, 100, 30, "Exit" );
72
73 fl_end_form( );
74
75 fl_show_form( form, FL_PLACE_CENTER, FL_NOBORDER, "Slider" );
76
77 fl_do_forms( );
78
79 fl_finish( );
80 return 0;
81 }
82
83
84 /*
85 * Local variables:
86 * tab-width: 4
87 * indent-tabs-mode: nil
88 * End:
89 */
90