Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / pal_scale.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23
24 /*
25  *      $XConsortium: pal_scale.c /main/5 1996/08/08 18:03:06 mustafa $
26  *
27  * @(#)pal_scale.c      1.26 11 Aug 1995      cde_app_builder/src/ab
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement between
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
35  *      Sun's specific written approval.  This document and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  */
42
43
44 /*
45  * pal_scale.c - Implements Palette Scale/Gauge object functionality
46  */
47 #include <stdio.h>
48 #include <Xm/Xm.h>
49 #include <ab_private/ab.h>
50 #include <ab_private/pal.h>
51 #include <ab_private/prop.h>
52 #include <ab_private/abobj.h> 
53 #include <ab_private/abobj_set.h> 
54 #include <ab_private/ui_util.h>
55 #include "scale_ui.h"
56
57
58 typedef struct  PROP_SCALE_SETTINGS
59 {
60     Widget                      prop_sheet;
61     PropFieldSettingRec         name;
62     PropRadioSettingRec         scale_type;
63     PropGeometrySettingRec      geometry;
64     PropRadioSettingRec         orient;
65     PropOptionsSettingRec       dir;
66     Widget                      dir_items[4];
67     PropOptionsSettingRec       label_type;
68     PropOptionsSettingRec       label_pos;
69     PropFieldSettingRec         label;
70     PropFieldSettingRec         min;
71     PropFieldSettingRec         max;
72     PropFieldSettingRec         incr;
73     PropFieldSettingRec         decimal;
74     PropFieldSettingRec         ivalue;
75     PropCheckboxSettingRec      show_value;
76     PropCheckboxSettingRec      init_state;
77     PropColorSettingRec         bg_color;
78     PropColorSettingRec         fg_color;
79     ABObj                       current_obj;
80 } PropScaleSettingsRec, *PropScaleSettings;
81
82 /*************************************************************************
83 **                                                                      **
84 **       Private Function Declarations                                  **
85 **                                                                      **
86 **************************************************************************/
87 /*
88  * Methods
89  */
90 static int      scale_initialize(
91                     ABObj   obj
92                 );
93 static Widget   scale_prop_init(
94                     Widget  parent,
95                     AB_PROP_TYPE type
96                 );
97 static int      scale_prop_activate(
98                     AB_PROP_TYPE type,
99                     BOOL         active
100                 );
101 static int      scale_prop_clear(
102                     AB_PROP_TYPE type
103                 );
104 static int      scale_prop_load(
105                     ABObj        obj,
106                     AB_PROP_TYPE type,
107                     unsigned long loadkey
108                 );
109 static int      scale_prop_apply(
110                     AB_PROP_TYPE type
111                 );
112 static BOOL     scale_prop_pending(
113                     AB_PROP_TYPE type
114                 );
115
116 /*
117  * General routines
118  */
119 static BOOL     verify_props(
120                     AB_PROP_TYPE type
121                 );
122 static void     turnoff_changebars(
123                     AB_PROP_TYPE type
124                 );
125 static void     setup_direction_setting(
126                     AB_PROP_TYPE type,
127                     AB_ORIENTATION orient
128                 );
129
130 /*
131  * Xt Callbacks
132  */
133 static void     orientCB(
134                     Widget   widget,
135                     XtPointer clientdata,
136                     XmToggleButtonCallbackStruct *state
137                 );
138
139 /*************************************************************************
140 **                                                                      **
141 **       Data                                                            **
142 **                                                                      **
143 **************************************************************************/
144 PalItemInfo scale_palitem_rec = {
145
146     /* type             */  AB_TYPE_SCALE,
147     /* name             */  "Scale",
148     /* animation pixmaps*/  NULL,
149     /* number of pixmaps*/  0,
150     /* rev_prop_frame   */  NULL,
151     /* fix_prop_dialog  */  NULL,
152     /* initialize       */  scale_initialize,
153     /* is_a_test        */  obj_is_scale,
154     /* prop_initialize  */  scale_prop_init,
155     /* prop_active      */  scale_prop_activate,
156     /* prop_clear       */  scale_prop_clear,
157     /* prop_load        */  scale_prop_load,
158     /* prop_apply       */  scale_prop_apply,
159     /* prop_pending     */  scale_prop_pending
160 };
161
162 PalItemInfo *ab_scale_palitem = &scale_palitem_rec;
163 PropScaleSettingsRec prop_scale_settings_rec[AB_PROP_TYPE_NUM_VALUES];
164
165
166 /*************************************************************************
167 **                                                                      **
168 **       Function Definitions                                           **
169 **                                                                      **
170 **************************************************************************/
171 static int
172 scale_initialize(
173     ABObj    obj
174 )
175 {
176     if (obj_get_read_only(obj) == False)
177     {
178         obj_set_unique_name(obj, "scale");
179         obj_set_label(obj, catgets(Dtb_project_catd, 100, 260, "Scale:"));
180     }
181     else /* Gauge */
182     {
183         obj_set_unique_name(obj, "gauge");
184         obj_set_label(obj, catgets(Dtb_project_catd, 100, 261, "Gauge:"));
185     }
186     obj_set_label_position(obj, AB_CP_NORTH);
187
188     obj_set_orientation(obj, AB_ORIENT_HORIZONTAL);
189     obj_set_direction(obj, AB_DIR_LEFT_TO_RIGHT);
190     obj_set_min_value(obj, 0);
191     obj_set_max_value(obj, 100);
192     obj_set_initial_value_int(obj, 50);
193     obj_set_increment(obj, 1);
194
195     obj_set_is_initially_visible(obj, True);
196     obj_set_is_initially_active(obj, True);
197
198     /* REMIND:  Hack to get around Motif XmNtitleString bug (when set to NULL) */
199     obj_set_width(obj, 90);
200     obj_set_height(obj, 18);
201
202     obj_set_attachment(obj, AB_CP_NORTH, AB_ATTACH_POINT, NULL, obj->y);
203     obj_set_attachment(obj, AB_CP_WEST,  AB_ATTACH_POINT, NULL, obj->x);
204
205     return OK;
206
207 }
208
209 static Widget
210 scale_prop_init(
211     Widget    parent,
212     AB_PROP_TYPE type
213 )
214 {
215     DtbScalePropDialogInfoRec   rev_scale_prop_dialog; /* Revolving Props */
216     DtbScalePropDialogInfo      cgen = &dtb_scale_prop_dialog; /* Codegen structure */
217     DtbRevolvPropDialogInfo     rpd = &(dtb_revolv_prop_dialog);
218     PropScaleSettingsRec        *pss = &(prop_scale_settings_rec[type]);
219     Widget                      item[6];
220     int                         item_val[6];
221     int                         n;
222     int                         i;
223
224     if (type == AB_PROP_REVOLVING)
225     {
226         /* Cloning Trick:
227          * Only the Attributes ControlPanel needs to be created within
228          * the existing Revolving Prop dialog, so fill out all other
229          * fields with the Revolving Prop dialog equivelents, so the
230          * dtb initialize proc will skip those non-NULL fields...
231          */
232         dtbScalePropDialogInfo_clear(&rev_scale_prop_dialog);
233
234         cgen = &(rev_scale_prop_dialog);
235         cgen->prop_dialog = rpd->prop_dialog;
236         cgen->prop_dialog_shellform = rpd->prop_dialog_shellform; 
237         cgen->prop_dialog_panedwin = rpd->prop_dialog_panedwin;
238         cgen->prop_dialog_form = rpd->prop_dialog_form;
239         cgen->objlist_panel = rpd->objlist_panel;
240         cgen->objlist_label = rpd->objlist_label2;
241         cgen->objlist_scrolledwin = rpd->objlist_scrolledwin;
242         cgen->objlist = rpd->objlist;
243         cgen->attrs_ctrlpanel_frame = rpd->attrs_ctrlpanel_frame;
244         cgen->activate_panel = rpd->activate_panel;
245         cgen->apply_button = rpd->apply_button; 
246         cgen->ok_button = rpd->ok_button;
247         cgen->cancel_button = rpd->cancel_button;
248         cgen->reset_button = rpd->reset_button; 
249         cgen->help_button = rpd->help_button; 
250
251     }
252     else /* AB_PROP_FIXED */
253         cgen = &dtb_scale_prop_dialog; 
254
255
256     if (dtb_scale_prop_dialog_initialize(cgen, parent) == 0)
257     {
258         pss->prop_sheet = cgen->attrs_ctrlpanel;
259         pss->current_obj = NULL;
260
261         if (type == AB_PROP_REVOLVING)
262                 XtVaSetValues(parent,
263                         XmNuserData, pss->current_obj,
264                         NULL);
265
266         /* Dialog/Object List */
267         if (type == AB_PROP_FIXED)
268         {
269             prop_fixed_dialog_init(ab_scale_palitem,
270                         cgen->prop_dialog_shellform, cgen->objlist);
271             prop_activate_panel_init(type, ab_scale_palitem, 
272                         cgen->ok_button, cgen->apply_button, 
273                         cgen->reset_button, cgen->cancel_button,
274                         cgen->help_button);
275         }
276
277         /* Alternate Editor Buttons */
278         prop_editors_panel_init(type, ab_scale_palitem,
279             cgen->attach_button, cgen->conn_button, cgen->helptxt_button);
280
281         /*
282           * Prop Sheet Settings....
283          */
284
285         /* Name */
286         prop_field_init(&(pss->name), cgen->name_field_label,
287                 cgen->name_field, cgen->name_cb);
288
289         /* Label, Type, Position */
290         n = 0;
291         item[n] = cgen->labeltype_opmenu_items.String_item;
292         item_val[n] = AB_LABEL_STRING; n++;
293         item[n] = cgen->labeltype_opmenu_items.Graphic_item;
294         item_val[n] = AB_LABEL_GLYPH; n++;
295         prop_options_init(&(pss->label_type), cgen->labeltype_opmenu_label,
296                         cgen->labeltype_opmenu,
297                         cgen->labeltype_opmenu_menu,
298                         n, item, (XtPointer*)item_val,
299                         cgen->labeltype_cb);
300  
301         prop_field_init(&(pss->label), cgen->label_field_label, 
302                 cgen->label_field, cgen->label_cb); 
303  
304         prop_label_field_init(&(pss->label), cgen->graphic_hint, item, n); 
305  
306         n = 0;
307         item[n] = cgen->labelpos_opmenu_items.Left_item;
308         item_val[n] = AB_CP_WEST; n++;
309         item[n] = cgen->labelpos_opmenu_items.Above_item;
310         item_val[n] = AB_CP_NORTH; n++;
311         prop_options_init(&(pss->label_pos), cgen->labelpos_opmenu_label,
312                         cgen->labelpos_opmenu,
313                         cgen->labelpos_opmenu_menu,
314                         n, item, (XtPointer*)item_val,
315                         cgen->labeltype_cb);
316
317         /* Scale Type */
318         n = 0;
319         item[n] = cgen->scaletype_rbox_items.Scale_item;
320         item_val[n] = False; n++;
321         item[n] = cgen->scaletype_rbox_items.Gauge_item;
322         item_val[n] = True; n++;
323         prop_radiobox_init(&(pss->scale_type), cgen->scaletype_rbox_label,
324                                 cgen->scaletype_rbox, n, item, (XtPointer*)item_val,
325                                 cgen->scaletype_cb);
326
327         /* Geometry */
328         prop_geomfield_init(&(pss->geometry), cgen->geom_label,
329                 cgen->x_field_label, cgen->x_field,
330                 cgen->y_field_label, cgen->y_field,
331                 cgen->width_field_label, cgen->width_field,
332                 cgen->height_field_label, cgen->height_field,
333                 cgen->geom_cb);
334
335         /* Orientation */
336         n = 0;
337         item[n] = cgen->orient_rbox_items.Horizontal_item;
338         item_val[n] = AB_ORIENT_HORIZONTAL; n++;
339         item[n] = cgen->orient_rbox_items.Vertical_item;
340         item_val[n] = AB_ORIENT_VERTICAL; n++;
341         prop_radiobox_init(&(pss->orient), cgen->orient_rbox_label,
342                                 cgen->orient_rbox, n, item, (XtPointer*)item_val,
343                                 cgen->orient_cb);
344
345         for(i=0; i < n; i++)
346             XtAddCallback(item[i], XmNvalueChangedCallback,
347                         (XtCallbackProc)orientCB, (XtPointer)type);
348
349         /* Direction */
350         n = 0;
351         item[n] = cgen->dir_opmenu_items.Left_to_Right_item;
352         item_val[n] = AB_DIR_LEFT_TO_RIGHT; n++;
353         item[n] = cgen->dir_opmenu_items.Right_to_Left_item;
354         item_val[n] = AB_DIR_RIGHT_TO_LEFT; n++;
355         item[n] = cgen->dir_opmenu_items.Top_to_Bottom_item;
356         item_val[n] = AB_DIR_TOP_TO_BOTTOM; n++;
357         item[n] = cgen->dir_opmenu_items.Bottom_to_Top_item;
358         item_val[n] = AB_DIR_BOTTOM_TO_TOP; n++;
359         prop_options_init(&(pss->dir), cgen->dir_opmenu_label,
360                 cgen->dir_opmenu, cgen->dir_opmenu_menu,
361                 n, item, (XtPointer*)item_val,
362                 cgen->dir_cb);
363
364         for (i=0; i < n; i++)
365             pss->dir_items[i] = item[i];
366
367         /* Min & Max & Increment */
368         prop_field_init(&(pss->min), cgen->min_field_label,
369                 cgen->min_field, cgen->valrange_cb);
370         prop_field_init(&(pss->max), cgen->max_field_label,
371                 cgen->max_field, cgen->valrange_cb);
372         prop_field_init(&(pss->incr), cgen->incr_field_label,
373                 cgen->incr_field, cgen->valrange_cb);
374
375         /* Decimal Points */
376         prop_field_init(&(pss->decimal), cgen->decimal_field_label,
377                 cgen->decimal_field, cgen->dec_cb);
378
379         /* Initial Value */
380         prop_field_init(&(pss->ivalue), cgen->ivalue_field_label, 
381                 cgen->ivalue_field, cgen->ivalue_cb);
382         n = 0;
383         item[n] = cgen->showval_ckbox_items.Show_Value_item;
384         item_val[n] = SHOW_VALUE_KEY; n++;
385         prop_checkbox_init(&(pss->show_value), NULL,
386                 cgen->showval_ckbox, n, item, item_val,
387                 cgen->ivalue_cb);
388
389         /* Initial State */
390         n = 0;
391         item[n] = cgen->istate_ckbox_items.Visible_item;
392         item_val[n] = AB_STATE_VISIBLE; n++;
393         item[n] = cgen->istate_ckbox_items.Active_item;
394         item_val[n] = AB_STATE_ACTIVE; n++;
395         prop_checkbox_init(&(pss->init_state), cgen->istate_ckbox_label,
396                 cgen->istate_ckbox, n, item, item_val,
397                 cgen->istate_cb);
398
399         /* Color */
400         prop_colorfield_init(&(pss->bg_color), cgen->bg_mbutton, 
401                 cgen->bg_mbutton_bg_mbutton_menu_items.None_item,
402                 cgen->bg_mbutton_bg_mbutton_menu_items.Color_Chooser_item,
403                 cgen->bg_swatch, cgen->bg_field, cgen->bg_cb);
404
405         prop_colorfield_init(&(pss->fg_color), cgen->fg_mbutton,
406                 cgen->fg_mbutton_fg_mbutton_menu_items.None_item,  
407                 cgen->fg_mbutton_fg_mbutton_menu_items.Color_Chooser_item, 
408                 cgen->fg_swatch, cgen->fg_field, cgen->fg_cb); 
409
410         prop_changebars_cleared(pss->prop_sheet);
411
412         return (cgen->prop_dialog_shellform);
413     }
414     else
415         return NULL;
416
417 }
418
419 static int
420 scale_prop_activate(
421     AB_PROP_TYPE type,
422     BOOL         active
423 )
424 {
425     ui_set_active(prop_scale_settings_rec[type].prop_sheet, active);
426
427     return OK;
428 }
429
430
431 static int
432 scale_prop_clear(
433     AB_PROP_TYPE type
434 )
435 {
436     PropScaleSettingsRec        *pss = &(prop_scale_settings_rec[type]);
437
438     if (pss->current_obj == NULL)
439         return OK;
440
441     /* Clear Name */
442     prop_field_set_value(&(pss->name), "", False);
443
444     /* Clear Label Type/Position */
445     prop_options_set_value(&(pss->label_type), (XtPointer)AB_LABEL_STRING, False);
446     prop_options_set_value(&(pss->label_pos), (XtPointer)AB_CP_WEST, False);
447
448     /* Clear Label */
449     ui_set_label_string(pss->label.label, "Label:");
450     prop_field_set_value(&(pss->label), "", False);
451
452     /* Clear Scale Type*/ 
453     prop_radiobox_set_value(&(pss->scale_type), (XtPointer)False, False); 
454
455     /* Clear Orientation */
456     prop_radiobox_set_value(&(pss->orient),
457                             (XtPointer)AB_ORIENT_HORIZONTAL, False);
458
459     /* Clear Direction */
460     prop_options_set_value(&(pss->dir), (XtPointer)AB_DIR_LEFT_TO_RIGHT, False);
461  
462     /* Clear Value Range */
463     prop_field_set_value(&(pss->min), "", False);
464     prop_field_set_value(&(pss->max), "", False);
465     prop_field_set_value(&(pss->incr), "", False);
466
467     /* Clear Decimal Points */
468     prop_field_set_value(&(pss->decimal), "", False);
469
470     /* Clear Initial Value/Show Value */ 
471     prop_field_set_value(&(pss->ivalue), "", False); 
472     prop_checkbox_set_value(&(pss->show_value), True, False, False);
473
474     /* Clear Geometry */
475     prop_geomfield_clear(&(pss->geometry), GEOM_X);
476     prop_geomfield_clear(&(pss->geometry), GEOM_Y);
477     prop_geomfield_clear(&(pss->geometry), GEOM_WIDTH);
478     prop_geomfield_clear(&(pss->geometry), GEOM_HEIGHT);
479  
480     /* Clear Initial State */
481     prop_checkbox_set_value(&(pss->init_state), AB_STATE_VISIBLE, True, False);
482     prop_checkbox_set_value(&(pss->init_state), AB_STATE_ACTIVE, True, False);
483
484     /* Clear Color */
485     prop_colorfield_set_value(&(pss->bg_color), "", False);
486     prop_colorfield_set_value(&(pss->fg_color), "", False);
487
488     pss->current_obj = NULL;
489
490     turnoff_changebars(type);
491
492     return OK;
493 }
494
495 static int
496 scale_prop_load(
497     ABObjPtr     obj,
498     AB_PROP_TYPE type,
499     unsigned long loadkey
500 )
501 {
502     PropScaleSettingsRec        *pss = &(prop_scale_settings_rec[type]);
503     AB_ORIENTATION              orient;
504     BOOL                        load_all = (loadkey & LoadAll);
505  
506     if (obj == NULL)
507     {
508         if (pss->current_obj != NULL)
509             obj = pss->current_obj;
510         else
511             return ERROR;
512     }
513     else if (!obj_is_scale(obj))
514         return ERROR;
515     else
516         pss->current_obj = obj;
517
518     /* Load Name */
519     if (load_all || loadkey & LoadName)
520         prop_field_set_value(&(pss->name), obj_get_name(obj), False);
521
522     if (load_all)
523     {
524         /* Load Label Type/Position */
525         prop_options_set_value(&(pss->label_type), (XtPointer)obj->label_type, False);
526         prop_options_set_value(&(pss->label_pos), (XtPointer)obj_get_label_position(obj), False);
527
528         /* Load Label */
529         prop_setup_label_field(&(pss->label), NULL,
530                                 obj->label_type, obj_get_label(obj), AB_LINE_UNDEF);
531
532         /* Load Scale Type */
533         prop_radiobox_set_value(&(pss->scale_type),
534                                 (XtPointer)obj_get_read_only(obj), False);
535
536         /* Load Orientation */
537         orient = obj_get_orientation(obj);
538         prop_radiobox_set_value(&(pss->orient), (XtPointer)orient, False); 
539         setup_direction_setting(type, orient);
540
541         /* Load Direction */
542         prop_options_set_value(&(pss->dir), (XtPointer)obj_get_direction(obj), False);
543
544         /* Load Value Range */
545         prop_field_set_numeric_value(&(pss->min), obj_get_min_value(obj), False);
546         prop_field_set_numeric_value(&(pss->max), obj_get_max_value(obj), False);
547         prop_field_set_numeric_value(&(pss->incr), obj_get_increment(obj), False);
548
549         /* Load Decimal Points */
550         prop_field_set_numeric_value(&(pss->decimal), 
551                 obj_get_decimal_points(obj), False);
552
553         /* Load Initial Value/Show Value */
554         prop_field_set_numeric_value(&(pss->ivalue), 
555                 obj_get_initial_value_int(obj), False);
556         prop_checkbox_set_value(&(pss->show_value), SHOW_VALUE_KEY,
557                 obj_get_show_value(obj), False);
558
559         /* Load Initial State */
560         prop_checkbox_set_value(&(pss->init_state), AB_STATE_VISIBLE,
561                 obj_is_initially_visible(obj), False);
562         prop_checkbox_set_value(&(pss->init_state), AB_STATE_ACTIVE,
563                 obj_is_initially_active(obj), False);
564
565         /* Load Color */
566         prop_colorfield_set_value(&(pss->bg_color), obj_get_bg_color(obj), False); 
567         prop_colorfield_set_value(&(pss->fg_color), obj_get_fg_color(obj), False);
568  
569         turnoff_changebars(type);
570     }
571
572     /* Load Geometry */
573     if (load_all || loadkey & LoadPosition)
574         prop_load_obj_position(obj, &(pss->geometry)); 
575
576     if (load_all || loadkey & LoadSize)
577         prop_load_obj_size(obj, &(pss->geometry)); 
578
579     return OK;
580 }
581
582 int
583 scale_prop_apply(
584     AB_PROP_TYPE   type
585 )
586 {
587     PropScaleSettingsRec        *pss = &(prop_scale_settings_rec[type]);
588     STRING                      value;
589     int                         new_w, new_h;
590     BOOL                        size_chg = False;
591     BOOL                        reset_bg = False;
592     BOOL                        reset_fg = False;
593
594     if (!verify_props(type))
595         return ERROR;
596
597     if (prop_changed(pss->name.changebar))
598     {
599         value = prop_field_get_value(&(pss->name));     
600         abobj_set_name(pss->current_obj, value);
601         util_free(value);
602     }
603     if (prop_changed(pss->label.changebar) || 
604         prop_changed(pss->label_type.changebar))
605     {
606         value = prop_field_get_value(&(pss->label));
607         abobj_set_label(pss->current_obj,
608             (AB_LABEL_TYPE)prop_options_get_value(&(pss->label_type)),
609                         value);
610         util_free(value);
611
612         abobj_set_label_position(pss->current_obj,
613                 (AB_COMPASS_POINT)prop_options_get_value(&(pss->label_pos)));
614         size_chg = True;
615     }
616     if (prop_changed(pss->scale_type.changebar))
617     {
618         abobj_set_read_only(pss->current_obj,
619             (BOOL)prop_radiobox_get_value(&(pss->scale_type)));
620         size_chg = True;
621     }   
622     if (prop_changed(pss->orient.changebar))
623     {
624         abobj_set_orientation(pss->current_obj,
625             (AB_ORIENTATION)prop_radiobox_get_value(&(pss->orient)));
626     }
627     if (prop_changed(pss->dir.changebar))
628     {
629         abobj_set_direction(pss->current_obj,
630                 (AB_DIRECTION)prop_options_get_value(&(pss->dir)));
631     }
632     if (prop_changed(pss->min.changebar))
633     {
634         abobj_set_min_max_values(pss->current_obj, 
635                 prop_field_get_numeric_value(&(pss->min)),
636                 prop_field_get_numeric_value(&(pss->max)));
637         abobj_set_increment(pss->current_obj,
638                 prop_field_get_numeric_value(&(pss->incr)));
639     }   
640     if (prop_changed(pss->decimal.changebar))
641     {
642         abobj_set_decimal_points(pss->current_obj,
643                 prop_field_get_numeric_value(&(pss->decimal)));
644     }
645     if (prop_changed(pss->ivalue.changebar))
646     {
647         abobj_set_initial_value(pss->current_obj, NULL,
648                 prop_field_get_numeric_value(&(pss->ivalue)));
649         abobj_set_show_value(pss->current_obj,
650                 prop_checkbox_get_value(&(pss->show_value), SHOW_VALUE_KEY));
651
652     }
653     if (prop_changed(pss->geometry.changebar))
654     {
655         if (abobj_width_resizable(pss->current_obj))
656         {
657             new_w = prop_geomfield_get_value(&(pss->geometry), GEOM_WIDTH);
658             abobj_set_pixel_width(pss->current_obj, new_w, 0);
659         }
660         if (abobj_height_resizable(pss->current_obj))
661         {
662             new_h = prop_geomfield_get_value(&(pss->geometry), GEOM_HEIGHT);
663             abobj_set_pixel_height(pss->current_obj, new_h, 0);
664         }
665         if (abobj_is_movable(pss->current_obj))
666             abobj_set_xy(pss->current_obj,
667                 prop_geomfield_get_value(&(pss->geometry), GEOM_X),
668                 prop_geomfield_get_value(&(pss->geometry), GEOM_Y));
669         size_chg = True;
670
671     }
672     if (prop_changed(pss->init_state.changebar))
673     {
674         abobj_set_visible(pss->current_obj, 
675                 prop_checkbox_get_value(&(pss->init_state), AB_STATE_VISIBLE));
676         abobj_set_active(pss->current_obj,
677                 prop_checkbox_get_value(&(pss->init_state), AB_STATE_ACTIVE));
678     }
679     if (prop_changed(pss->fg_color.changebar))
680     {
681         value = prop_colorfield_get_value(&(pss->fg_color));
682         abobj_set_foreground_color(pss->current_obj, value);
683         if (util_strempty(value))
684             reset_fg = True;
685         util_free(value);
686         prop_colorfield_set_value(&(pss->fg_color), 
687                 obj_get_fg_color(pss->current_obj), False);
688     }
689     if (prop_changed(pss->bg_color.changebar))
690     {
691         value = prop_colorfield_get_value(&(pss->bg_color));
692         abobj_set_background_color(pss->current_obj, value);
693         if (util_strempty(value))
694             reset_bg = True;
695         util_free(value);
696         prop_colorfield_set_value(&(pss->bg_color), 
697                 obj_get_bg_color(pss->current_obj), False);
698     }
699
700     abobj_instantiate_changes(pss->current_obj);
701
702     if (reset_bg || reset_fg) /* Set back to No Color */ 
703         abobj_reset_colors(pss->current_obj, reset_bg, reset_fg); 
704     if (size_chg)
705         abobj_force_dang_form_resize(pss->current_obj);
706  
707     turnoff_changebars(type);
708
709     return OK;
710 }
711
712 static BOOL
713 scale_prop_pending(
714     AB_PROP_TYPE type
715 )
716 {
717     return(prop_changebars_pending(prop_scale_settings_rec[type].prop_sheet));
718 }
719
720 static BOOL
721 verify_props(
722     AB_PROP_TYPE type
723 )
724 {
725     PropScaleSettingsRec *pss = &(prop_scale_settings_rec[type]);
726     int                   min, max;
727
728     if (prop_changed(pss->name.changebar) && 
729         !prop_name_ok(pss->current_obj, pss->name.field))
730         return False;
731
732     if ((prop_changed(pss->label_type.changebar) || prop_changed(pss->label.changebar)) &&
733         prop_options_get_value(&(pss->label_type)) == (XtPointer)AB_LABEL_GLYPH &&
734         !prop_graphic_filename_ok(pss->label.field, False))
735         return False;
736
737     if (!prop_number_ok(pss->min.field, "Min Field", INT_MIN, INT_MAX))
738         return False;
739
740     min = prop_field_get_numeric_value(&(pss->min));
741     if (!prop_number_ok(pss->max.field, "Max Field", min+1, INT_MAX))
742         return False;
743  
744     max = prop_field_get_numeric_value(&(pss->max));
745     if (!prop_number_ok(pss->incr.field, "Increment Field", 1, max - min))
746         return False;
747  
748     if (prop_changed(pss->ivalue.changebar) &&
749         !prop_number_ok(pss->ivalue.field, "Initial Value Field", min, max))
750         return False;
751
752     if (prop_changed(pss->decimal.changebar) &&
753          !prop_number_ok(pss->decimal.field, "Decimal Field", 0, 99))
754         return False;
755          
756     if (prop_changed(pss->geometry.changebar) &&
757         (!prop_number_ok(pss->geometry.x_field,(STRING)XFieldStr, -SHRT_MAX, SHRT_MAX) ||
758          !prop_number_ok(pss->geometry.y_field,(STRING)YFieldStr, -SHRT_MAX, SHRT_MAX) ||
759          !prop_number_ok(pss->geometry.h_field,(STRING)HFieldStr, 1, SHRT_MAX) ||
760          !prop_number_ok(pss->geometry.w_field,(STRING)WFieldStr, 1, SHRT_MAX)))
761         return False;
762
763     if (prop_changed(pss->fg_color.changebar) && !prop_color_ok(pss->fg_color.field))
764         return False;
765  
766     if (prop_changed(pss->bg_color.changebar) && !prop_color_ok(pss->bg_color.field))
767         return False;
768
769     return True;
770 }
771
772 static void
773 turnoff_changebars(
774     AB_PROP_TYPE type
775 )
776 {
777     PropScaleSettingsRec *pss = &(prop_scale_settings_rec[type]);
778
779     prop_set_changebar(pss->name.changebar,             PROP_CB_OFF);
780     prop_set_changebar(pss->scale_type.changebar,       PROP_CB_OFF);
781     prop_set_changebar(pss->orient.changebar,           PROP_CB_OFF);
782     prop_set_changebar(pss->dir.changebar,              PROP_CB_OFF);
783     prop_set_changebar(pss->label_type.changebar,       PROP_CB_OFF);
784     prop_set_changebar(pss->label.changebar,            PROP_CB_OFF);
785     prop_set_changebar(pss->min.changebar,              PROP_CB_OFF);
786     prop_set_changebar(pss->decimal.changebar,          PROP_CB_OFF);
787     prop_set_changebar(pss->geometry.changebar,         PROP_CB_OFF);
788     prop_set_changebar(pss->ivalue.changebar,           PROP_CB_OFF);
789     prop_set_changebar(pss->init_state.changebar,       PROP_CB_OFF);
790     prop_set_changebar(pss->bg_color.changebar,         PROP_CB_OFF);
791     prop_set_changebar(pss->fg_color.changebar,         PROP_CB_OFF);
792
793     prop_changebars_cleared(pss->prop_sheet);
794
795 }
796
797 static void
798 orientCB(
799     Widget      item,
800     XtPointer   clientdata,
801     XmToggleButtonCallbackStruct *state
802 )
803 {
804     AB_PROP_TYPE        type = (AB_PROP_TYPE)clientdata;
805     PropScaleSettingsRec *pss = &(prop_scale_settings_rec[type]);
806     int                 value;
807
808     if (state->set)
809     {
810         XtVaGetValues(item, XmNuserData, &value, NULL); 
811         setup_direction_setting(type, (AB_ORIENTATION)value);
812
813         if (value == AB_ORIENT_HORIZONTAL)
814             prop_options_set_value(&(pss->dir), 
815                 (XtPointer)AB_DIR_LEFT_TO_RIGHT, True);
816         else
817             prop_options_set_value(&(pss->dir),
818                 (XtPointer)AB_DIR_BOTTOM_TO_TOP, True);
819     }
820 }
821
822 static void
823 setup_direction_setting(
824     AB_PROP_TYPE        type,
825     AB_ORIENTATION      orient
826 )
827 {
828     PropScaleSettingsRec *pss = &(prop_scale_settings_rec[type]);
829
830     ui_set_active(pss->dir_items[0], 
831                 orient == AB_ORIENT_HORIZONTAL? True : False);
832     ui_set_active(pss->dir_items[1], 
833                 orient == AB_ORIENT_HORIZONTAL? True : False);
834     ui_set_active(pss->dir_items[2], 
835                 orient == AB_ORIENT_VERTICAL? True : False);
836     ui_set_active(pss->dir_items[3], 
837                 orient == AB_ORIENT_VERTICAL? True : False);
838 }