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 is an example of the use of filled dials, dial range
22 * and dial direction.
23 *
24 * T.C. Zhao and M. Overmars
25 */
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include <stdio.h>
32 #include "include/forms.h"
33
34 FL_FORM *form;
35 FL_OBJECT *button,
36 *red,
37 *green,
38 *blue,
39 *redtext,
40 *greentext,
41 *bluetext,
42 *result;
43
44
45 /***************************************
46 ***************************************/
47
48 void
makeform(void)49 makeform( void )
50 {
51 form = fl_bgn_form( FL_UP_BOX, 300, 330 );
52
53 button = fl_add_button( FL_NORMAL_BUTTON, 45, 15, 210, 45,
54 "A Color Editor" );
55 fl_set_object_lsize( button, FL_LARGE_SIZE );
56
57 red = fl_add_dial( FL_FILL_DIAL, 30, 240, 60, 60, "Red" );
58 fl_set_dial_bounds( red, 0.0, 255.0 );
59 fl_set_dial_value( red, 128.0 );
60 fl_set_object_color( red, FL_DIAL_COL1, FL_RED );
61 fl_set_object_return( red, FL_RETURN_CHANGED );
62
63 redtext = fl_add_box( FL_DOWN_BOX, 105, 255, 50, 25, "" );
64
65 green = fl_add_dial( FL_FILL_DIAL, 30, 155, 60, 60, "Green" );
66 fl_set_dial_bounds( green, 0.0, 255.0 );
67 fl_set_dial_value( green, 128.0 );
68 fl_set_dial_angles( green, 45.0, 360 - 45.0 );
69 fl_set_object_color( green, FL_DIAL_COL1, FL_GREEN );
70 fl_set_object_return( green, FL_RETURN_CHANGED );
71
72 greentext = fl_add_box( FL_DOWN_BOX, 105, 170, 50, 25,"" );
73
74 blue = fl_add_dial( FL_FILL_DIAL, 30, 70, 60, 60, "Blue" );
75 fl_set_dial_bounds( blue, 0.0, 255.0 );
76 fl_set_dial_value( blue, 128.0 );
77 fl_set_object_color( blue, FL_DIAL_COL1, FL_BLUE );
78 fl_set_dial_direction( blue, FL_DIAL_CCW );
79 fl_set_object_return( blue, FL_RETURN_CHANGED );
80
81 bluetext = fl_add_box( FL_DOWN_BOX, 105, 90, 50, 25, "" );
82
83 result = fl_add_box( FL_DOWN_BOX, 180, 70, 90, 245, "" );
84 fl_set_object_color( result, FL_FREE_COL1, FL_FREE_COL1 );
85 fl_set_object_dblbuffer( result, 1 );
86
87 fl_end_form( );
88 }
89
90
91 /***************************************
92 ***************************************/
93
94 int
main(int argc,char * argv[])95 main( int argc,
96 char * argv[ ] )
97 {
98 FL_OBJECT *ret;
99 int r,
100 g,
101 b;
102 char str[ 100 ];
103
104 fl_initialize( &argc, argv, "FormDemo", 0, 0 );
105 makeform( );
106
107 fl_show_form( form, FL_PLACE_MOUSE, FL_TRANSIENT, "A Form" );
108
109 do
110 {
111 r = fl_get_dial_value( red ) + 0.001;
112 g = fl_get_dial_value( green ) + 0.001;
113 b = fl_get_dial_value( blue ) + 0.001;
114
115 fl_freeze_form( form );
116
117 fl_mapcolor( FL_FREE_COL1, r, g, b );
118
119 sprintf( str, "%d", r );
120 fl_set_object_label( redtext, str );
121 sprintf( str, "%d", g );
122 fl_set_object_label( greentext, str );
123 sprintf( str, "%d", b );
124 fl_set_object_label( bluetext, str );
125
126 fl_unfreeze_form( form );
127
128 ret = fl_do_forms( );
129 } while ( ret != button );
130
131 fl_hide_form( form );
132 fl_finish( );
133
134 return 0;
135 }
136
137
138 /*
139 * Local variables:
140 * tab-width: 4
141 * indent-tabs-mode: nil
142 * End:
143 */
144