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 /*
22 * This demo shows the use of a positioner with XOR drawmode, most
23 * useful for overlaying positioner on top of other object
24 *
25 * This file is part of xforms package
26 * T.C. Zhao and M. Overmars 1997
27 */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include <stdio.h>
34 #include "include/forms.h"
35
36 FL_OBJECT * xval,
37 * yval;
38
39
40 /***************************************
41 * Callback routine
42 ***************************************/
43
44 void
positioner_cb(FL_OBJECT * obj,long data FL_UNUSED_ARG)45 positioner_cb( FL_OBJECT * obj,
46 long data FL_UNUSED_ARG )
47 {
48 char str[ 30 ];
49
50 sprintf( str, "%f", fl_get_positioner_xvalue( obj ) );
51 fl_set_object_label( xval, str );
52
53 sprintf( str, "%f", fl_get_positioner_yvalue( obj ) );
54 fl_set_object_label( yval, str );
55 }
56
57
58 /***************************************
59 ***************************************/
60
61 int
main(int argc,char * argv[])62 main( int argc,
63 char * argv[ ] )
64 {
65 FL_FORM * form;
66 FL_OBJECT * pos,
67 * obj;
68
69 fl_set_border_width( -2 );
70 fl_initialize( &argc, argv, "FormDemo", 0, 0 );
71
72 form = fl_bgn_form( FL_UP_BOX, 350, 250 );
73
74 obj = fl_add_pixmap( FL_NORMAL_PIXMAP, 60, 70, 100, 100, "" );
75 fl_set_object_boxtype( obj, FL_DOWN_BOX );
76 fl_set_pixmap_file( obj, "porsche.xpm" );
77
78 pos = fl_add_positioner( FL_OVERLAY_POSITIONER, 60, 70, 100, 100, "" );
79 fl_set_positioner_xbounds( pos, 0, 1 );
80 fl_set_positioner_ybounds( pos, 0, 1 );
81 fl_set_object_callback( pos, positioner_cb, 0 );
82
83 xval = fl_add_box( FL_DOWN_BOX, 230, 40, 100, 30, "" );
84 fl_set_object_color( xval, FL_COL1, FL_COL1 );
85
86 yval = fl_add_box( FL_DOWN_BOX, 230, 90, 100, 30, "" );
87 fl_set_object_color( yval, FL_COL1, FL_COL1 );
88
89 fl_add_button( FL_NORMAL_BUTTON, 230, 200, 100, 30, "Exit" );
90
91 fl_end_form( );
92
93 fl_show_form( form, FL_PLACE_CENTER, FL_TRANSIENT, "XOR Positioner" );
94
95 positioner_cb( pos, 0 );
96 fl_do_forms( );
97 fl_hide_form( form );
98 fl_finish( );
99
100 return 0;
101 }
102
103
104 /*
105 * Local variables:
106 * tab-width: 4
107 * indent-tabs-mode: nil
108 * End:
109 */
110