Convert uses of XKeycodeToKeysym (deprecated) to XkbKeycodeToKeysym
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / pal_list.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 libraries 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_list.c /main/5 1996/08/08 18:02:00 mustafa $
26  *
27  * @(#)pal_list.c       1.41 15 Feb 1994      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_list.c - Implements Palette List object functionality
46  */
47 #include <stdint.h>
48 #include <stdio.h>
49 #include <Xm/Xm.h>
50 #include <ab_private/obj_notify.h>
51 #include <ab_private/objxm.h>
52 #include <ab_private/ab.h>
53 #include <ab_private/pal.h>
54 #include <ab_private/prop.h>
55 #include <ab_private/abobj.h>
56 #include <ab_private/abobj_set.h>
57 #include <ab_private/abobj_edit.h>
58 #include <ab_private/ui_util.h>
59 #include "list_ui.h"
60
61 const    int    list_init_width  = 130;
62
63 typedef struct  PROP_LIST_SETTINGS
64 {
65     Widget                      prop_sheet;
66     PropFieldSettingRec         name;
67     PropOptionsSettingRec       sel_mode;
68     PropGeometrySettingRec      pos;
69     PropRadioSettingRec         wth_policy;
70     PropGeometrySettingRec      wth;
71     PropOptionsSettingRec       hgt_metric;
72     PropGeometrySettingRec      hgt;
73     PropOptionsSettingRec       label_type;
74     PropFieldSettingRec         label;
75     PropOptionsSettingRec       label_pos;
76     PropCheckboxSettingRec      init_state;
77     PropColorSettingRec         bg_color;
78     PropColorSettingRec         fg_color;
79     PropMenunameSettingRec      menuname;
80     PropFieldSettingRec         menu_title;
81     PropFieldSettingRec         item_label;
82     PropCheckboxSettingRec      item_state;
83     PropItemsSettingRec         items;
84     ABObj                       current_obj;
85 } PropListSettingsRec, *PropListSettings;
86
87 /*************************************************************************
88 **                                                                      **
89 **       Private Function Declarations                                  **
90 **                                                                      **
91 **************************************************************************/
92 /*
93  * Methods
94  */
95 static int      list_initialize(
96                     ABObj   obj
97                 );
98 static Widget   list_prop_init(
99                     Widget  parent,
100                     AB_PROP_TYPE type
101                 );
102 static int      list_prop_activate(
103                     AB_PROP_TYPE type,
104                     BOOL         active
105                 );
106 static int      list_prop_clear(
107                     AB_PROP_TYPE type
108                 );
109 static int      list_prop_load(
110                     ABObj        obj,
111                     AB_PROP_TYPE type,
112                     unsigned long loadkey
113                 );
114 static int      list_prop_apply(
115                     AB_PROP_TYPE type
116                 );
117 static BOOL     list_prop_pending(
118                     AB_PROP_TYPE type
119                 );
120 static BOOL     verify_props(
121                     AB_PROP_TYPE type
122                 );
123 static void     turnoff_changebars(
124                     AB_PROP_TYPE type
125                 );
126
127 /*
128  * ABObj callbacks
129  */
130 static int      prop_list_install_obj_destroy_CB(void);
131
132 static int      prop_list_obj_destroy_CB(
133                     ObjEvDestroyInfo destroyInfo
134                 );
135
136 /*
137  * Xt Callbacks
138  */
139 static void     wth_policyCB(
140                     Widget      widget,
141                     XtPointer   clientdata,
142                     XmToggleButtonCallbackStruct *state
143                 );
144
145
146 /*************************************************************************
147 **                                                                      **
148 **       Data                                                            **
149 **                                                                      **
150 **************************************************************************/
151 PalItemInfo list_palitem_rec = {
152
153     /* type             */  AB_TYPE_LIST,
154     /* name             */  "List",
155     /* animation pixmaps*/  NULL,
156     /* number of pixmaps*/  0,
157     /* rev_prop_frame   */  NULL,
158     /* fix_prop_dialog  */  NULL,
159     /* initialize       */  list_initialize,
160     /* is_a_test        */  obj_is_list,
161     /* prop_initialize  */  list_prop_init,
162     /* prop_activate    */  list_prop_activate,
163     /* prop_clear       */  list_prop_clear,
164     /* prop_load        */  list_prop_load,
165     /* prop_apply       */  list_prop_apply,
166     /* prop_pending     */  list_prop_pending
167
168 };
169
170 PalItemInfo *ab_list_palitem = &list_palitem_rec;
171 PropListSettingsRec prop_list_settings_rec[AB_PROP_TYPE_NUM_VALUES];
172
173
174 /*************************************************************************
175 **                                                                      **
176 **       Function Definitions                                           **
177 **                                                                      **
178 **************************************************************************/
179 static int
180 list_initialize(
181     ABObj    obj
182 )
183 {
184     AB_LIST_INFO *info = &(obj->info.list);
185     ABObj       module = obj_get_module(obj);
186     ABObj       iobj;
187     String  items[2];
188     int         i;
189
190     obj_set_unique_name(obj, "list");
191
192     obj_set_num_rows(obj, 4);
193     obj_set_height(obj, -1);
194     obj_set_width(obj, list_init_width);
195     obj_set_selection_mode(obj, AB_SELECT_BROWSE);
196     obj_set_is_initially_visible(obj, True);
197     obj_set_is_initially_active(obj, True);
198
199     /* Add initial items to list */
200     items[0] = catgets(Dtb_project_catd, 6, 70, "itemA");
201     items[1] = catgets(Dtb_project_catd, 6, 71, "itemB");
202     for (i=0; i < XtNumber(items); i++)
203     {
204         iobj = obj_create(AB_TYPE_ITEM, NULL);
205         obj_set_subtype(iobj, AB_ITEM_FOR_LIST);
206         obj_append_child(obj, iobj);
207         abobj_set_item_name(iobj, obj_get_module(obj), obj_get_name(obj), items[i]);
208         obj_set_label(iobj, items[i]);
209         obj_set_is_initially_selected(iobj, False);
210     }
211     obj_set_attachment(obj, AB_CP_NORTH, AB_ATTACH_POINT, NULL, obj->y);
212     obj_set_attachment(obj, AB_CP_WEST,  AB_ATTACH_POINT, NULL, obj->x);
213
214     return OK;
215
216 }
217
218
219 static Widget
220 list_prop_init(
221     Widget    parent,
222     AB_PROP_TYPE type
223 )
224 {
225     DtbListPropDialogInfoRec    rev_list_prop_dialog; /* Revolving Props */
226     DtbListPropDialogInfo       cgen = &dtb_list_prop_dialog; /* Codegen structure */
227     DtbRevolvPropDialogInfo     rpd = &(dtb_revolv_prop_dialog);
228     PropListSettingsRec         *pls = &(prop_list_settings_rec[type]);
229     Widget                      item[8];
230     int                         item_val[8];
231     Widget                      item2[8];
232     int                         item2_val[8];
233     int                         n, j;
234     int                         i;
235
236     if (type == AB_PROP_REVOLVING)
237     {
238         /* Cloning Trick:
239          * Only the Attributes ControlPanel needs to be created within
240          * the existing Revolving Prop dialog, so fill out all other
241          * fields with the Revolving Prop dialog equivelents, so the
242          * dtb initialize proc will skip those non-NULL fields...
243          */
244         dtbListPropDialogInfo_clear(&rev_list_prop_dialog);
245
246         cgen = &(rev_list_prop_dialog);
247         cgen->prop_dialog = rpd->prop_dialog;
248         cgen->prop_dialog_shellform = rpd->prop_dialog_shellform;
249         cgen->prop_dialog_panedwin = rpd->prop_dialog_panedwin;
250         cgen->prop_dialog_form = rpd->prop_dialog_form;
251         cgen->objlist_panel = rpd->objlist_panel;
252         cgen->objlist_label = rpd->objlist_label2;
253         cgen->objlist_scrolledwin = rpd->objlist_scrolledwin;
254         cgen->objlist = rpd->objlist;
255         cgen->attrs_ctrlpanel_frame = rpd->attrs_ctrlpanel_frame;
256         cgen->activate_panel = rpd->activate_panel;
257         cgen->apply_button = rpd->apply_button;
258         cgen->ok_button = rpd->ok_button;
259         cgen->cancel_button = rpd->cancel_button;
260         cgen->reset_button = rpd->reset_button;
261         cgen->help_button = rpd->help_button;
262
263         /*
264          * Get notification of object destruction!
265          */
266         prop_list_install_obj_destroy_CB();
267
268     }
269     else /* AB_PROP_FIXED - create entire dialog*/
270         cgen = &dtb_list_prop_dialog;
271
272     if (dtb_list_prop_dialog_initialize(cgen, parent) == 0)
273     {
274         pls->prop_sheet = cgen->attrs_ctrlpanel;
275         pls->current_obj = NULL;
276
277         if (type == AB_PROP_REVOLVING)
278                 XtVaSetValues(parent,
279                         XmNuserData, pls->current_obj,
280                         NULL);
281
282         /* Dialog/Object List */
283         if (type == AB_PROP_FIXED)
284         {
285             prop_fixed_dialog_init(ab_list_palitem,
286                         cgen->prop_dialog_shellform, cgen->objlist);
287             prop_activate_panel_init(type, ab_list_palitem,
288                         cgen->ok_button, cgen->apply_button,
289                         cgen->reset_button, cgen->cancel_button,
290                         cgen->help_button);
291         }
292
293         /* Alternate Editor Buttons */
294         prop_editors_panel_init(type, ab_list_palitem,
295             cgen->attach_button, cgen->conn_button, cgen->helptxt_button);
296
297         /*
298           * Prop Sheet Settings....
299          */
300
301         /* Name */
302         prop_field_init(&(pls->name), cgen->name_field_label,
303                 cgen->name_field, cgen->name_cb);
304
305         /* Label, Type, Position */
306         n = 0;
307         item[n] = cgen->labeltype_rbox_items.String_item;
308         item_val[n] = AB_LABEL_STRING; n++;
309         item[n] = cgen->labeltype_rbox_items.Graphic_item;
310         item_val[n] = AB_LABEL_GLYPH; n++;
311         prop_options_init(&(pls->label_type), cgen->labeltype_rbox_label,
312                 cgen->labeltype_rbox, cgen->labeltype_rbox_menu,
313                 n, item, (XtPointer*)item_val,
314                 cgen->labeltype_cb);
315
316         prop_field_init(&(pls->label), cgen->label_field_label,
317                 cgen->label_field, cgen->label_cb);
318
319         prop_label_field_init(&(pls->label), cgen->graphic_hint, item, n);
320
321         n = 0;
322         item[n] = cgen->labelpos_rbox_items.Above_item;
323         item_val[n] = AB_CP_NORTH; n++;
324         item[n] = cgen->labelpos_rbox_items.Left_item;
325         item_val[n] = AB_CP_WEST; n++;
326         prop_options_init(&(pls->label_pos), cgen->labelpos_rbox_label,
327                 cgen->labelpos_rbox, cgen->labelpos_rbox_menu,
328                 n, item, (XtPointer*)item_val,
329                 cgen->labeltype_cb);
330
331         /* Selection Mode */
332         n = 0;
333         item[n] = cgen->selmode_rbox_items.Single_Select_item;
334         item_val[n] = AB_SELECT_SINGLE; n++;
335         item[n] = cgen->selmode_rbox_items.Browse_Select_item;
336         item_val[n] = AB_SELECT_BROWSE; n++;
337         item[n] = cgen->selmode_rbox_items.Multiple_Select_item;
338         item_val[n] = AB_SELECT_MULTIPLE; n++;
339         item[n] = cgen->selmode_rbox_items.Browse_Multiple_Select_item;
340         item_val[n] = AB_SELECT_BROWSE_MULTIPLE; n++;
341         prop_options_init(&(pls->sel_mode), cgen->selmode_rbox_label,
342                                 cgen->selmode_rbox, cgen->selmode_rbox_menu,
343                                 n, item, (XtPointer*)item_val,
344                                 cgen->selmode_cb);
345
346         /* Position */
347         prop_geomfield_init(&(pls->pos), cgen->pos_label,
348                             cgen->x_field_label, cgen->x_field,
349                             cgen->y_field_label, cgen->y_field,
350                             NULL, NULL, NULL, NULL,
351                             cgen->pos_cb);
352
353         /* Width */
354         n = 0;
355         item[n] = cgen->wpolicy_rbox_items.Longest_Item_item;
356         item_val[n] = SIZE_OF_CONTENTS_KEY; n++;
357         item[n] = cgen->wpolicy_rbox_items.Fixed_item;
358         item_val[n] = SIZE_FIXED_KEY; n++;
359         prop_radiobox_init(&(pls->wth_policy), cgen->wpolicy_rbox_label,
360                 cgen->wpolicy_rbox, n, item, (XtPointer*)item_val,
361                 cgen->wpolicy_cb);
362
363         for(i=0; i < n; i++)
364             XtAddCallback(item[i], XmNvalueChangedCallback,
365                         (XtCallbackProc)prop_size_policyCB, (XtPointer)&(pls->wth));
366
367         prop_geomfield_init(&(pls->wth), cgen->wpolicy_rbox_label,
368                             NULL, NULL, NULL, NULL,
369                             cgen->width_field_label, cgen->width_field,
370                             NULL, NULL,
371                             cgen->wpolicy_cb);
372
373         /* Height */
374         prop_geomfield_init(&(pls->hgt), cgen->hgt_opmenu_label,
375                             NULL, NULL, NULL, NULL,
376                             NULL, NULL,
377                             cgen->height_field_label, cgen->height_field,
378                             cgen->hgt_cb);
379
380         n = 0;
381         item[n] = cgen->hgt_opmenu_items.Lines_item;
382         item_val[n] = SIZE_IN_CHARS_KEY; n++;
383         item[n] = cgen->hgt_opmenu_items.Pixels_item;
384         item_val[n] = SIZE_IN_PIXELS_KEY; n++;
385         prop_options_init(&(pls->hgt_metric), cgen->hgt_opmenu_label,
386                            cgen->hgt_opmenu,
387                            cgen->hgt_opmenu_menu,
388                            n, item, (XtPointer*)item_val,
389                            cgen->hgt_cb);
390
391         /* Initial State */
392         n = 0;
393         item[n] = cgen->istate_ckbox_items.Visible_item;
394         item_val[n] = AB_STATE_VISIBLE; n++;
395         item[n] = cgen->istate_ckbox_items.Active_item;
396         item_val[n] = AB_STATE_ACTIVE; n++;
397         prop_checkbox_init(&(pls->init_state), cgen->istate_ckbox_label,
398                 cgen->istate_ckbox, n, item, item_val,
399                 cgen->istate_cb);
400
401         /* Color */
402         prop_colorfield_init(&(pls->bg_color), cgen->bg_mbutton,
403                 cgen->bg_mbutton_bg_mbutton_menu_items.None_item,
404                 cgen->bg_mbutton_bg_mbutton_menu_items.Color_Chooser_item,
405                 cgen->bg_swatch, cgen->bg_field, cgen->bg_cb);
406
407         prop_colorfield_init(&(pls->fg_color), cgen->fg_mbutton,
408                 cgen->fg_mbutton_fg_mbutton_menu_items.None_item,
409                 cgen->fg_mbutton_fg_mbutton_menu_items.Color_Chooser_item,
410                 cgen->fg_swatch, cgen->fg_field, cgen->fg_cb);
411
412         /* Menu Title */
413         prop_field_init(&(pls->menu_title), cgen->menutitle_field_label,
414                             cgen->menutitle_field, cgen->menutitle_cb);
415
416         /* Menu Name Setting */
417         prop_menuname_init(&(pls->menuname), type, cgen->menu_label,
418                         cgen->menu_mbutton, cgen->menu_field,
419                         cgen->name_field, cgen->menu_cb,
420                         &(pls->menu_title),
421                         &(pls->current_obj), True);
422
423         /* Item Editor....*/
424
425         /* Item Label */
426         prop_field_init(&(pls->item_label), cgen->itemlabel_label,
427                 cgen->itemlabel_field, cgen->itemlist_cb);
428
429         /* Item State */
430         n = 0;
431         item[n] = cgen->itemstate_ckbox_items.Selected_item;
432         item_val[n] = AB_STATE_SELECTED; n++;
433         prop_checkbox_init(&(pls->item_state), NULL,
434                 cgen->itemstate_ckbox, n, item, item_val,
435                 cgen->itemlist_cb);
436
437         /* Store Items->Insert menu items in array */
438         n = 0;
439         item[n] = cgen->item_edit_mbutton_editmenu_items.Add_Before_item;
440         item_val[n] = INSERT_BEFORE; n++;
441         item[n] = cgen->item_edit_mbutton_editmenu_items.Add_After_item;
442         item_val[n] = INSERT_AFTER; n++;
443
444         /* Store Items->Edit menu_items.items in array */
445         j = 0;
446         item2[j] = cgen->item_edit_mbutton_editmenu_items.Cut_item;
447         item2_val[j] = AB_EDIT_CUT; j++;
448         item2[j] = cgen->item_edit_mbutton_editmenu_items.Copy_item;
449         item2_val[j] = AB_EDIT_COPY; j++;
450         item2[j] = cgen->item_edit_mbutton_editmenu_items.Paste_item;
451         item2_val[j] = AB_EDIT_PASTE; j++;
452         item2[j] = cgen->item_edit_mbutton_editmenu_items.Delete_item;
453         item2_val[j] = AB_EDIT_DELETE; j++;
454         item2[j] = cgen->item_edit_mbutton_editmenu_items.Change_item;
455         item2_val[j] = EDIT_CHANGE; j++;
456
457         /* Hook up Item Editing mechanism to Item List */
458         prop_item_editor_init(&(pls->items), AB_ITEM_FOR_LIST,
459                 cgen->itemlist, cgen->itemlist_cb,
460                 cgen->item_add_button,
461                 n, item, item_val, /* Insert */
462                 j, item2, item2_val,/* Edit */
463                 &(pls->item_label), NULL/*label_type*/, NULL/*graphic_hint*/,
464                 NULL/*mnemonic*/, NULL/*accel*/, NULL/*line_style*/,
465                 &(pls->item_state), NULL/*submenu*/,
466                 &(pls->current_obj));
467
468         prop_changebars_cleared(pls->prop_sheet);
469
470         return (cgen->prop_dialog_shellform);
471     }
472     else
473         return NULL;
474
475 }
476
477 static int
478 list_prop_activate(
479     AB_PROP_TYPE type,
480     BOOL         active
481 )
482 {
483     ui_set_active(prop_list_settings_rec[type].prop_sheet, active);
484
485     return OK;
486
487 }
488
489 static int
490 list_prop_clear(
491     AB_PROP_TYPE type
492 )
493 {
494     PropListSettingsRec *pls = &(prop_list_settings_rec[type]);
495
496     if (pls->current_obj == NULL)
497         return OK;
498
499     /* Clear Name */
500     prop_field_set_value(&(pls->name), "", False);
501
502     /* Clear Label Type/Position */
503     prop_options_set_value(&(pls->label_type), (XtPointer)AB_LABEL_STRING, False);
504     prop_options_set_value(&(pls->label_pos), (XtPointer)AB_CP_WEST, False);
505
506     /* Clear Label */
507     ui_set_label_string(pls->label.label, "Label:");
508     prop_field_set_value(&(pls->label), "", False);
509
510     /* Clear Selection Mode */
511     prop_options_set_value(&(pls->sel_mode), (XtPointer)AB_SELECT_SINGLE, False);
512
513     /* Clear Position */
514     prop_geomfield_clear(&(pls->pos), GEOM_X);
515     prop_geomfield_clear(&(pls->pos), GEOM_Y);
516
517     /* Clear Width */
518     prop_radiobox_set_value(&(pls->wth_policy),
519                             (XtPointer)SIZE_FIXED_KEY, False);
520     prop_geomfield_clear(&(pls->wth), GEOM_WIDTH);
521
522     /* Clear Height */
523     prop_geomfield_clear(&(pls->hgt), GEOM_HEIGHT);
524
525     /* Clear Initial State */
526     prop_checkbox_set_value(&(pls->init_state), AB_STATE_VISIBLE, True, False);
527     prop_checkbox_set_value(&(pls->init_state), AB_STATE_ACTIVE, True, False);
528
529     /* Clear Color */
530     prop_colorfield_set_value(&(pls->bg_color), "", False);
531     prop_colorfield_set_value(&(pls->fg_color), "", False);
532
533     /* Clear Menu Name/Title */
534     prop_menuname_set_value(&(pls->menuname), "", False);
535     prop_field_set_value(&(pls->menu_title), "", False);
536
537     /* Clear Items */
538     prop_item_editor_clear(&(pls->items));
539
540     pls->current_obj = NULL;
541
542     turnoff_changebars(type);
543
544     return OK;
545 }
546
547
548 static int
549 list_prop_load(
550     ABObjPtr     obj,
551     AB_PROP_TYPE type,
552     unsigned long loadkey
553 )
554 {
555     PropListSettingsRec *pls = &(prop_list_settings_rec[type]);
556     int                 height;
557     BOOL                load_all = (loadkey & LoadAll);
558     BOOL                editable;
559
560     if (obj == NULL)
561     {
562         if (pls->current_obj != NULL)
563             obj = pls->current_obj;
564         else
565             return ERROR;
566     }
567     else if (!obj_is_list(obj))
568         return ERROR;
569     else
570         pls->current_obj = obj;
571
572     /* Load Name */
573     if (load_all || loadkey & LoadName)
574         prop_field_set_value(&(pls->name), obj_get_name(obj), False);
575
576     if (load_all)
577     {
578         /* Load Label Type/Position */
579         prop_options_set_value(&(pls->label_type), (XtPointer)obj->label_type, False);
580         prop_options_set_value(&(pls->label_pos), (XtPointer)obj_get_label_position(obj), False);
581
582         /* Load Label */
583         prop_setup_label_field(&(pls->label), NULL,
584                                 obj->label_type, obj_get_label(obj), AB_LINE_UNDEF);
585
586         /* Load Selection Mode */
587         prop_options_set_value(&(pls->sel_mode),
588                 (XtPointer)((AB_SELECT_TYPE)obj_get_selection_mode(obj)), False);
589
590         /* Load Initial State */
591         prop_checkbox_set_value(&(pls->init_state), AB_STATE_VISIBLE,
592                 obj_is_initially_visible(obj), False);
593         prop_checkbox_set_value(&(pls->init_state), AB_STATE_ACTIVE,
594                 obj_is_initially_active(obj), False);
595
596         /* Load Color */
597         prop_colorfield_set_value(&(pls->bg_color), obj_get_bg_color(obj), False);
598         prop_colorfield_set_value(&(pls->fg_color), obj_get_fg_color(obj), False);
599
600         /* Load Menu Name/Title */
601         prop_menuname_set_value(&(pls->menuname), obj_get_menu_name(obj), False);
602         prop_field_set_value(&(pls->menu_title), obj_get_menu_title(obj), False);
603
604         /* Load Items */
605         prop_item_editor_load(&(pls->items), obj);
606
607         turnoff_changebars(type);
608     }
609
610     /* Load Position */
611     if (load_all || loadkey & LoadPosition)
612         prop_load_obj_position(obj, &(pls->pos));
613
614     /* Load Size */
615     if (load_all || loadkey & LoadSize)
616     {
617         /* Load Width */
618         editable = abobj_width_resizable(obj);
619         prop_radiobox_set_value(&(pls->wth_policy), editable?
620                                 (XtPointer)SIZE_FIXED_KEY :
621                                 (XtPointer)SIZE_OF_CONTENTS_KEY, False);
622
623         ui_set_active(pls->wth.w_field, editable);
624         ui_set_active(pls->wth.w_label, editable);
625
626         prop_geomfield_set_value(&(pls->wth), GEOM_WIDTH,
627                 abobj_get_comp_width(obj), False);
628
629         /* Load Height */
630         if (obj_get_num_rows(obj) == -1) /* Size in Pixels */
631         {
632             prop_options_set_value(&(pls->hgt_metric), (XtPointer)SIZE_IN_PIXELS_KEY, False);
633             height = abobj_get_comp_height(obj);
634         }
635         else /* Size in Chars */
636         {
637             prop_options_set_value(&(pls->hgt_metric), (XtPointer)SIZE_IN_CHARS_KEY, False);
638             height = obj_get_num_rows(obj);
639         }
640         prop_geomfield_set_value(&(pls->hgt), GEOM_HEIGHT, height, False);
641     }
642
643     return OK;
644
645 }
646
647 static int
648 list_prop_apply(
649     AB_PROP_TYPE   type
650 )
651 {
652     PropListSettingsRec         *pls = &(prop_list_settings_rec[type]);
653     ABObj                       szObj;
654     STRING                      value;
655     int                         width_policy, metric, new_w, new_h;
656     BOOL                        size_chg = False;
657     BOOL                        reset_bg = False;
658     BOOL                        reset_fg = False;
659
660     if (!verify_props(type))
661         return ERROR;
662
663     if (prop_changed(pls->name.changebar))
664     {
665         value = prop_field_get_value(&(pls->name));
666         abobj_set_name(pls->current_obj, value);
667         util_free(value);
668     }
669     if (prop_changed(pls->label.changebar) ||
670         prop_changed(pls->label_type.changebar))
671     {
672         value = prop_field_get_value(&(pls->label));
673
674         abobj_set_label(pls->current_obj,
675             (AB_LABEL_TYPE)prop_options_get_value(&(pls->label_type)),
676                         value);
677         util_free(value);
678
679         abobj_set_label_position(pls->current_obj,
680                 (AB_COMPASS_POINT)prop_options_get_value(&(pls->label_pos)));
681
682         size_chg = True;
683     }
684     if (prop_changed(pls->sel_mode.changebar))
685     {
686         abobj_set_selection_mode(pls->current_obj,
687             (AB_SELECT_TYPE)prop_options_get_value(&(pls->sel_mode)));
688     }
689     if (prop_changed(pls->pos.changebar))
690     {
691         if (abobj_is_movable(pls->current_obj))
692             abobj_set_xy(pls->current_obj,
693                 prop_geomfield_get_value(&(pls->pos), GEOM_X),
694                 prop_geomfield_get_value(&(pls->pos), GEOM_Y));
695     }
696     if (prop_changed(pls->wth_policy.changebar))
697     {
698         width_policy = prop_radiobox_get_value(&(pls->wth_policy));
699         abobj_set_size_policy(pls->current_obj, width_policy == SIZE_FIXED_KEY);
700
701         if (width_policy == SIZE_FIXED_KEY)
702         {
703             new_w = prop_geomfield_get_value(&(pls->wth), GEOM_WIDTH);
704             abobj_set_pixel_width(pls->current_obj, new_w, 0);
705         }
706         size_chg = True;
707     }
708     if (prop_changed(pls->hgt.changebar))
709     {
710         metric = (int)(intptr_t) prop_options_get_value(&(pls->hgt_metric));
711         new_h = prop_geomfield_get_value(&(pls->hgt), GEOM_HEIGHT);
712
713         abobj_set_num_rows(pls->current_obj,
714                 metric == SIZE_IN_CHARS_KEY? new_h : -1);
715
716         abobj_set_pixel_height(pls->current_obj,
717                 metric == SIZE_IN_PIXELS_KEY? new_h : -1, 0);
718
719         size_chg = True;
720     }
721     if (prop_changed(pls->init_state.changebar))
722     {
723         abobj_set_visible(pls->current_obj,
724                 prop_checkbox_get_value(&(pls->init_state), AB_STATE_VISIBLE));
725         abobj_set_active(pls->current_obj,
726                 prop_checkbox_get_value(&(pls->init_state), AB_STATE_ACTIVE));
727     }
728     if (prop_changed(pls->fg_color.changebar))
729     {
730         value = prop_colorfield_get_value(&(pls->fg_color));
731         abobj_set_foreground_color(pls->current_obj, value);
732         if (util_strempty(value))
733             reset_fg = True;
734         util_free(value);
735         prop_colorfield_set_value(&(pls->fg_color),
736                 obj_get_fg_color(pls->current_obj), False);
737     }
738     if (prop_changed(pls->bg_color.changebar))
739     {
740         value = prop_colorfield_get_value(&(pls->bg_color));
741         abobj_set_background_color(pls->current_obj, value);
742         if (util_strempty(value))
743             reset_bg = True;
744         util_free(value);
745         prop_colorfield_set_value(&(pls->bg_color),
746                 obj_get_bg_color(pls->current_obj), False);
747     }
748     if (prop_changed(pls->menuname.changebar))
749     {
750         value = prop_menuname_get_value(&(pls->menuname));
751         abobj_set_menu_name(pls->current_obj, value);
752         util_free(value);
753         prop_menuname_set_value(&(pls->menuname),
754                 obj_get_menu_name(pls->current_obj), False);
755     }
756     if (prop_changed(pls->menu_title.changebar))
757     {
758         value = prop_field_get_value(&(pls->menu_title));
759         abobj_set_menu_title(pls->current_obj, value);
760         util_free(value);
761     }
762     if (prop_changed(pls->items.changebar))
763     {
764         /* Ensure edits to current item are saved before apply */
765         prop_item_change(&(pls->items), False);
766         prop_item_editor_apply(&(pls->items));
767         size_chg = True;
768     }
769
770     abobj_tree_instantiate_changes(pls->current_obj);
771
772     if (reset_bg || reset_fg) /* Set back to No Color */
773         abobj_reset_colors(pls->current_obj, reset_bg, reset_fg);
774
775     if (size_chg)
776     {
777         /* Need to force XmList to be fixed width, since often it's
778          * finicky and snaps back to the width of the longest item...
779          */
780         if (obj_get_width(pls->current_obj) != -1)
781         {
782             szObj = objxm_comp_get_subobj(pls->current_obj, AB_CFG_SIZE_OBJ);
783             XtVaSetValues(objxm_get_widget(szObj),
784                 XmNwidth, obj_get_width(pls->current_obj),
785                 NULL);
786         }
787         abobj_force_dang_form_resize(pls->current_obj);
788     }
789     turnoff_changebars(type);
790
791     return OK;
792 }
793
794 static BOOL
795 list_prop_pending(
796     AB_PROP_TYPE type
797 )
798 {
799     return(prop_changebars_pending(prop_list_settings_rec[type].prop_sheet));
800 }
801
802 static BOOL
803 verify_props(
804     AB_PROP_TYPE type
805 )
806 {
807     PropListSettingsRec *pls = &(prop_list_settings_rec[type]);
808
809     if (prop_changed(pls->name.changebar) &&
810         !prop_name_ok(pls->current_obj, pls->name.field))
811         return False;
812
813     if ((prop_changed(pls->label_type.changebar) || prop_changed(pls->label.changebar)) &&
814         prop_options_get_value(&(pls->label_type)) == (XtPointer)AB_LABEL_GLYPH &&
815         !prop_graphic_filename_ok(pls->label.field, False))
816         return False;
817
818     if (prop_changed(pls->pos.changebar) &&
819         (!prop_number_ok(pls->pos.x_field, (STRING)XFieldStr, -SHRT_MAX, SHRT_MAX) ||
820          !prop_number_ok(pls->pos.y_field, (STRING)YFieldStr, -SHRT_MAX, SHRT_MAX)))
821         return False;
822
823     if (prop_changed(pls->wth.changebar) &&
824         !prop_number_ok(pls->wth.w_field, (STRING)WFieldStr, 1, SHRT_MAX))
825         return False;
826
827     if (prop_changed(pls->hgt.changebar) &&
828         !prop_number_ok(pls->hgt.h_field, (STRING)HFieldStr, 1, SHRT_MAX))
829         return False;
830
831     if (prop_changed(pls->fg_color.changebar) && !prop_color_ok(pls->fg_color.field))
832         return False;
833
834     if (prop_changed(pls->bg_color.changebar) && !prop_color_ok(pls->bg_color.field))
835         return False;
836
837     if (prop_changed(pls->menuname.changebar) && !prop_obj_name_ok(pls->menuname.field,
838                         obj_get_module(pls->current_obj), AB_TYPE_MENU, "Menu"))
839         return False;
840
841     return True;
842 }
843
844 static void
845 turnoff_changebars(
846     AB_PROP_TYPE type
847 )
848 {
849     PropListSettingsRec *pls = &(prop_list_settings_rec[type]);
850
851     prop_set_changebar(pls->name.changebar,     PROP_CB_OFF);
852     prop_set_changebar(pls->sel_mode.changebar, PROP_CB_OFF);
853     prop_set_changebar(pls->wth_policy.changebar,PROP_CB_OFF);
854     prop_set_changebar(pls->hgt.changebar,       PROP_CB_OFF);
855     prop_set_changebar(pls->pos.changebar,       PROP_CB_OFF);
856     prop_set_changebar(pls->label_type.changebar,PROP_CB_OFF);
857     prop_set_changebar(pls->label.changebar,     PROP_CB_OFF);
858     prop_set_changebar(pls->init_state.changebar,PROP_CB_OFF);
859     prop_set_changebar(pls->bg_color.changebar,  PROP_CB_OFF);
860     prop_set_changebar(pls->fg_color.changebar,  PROP_CB_OFF);
861     prop_set_changebar(pls->menuname.changebar,  PROP_CB_OFF);
862     prop_set_changebar(pls->menu_title.changebar,  PROP_CB_OFF);
863     prop_set_changebar(pls->items.changebar,     PROP_CB_OFF);
864
865     prop_changebars_cleared(pls->prop_sheet);
866
867 }
868
869 /*
870  * Object destroy callback
871  */
872 static int
873 prop_list_install_obj_destroy_CB(void)
874 {
875     static BOOL callback_installed = False;
876
877     if (callback_installed)
878     {
879         return 0;
880     }
881     obj_add_destroy_callback(prop_list_obj_destroy_CB, "List Props");
882     return 0;
883 }
884
885
886 static int
887 prop_list_obj_destroy_CB(ObjEvDestroyInfo destroyInfo)
888 {
889     int                 i;
890     ABObj               doomedObj = destroyInfo->obj;
891     PropListSettingsRec *pls;
892
893     if (!obj_is_list_item(doomedObj))
894     {
895         return 0;
896     }
897
898     for (i = 0; i < AB_PROP_TYPE_NUM_VALUES; ++i)
899     {
900         pls = &(prop_list_settings_rec[i]);
901
902         if (pls->current_obj == doomedObj)
903             pls->current_obj = NULL;
904         if (pls->items.current_item == doomedObj)
905             pls->items.current_item = NULL;
906         if (pls->items.clipboard_item == doomedObj)
907             pls->items.clipboard_item = NULL;
908     }
909
910     return 0;
911 }
912 static void
913 wth_policyCB(
914     Widget      w,
915     XtPointer   clientdata,
916     XmToggleButtonCallbackStruct *state
917 )
918 {
919     AB_PROP_TYPE                type = (AB_PROP_TYPE)clientdata;
920     PropListSettingsRec         *pls = &(prop_list_settings_rec[type]);
921     XtArgVal                    value;
922
923     /* Width field should ONLY be editable if Size Policy
924      * is "Fixed"
925      */
926     if (state->set)
927     {
928         XtVaGetValues(w, XmNuserData, &value, NULL);
929         ui_field_set_editable(pls->wth.w_field, value == SIZE_FIXED_KEY);
930     }
931 }