Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / pal_combobox.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_combobox.c /main/5 1996/08/08 17:52:08 mustafa $
26  *
27  *      @(#)pal_combobox.c      1.1 23 Feb 1994 
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_combobox.c - Implements Palette ComboBox object functionality
46  */
47 #include <stdio.h>
48 #include <Xm/Xm.h>
49 #include <ab_private/obj_notify.h>
50 #include <ab_private/ab.h>
51 #include <ab_private/pal.h>
52 #include <ab_private/prop.h>
53 #include <ab_private/abobj.h>
54 #include <ab_private/abobj_set.h>
55 #include <ab_private/ui_util.h>
56 #include "combobox_ui.h"
57
58 const    int    combo_box_init_width  = 100;
59
60 static const    int input_rows = 3;
61
62 typedef struct  PROP_COMBOBOX_SETTINGS
63 {
64     Widget                      prop_sheet;
65     PropFieldSettingRec         name;
66     PropRadioSettingRec         combobox_type;
67     PropGeometrySettingRec      pos;
68     PropRadioSettingRec         wth_policy;
69     PropGeometrySettingRec      wth;
70     PropOptionsSettingRec       label_type;
71     PropFieldSettingRec         label;
72     PropOptionsSettingRec       label_pos;
73     PropCheckboxSettingRec      init_state;
74     PropColorSettingRec         bg_color;
75     PropColorSettingRec         fg_color;
76     PropFieldSettingRec         item_label;
77     PropCheckboxSettingRec      item_state;
78     PropItemsSettingRec         items;
79     ABObj                       current_obj;
80 } PropComboboxSettingsRec, *PropComboboxSettings;
81
82 /*************************************************************************
83 **                                                                      **
84 **       Private Function Declarations                                  **
85 **                                                                      **
86 **************************************************************************/
87 /*
88  * Methods
89  */
90 static int      combo_box_initialize(
91                     ABObj   obj
92                 );
93 static Widget   combo_box_prop_init(
94                     Widget  parent,
95                     AB_PROP_TYPE type
96                 );
97 static int      combo_box_prop_activate(
98                     AB_PROP_TYPE type,
99                     BOOL         active
100                 );
101 static int      combo_box_prop_clear(
102                     AB_PROP_TYPE type
103                 );
104 static int      combo_box_prop_load(
105                     ABObj        obj,
106                     AB_PROP_TYPE type,
107                     unsigned long loadkey
108                 );
109 static int      combo_box_prop_apply(
110                     AB_PROP_TYPE type
111                 );
112 static BOOL     combo_box_prop_pending(
113                     AB_PROP_TYPE type
114                 );
115
116 static BOOL     verify_props(
117                     AB_PROP_TYPE type
118                 );
119 static void     turnoff_changebars(
120                     AB_PROP_TYPE type
121                 );
122
123 /*
124  * ABObj Callbacks
125  */
126 static int      combobox_install_obj_destroy_CB(void);
127
128 static int      combobox_obj_destroy_CB(
129                     ObjEvDestroyInfo destroyInfo
130                 );
131
132 /*
133  * Xt Callbacks
134  */
135 static void     wth_policyCB(
136                     Widget      widget,
137                     XtPointer   clientdata,
138                     XmToggleButtonCallbackStruct *state
139                 );
140
141 /*************************************************************************
142 **                                                                      **
143 **       Data                                                            **
144 **                                                                      **
145 **************************************************************************/
146 PalItemInfo combo_box_palitem_rec = {
147
148     /* type             */  AB_TYPE_COMBO_BOX,
149     /* name             */  "Combo Box",
150     /* animation pixmaps*/  NULL,
151     /* number of pixmaps*/  0,
152     /* rev_prop_frame   */  NULL,
153     /* fix_prop_dialog  */  NULL,
154     /* initialize       */  combo_box_initialize,
155     /* is_a_test        */  obj_is_combo_box,
156     /* prop_initialize  */  combo_box_prop_init,
157     /* prop_activate    */  combo_box_prop_activate,
158     /* prop_clear       */  combo_box_prop_clear,
159     /* prop_load        */  combo_box_prop_load,
160     /* prop_apply       */  combo_box_prop_apply,
161     /* prop_pending     */  combo_box_prop_pending
162
163 };
164
165 PalItemInfo *ab_combo_box_palitem = &combo_box_palitem_rec;
166 PropComboboxSettingsRec prop_combobox_settings_rec[AB_PROP_TYPE_NUM_VALUES];
167
168
169 /*************************************************************************
170 **                                                                      **
171 **       Function Definitions                                           **
172 **                                                                      **
173 **************************************************************************/
174 static int
175 combo_box_initialize(
176     ABObj    obj
177 )
178 {
179     ABObj       iobj;
180     String  items[2];
181     int         i;
182
183     obj_set_unique_name(obj, "combobox");
184
185     obj_set_label(obj, catgets(Dtb_project_catd, 100, 255, "ComboBox:"));
186     obj_set_label_position(obj, AB_CP_WEST);
187     obj_set_height(obj, -1);
188
189     /* Add initial items to list */
190     items[0] = catgets(Dtb_project_catd, 6, 70, "itemA");
191     items[1] = catgets(Dtb_project_catd, 6, 71, "itemB");
192     for (i=0; i < XtNumber(items); i++)
193     {
194         iobj = obj_create(AB_TYPE_ITEM, NULL);
195         obj_set_subtype(iobj, AB_ITEM_FOR_COMBO_BOX);
196         obj_append_child(obj, iobj);
197         abobj_set_item_name(iobj, obj_get_module(obj), obj_get_name(obj), items[i]);
198         obj_set_label(iobj, items[i]);
199         obj_set_is_initially_selected(iobj, i==0? True : False);
200     }
201     obj_set_attachment(obj, AB_CP_NORTH, AB_ATTACH_POINT, NULL, obj->y);
202     obj_set_attachment(obj, AB_CP_WEST,  AB_ATTACH_POINT, NULL, obj->x);
203
204     return OK;
205 }
206
207 static Widget
208 combo_box_prop_init(
209     Widget parent,
210     AB_PROP_TYPE type
211 )
212 {
213     DtbComboboxPropDialogInfoRec rev_combobox_prop_dialog; /* Revolving Props */
214     DtbComboboxPropDialogInfo   cgen = &dtb_combobox_prop_dialog; /* Codegen structure */
215     DtbRevolvPropDialogInfo     rpd = &(dtb_revolv_prop_dialog);
216     PropComboboxSettingsRec     *pcs = &(prop_combobox_settings_rec[type]);
217     Widget                      item[6];
218     int                         item_val[6];
219     Widget                      item2[6];
220     int                         item2_val[6];
221     int                         i, n, j;
222
223     if (type == AB_PROP_REVOLVING)
224     {
225         /* Cloning Trick:
226          * Only the Attributes ControlPanel needs to be created within
227          * the existing Revolving Prop dialog, so fill out all other
228          * fields with the Revolving Prop dialog equivelents, so the
229          * dtb initialize proc will skip those non-NULL fields...
230          */
231         dtbComboboxPropDialogInfo_clear(&rev_combobox_prop_dialog);
232
233         cgen = &(rev_combobox_prop_dialog);
234         cgen->prop_dialog = rpd->prop_dialog;
235         cgen->prop_dialog_shellform = rpd->prop_dialog_shellform; 
236         cgen->prop_dialog_panedwin = rpd->prop_dialog_panedwin;
237         cgen->prop_dialog_form = rpd->prop_dialog_form;
238         cgen->objlist_panel = rpd->objlist_panel;
239         cgen->objlist_label = rpd->objlist_label2;
240         cgen->objlist_scrolledwin = rpd->objlist_scrolledwin;
241         cgen->objlist = rpd->objlist;
242         cgen->attrs_ctrlpanel_frame = rpd->attrs_ctrlpanel_frame;
243         cgen->activate_panel = rpd->activate_panel;
244         cgen->ok_button = rpd->ok_button;
245         cgen->cancel_button = rpd->cancel_button;
246         cgen->apply_button = rpd->apply_button; 
247         cgen->reset_button = rpd->reset_button; 
248         cgen->help_button = rpd->help_button; 
249
250         /*
251          * Get notification of object destruction!
252          */  
253         combobox_install_obj_destroy_CB();
254
255     }
256     else /* AB_PROP_FIXED */
257         cgen = &dtb_combobox_prop_dialog; 
258
259     if (dtb_combobox_prop_dialog_initialize(cgen, parent) == 0)
260     {
261         pcs->prop_sheet = cgen->attrs_ctrlpanel;
262         pcs->current_obj = NULL;
263
264         if (type == AB_PROP_REVOLVING)
265                 XtVaSetValues(parent,
266                         XmNuserData, pcs->current_obj,
267                         NULL);
268
269         /* Dialog/Object List */
270         if (type == AB_PROP_FIXED)
271         {
272             prop_fixed_dialog_init(ab_combo_box_palitem,
273                         cgen->prop_dialog_shellform, cgen->objlist);
274             prop_activate_panel_init(type, ab_combo_box_palitem, 
275                         cgen->ok_button, cgen->apply_button, 
276                         cgen->reset_button, cgen->cancel_button,
277                         cgen->help_button);
278         }
279
280         /* Alternate Editor Buttons */
281         prop_editors_panel_init(type, ab_combo_box_palitem,
282             cgen->attach_button, cgen->conn_button, cgen->helptxt_button);
283
284         /*
285           * Prop Sheet Settings....
286          */
287
288         /* Name */
289         prop_field_init(&(pcs->name), cgen->name_field_label,
290                 cgen->name_field, cgen->name_cb);
291
292         /* Label, Type, Position */
293         n = 0;
294         item[n] = cgen->labeltype_rbox_items.String_item;
295         item_val[n] = AB_LABEL_STRING; n++;
296         item[n] = cgen->labeltype_rbox_items.Graphic_item;
297         item_val[n] = AB_LABEL_GLYPH; n++;
298         prop_options_init(&(pcs->label_type), cgen->labeltype_rbox_label,
299                         cgen->labeltype_rbox, cgen->labeltype_rbox_menu,
300                         n, item, (XtPointer*)item_val,
301                         cgen->labeltype_cb);
302
303         prop_field_init(&(pcs->label), cgen->label_field_label,
304                 cgen->label_field, cgen->label_cb);
305
306         prop_label_field_init(&(pcs->label), cgen->graphic_hint, item, n);
307
308         n = 0;
309         item[n] = cgen->labelpos_rbox_items.Above_item;
310         item_val[n] = AB_CP_NORTH; n++;
311         item[n] = cgen->labelpos_rbox_items.Left_item;
312         item_val[n] = AB_CP_WEST; n++;
313         prop_options_init(&(pcs->label_pos), cgen->labelpos_rbox_label,
314                         cgen->labelpos_rbox, cgen->labelpos_rbox_menu,
315                         n, item, (XtPointer*)item_val,
316                         cgen->labeltype_cb);
317
318         /* Read Only */
319         n = 0;
320         item[n] = cgen->comboboxtype_rbox_items.Static_item;
321         item_val[n] = True; n++;
322         item[n] = cgen->comboboxtype_rbox_items.Editable_item;
323         item_val[n] = False; n++;
324         prop_radiobox_init(&(pcs->combobox_type), cgen->comboboxtype_rbox_label,
325                        cgen->comboboxtype_rbox, n, item, (XtPointer*)item_val,
326                        cgen->comboboxtype_cb);
327
328         /* Position */
329         prop_geomfield_init(&(pcs->pos), cgen->pos_label,
330                 cgen->x_field_label, cgen->x_field,
331                 cgen->y_field_label, cgen->y_field,
332                 NULL, NULL,
333                 NULL, NULL,
334                 cgen->pos_cb);
335
336         /* Width */
337         n = 0;
338         item[n] = cgen->wpolicy_rbox_items.Longest_Item_item;
339         item_val[n] = SIZE_OF_CONTENTS_KEY; n++;
340         item[n] = cgen->wpolicy_rbox_items.Fixed_item;
341         item_val[n] = SIZE_FIXED_KEY; n++;
342         prop_radiobox_init(&(pcs->wth_policy), cgen->wpolicy_rbox_label,
343                 cgen->wpolicy_rbox, n, item, (XtPointer*)item_val,
344                 cgen->wpolicy_cb);
345
346         for(i=0; i < n; i++)
347             XtAddCallback(item[i], XmNvalueChangedCallback,
348                         (XtCallbackProc)prop_size_policyCB, (XtPointer)&(pcs->wth));
349
350         prop_geomfield_init(&(pcs->wth), cgen->wpolicy_rbox_label,
351                             NULL, NULL, NULL, NULL,
352                             cgen->w_field_label, cgen->w_field,
353                             NULL, NULL,
354                             cgen->wpolicy_cb);
355
356         /* Initial State */
357         n = 0;
358         item[n] = cgen->istate_ckbox_items.Visible_item;
359         item_val[n] = AB_STATE_VISIBLE; n++;
360         item[n] = cgen->istate_ckbox_items.Active_item;
361         item_val[n] = AB_STATE_ACTIVE; n++;
362         prop_checkbox_init(&(pcs->init_state), cgen->istate_ckbox_label,
363                 cgen->istate_ckbox, n, item, item_val,
364                 cgen->istate_cb);
365
366         /* Color */
367         prop_colorfield_init(&(pcs->bg_color), cgen->bg_mbutton, 
368                 cgen->bg_mbutton_bg_mbutton_menu_items.None_item,
369                 cgen->bg_mbutton_bg_mbutton_menu_items.Color_Chooser_item,
370                 cgen->bg_swatch, cgen->bg_field, cgen->bg_cb);
371
372         prop_colorfield_init(&(pcs->fg_color), cgen->fg_mbutton,
373                 cgen->fg_mbutton_fg_mbutton_menu_items.None_item,  
374                 cgen->fg_mbutton_fg_mbutton_menu_items.Color_Chooser_item, 
375                 cgen->fg_swatch, cgen->fg_field, cgen->fg_cb); 
376
377         /* Item Editor....*/
378
379         /* Item Label */
380         prop_field_init(&(pcs->item_label), cgen->itemlabel_label,
381                 cgen->itemlabel_field, cgen->itemlist_cb);
382
383         /* Item State */
384         n = 0;
385         item[n] = cgen->item_state_ckbox_items.Selected_item;
386         item_val[n] = AB_STATE_SELECTED; n++;
387         prop_checkbox_init(&(pcs->item_state), NULL,
388                 cgen->item_state_ckbox, n, item, item_val,
389                 cgen->itemlist_cb);
390
391         /* Store Items->Add menu items in array */
392         n = 0;
393         item[n] = cgen->item_edit_mbutton_editmenu_items.Add_Before_item;
394         item_val[n] = INSERT_BEFORE; n++;
395         item[n] = cgen->item_edit_mbutton_editmenu_items.Add_After_item;
396         item_val[n] = INSERT_AFTER; n++;
397
398         /* Store Items->Edit menu items in array */
399         j = 0;
400         item2[j] = cgen->item_edit_mbutton_editmenu_items.Cut_item;
401         item2_val[j] = AB_EDIT_CUT; j++;
402         item2[j] = cgen->item_edit_mbutton_editmenu_items.Copy_item; 
403         item2_val[j] = AB_EDIT_COPY; j++; 
404         item2[j] = cgen->item_edit_mbutton_editmenu_items.Paste_item; 
405         item2_val[j] = AB_EDIT_PASTE; j++; 
406         item2[j] = cgen->item_edit_mbutton_editmenu_items.Delete_item;  
407         item2_val[j] = AB_EDIT_DELETE; j++;  
408         item2[j] = cgen->item_edit_mbutton_editmenu_items.Change_item;
409         item2_val[j] = EDIT_CHANGE; j++;
410
411         prop_item_editor_init(&(pcs->items), AB_ITEM_FOR_COMBO_BOX,
412                 cgen->itemlist, cgen->itemlist_cb, 
413                 cgen->item_add_button,
414                 n, item, item_val, 
415                 j, item2, item2_val,
416                 &(pcs->item_label), NULL/*label_type*/, NULL/*graphic_hint*/,
417                 NULL/*mnemonic*/, NULL/*accel*/, NULL/*line_style*/,
418                 &(pcs->item_state), NULL,
419                 &(pcs->current_obj));
420
421         prop_changebars_cleared(pcs->prop_sheet);
422
423         return (cgen->prop_dialog_shellform);
424     }
425     else
426         return NULL;
427 }
428
429 static int
430 combo_box_prop_activate(
431     AB_PROP_TYPE type,
432     BOOL         active
433 )
434 {
435     ui_set_active(prop_combobox_settings_rec[type].prop_sheet, active);
436
437     return OK;
438 }
439
440
441 static int
442 combo_box_prop_clear(
443     AB_PROP_TYPE type
444 )
445 {
446     PropComboboxSettingsRec     *pcs = &(prop_combobox_settings_rec[type]);
447
448     if (pcs->current_obj == NULL)
449         return OK;
450
451     /* Clear Name */
452     prop_field_set_value(&(pcs->name), "", False);
453
454     /* Clear Label Type/Position */
455     prop_options_set_value(&(pcs->label_type), (XtPointer)AB_LABEL_STRING, False);
456     prop_options_set_value(&(pcs->label_pos), (XtPointer)AB_CP_WEST, False);
457
458     /* Clear Label */
459     ui_set_label_string(pcs->label.label, "Label:");
460     prop_field_set_value(&(pcs->label), "", False);
461
462     /* Clear Read Only */ 
463     prop_radiobox_set_value(&(pcs->combobox_type), (XtPointer)True, False);
464
465     /* Clear Position */
466     prop_geomfield_clear(&(pcs->pos), GEOM_X);
467     prop_geomfield_clear(&(pcs->pos), GEOM_Y);
468
469     /* Clear Width */
470     prop_radiobox_set_value(&(pcs->wth_policy), (XtPointer)SIZE_OF_CONTENTS_KEY, False);
471     prop_geomfield_clear(&(pcs->wth), GEOM_WIDTH);
472
473     /* Clear Initial State */
474     prop_checkbox_set_value(&(pcs->init_state), AB_STATE_VISIBLE, True, False);
475     prop_checkbox_set_value(&(pcs->init_state), AB_STATE_ACTIVE, True, False);
476
477     /* Clear Color */
478     prop_colorfield_set_value(&(pcs->bg_color), "", False);
479     prop_colorfield_set_value(&(pcs->fg_color), "", False);
480
481     /* Clear Items */
482     prop_item_editor_clear(&(pcs->items));
483
484     pcs->current_obj = NULL;
485
486     turnoff_changebars(type);
487
488     return OK;
489 }
490
491 static int
492 combo_box_prop_load(
493     ABObjPtr     obj,
494     AB_PROP_TYPE type,
495     unsigned long loadkey
496 )
497 {
498     PropComboboxSettingsRec     *pcs = &(prop_combobox_settings_rec[type]);
499     BOOL                        editable;
500     BOOL                        load_all = (loadkey & LoadAll);
501  
502     if (obj == NULL)
503     {
504         if (pcs->current_obj != NULL)
505             obj = pcs->current_obj;
506         else
507             return ERROR;
508     }
509     else if (!obj_is_combo_box(obj))
510         return ERROR;
511     else
512         pcs->current_obj = obj;
513
514     /* Load Name */
515     if (load_all || loadkey & LoadName)
516         prop_field_set_value(&(pcs->name), obj_get_name(obj), False);
517
518     if (load_all)
519     {
520         /* Load Label Type/Position */
521         prop_options_set_value(&(pcs->label_type), (XtPointer)obj->label_type, False);
522         prop_options_set_value(&(pcs->label_pos), (XtPointer)obj_get_label_position(obj), False);
523
524         /* Load Label */
525         prop_setup_label_field(&(pcs->label), NULL,
526                                 obj->label_type, obj_get_label(obj), AB_LINE_UNDEF);
527
528         /* Load Read Only */
529         prop_radiobox_set_value(&(pcs->combobox_type),
530                                 (XtPointer)obj_get_read_only(obj), False);
531
532         /* Load Initial State */
533         prop_checkbox_set_value(&(pcs->init_state), AB_STATE_VISIBLE,
534                 obj_is_initially_visible(obj), False);
535         prop_checkbox_set_value(&(pcs->init_state), AB_STATE_ACTIVE,
536                 obj_is_initially_active(obj), False);
537
538         /* Load Color */
539         prop_colorfield_set_value(&(pcs->bg_color), obj_get_bg_color(obj), False); 
540         prop_colorfield_set_value(&(pcs->fg_color), obj_get_fg_color(obj), False);
541
542         /* Load Items */
543         prop_item_editor_load(&(pcs->items), obj);
544  
545         turnoff_changebars(type);
546     }
547
548     /* Load Position */
549     if (load_all || loadkey & LoadPosition)
550         prop_load_obj_position(obj, &(pcs->pos)); 
551
552     /* Load Width */
553     if (load_all || loadkey & LoadSize)
554     {
555         editable = abobj_width_resizable(obj);
556         prop_radiobox_set_value(&(pcs->wth_policy),
557                                 editable? (XtPointer)SIZE_FIXED_KEY :
558                                 (XtPointer)SIZE_OF_CONTENTS_KEY, False);
559
560         ui_set_active(pcs->wth.w_field, editable);
561         ui_set_active(pcs->wth.w_label, editable);
562         prop_geomfield_set_value(&(pcs->wth), GEOM_WIDTH,
563                 abobj_get_comp_width(obj), False);
564     }
565
566     return OK;
567 }
568
569 int
570 combo_box_prop_apply(
571     AB_PROP_TYPE   type
572 )
573 {
574     PropComboboxSettingsRec     *pcs = &(prop_combobox_settings_rec[type]);
575     STRING                      value;
576     int                         width_policy, new_w;
577     BOOL                        size_chg = False;
578     BOOL                        reset_bg = False;
579     BOOL                        reset_fg = False;
580
581     if (!verify_props(type))
582         return ERROR;
583
584     if (prop_changed(pcs->name.changebar))
585     {
586         value = prop_field_get_value(&(pcs->name));   
587         abobj_set_name(pcs->current_obj, value);
588         util_free(value);
589     }
590     if (prop_changed(pcs->label.changebar) || 
591         prop_changed(pcs->label_type.changebar))
592     {
593         value = prop_field_get_value(&(pcs->label));
594
595         abobj_set_label(pcs->current_obj,
596             (AB_LABEL_TYPE)prop_options_get_value(&(pcs->label_type)),
597                         value);
598         util_free(value);
599
600         abobj_set_label_position(pcs->current_obj,
601                 (AB_COMPASS_POINT)prop_options_get_value(&(pcs->label_pos)));
602
603         size_chg = True;
604     }
605     if (prop_changed(pcs->combobox_type.changebar))
606     {
607         abobj_set_read_only(pcs->current_obj,
608             (BOOL)prop_radiobox_get_value(&(pcs->combobox_type)));
609     }
610     if (prop_changed(pcs->pos.changebar))
611     {
612         if (abobj_is_movable(pcs->current_obj))
613             abobj_set_xy(pcs->current_obj,
614                 prop_geomfield_get_value(&(pcs->pos), GEOM_X),
615                 prop_geomfield_get_value(&(pcs->pos), GEOM_Y));
616     }
617     if (prop_changed(pcs->wth_policy.changebar))
618     {
619         width_policy = prop_radiobox_get_value(&(pcs->wth_policy));
620         abobj_set_size_policy(pcs->current_obj, width_policy == SIZE_FIXED_KEY);
621
622         if (width_policy == SIZE_FIXED_KEY)
623         {
624             new_w = prop_geomfield_get_value(&(pcs->wth), GEOM_WIDTH);
625             abobj_set_pixel_width(pcs->current_obj, new_w, 0);
626         }
627         size_chg = True;
628     }
629     if (prop_changed(pcs->init_state.changebar))
630     {
631         abobj_set_visible(pcs->current_obj, 
632                 prop_checkbox_get_value(&(pcs->init_state), AB_STATE_VISIBLE));
633         abobj_set_active(pcs->current_obj,
634                 prop_checkbox_get_value(&(pcs->init_state), AB_STATE_ACTIVE));
635     }
636     if (prop_changed(pcs->fg_color.changebar))
637     {
638         value = prop_colorfield_get_value(&(pcs->fg_color));   
639         abobj_set_foreground_color(pcs->current_obj, value);
640         if (util_strempty(value))
641             reset_fg = True;
642         util_free(value);
643         prop_colorfield_set_value(&(pcs->fg_color), obj_get_fg_color(pcs->current_obj),
644 False);
645     }
646     if (prop_changed(pcs->bg_color.changebar))
647     {
648         value = prop_colorfield_get_value(&(pcs->bg_color));   
649         abobj_set_background_color(pcs->current_obj, value);
650         if (util_strempty(value))
651             reset_bg = True;
652         util_free(value);
653         prop_colorfield_set_value(&(pcs->bg_color), obj_get_bg_color(pcs->current_obj),
654 False);
655     }
656     if (prop_changed(pcs->items.changebar))
657     {
658         prop_item_change(&(pcs->items), False);
659         prop_item_editor_apply(&(pcs->items));
660         size_chg = True;
661     }
662     abobj_tree_instantiate_changes(pcs->current_obj);
663
664     if (reset_bg || reset_fg) /* Set back to No Color */ 
665         abobj_reset_colors(pcs->current_obj, reset_bg, reset_fg); 
666     if (size_chg)
667         abobj_force_dang_form_resize(pcs->current_obj);
668
669     turnoff_changebars(type);
670
671     return OK;
672 }
673
674 static BOOL
675 combo_box_prop_pending(
676     AB_PROP_TYPE type
677 )
678 {
679     return(prop_changebars_pending(prop_combobox_settings_rec[type].prop_sheet));
680 }
681
682 static BOOL
683 verify_props(
684     AB_PROP_TYPE type
685 )
686 {
687     PropComboboxSettingsRec *pcs = &(prop_combobox_settings_rec[type]);
688
689     if (prop_changed(pcs->name.changebar) && !prop_name_ok(pcs->current_obj,
690 pcs->name.field))
691         return False;
692
693     if ((prop_changed(pcs->label_type.changebar) || prop_changed(pcs->label.changebar)) &&
694         prop_options_get_value(&(pcs->label_type)) == (XtPointer)AB_LABEL_GLYPH &&
695         !prop_graphic_filename_ok(pcs->label.field, False))
696         return False;
697  
698     if (prop_changed(pcs->pos.changebar) &&
699         (!prop_number_ok(pcs->pos.x_field, (STRING)XFieldStr, -SHRT_MAX, SHRT_MAX) ||
700          !prop_number_ok(pcs->pos.y_field, (STRING)YFieldStr, -SHRT_MAX, SHRT_MAX)))
701         return False;
702
703     if (prop_changed(pcs->wth.changebar) &&
704         !prop_number_ok(pcs->wth.w_field, (STRING)WFieldStr, 1, SHRT_MAX))
705         return False;
706
707     if (prop_changed(pcs->fg_color.changebar) && !prop_color_ok(pcs->fg_color.field))
708         return False;
709  
710     if (prop_changed(pcs->bg_color.changebar) && !prop_color_ok(pcs->bg_color.field))
711         return False;
712
713     return True;
714 }
715
716 static void
717 turnoff_changebars(
718     AB_PROP_TYPE type
719 )
720 {
721     PropComboboxSettingsRec *pcs = &(prop_combobox_settings_rec[type]);
722
723     prop_set_changebar(pcs->name.changebar,             PROP_CB_OFF);
724     prop_set_changebar(pcs->combobox_type.changebar,    PROP_CB_OFF);
725     prop_set_changebar(pcs->pos.changebar,              PROP_CB_OFF);
726     prop_set_changebar(pcs->wth_policy.changebar,       PROP_CB_OFF);
727     prop_set_changebar(pcs->label_type.changebar,       PROP_CB_OFF);
728     prop_set_changebar(pcs->label.changebar,            PROP_CB_OFF);
729     prop_set_changebar(pcs->init_state.changebar,       PROP_CB_OFF);
730     prop_set_changebar(pcs->bg_color.changebar,         PROP_CB_OFF);
731     prop_set_changebar(pcs->fg_color.changebar,         PROP_CB_OFF);
732     prop_set_changebar(pcs->items.changebar,            PROP_CB_OFF);
733
734     prop_changebars_cleared(pcs->prop_sheet);
735 }
736
737 static int
738 combobox_install_obj_destroy_CB()
739 {
740     static BOOL callback_installed = False;
741
742     if (callback_installed)
743         return 0;
744
745     obj_add_destroy_callback(combobox_obj_destroy_CB, "ComboBox Props");
746     return 0;
747 }
748
749
750 static int
751 combobox_obj_destroy_CB(ObjEvDestroyInfo destroyInfo)
752 {
753     int                 i;
754     ABObj               doomedObj = destroyInfo->obj;
755     PropComboboxSettingsRec *pcs;
756
757     if (!obj_is_combo_box_item(doomedObj))
758         return 0;
759
760     for (i = 0; i < AB_PROP_TYPE_NUM_VALUES; ++i)
761     {
762         pcs = &(prop_combobox_settings_rec[i]);
763
764         if (pcs->current_obj == doomedObj)
765             pcs->current_obj = NULL;
766         if (pcs->items.current_item == doomedObj)
767             pcs->items.current_item = NULL;
768         if (pcs->items.clipboard_item == doomedObj)
769             pcs->items.clipboard_item = NULL;
770     }
771     return 0;
772 }
773
774 static void
775 wth_policyCB(
776     Widget      w,
777     XtPointer   clientdata,
778     XmToggleButtonCallbackStruct *state
779 )
780 {
781     AB_PROP_TYPE                type = (AB_PROP_TYPE)clientdata;
782     PropComboboxSettingsRec     *pcs = &(prop_combobox_settings_rec[type]);
783     XtArgVal                    value;
784
785     /* Width field should ONLY be editable if Size Policy
786      * is "Fixed"
787      */
788     if (state->set)
789     {
790         XtVaGetValues(w, XmNuserData, &value, NULL);
791         ui_field_set_editable(pcs->wth.w_field, value == SIZE_FIXED_KEY);
792     }
793 }
794