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 positioner. */
22
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26
27 #include <stdio.h>
28 #include <math.h>
29 #include "include/forms.h"
30
31 static FL_OBJECT * xval,
32 * yval;
33
34
35 /***************************************
36 * Callback routine
37 ***************************************/
38
39 static void
positioner_cb(FL_OBJECT * obj,long data FL_UNUSED_ARG)40 positioner_cb( FL_OBJECT * obj,
41 long data FL_UNUSED_ARG )
42 {
43 fl_set_object_label_f( xval, "%f", fl_get_positioner_xvalue( obj ) );
44 fl_set_object_label_f( yval, "%f", fl_get_positioner_yvalue( obj ) );
45 }
46
47
48 /***************************************
49 ***************************************/
50
51 int
main(int argc,char * argv[])52 main( int argc,
53 char * argv[ ] )
54 {
55 FL_FORM * form;
56 FL_OBJECT * pos;
57
58 fl_initialize( &argc, argv, "FormDemo", 0, 0 );
59
60 form = fl_bgn_form( FL_UP_BOX, 400, 280 );
61
62 pos = fl_add_positioner( FL_NORMAL_POSITIONER, 40, 40, 200, 200, "" );
63 fl_set_positioner_xbounds( pos, 0, 1 );
64 fl_set_positioner_ybounds( pos, 0, 1 );
65 fl_set_object_callback( pos, positioner_cb, 0 );
66
67 xval = fl_add_box( FL_DOWN_BOX, 270, 40, 100, 30, "" );
68 fl_set_object_color( xval, FL_COL1, FL_COL1 );
69
70 yval = fl_add_box( FL_DOWN_BOX, 270, 90, 100, 30, "" );
71 fl_set_object_color( yval, FL_COL1, FL_COL1 );
72
73 fl_add_button( FL_NORMAL_BUTTON, 270, 210, 100, 30, "Exit" );
74
75 fl_end_form( );
76
77 fl_show_form( form, FL_PLACE_CENTER, FL_NOBORDER, "positioner" );
78
79 positioner_cb( pos, 0 );
80
81 fl_do_forms( );
82 fl_hide_form( form );
83 fl_finish( );
84
85 return 0;
86 }
87
88
89 /*
90 * Local variables:
91 * tab-width: 4
92 * indent-tabs-mode: nil
93 * End:
94 */
95