comparison lwlib/lwlib-Xlw.c @ 78:c7528f8e288d r20-0b34

Import from CVS: tag r20-0b34
author cvs
date Mon, 13 Aug 2007 09:05:42 +0200
parents 131b0175ea99
children 1ce6082ce73f
comparison
equal deleted inserted replaced
77:6cb4f478e7bc 78:c7528f8e288d
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to 17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
19 20
20 #include <stdlib.h> /* for abort () */ 21 #include <stdlib.h> /* for abort () */
21 #include <limits.h> 22 #include <limits.h>
22 23
23 #include "lwlib-Xlw.h" 24 #include "lwlib-Xlw.h"
51 val = lw_get_widget_value_for_widget (instance, w); 52 val = lw_get_widget_value_for_widget (instance, w);
52 #if 0 53 #if 0
53 /* #### - this code used to (for some random back_asswards reason) pass 54 /* #### - this code used to (for some random back_asswards reason) pass
54 the expression below in the call_data slot. For incremental menu 55 the expression below in the call_data slot. For incremental menu
55 construction, this needs to go. I can't even figure out why it was done 56 construction, this needs to go. I can't even figure out why it was done
56 this way in the first place...it's just a historical wierdism. --Stig */ 57 this way in the first place...it's just a historical weirdism. --Stig */
57 call_data = (val ? val->call_data : NULL); 58 call_data = (val ? val->call_data : NULL);
58 #endif 59 #endif
59 if (val && val->call_data) 60 if (val && val->call_data)
60 abort(); /* #### - the call_data for the top_level 61 abort(); /* #### - the call_data for the top_level
61 "menubar" widget_value used to be passed 62 "menubar" widget_value used to be passed
159 else if (event_data.slider_value < val->minimum) 160 else if (event_data.slider_value < val->minimum)
160 event_data.slider_value = val->minimum; 161 event_data.slider_value = val->minimum;
161 162
162 if (data->event) 163 if (data->event)
163 { 164 {
164 switch (data->event->xany.type) 165 switch (data->event->type)
165 { 166 {
166 case KeyPress: 167 case KeyPress:
167 case KeyRelease: 168 case KeyRelease:
168 event_data.time = data->event->xkey.time; 169 event_data.time = data->event->xkey.time;
169 break; 170 break;
219 220
220 if (instance->info->pre_activate_cb) 221 if (instance->info->pre_activate_cb)
221 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data); 222 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data);
222 } 223 }
223 224
225 #define add_scrollbar_callback(resource) \
226 XtAddCallback (scrollbar, resource, xlw_scrollbar_callback, (XtPointer) instance)
227
224 /* #### Does not yet support horizontal scrollbars. */ 228 /* #### Does not yet support horizontal scrollbars. */
225 static Widget 229 static Widget
226 xlw_create_scrollbar (widget_instance *instance, int vertical) 230 xlw_create_scrollbar (widget_instance *instance, int vertical)
227 { 231 {
228 Arg al[20]; 232 Arg al[20];
229 int ac = 0; 233 int ac = 0;
230 Widget scrollbar; 234 static XtCallbackRec callbacks[2] =
231 235 { {xlw_scrollbar_callback, NULL}, {NULL, NULL} };
232 XtSetArg (al[ac], (String) XmNminimum, 1); ac++; 236
233 XtSetArg (al[ac], (String) XmNmaximum, INT_MAX); ac++; 237 callbacks[0].closure = (XtPointer) instance;
234 XtSetArg (al[ac], (String) XmNincrement, 1); ac++; 238
235 XtSetArg (al[ac], (String) XmNpageIncrement, 1); ac++; 239 XtSetArg (al[ac], XmNminimum, 1); ac++;
236 if (vertical) 240 XtSetArg (al[ac], XmNmaximum, INT_MAX); ac++;
237 { 241 XtSetArg (al[ac], XmNincrement, 1); ac++;
238 XtSetArg (al[ac], (String) XmNorientation, XmVERTICAL); ac++; 242 XtSetArg (al[ac], XmNpageIncrement, 1); ac++;
239 } 243 XtSetArg (al[ac], XmNorientation, (vertical ? XmVERTICAL : XmHORIZONTAL)); ac++;
240 else 244
241 { 245 XtSetArg (al[ac], XmNdecrementCallback, callbacks); ac++;
242 XtSetArg (al[ac], (String) XmNorientation, XmHORIZONTAL); ac++; 246 XtSetArg (al[ac], XmNdragCallback, callbacks); ac++;
243 } 247 XtSetArg (al[ac], XmNincrementCallback, callbacks); ac++;
244 248 XtSetArg (al[ac], XmNpageDecrementCallback, callbacks); ac++;
245 scrollbar = 249 XtSetArg (al[ac], XmNpageIncrementCallback, callbacks); ac++;
246 XtCreateWidget (instance->info->name, xlwScrollBarWidgetClass, instance->parent, al, ac); 250 XtSetArg (al[ac], XmNtoBottomCallback, callbacks); ac++;
247 251 XtSetArg (al[ac], XmNtoTopCallback, callbacks); ac++;
248 XtAddCallback(scrollbar, XmNdecrementCallback, xlw_scrollbar_callback, 252 XtSetArg (al[ac], XmNvalueChangedCallback, callbacks); ac++;
249 (XtPointer) instance); 253
250 XtAddCallback(scrollbar, XmNdragCallback, xlw_scrollbar_callback, 254 return XtCreateWidget (instance->info->name, xlwScrollBarWidgetClass,
251 (XtPointer) instance); 255 instance->parent, al, ac);
252 XtAddCallback(scrollbar, XmNincrementCallback, xlw_scrollbar_callback,
253 (XtPointer) instance);
254 XtAddCallback(scrollbar, XmNpageDecrementCallback, xlw_scrollbar_callback,
255 (XtPointer) instance);
256 XtAddCallback(scrollbar, XmNpageIncrementCallback, xlw_scrollbar_callback,
257 (XtPointer) instance);
258 XtAddCallback(scrollbar, XmNtoBottomCallback, xlw_scrollbar_callback,
259 (XtPointer) instance);
260 XtAddCallback(scrollbar, XmNtoTopCallback, xlw_scrollbar_callback,
261 (XtPointer) instance);
262 XtAddCallback(scrollbar, XmNvalueChangedCallback, xlw_scrollbar_callback,
263 (XtPointer) instance);
264
265 return scrollbar;
266 } 256 }
267 257
268 static Widget 258 static Widget
269 xlw_create_vertical_scrollbar (widget_instance *instance) 259 xlw_create_vertical_scrollbar (widget_instance *instance)
270 { 260 {
286 scrollbar_values *data = val->scrollbar_data; 276 scrollbar_values *data = val->scrollbar_data;
287 int widget_sliderSize, widget_val; 277 int widget_sliderSize, widget_val;
288 int new_sliderSize, new_value; 278 int new_sliderSize, new_value;
289 double percent; 279 double percent;
290 280
291 /* 281 /* First size and position the scrollbar widget. */
292 * First size and position the scrollbar widget.
293 */
294 XtVaSetValues (widget, 282 XtVaSetValues (widget,
295 XtNx, data->scrollbar_x, 283 XtNx, data->scrollbar_x,
296 XtNy, data->scrollbar_y, 284 XtNy, data->scrollbar_y,
297 XtNwidth, data->scrollbar_width, 285 XtNwidth, data->scrollbar_width,
298 XtNheight, data->scrollbar_height, 286 XtNheight, data->scrollbar_height,
299 0); 287 0);
300 288
301 /* 289 /* Now the size the scrollbar's slider. */
302 * Now the size the scrollbar's slider.
303 */
304 290
305 XtVaGetValues (widget, 291 XtVaGetValues (widget,
306 XmNsliderSize, &widget_sliderSize, 292 XmNsliderSize, &widget_sliderSize,
307 XmNvalue, &widget_val, 293 XmNvalue, &widget_val,
308 0); 294 0);