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 License
15 * along with XForms. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19 /**
20 * \file sp_twheel.c
21 *
22 * This file is part of XForms package
23 * Copyright (c) 1996-2002 T.C. Zhao and Mark Overmars
24 * All rights reserved.
25 *
26 * Settting twheel class specific attributes.
27 */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include "fd_main.h"
34 #include "fd_spec.h"
35 #include "sp_twheel.h"
36 #include "private/ptwheel.h"
37 #include "private/pvaluator.h"
38 #include "spec/twheel_spec.h"
39
40 static FD_twheelattrib * twheel_attrib;
41 static FL_OBJECT * curobj;
42
43
44 /***************************************
45 ***************************************/
46
47 FL_FORM *
thwheel_create_spec_form(void)48 thwheel_create_spec_form( void )
49 {
50 if ( twheel_attrib )
51 return twheel_attrib->twheelattrib;
52
53 twheel_attrib = create_form_twheelattrib( );
54
55 setup_how_return_menu( twheel_attrib->returnsetting );
56 fl_set_menu_item_mode( twheel_attrib->returnsetting, 5,
57 FL_PUP_BOX | FL_PUP_GRAY );
58 fl_set_menu_item_mode( twheel_attrib->returnsetting, 6,
59 FL_PUP_BOX | FL_PUP_GRAY );
60
61 return twheel_attrib->twheelattrib;
62 }
63
64
65 /***************************************
66 ***************************************/
67
68 void
twheel_fill_in_spec_form(FL_OBJECT * obj)69 twheel_fill_in_spec_form( FL_OBJECT * obj )
70 {
71 FLI_THUMBWHEEL_SPEC *sp = obj->spec;
72
73 curobj = obj;
74
75 set_finput_value( twheel_attrib->minval, sp->min, -1 );
76 set_finput_value( twheel_attrib->maxval, sp->max, -1 );
77 set_finput_value( twheel_attrib->initial_val, sp->val, -1 );
78 set_finput_value( twheel_attrib->step, sp->step, 3 );
79
80 reset_how_return_menu( twheel_attrib->returnsetting, obj->how_return );
81 }
82
83
84 /***************************************
85 ***************************************/
86
87 void
twheel_reread_spec_form(FL_OBJECT * obj)88 twheel_reread_spec_form( FL_OBJECT * obj )
89 {
90 double r1, r2;
91
92 if ( get_checked_float( fl_get_input( twheel_attrib->minval ), &r1 )
93 && get_checked_float( fl_get_input( twheel_attrib->maxval ), &r2 ) )
94 fl_set_thumbwheel_bounds( obj, r1, r2 );
95
96 if ( get_checked_float( fl_get_input( twheel_attrib->initial_val ), &r1 ) )
97 fl_set_thumbwheel_value( obj, r1 );
98
99 if ( get_checked_float( fl_get_input( twheel_attrib->step ), &r1 ) )
100 fl_set_thumbwheel_step( obj, r1 );
101
102 redraw_the_form( 0 );
103 }
104
105
106 /***************************************
107 ***************************************/
108
109 void
twheel_emit_spec_fd_code(FILE * fp,FL_OBJECT * obj)110 twheel_emit_spec_fd_code( FILE * fp,
111 FL_OBJECT * obj )
112 {
113 FL_OBJECT *defobj = fl_create_thumbwheel( obj->type, 0, 0, 0, 0, "" );
114 FLI_THUMBWHEEL_SPEC *sp = obj->spec,
115 *defsp = defobj->spec;
116
117 if ( sp->min != defsp->min || sp->max != defsp->max )
118 fprintf( fp, " bounds: %g %g\n", sp->min, sp->max );
119
120 if ( sp->val != defsp->val )
121 fprintf( fp, " value: %g\n", sp->val );
122
123 if ( sp->ldelta != defsp->ldelta || sp->rdelta != defsp->rdelta )
124 fprintf( fp, " increment: %g %g\n", sp->ldelta, sp->rdelta );
125
126 if ( sp->slsize != defsp->slsize )
127 fprintf( fp, " slsize: %.2f\n", sp->slsize );
128
129 if ( sp->step != defsp->step )
130 fprintf( fp, " step: %g\n", sp->step );
131
132 fl_free_object( defobj );
133 }
134
135
136 /***************************************
137 ***************************************/
138
139 void
twheel_emit_spec_c_code(FILE * fp,FL_OBJECT * obj)140 twheel_emit_spec_c_code( FILE * fp,
141 FL_OBJECT * obj )
142 {
143 FL_OBJECT *defobj = fl_create_thumbwheel( obj->type, 0, 0, 0, 0, "" );
144 FLI_THUMBWHEEL_SPEC *sp = obj->spec,
145 *defsp = defobj->spec;
146
147 if ( sp->min != defsp->min || sp->max != defsp->max )
148 fprintf( fp, " fl_set_thumbwheel_bounds( obj, %g, %g );\n",
149 sp->min, sp->max );
150
151 if ( sp->val != defsp->val )
152 fprintf( fp, " fl_set_thumbwheel_value( obj, %g );\n", sp->val );
153
154 if ( sp->step != defsp->step )
155 fprintf( fp, " fl_set_thumbwheel_step( obj, %g );\n", sp->step );
156
157 fl_free_object( defobj );
158 }
159
160
161 /***************************************
162 ***************************************/
163
164 void
twheel_minmax_change(FL_OBJECT * ob FL_UNUSED_ARG,long data FL_UNUSED_ARG)165 twheel_minmax_change( FL_OBJECT * ob FL_UNUSED_ARG,
166 long data FL_UNUSED_ARG )
167 {
168 fl_set_thumbwheel_bounds( curobj,
169 get_finput_value( twheel_attrib->minval ),
170 get_finput_value( twheel_attrib->maxval ) );
171 redraw_the_form( 0 );
172 }
173
174
175 /***************************************
176 ***************************************/
177
178 void
twheel_step_change(FL_OBJECT * obj,long data FL_UNUSED_ARG)179 twheel_step_change( FL_OBJECT * obj,
180 long data FL_UNUSED_ARG )
181 {
182 fl_set_thumbwheel_step( curobj, get_finput_value( obj ) );
183 redraw_the_form( 0 );
184 }
185
186
187 /***************************************
188 ***************************************/
189
190 void
twheel_initialvalue_change(FL_OBJECT * obj,long data FL_UNUSED_ARG)191 twheel_initialvalue_change( FL_OBJECT * obj,
192 long data FL_UNUSED_ARG )
193 {
194 fl_set_thumbwheel_value( curobj, get_finput_value( obj ) );
195 redraw_the_form( 0 );
196 }
197
198
199 /***************************************
200 ***************************************/
201
202 void
twheel_returnsetting_change(FL_OBJECT * obj,long data FL_UNUSED_ARG)203 twheel_returnsetting_change( FL_OBJECT * obj,
204 long data FL_UNUSED_ARG )
205 {
206 handle_how_return_changes( obj, curobj );
207 }
208
209
210 #include "spec/twheel_spec.c"
211
212
213 /*
214 * Local variables:
215 * tab-width: 4
216 * indent-tabs-mode: nil
217 * End:
218 */
219