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 * Show the use of setting object colors and call-back routines.
23 ************/
24
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include <stdio.h>
31 #include "include/forms.h"
32
33
34 FL_FORM *form;
35 FL_OBJECT *topbox;
36
37
38 /***************************************
39 ***************************************/
40
41 void
change_color(FL_OBJECT * obj FL_UNUSED_ARG,long col)42 change_color( FL_OBJECT * obj FL_UNUSED_ARG,
43 long col )
44 {
45 fl_set_object_color( topbox, col, col );
46 }
47
48
49 /***************************************
50 ***************************************/
51
52 void
makeform(void)53 makeform( void )
54 {
55 FL_OBJECT *obj;
56 int i, j;
57 char str[ 32 ];
58
59 form = fl_bgn_form( FL_UP_BOX, 100, 100 );
60
61 for ( i = 0; i < 8; i++ )
62 for ( j = 0; j < 8; j++ )
63 {
64 sprintf( str, "%d", 8 * j + i );
65 obj = fl_add_button( FL_RADIO_BUTTON,
66 11 + 10 * i, 15 + 10 * j, 8, 6, str );
67 fl_set_object_color( obj, 8 * j + i, 8 * j + i );
68 fl_set_object_lalign( obj, FL_ALIGN_BOTTOM );
69 fl_set_object_callback( obj, change_color, ( long ) ( 8 * j + i ) );
70 }
71
72 topbox = fl_add_button( FL_NORMAL_BUTTON, 30, 5, 40, 8, "The Color Map" );
73 fl_set_object_lsize( topbox, FL_LARGE_SIZE );
74 fl_set_object_lstyle( topbox, FL_BOLD_STYLE );
75
76 fl_end_form( );
77
78 fl_adjust_form_size( form );
79 }
80
81
82 /***************************************
83 ***************************************/
84
85 int
main(int argc,char * argv[])86 main( int argc,
87 char * argv[ ] )
88 {
89 FL_OBJECT *ret;
90
91 fl_initialize( &argc, argv, "FormDemo", 0, 0 );
92
93 makeform( );
94 fl_scale_form( form, 4.0, 4.0 );
95 fl_show_form( form, FL_PLACE_FREE, FL_TRANSIENT, "colsel" );
96
97 do
98 ret = fl_do_forms( );
99 while ( ret != topbox );
100
101 fl_hide_form( form );
102 fl_finish( );
103
104 return 0;
105 }
106
107
108 /*
109 * Local variables:
110 * tab-width: 4
111 * indent-tabs-mode: nil
112 * End:
113 */
114