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 touch buttons.
22 */
23 
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27 
28 #include <stdio.h>
29 #include "include/forms.h"
30 
31 static void show_val( FL_OBJECT *, long );
32 FL_OBJECT *valobj;
33 
34 
35 /***************************************
36  ***************************************/
37 
38 int
main(int argc,char * argv[])39 main( int    argc,
40       char * argv[ ] )
41 {
42     FL_FORM *form;
43     FL_OBJECT *obj;
44 
45     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
46 
47     form = fl_bgn_form( FL_UP_BOX, 360, 140);
48 
49     obj = fl_add_button( FL_TOUCH_BUTTON, 50, 30, 40, 30, "@<<" );
50     fl_set_object_boxtype( obj, FL_FRAME_BOX );
51     fl_set_object_color( obj, FL_COL1, FL_INDIANRED );
52     fl_set_object_callback( obj, show_val, -5 );
53     fl_set_button_shortcut( obj, "1", 0 );
54 
55     obj = fl_add_button( FL_TOUCH_BUTTON, 90, 30, 40, 30, "@<" );
56     fl_set_object_boxtype( obj, FL_FRAME_BOX );
57     fl_set_object_color( obj, FL_COL1, FL_INDIANRED );
58     fl_set_object_callback( obj,  show_val, -1 );
59     fl_set_button_shortcut( obj, "2",  0 );
60 
61     valobj = obj = fl_add_box( FL_BORDER_BOX, 130, 30, 100, 30, "" );
62     fl_set_object_color( obj, FL_LEFT_BCOL, FL_LEFT_BCOL );
63 
64     obj = fl_add_button( FL_TOUCH_BUTTON, 230, 30, 40, 30, "@>" );
65     fl_set_object_boxtype( obj, FL_FRAME_BOX );
66     fl_set_object_color( obj, FL_COL1, FL_INDIANRED );
67     fl_set_object_callback( obj, show_val, 1 );
68     fl_set_button_shortcut( obj, "3", 0 );
69 
70     obj = fl_add_button( FL_TOUCH_BUTTON, 270, 30, 40, 30, "@>>" );
71     fl_set_object_boxtype( obj, FL_FRAME_BOX );
72     fl_set_object_callback( obj, show_val, 5 );
73     fl_set_object_color( obj, FL_COL1, FL_INDIANRED );
74     fl_set_button_shortcut( obj, "4", 0 );
75 
76     fl_add_button( FL_NORMAL_BUTTON, 220, 90, 100, 30, "Exit" );
77 
78     fl_end_form( );
79 
80     fl_show_form( form, FL_PLACE_CENTER, FL_NOBORDER, "Touch Buttons" );
81 
82     fl_do_forms( );
83     fl_finish( );
84 
85     return 0;
86 }
87 
88 
89 /***************************************
90  ***************************************/
91 
92 static void
show_val(FL_OBJECT * ob FL_UNUSED_ARG,long delta)93 show_val( FL_OBJECT * ob  FL_UNUSED_ARG,
94           long        delta )
95 {
96     static int val = 0;
97     char str[ 32 ];
98 
99     val += delta;
100     sprintf( str,"%d", val );
101     fl_set_object_label( valobj, str );
102 }
103 
104 
105 /*
106  * Local variables:
107  * tab-width: 4
108  * indent-tabs-mode: nil
109  * End:
110  */
111