Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / libABobjXm / objxm_objects.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  *      $XConsortium: objxm_objects.c /main/6 1996/10/28 16:24:20 mustafa $
25  *
26  *      @(#)objxm_objects.c     1.117 23 May 1995
27  *
28  *      RESTRICTED CONFIDENTIAL INFORMATION:
29  *
30  *      The information in this document is subject to special
31  *      restrictions in a confidential disclosure agreement between
32  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
33  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
34  *      Sun's specific written approval.  This document and all copies
35  *      and derivative works thereof must be returned or destroyed at
36  *      Sun's request.
37  *
38  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  *
40  */
41
42
43 /*
44  * objxm_objects.c - Implements methods for configuring the Set
45  *                   of UI Objects into their appropriate
46  *                   Motif hierarchies
47  */
48 #include <stdio.h>
49 #include <Xm/Xm.h>
50 #include <Xm/MenuShell.h>
51 #include <Xm/PanedW.h>
52 #include <Xm/ScrolledW.h>
53 #include <Xm/ToggleB.h>
54 #include <Xm/RowColumn.h>
55 #include <Xm/FileSB.h>
56 #include <Xm/TextF.h>
57 #include <Xm/List.h>
58 #include <Dt/ComboBox.h>
59 #include <Dt/TermPrim.h>
60 #include <Dt/Term.h>
61 #include <Dt/SpinBox.h>
62 #include <ab_private/obj.h>
63 #include <ab_private/obj_notify.h>
64 #include "objxmP.h"
65
66
67 #define SELECT_OBJ_KEY  "__selected__"
68
69
70 /*************************************************************************
71 **                                                                      **
72 **       Private Function Declartions                                   **
73 **                                                                      **
74 **************************************************************************/
75 /*
76  * General methods
77  */
78 #define check_obj_class_name(obj) \
79             ((obj_get_class_name(obj) != NULL)? \
80                  OK \
81              : \
82                  obj_set_class_name(obj, objxm_obj_get_default_motif_class(obj)))
83
84 /*
85  * XmConfigure/UnConfigure Methods
86  */
87 static int      mainwin_xmconfig(
88                     ABObj       obj
89                 );
90 static int      mainwin_unconfig(
91                     ABObj       obj
92                 );
93 static int      choice_xmconfig(
94                     ABObj       obj
95                 );
96 static int      choice_unconfig(
97                     ABObj       obj
98                 );
99 static int      combo_box_xmconfig(
100                     ABObj       obj
101                 );
102 static int      combo_box_unconfig(
103                     ABObj       obj
104                 );
105 static ABObj    combo_box_get_config_obj(
106                     ABObj           obj,
107                     AB_CFG_OBJ_TYPE type
108                 );
109 static int      cpanel_xmconfig(
110                     ABObj       obj
111                 );
112 static int      cpanel_unconfig(
113                     ABObj       obj
114                 );
115 static int      custdlg_xmconfig(
116                     ABObj       obj
117                 );
118 static int      custdlg_unconfig(
119                     ABObj       obj
120                 );
121 static int      layer_xmconfig(
122                     ABObj       obj
123                 );
124 static int      layer_unconfig(
125                     ABObj       obj
126                 );
127 static int      group_xmconfig(
128                     ABObj       obj
129                 );
130 static int      group_unconfig(
131                     ABObj       obj
132                 );
133 static int      item_xmconfig(
134                     ABObj       obj
135                 );
136 static int      list_xmconfig(
137                     ABObj       obj
138                 );
139 static int      list_unconfig(
140                     ABObj       obj
141                 );
142 static int      menu_xmconfig(
143                     ABObj       obj
144                 );
145 static int      menu_unconfig(
146                     ABObj       obj
147                 );
148 static int      menubar_xmconfig(
149                     ABObj       obj
150                 );
151 static int      pane_xmconfig(
152                     ABObj       obj
153                 );
154 static int      pane_unconfig(
155                     ABObj       obj
156                 );
157 static int      simple_xmconfig(
158                     ABObj       obj
159                 );
160 static int      simple_unconfig(
161                     ABObj       obj
162                 );
163 static int      scale_xmconfig(
164                     ABObj       obj
165                 );
166 static int      scale_unconfig(
167                     ABObj       obj
168                 );
169 static int      spin_box_xmconfig(
170                     ABObj       obj
171                 );
172 static int      spin_box_unconfig(
173                     ABObj       obj
174                 );
175 static int      textf_xmconfig(
176                     ABObj       obj
177                 );
178 static int      textf_unconfig(
179                     ABObj       obj
180                 );
181 static int      fchooser_xmconfig(
182                     ABObj       obj
183                 );
184 static int      box_unconfig(
185                     ABObj       obj
186                 );
187
188 /*
189  * GetConfigObj Methods
190  */
191 static ABObj    mainwin_get_config_obj(
192                     ABObj           obj,
193                     AB_CFG_OBJ_TYPE type
194                 );
195 static ABObj    choice_get_config_obj(
196                     ABObj           obj,
197                     AB_CFG_OBJ_TYPE type
198                 );
199 static ABObj    container_get_config_obj(
200                     ABObj           obj,
201                     AB_CFG_OBJ_TYPE type
202                 );
203 static ABObj    custdlg_get_config_obj(
204                     ABObj           obj,
205                     AB_CFG_OBJ_TYPE type
206                 );
207 static ABObj    layer_get_config_obj(
208                     ABObj           obj,
209                     AB_CFG_OBJ_TYPE type
210                 );
211 static ABObj    item_get_config_obj(
212                     ABObj           obj,
213                     AB_CFG_OBJ_TYPE type
214                 );
215 static ABObj    list_get_config_obj(
216                     ABObj           obj,
217                     AB_CFG_OBJ_TYPE type
218                 );
219 static ABObj    menu_get_config_obj(
220                     ABObj           obj,
221                     AB_CFG_OBJ_TYPE type
222                 );
223 static ABObj    pane_get_config_obj(
224                     ABObj           obj,
225                     AB_CFG_OBJ_TYPE type
226                 );
227 static ABObj    separator_get_config_obj(
228                     ABObj           obj,
229                     AB_CFG_OBJ_TYPE type
230                 );
231 static ABObj    spin_box_get_config_obj(
232                     ABObj           obj,
233                     AB_CFG_OBJ_TYPE type
234                 );
235 static ABObj    simple_get_config_obj(
236                     ABObj           obj,
237                     AB_CFG_OBJ_TYPE type
238                 );
239 static ABObj    textf_get_config_obj(
240                     ABObj           obj,
241                     AB_CFG_OBJ_TYPE type
242                 );
243 static ABObj    scale_get_config_obj(
244                     ABObj       obj,
245                     AB_CFG_OBJ_TYPE type
246                 );
247 static ABObj    box_get_config_obj(
248                     ABObj       obj,
249                     AB_CFG_OBJ_TYPE type
250                 );
251 static ABObj    panedwin_get_config_obj(
252                     ABObj       obj,
253                     AB_CFG_OBJ_TYPE type
254                 );
255
256 /*
257  * Resource Setting methods
258  */
259 static int      mainwin_set_args(
260                     ABObj       obj,
261                     OBJXM_CONFIG_TYPE ctype
262                 );
263 static int      simple_set_args(
264                     ABObj       obj,
265                     OBJXM_CONFIG_TYPE ctype
266                 );
267 static int      choice_set_args(
268                     ABObj       obj,
269                     OBJXM_CONFIG_TYPE ctype
270                 );
271 static int      combo_box_set_args(
272                     ABObj       obj,
273                     OBJXM_CONFIG_TYPE ctype
274                 );
275 static int      cpanel_set_args(
276                     ABObj       obj,
277                     OBJXM_CONFIG_TYPE ctype
278                 );
279 static int      custdlg_set_args(
280                     ABObj       obj,
281                     OBJXM_CONFIG_TYPE ctype
282                 );
283 static int      layer_set_args(
284                     ABObj       obj,
285                     OBJXM_CONFIG_TYPE ctype
286                 );
287 static int      group_set_args(
288                     ABObj       obj,
289                     OBJXM_CONFIG_TYPE ctype
290                 );
291 static int      item_set_args(
292                     ABObj       obj,
293                     OBJXM_CONFIG_TYPE ctype
294                 );
295 static int      drawp_set_args(
296                     ABObj       obj,
297                     OBJXM_CONFIG_TYPE ctype
298                 );
299 static int      separator_set_args(
300                     ABObj       obj,
301                     OBJXM_CONFIG_TYPE ctype
302                 );
303 static int      spin_box_set_args(
304                     ABObj       obj,
305                     OBJXM_CONFIG_TYPE ctype
306                 );
307 static int      termp_set_args(
308                     ABObj       obj,
309                     OBJXM_CONFIG_TYPE ctype
310                 );
311 static int      textp_set_args(
312                     ABObj       obj,
313                     OBJXM_CONFIG_TYPE ctype
314                 );
315 static int      list_set_args(
316                     ABObj       obj,
317                     OBJXM_CONFIG_TYPE ctype
318                 );
319 static int      menu_set_args(
320                     ABObj       obj,
321                     OBJXM_CONFIG_TYPE ctype
322                 );
323 static int      menubar_set_args(
324                     ABObj       obj,
325                     OBJXM_CONFIG_TYPE ctype
326                 );
327 static int      textf_set_args(
328                     ABObj       obj,
329                     OBJXM_CONFIG_TYPE ctype
330                 );
331 static int      scale_set_args(
332                     ABObj       obj,
333                     OBJXM_CONFIG_TYPE ctype
334                 );
335 static int      fchooser_set_args(
336                     ABObj       obj,
337                     OBJXM_CONFIG_TYPE ctype
338                 );
339
340 /*
341  * Post-Instantiation Methods
342  */
343 static int      post_set_size(
344                     ABObj       obj,
345                     OBJXM_CONFIG_TYPE ctype
346                 );
347 static int      mainwin_post_inst(
348                     ABObj       obj,
349                     OBJXM_CONFIG_TYPE ctype
350                 );
351 static int      choice_post_inst(
352                     ABObj       obj,
353                     OBJXM_CONFIG_TYPE ctype
354                 );
355 static int      cpanel_post_inst(
356                     ABObj       obj,
357                     OBJXM_CONFIG_TYPE ctype
358                 );
359 static int      dialog_post_inst(
360                     ABObj       obj,
361                     OBJXM_CONFIG_TYPE ctype
362                 );
363 static int      drawp_post_inst(
364                     ABObj       obj,
365                     OBJXM_CONFIG_TYPE ctype
366                 );
367 static int      item_post_inst(
368                     ABObj       obj,
369                     OBJXM_CONFIG_TYPE ctype
370                 );
371 static int      list_post_inst(
372                     ABObj       obj,
373                     OBJXM_CONFIG_TYPE ctype
374                 );
375 static int      menubar_post_inst(
376                     ABObj       obj,
377                     OBJXM_CONFIG_TYPE ctype
378                 );
379 static int      termp_post_inst(
380                     ABObj       obj,
381                     OBJXM_CONFIG_TYPE ctype
382                 );
383 static int      fchooser_post_inst(
384                     ABObj       obj,
385                     OBJXM_CONFIG_TYPE ctype
386                 );
387 static void     clear_fchooser_fields(
388                     Widget      widget
389                 );
390
391 /*
392  * General
393  */
394
395 static ABObj    get_menu_ref(
396                     ABObj       obj
397                 );
398
399
400 /*************************************************************************
401 **                                                                      **
402 **       Data                                                           **
403 **                                                                      **
404 **************************************************************************/
405
406 XmConfigInfoRec button_config_rec = {
407     /* xmconfig         */  simple_xmconfig,
408     /* xmunconfig       */  simple_unconfig,
409     /* get_config_obj   */  simple_get_config_obj,
410     /* set_args         */  simple_set_args,
411     /* post_instantiate */  NULL,
412     /* is_a_test        */  obj_is_button,
413 };
414
415 XmConfigInfoRec choice_config_rec = {
416     /* xmconfig         */  choice_xmconfig,
417     /* xmunconfig       */  choice_unconfig,
418     /* get_config_obj   */  choice_get_config_obj,
419     /* set_args         */  choice_set_args,
420     /* post_instantiate */  choice_post_inst,
421     /* is_a_test        */  obj_is_choice,
422 };
423
424 XmConfigInfoRec combo_box_config_rec = {
425     /* xmconfig         */  combo_box_xmconfig,
426     /* xmunconfig       */  combo_box_unconfig,
427     /* get_config_obj   */  combo_box_get_config_obj,
428     /* set_args         */  combo_box_set_args,
429     /* post_instantiate */  post_set_size,
430     /* is_a_test        */  obj_is_combo_box,
431 };
432
433 XmConfigInfoRec cpanel_config_rec = {
434     /* xmconfig         */  cpanel_xmconfig,
435     /* xmunconfig       */  cpanel_unconfig,
436     /* get_config_obj   */  container_get_config_obj,
437     /* set_args         */  cpanel_set_args,
438     /* post_instantiate */  cpanel_post_inst,
439     /* is_a_test        */  obj_is_control_panel,
440 };
441
442 XmConfigInfoRec custdlg_config_rec = {
443     /* xmconfig         */  custdlg_xmconfig,
444     /* xmunconfig       */  custdlg_unconfig,
445     /* get_config_obj   */  custdlg_get_config_obj,
446     /* set_args         */  custdlg_set_args,
447     /* post_instantiate */  dialog_post_inst,
448     /* is_a_test        */  obj_is_popup_win,
449 };
450
451 XmConfigInfoRec layer_config_rec = {
452     /* xmconfig         */  layer_xmconfig,
453     /* xmunconfig       */  layer_unconfig,
454     /* get_config_obj   */  layer_get_config_obj,
455     /* set_args         */  layer_set_args,
456     /* post_instantiate */  NULL,
457     /* is_a_test        */  obj_is_layers,
458 };
459
460 XmConfigInfoRec group_config_rec = {
461     /* xmconfig         */  group_xmconfig,
462     /* xmunconfig       */  group_unconfig,
463     /* get_config_obj   */  container_get_config_obj,
464     /* set_args         */  group_set_args,
465     /* post_instantiate */  NULL,
466     /* is_a_test        */  obj_is_group,
467 };
468
469 XmConfigInfoRec drawp_config_rec = {
470     /* xmconfig         */  pane_xmconfig,
471     /* xmunconfig       */  pane_unconfig,
472     /* get_config_obj   */  pane_get_config_obj,
473     /* set_args         */  drawp_set_args,
474     /* post_instantiate */  drawp_post_inst,
475     /* is_a_test        */  obj_is_drawing_area,
476 };
477
478 XmConfigInfoRec item_config_rec = {
479     /* xmconfig         */  item_xmconfig,
480     /* xmunconfig       */  simple_unconfig,
481     /* get_config_obj   */  item_get_config_obj,
482     /* set_args         */  item_set_args,
483     /* post_instantiate */  item_post_inst,
484     /* is_a_test        */  obj_is_item,
485 };
486
487 XmConfigInfoRec label_config_rec = {
488     /* xmconfig         */  simple_xmconfig,
489     /* xmunconfig       */  simple_unconfig,
490     /* get_config_obj   */  simple_get_config_obj,
491     /* set_args         */  simple_set_args,
492     /* post_instantiate */  NULL,
493     /* is_a_test        */  obj_is_label,
494 };
495
496 XmConfigInfoRec list_config_rec = {
497     /* xmconfig         */  list_xmconfig,
498     /* xmunconfig       */  list_unconfig,
499     /* get_config_obj   */  list_get_config_obj,
500     /* set_args         */  list_set_args,
501     /* post_instantiate */  list_post_inst,
502     /* is_a_test        */  obj_is_list,
503 };
504
505 XmConfigInfoRec mainwin_config_rec = {
506     /* xmconfig         */  mainwin_xmconfig,
507     /* xmunconfig       */  mainwin_unconfig,
508     /* get_config_obj   */  mainwin_get_config_obj,
509     /* set_args         */  mainwin_set_args,
510     /* post_instantiate */  mainwin_post_inst,
511     /* is_a_test        */  obj_is_base_win,
512 };
513
514 XmConfigInfoRec menu_config_rec = {
515     /* xmconfig         */  menu_xmconfig,
516     /* xmunconfig       */  menu_unconfig,
517     /* get_config_obj   */  menu_get_config_obj,
518     /* set_args         */  menu_set_args,
519     /* post_instantiate */  NULL,
520     /* is_a_test        */  obj_is_menu,
521 };
522
523 XmConfigInfoRec menubar_config_rec = {
524     /* xmconfig         */  menubar_xmconfig,
525     /* xmunconfig       */  simple_unconfig,
526     /* get_config_obj   */  container_get_config_obj,
527     /* set_args         */  menubar_set_args,
528     /* post_instantiate */  menubar_post_inst,
529     /* is_a_test        */  obj_is_menubar,
530 };
531
532 XmConfigInfoRec separator_config_rec = {
533     /* xmconfig         */  simple_xmconfig,
534     /* xmunconfig       */  simple_unconfig,
535     /* get_config_obj   */  separator_get_config_obj,
536     /* set_args         */  separator_set_args,
537     /* post_instantiate */  NULL,
538     /* is_a_test        */  obj_is_separator,
539 };
540
541 XmConfigInfoRec spin_box_config_rec = {
542     /* xmconfig         */  spin_box_xmconfig,
543     /* xmunconfig       */  spin_box_unconfig,
544     /* get_config_obj   */  spin_box_get_config_obj,
545     /* set_args         */  spin_box_set_args,
546     /* post_instantiate */  post_set_size,
547     /* is_a_test        */  obj_is_spin_box,
548 };
549
550 XmConfigInfoRec termp_config_rec = {
551     /* xmconfig         */  pane_xmconfig,
552     /* xmunconfig       */  pane_unconfig,
553     /* get_config_obj   */  pane_get_config_obj,
554     /* set_args         */  termp_set_args,
555     /* post_instantiate */  termp_post_inst,
556     /* is_a_test        */  obj_is_term_pane,
557 };
558
559 XmConfigInfoRec textf_config_rec = {
560     /* xmconfig         */  textf_xmconfig,
561     /* xmunconfig       */  textf_unconfig,
562     /* get_config_obj   */  textf_get_config_obj,
563     /* set_args         */  textf_set_args,
564     /* post_instantiate */  NULL,
565     /* is_a_test        */  obj_is_text_field,
566 };
567
568 XmConfigInfoRec textp_config_rec = {
569     /* xmconfig         */  pane_xmconfig,
570     /* xmunconfig       */  pane_unconfig,
571     /* get_config_obj   */  pane_get_config_obj,
572     /* set_args         */  textp_set_args,
573     /* post_instantiate */  NULL,
574     /* is_a_test        */  obj_is_text_pane,
575 };
576
577 XmConfigInfoRec scale_config_rec = {
578     /* xmconfig         */  scale_xmconfig,
579     /* xmunconfig       */  scale_unconfig,
580     /* get_config_obj   */  scale_get_config_obj,
581     /* set_args         */  scale_set_args,
582     /* post_instantiate */  NULL,
583     /* is_a_test        */  obj_is_scale,
584 };
585
586 XmConfigInfoRec file_chooser_config_rec = {
587     /* xmconfig         */  fchooser_xmconfig,
588     /* xmunconfig       */  box_unconfig,
589     /* get_config_obj   */  box_get_config_obj,
590     /* set_args         */  fchooser_set_args,
591     /* post_instantiate */  fchooser_post_inst,
592     /* is_a_test        */  obj_is_file_chooser,
593 };
594
595 XmConfigInfoRec panedwin_config_rec = {
596     /* xmconfig         */  simple_xmconfig,
597     /* xmunconfig       */  simple_unconfig,
598     /* get_config_obj   */  panedwin_get_config_obj,
599     /* set_args         */  NULL,
600     /* post_instantiate */  NULL,
601     /* is_a_test        */  obj_is_paned_win,
602 };
603
604
605 static BOOL     init_done = FALSE;
606
607 Widget          ObjxmP_toplevel = NULL;
608 int             ObjxmP_visual_depth = 0;
609
610 /*************************************************************************
611 **                                                                      **
612 **       Function Definitions                                           **
613 **                                                                      **
614 **************************************************************************/
615
616 /*
617  * Initialize Data & state information for Objxm library.
618  * "toplevel" can be a valid widget ID (when called by AB Front-end)
619  * or NULL (when called from code-generator)
620  */
621 int
622 objxm_init(
623     Widget      toplevel
624 )
625 {
626    if (!init_done)
627    {
628         ObjxmP_toplevel = toplevel;
629         if (toplevel != NULL)
630             XtVaGetValues(toplevel, XmNdepth, &ObjxmP_visual_depth, NULL);
631
632         objxm_strs_init();
633
634         objxm_register_config_info(&mainwin_config_rec);
635         objxm_register_config_info(&button_config_rec);
636         objxm_register_config_info(&choice_config_rec);
637         objxm_register_config_info(&combo_box_config_rec);
638         objxm_register_config_info(&cpanel_config_rec);
639         objxm_register_config_info(&custdlg_config_rec);
640         objxm_register_config_info(&drawp_config_rec);
641         objxm_register_config_info(&group_config_rec);
642         objxm_register_config_info(&item_config_rec);
643         objxm_register_config_info(&label_config_rec);
644         objxm_register_config_info(&layer_config_rec);
645         objxm_register_config_info(&list_config_rec);
646         objxm_register_config_info(&separator_config_rec);
647         objxm_register_config_info(&spin_box_config_rec);
648         objxm_register_config_info(&menu_config_rec);
649         objxm_register_config_info(&menubar_config_rec);
650         objxm_register_config_info(&termp_config_rec);
651         objxm_register_config_info(&textf_config_rec);
652         objxm_register_config_info(&textp_config_rec);
653         objxm_register_config_info(&scale_config_rec);
654         objxm_register_config_info(&file_chooser_config_rec);
655         objxm_register_config_info(&panedwin_config_rec);
656
657         obj_add_destroy_callback(objxmP_destroy, NULL);
658
659         init_done = TRUE;
660    }
661
662    return OK;
663 }
664
665 /*
666  * Create the footer-select area for Window Objects:
667  */
668 static int
669 xmconfig_window_select_area(
670     ABObj       winobj,
671     ABObj       parentobj
672 )
673 {
674     ABObj       msgobj, modobj, selobj;
675
676     /* Create MessageArea SubObj */
677     msgobj  = obj_create(AB_TYPE_LABEL, NULL);
678     msgobj->part_of = winobj;
679     obj_append_child(parentobj, msgobj);
680     obj_set_class_name(msgobj, _xmForm);
681     obj_set_flag(msgobj, NoCodeGenFlag);
682     obj_set_unique_name(msgobj,
683         ab_ident_from_name_and_label(obj_get_name(winobj),"status_area"));
684
685     /* Create StatusArea SubObj inside MessageArea */
686     modobj = obj_create(AB_TYPE_LABEL, NULL);
687     modobj->part_of = winobj;
688     obj_append_child(msgobj, modobj);
689     obj_set_unique_name(modobj,
690         ab_ident_from_name_and_label(obj_get_name(winobj),"module_display"));
691     obj_set_class_name(modobj, _xmLabel);
692     obj_set_attachment(modobj, AB_CP_WEST, AB_ATTACH_GRIDLINE, (void*)0, 0);
693     obj_set_attachment(modobj, AB_CP_EAST, AB_ATTACH_GRIDLINE, (void*)50, 0);
694     obj_set_flag(modobj, NoCodeGenFlag);
695
696     /* Create Select-Status SubObj inside MessageArea*/
697     selobj = obj_create(AB_TYPE_LABEL, NULL);
698     selobj->part_of = winobj;
699     obj_append_child(msgobj, selobj);
700     obj_set_label(selobj, SELECT_OBJ_KEY); /* Key for identifying */
701     obj_set_unique_name(selobj,
702         ab_ident_from_name_and_label(obj_get_name(winobj),"select_display"));
703     obj_set_class_name(selobj, _xmLabel);
704     obj_set_attachment(selobj, AB_CP_WEST, AB_ATTACH_GRIDLINE, (void*)50, 0);
705     obj_set_attachment(selobj, AB_CP_EAST, AB_ATTACH_GRIDLINE, (void*)100, 0);
706     obj_set_flag(selobj, NoCodeGenFlag);
707
708     return 0;
709 }
710
711 static int
712 set_window_select_area_args(
713     ABObj       obj
714 )
715 {
716     ABObj       modobj, selobj;
717     ABObj       msgobj;
718
719     modobj = objxm_comp_get_subobj(obj, AB_CFG_STATUS_OBJ);
720     selobj = objxm_comp_get_subobj(obj, AB_CFG_SELECT_OBJ);
721
722     msgobj = obj_get_parent(modobj);
723
724     /* Pane Resources */
725     objxm_obj_set_ui_arg(msgobj, AB_ARG_INT, XmNpositionIndex, XmLAST_POSITION);
726
727     /* REMIND: aim - memory leak */
728     /* Module-area Resources */
729     objxm_obj_set_ui_arg(modobj, AB_ARG_XMSTRING, XmNlabelString,
730                 XmStringCreateLocalized(obj_get_name(obj_get_module(obj))));
731     objxm_obj_set_ui_arg(modobj, AB_ARG_BOOLEAN, XmNrecomputeSize, FALSE);
732     objxm_obj_set_ui_arg(modobj, AB_ARG_LITERAL, XmNalignment, XmALIGNMENT_BEGINNING);
733
734     /* Select-area Resources */
735     objxm_obj_set_ui_arg(selobj, AB_ARG_XMSTRING, XmNlabelString,
736                 XmStringCreateLocalized("         "));
737     objxm_obj_set_ui_arg(selobj, AB_ARG_BOOLEAN, XmNrecomputeSize, FALSE);
738     objxm_obj_set_ui_arg(selobj, AB_ARG_LITERAL, XmNalignment, XmALIGNMENT_END);
739
740     return 0;
741
742 }
743
744 static int
745 make_pane_fixed_height(
746     ABObj       paneobj,
747     ABObj       child,
748     int         height,
749     int         margin
750 )
751 {
752     Dimension   hgt;
753     Dimension   pane_hgt = 0;
754
755     /* If a child is specified, it's height takes preference,
756      * else the "height" parameter is used.
757      */
758     if (child != NULL)
759     {
760         if (child->ui_handle != NULL)
761             XtVaGetValues((Widget)child->ui_handle,
762                             XmNheight,      &hgt,
763                             NULL);
764         else
765             return -1;
766     }
767     else
768         hgt = (Dimension)height;
769
770     pane_hgt = (Dimension)(hgt + margin);
771
772     /* If something goes wrong, at least force the pane to be visible! */
773     objxm_obj_set_ui_arg(paneobj, AB_ARG_INT, XmNpaneMinimum,
774                 pane_hgt > 1? pane_hgt : 32);
775     objxm_obj_set_ui_arg(paneobj, AB_ARG_INT, XmNpaneMaximum,
776                 pane_hgt > 1? pane_hgt : 32);
777
778     obj_set_flag(paneobj, AttrChangedFlag);
779
780     return 0;
781 }
782
783 static int
784 post_inst_window_select_area(
785     ABObj       obj
786 )
787 {
788     ABObj       selobj, msgobj;
789
790     selobj = objxm_comp_get_subobj(obj, AB_CFG_SELECT_OBJ);
791     msgobj = obj_get_parent(selobj);
792
793     make_pane_fixed_height(msgobj, selobj, 0, 0);
794
795     return 0;
796 }
797
798
799 /*
800  ************************************************
801  ************************************************
802  */
803 ABObj
804 objxm_comp_mainwin_get_area(
805     ABObj               obj,
806     AB_CONTAINER_TYPE   area_type
807 )
808 {
809     ABObj       pwobj, mwobj, child;
810     int         num_children;
811     int         i;
812
813     if (!obj_is_base_win(obj))
814         return NULL;
815
816     if (obj_has_flag(obj, XmConfiguredFlag))
817     {
818         pwobj = obj_get_child(obj, 0);
819         mwobj = obj_get_child(pwobj, 0);
820     }
821     else
822         mwobj = obj;
823
824     num_children = obj_get_num_children(mwobj);
825     for (i = 0; i < num_children; i++)
826     {
827         child = obj_get_child(mwobj, i);
828         if (child->type == AB_TYPE_CONTAINER &&
829             obj_get_subtype(child) == area_type)
830             return child;
831     }
832     return NULL;
833 }
834
835 static int
836 mainwin_xmconfig(
837     ABObj    obj
838 )
839 {
840     ABObj               project = obj_get_project(obj);
841     ABObj               pwobj, mwobj, workobj;
842     ABObj               menubar, toolbar, footer;
843
844     /* ApplicationShell */
845     obj->part_of = obj;
846     if (obj_get_root_window(project) == obj)
847         obj_set_class_name(obj, _applicationShell);
848     else
849         obj_set_class_name(obj, _topLevelShell);
850
851     /* Create PanedWindow SubObj (used for BUILD MODE ONLY) */
852     pwobj = obj_create(AB_TYPE_CONTAINER, NULL);
853     pwobj->part_of = obj;
854     obj_set_class_name(pwobj, _xmPanedWindow);
855     obj_set_flag(pwobj, NoCodeGenFlag);
856
857     /* Create MainWindow SubObj */
858     mwobj = obj_create(AB_TYPE_CONTAINER, NULL);
859     mwobj->part_of = obj;
860     obj_set_class_name(mwobj, _xmMainWindow);
861
862     /* If Window has a Menubar child, reparent it */
863     menubar = objxm_comp_mainwin_get_area(obj, AB_CONT_MENU_BAR);
864     if (menubar != NULL)
865     {
866         obj_unparent(menubar);
867         obj_insert_child(mwobj, menubar, 0);
868     }
869
870     /* If Window has a Toolbar child, reparent it */
871     toolbar = objxm_comp_mainwin_get_area(obj, AB_CONT_TOOL_BAR);
872     if (toolbar != NULL)
873     {
874         obj_unparent(toolbar);
875         obj_append_child(mwobj, toolbar);
876     }
877
878     /* Create WorkArea SubObj */
879     workobj = obj_create(AB_TYPE_CONTAINER, NULL);
880     workobj->part_of = obj;
881     obj_append_child(mwobj, workobj);
882     obj_set_class_name(workobj, _xmForm);
883
884     /* If Window has a Footer child, reparent it */
885     footer = objxm_comp_mainwin_get_area(obj, AB_CONT_FOOTER);
886     if (footer != NULL)
887     {
888         obj_unparent(footer);
889         obj_append_child(mwobj, footer);
890     }
891
892     /* Move any remaining children to be parented off WorkObj
893      * BEFORE the ShellObj is parented off obj
894      */
895     obj_move_children(workobj, obj);
896     obj_append_child(pwobj, mwobj);
897     obj_append_child(obj, pwobj);
898     obj_set_unique_name(pwobj,
899         ab_ident_from_name_and_label(obj_get_name(obj), "panedwin"));
900     obj_set_unique_name(mwobj,
901         ab_ident_from_name_and_label(obj_get_name(obj), "mainwin"));
902     obj_set_unique_name(workobj,
903         ab_ident_from_name_and_label(obj_get_name(obj), "form"));
904
905     xmconfig_window_select_area(obj, pwobj);
906
907     return OK;
908
909 }
910
911 static int
912 mainwin_unconfig(
913     ABObj       obj
914 )
915 {
916     ABObj       workobj, pwobj, mwobj;
917     ABObj       menubar, toolbar, footer;
918
919     workobj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);
920
921     pwobj = obj_get_child(obj, 0);
922     mwobj = obj_get_child(pwobj, 0);
923
924     menubar = objxm_comp_mainwin_get_area(obj, AB_CONT_MENU_BAR);
925     toolbar = objxm_comp_mainwin_get_area(obj, AB_CONT_TOOL_BAR);
926     footer  = objxm_comp_mainwin_get_area(obj, AB_CONT_FOOTER);
927
928     if (menubar != NULL)
929         obj_reparent(menubar, obj);
930
931     if (toolbar != NULL)
932         obj_reparent(toolbar, obj);
933
934     if (footer != NULL)
935         obj_reparent(footer, obj);
936
937     /* Move all other Children to RootObj */
938     obj_move_children(obj, workobj);
939
940     obj_destroy(pwobj); /* destroys PanedWindow,MainWindow & Message SubObjs */
941
942     return OK;
943
944 }
945 static ABObj
946 mainwin_get_config_obj(
947     ABObj       obj,
948     AB_CFG_OBJ_TYPE type
949 )
950 {
951     ABObj cfg_obj = NULL;
952     ABObj workobj = NULL;
953     ABObj pwobj, mwobj, msgobj, child;
954     int   i, num_children;
955
956     pwobj = obj_get_child(obj, 0);
957     mwobj = obj_get_child(pwobj, 0);
958     msgobj = obj_get_child(pwobj, 1);
959
960     switch(type)
961     {
962         case AB_CFG_WINDOW_PW_OBJ:
963             cfg_obj = pwobj;
964             break;
965         case AB_CFG_OBJECT_OBJ:
966         case AB_CFG_POSITION_OBJ:
967         case AB_CFG_LABEL_OBJ:
968             cfg_obj = obj;
969             break;
970         case AB_CFG_STATUS_OBJ:
971             cfg_obj = obj_get_child(msgobj, 0);
972             break;
973         case AB_CFG_SELECT_OBJ:
974             cfg_obj = obj_get_child(msgobj, 1);
975             break;
976         case AB_CFG_MENU_PARENT_OBJ:
977         case AB_CFG_WINDOW_MW_OBJ:
978         case AB_CFG_HELP_OBJ:
979             cfg_obj = mwobj;
980             break;
981         case AB_CFG_DND_OBJ:
982         case AB_CFG_SIZE_OBJ:
983         case AB_CFG_PARENT_OBJ:
984         {
985             num_children = obj_get_num_children(mwobj);
986             for (i = 0; i < num_children; i++)
987             {
988                 child = obj_get_child(mwobj, i);
989                 if (obj_is_control_panel(child) && child->part_of == obj)
990                 {
991                     workobj = child;
992                     break;
993                 }
994             }
995             cfg_obj = workobj;
996             break;
997         }
998
999         case AB_CFG_MENU_OBJ:
1000         case AB_CFG_BORDER_OBJ:
1001         case AB_CFG_SCROLLBAR_OBJ:
1002             cfg_obj = NULL;
1003             break;
1004
1005         default:
1006             util_dprintf(1, "mainwin_get_config_obj: unknown type\n");
1007             cfg_obj = NULL;
1008     }
1009
1010     return(cfg_obj);
1011 }
1012
1013 static int
1014 mainwin_set_args(
1015     ABObj       obj,
1016     OBJXM_CONFIG_TYPE ctype
1017 )
1018 {
1019     STRING      label;
1020     ABObj       module = obj_get_module(obj);
1021     ABObj       pwobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_PW_OBJ);
1022     ABObj       mwobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_MW_OBJ);
1023     ABObj       shobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1024     ABObj       workobj  = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);
1025     BOOL        cgen_args;
1026
1027     cgen_args = (ctype == OBJXM_CONFIG_CODEGEN? TRUE : FALSE);
1028
1029     /* Shell Resources */
1030     objxm_comp_set_icon_args(obj, ctype);
1031
1032     if ((label = obj_get_label(obj)) != NULL)
1033         objxm_obj_set_ui_arg(shobj, AB_ARG_STRING, XmNtitle, label);
1034
1035     objxm_obj_set_ui_arg(shobj, AB_ARG_BOOLEAN, XmNallowShellResize, TRUE);
1036
1037     /* PanedWindow Resources */
1038     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNmarginWidth, 0);
1039     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNmarginHeight, 0);
1040     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNspacing, 0);
1041     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNsashHeight, 1);
1042     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNsashWidth, 1);
1043
1044     /* MainWindow Resources */
1045     if (!cgen_args)
1046         objxm_obj_set_ui_arg(mwobj, AB_ARG_BOOLEAN, XmNallowResize,       True);
1047
1048     /* Form WorkArea resources */
1049     objxm_obj_set_literal_ui_arg(workobj, ctype,  XmNresizePolicy,
1050         obj_get_width(obj) == -1? XmRESIZE_ANY : XmRESIZE_GROW);
1051     objxm_obj_set_ui_arg(workobj, AB_ARG_INT,     XmNmarginWidth,      0);
1052     objxm_obj_set_ui_arg(workobj, AB_ARG_INT,     XmNmarginHeight,     0);
1053
1054     /* Set the interface name and select-state on the footer */
1055     if (ctype == OBJXM_CONFIG_BUILD)
1056         set_window_select_area_args(obj);
1057
1058     return 0;
1059 }
1060 static int
1061 mainwin_post_inst(
1062     ABObj       obj,
1063     OBJXM_CONFIG_TYPE ctype
1064 )
1065 {
1066     ABObj       workobj  = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);
1067     ABObj       mwobj    = obj_get_parent(workobj);
1068
1069     if (ctype == OBJXM_CONFIG_BUILD)
1070     {
1071         post_inst_window_select_area(obj);
1072
1073         XtManageChild(objxm_get_widget(workobj));
1074         util_dprintf(3,"MANAGING %s\n", obj_get_name(workobj));
1075         XtVaSetValues(objxm_get_widget(mwobj),
1076                 XmNworkWindow,  objxm_get_widget(workobj),
1077                 NULL);
1078     }
1079     else
1080     {
1081         objxm_obj_set_widget_ui_arg(mwobj, ctype, XmNworkWindow, workobj);
1082         obj_set_flag(mwobj, AttrChangedFlag);
1083     }
1084     return 0;
1085 }
1086
1087 /*
1088  ************************************************
1089  ** Custom Dialog Methods                       *
1090  ************************************************
1091  */
1092
1093 ABObj
1094 objxm_comp_custdlg_get_area(
1095     ABObj               obj,
1096     AB_CONTAINER_TYPE   area_type
1097 )
1098 {
1099     ABObj       pwobj, bbobj, child;
1100     int         num_children;
1101     int         i;
1102
1103     if (!obj_is_popup_win(obj))
1104         return NULL;
1105
1106     if (obj_has_flag(obj, XmConfiguredFlag))
1107     {
1108         bbobj = obj_get_child(obj, 0);
1109         pwobj = obj_get_child(bbobj, 0);
1110     }
1111     else
1112         pwobj = obj;
1113
1114     num_children = obj_get_num_children(pwobj);
1115     for (i = 0; i < num_children; i++)
1116     {
1117         child = obj_get_child(pwobj, i);
1118         if (child->type == AB_TYPE_CONTAINER &&
1119             obj_get_subtype(child) == area_type)
1120             return child;
1121     }
1122     return NULL;
1123
1124 }
1125 static int
1126 custdlg_xmconfig(
1127     ABObj    obj
1128 )
1129 {
1130     ABObj               bbobj, pwobj, workobj;
1131     ABObj               button_panel, footer;
1132     ABObj               apobj = NULL;
1133     STRING              name;
1134
1135     /* DialogShell */
1136     obj->part_of = obj;
1137     obj_set_class_name(obj, _xmDialogShell);
1138
1139     /* Dialog-Form */
1140     bbobj = obj_create(AB_TYPE_CONTAINER, NULL);
1141     bbobj->part_of = obj;
1142     obj_set_class_name(bbobj, _xmForm);
1143
1144     /* Create PanedWindow SubObj */
1145     pwobj = obj_create(AB_TYPE_CONTAINER, NULL);
1146     pwobj->part_of = obj;
1147     obj_set_class_name(pwobj, _xmPanedWindow);
1148
1149     /* Create WorkArea SubObj */
1150     workobj = obj_create(AB_TYPE_CONTAINER, NULL);
1151     workobj->part_of = obj;
1152     obj_append_child(pwobj, workobj);
1153     obj_set_class_name(workobj, _xmForm);
1154
1155     /* Look to see if it has an Button Panel child */
1156     button_panel = objxm_comp_custdlg_get_area(obj, AB_CONT_BUTTON_PANEL);
1157     if (button_panel != NULL)
1158         obj_reparent(button_panel, pwobj);
1159
1160     /* Look to see if it has a footer child */
1161     footer = objxm_comp_custdlg_get_area(obj, AB_CONT_FOOTER);
1162     if (footer != NULL)
1163         obj_reparent(footer, pwobj);
1164
1165     /* Move any remaining children to be parented off WorkObj
1166      * BEFORE the ShellObj is parented off obj
1167      */
1168     obj_move_children(workobj, obj);
1169     obj_append_child(obj, bbobj);
1170     obj_append_child(bbobj, pwobj);
1171
1172     name = obj_get_name(obj);
1173
1174     obj_set_unique_name(bbobj,
1175         ab_ident_from_name_and_label(name, "shellform"));
1176     obj_set_unique_name(pwobj,
1177         ab_ident_from_name_and_label(name, "panedwin"));
1178     obj_set_unique_name(workobj,
1179         ab_ident_from_name_and_label(name, "form"));
1180
1181     /* Make PanedWindow SubObj Fill entire Dialog-Form */
1182     obj_set_attachment(pwobj, AB_CP_WEST, AB_ATTACH_GRIDLINE, (void*)0, 0);
1183     obj_set_attachment(pwobj, AB_CP_EAST, AB_ATTACH_GRIDLINE, (void*)100, 0);
1184     obj_set_attachment(pwobj, AB_CP_NORTH, AB_ATTACH_GRIDLINE, (void*)0, 0);
1185     obj_set_attachment(pwobj, AB_CP_SOUTH, AB_ATTACH_GRIDLINE, (void*)100, 0);
1186
1187     xmconfig_window_select_area(obj, pwobj);
1188
1189     return OK;
1190
1191 }
1192
1193 static int
1194 custdlg_unconfig(
1195     ABObj       obj
1196 )
1197 {
1198     ABObj       bbobj, workobj;
1199     ABObj       button_panel, footer;
1200
1201     bbobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_BB_OBJ);
1202     workobj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);
1203
1204     button_panel = objxm_comp_custdlg_get_area(obj, AB_CONT_BUTTON_PANEL);
1205     footer  = objxm_comp_custdlg_get_area(obj, AB_CONT_FOOTER);
1206
1207     if (button_panel != NULL)
1208         obj_reparent(button_panel, obj);
1209
1210     if (footer != NULL)
1211         obj_reparent(footer, obj);
1212
1213     /* Move all other Children to RootObj */
1214     obj_move_children(obj, workobj);
1215
1216     obj_destroy(bbobj);
1217
1218     return OK;
1219
1220 }
1221
1222 static ABObj
1223 custdlg_get_config_obj(
1224     ABObj       obj,
1225     AB_CFG_OBJ_TYPE type
1226 )
1227 {
1228     ABObj cfg_obj = NULL;
1229     ABObj workobj = NULL;
1230     ABObj modobj = NULL;
1231     ABObj selobj  = NULL;
1232     ABObj bbobj, pwobj, msgobj, child;
1233     int   i, num_children;
1234
1235     bbobj = obj_get_child(obj, 0);
1236     pwobj = obj_get_child(bbobj, 0);
1237
1238     switch(type)
1239     {
1240         case AB_CFG_WINDOW_BB_OBJ:
1241         case AB_CFG_HELP_OBJ:
1242             cfg_obj = bbobj;
1243             break;
1244         case AB_CFG_WINDOW_PW_OBJ:
1245         case AB_CFG_MENU_PARENT_OBJ:
1246             cfg_obj = pwobj;
1247             break;
1248         case AB_CFG_OBJECT_OBJ:
1249         case AB_CFG_POSITION_OBJ:
1250         case AB_CFG_LABEL_OBJ:
1251             cfg_obj = obj;
1252             break;
1253         case AB_CFG_DND_OBJ:
1254         case AB_CFG_SIZE_OBJ:
1255         case AB_CFG_PARENT_OBJ:
1256         case AB_CFG_STATUS_OBJ:
1257         case AB_CFG_SELECT_OBJ:
1258             num_children = obj_get_num_children(pwobj);
1259             /* Search through immediate children of the Shell-container
1260              * and find the WorkArea & Status SubObjs if they exist
1261              */
1262             for (i = 0; i < num_children; i++)
1263             {
1264                 child = obj_get_child(pwobj, i);
1265                 if (obj_is_control_panel(child) && child->part_of == obj)
1266                     workobj = child;
1267                 else if (obj_is_label(child) && child->part_of == obj)
1268                 {
1269                     msgobj = child;
1270                     modobj = obj_get_child(msgobj, 0);
1271                     selobj = obj_get_child(msgobj, 1);
1272                 }
1273             }
1274             if (type == AB_CFG_SELECT_OBJ)
1275                 cfg_obj = selobj;
1276             else if (type == AB_CFG_STATUS_OBJ)
1277                 cfg_obj = modobj;
1278             else  /* PARENT or SIZE */
1279                 cfg_obj = (workobj? workobj : pwobj);
1280
1281             break;
1282
1283         case AB_CFG_BORDER_OBJ:
1284         case AB_CFG_MENU_OBJ:
1285         case AB_CFG_SCROLLBAR_OBJ:
1286             cfg_obj = NULL;
1287             break;
1288
1289         default:
1290             util_dprintf(1, "custdlg_get_config_obj: unknown type\n");
1291             cfg_obj = NULL;
1292     }
1293     return(cfg_obj);
1294 }
1295
1296 static int
1297 custdlg_set_args(
1298     ABObj       obj,
1299     OBJXM_CONFIG_TYPE ctype
1300 )
1301 {
1302     STRING      label;
1303     ABObj       shobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1304     ABObj       bbobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_BB_OBJ);
1305     ABObj       pwobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_PW_OBJ);
1306     ABObj       workobj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);
1307     BOOL        cgen_args;
1308
1309     cgen_args = (ctype == OBJXM_CONFIG_CODEGEN? TRUE : FALSE);
1310
1311     /* Shell Resources */
1312     if ((label = obj_get_label(obj)) != NULL)
1313         objxm_obj_set_ui_arg(shobj, AB_ARG_STRING, XmNtitle, label);
1314     objxm_obj_set_ui_arg(shobj, AB_ARG_BOOLEAN, XmNallowShellResize, TRUE);
1315
1316     /* BulletinBoard-Dialog Resources */
1317     objxm_obj_set_ui_arg(bbobj, AB_ARG_INT, XmNmarginWidth, 0);
1318     objxm_obj_set_ui_arg(bbobj, AB_ARG_INT, XmNmarginHeight, 0);
1319     objxm_obj_set_ui_arg(bbobj, AB_ARG_BOOLEAN, XmNdefaultPosition, False);
1320
1321     /* Since all windows should be resizable in Build mode, ONLY set
1322      * this resource (to remove resize decorations from the dialog) if
1323      * we are doing Code-generation.
1324      */
1325     if (cgen_args && !obj_get_resizable(obj))
1326         objxm_obj_set_ui_arg(bbobj, AB_ARG_BOOLEAN, XmNnoResize, True);
1327
1328     /* PanedWindow Resources */
1329     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNmarginWidth, 0);
1330     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNmarginHeight, 0);
1331     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNspacing, 0);
1332     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNsashHeight, 1);
1333     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNsashWidth, 1);
1334
1335     /* Form WorkArea resources */
1336     objxm_obj_set_literal_ui_arg(workobj, ctype,  XmNresizePolicy,
1337         obj_get_width(obj) == -1? XmRESIZE_ANY : XmRESIZE_GROW);
1338     objxm_obj_set_ui_arg(workobj, AB_ARG_INT,     XmNmarginWidth,      0);
1339     objxm_obj_set_ui_arg(workobj, AB_ARG_INT,     XmNmarginHeight,     0);
1340     objxm_obj_set_ui_arg(workobj, AB_ARG_BOOLEAN, XmNallowResize,       True);
1341
1342     /* Set the interface name and select-state on the footer */
1343     if (ctype == OBJXM_CONFIG_BUILD)
1344         set_window_select_area_args(obj);
1345
1346     return 0;
1347 }
1348
1349 static int
1350 dialog_post_inst(
1351     ABObj       obj,
1352     OBJXM_CONFIG_TYPE ctype
1353 )
1354 {
1355
1356     if (ctype == OBJXM_CONFIG_BUILD)
1357         post_inst_window_select_area(obj);
1358
1359     if (obj_is_popup_win(obj))
1360         objxm_comp_set_default_button_args(obj, ctype);
1361
1362     return 0;
1363 }
1364
1365
1366 /*
1367  **********************************************
1368  ** Simple Methods (Button, Label, Item, ...)**
1369  **********************************************
1370  */
1371 int
1372 simple_xmconfig(
1373     ABObj    obj
1374 )
1375 {
1376     /* Configure Menu-reference if a menu exists for obj */
1377     objxm_comp_config_menu_ref(obj);
1378
1379     obj_set_class_name(obj, objxm_obj_get_default_motif_class(obj));
1380
1381     return OK;
1382 }
1383
1384 static int
1385 simple_unconfig(
1386     ABObj       obj
1387 )
1388 {
1389     ABObj       mr_obj = NULL;
1390
1391     /* Delete Menu-reference */
1392     objxm_comp_unconfig_menu_ref(obj);
1393
1394     return OK;
1395 }
1396
1397 static ABObj
1398 simple_get_config_obj(
1399     ABObj       obj,
1400     AB_CFG_OBJ_TYPE type
1401 )
1402 {
1403     ABObj cfg_obj = NULL;
1404
1405     switch(type)
1406     {
1407         case AB_CFG_OBJECT_OBJ:
1408         case AB_CFG_DND_OBJ:
1409         case AB_CFG_HELP_OBJ:
1410         case AB_CFG_LABEL_OBJ:
1411         case AB_CFG_POSITION_OBJ:
1412         case AB_CFG_SIZE_OBJ:
1413         case AB_CFG_SELECT_OBJ:
1414         case AB_CFG_MENU_PARENT_OBJ:
1415             cfg_obj = obj;
1416             break;
1417
1418         case AB_CFG_MENU_OBJ:
1419             /* Menu-Refs are the only possible children */
1420             cfg_obj = (obj_get_num_children(obj) > 0)? obj_get_child(obj, 0) : NULL;
1421             break;
1422         case AB_CFG_PARENT_OBJ:
1423         case AB_CFG_SCROLLBAR_OBJ:
1424         case AB_CFG_SCROLLING_OBJ:
1425         case AB_CFG_STATUS_OBJ:
1426         case AB_CFG_BORDER_OBJ:
1427             break;
1428         default:
1429             util_dprintf(1, "simple_get_config_obj: unsupported config-type\n");
1430     }
1431
1432     return(cfg_obj);
1433 }
1434
1435 static int
1436 simple_set_args(
1437     ABObj       obj,
1438     OBJXM_CONFIG_TYPE ctype
1439 )
1440 {
1441     ABObj       lbl_obj;
1442
1443     objxm_comp_set_label_args(obj, ctype);
1444     objxm_comp_set_lbl_align_args(obj, ctype);
1445
1446     lbl_obj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
1447     objxm_obj_set_ui_arg(lbl_obj, AB_ARG_BOOLEAN, XmNrecomputeSize,
1448         obj_get_width(obj) == -1? True : False);
1449
1450     return 0;
1451
1452 }
1453
1454 /*
1455  *************************
1456  ** Choice Methods      **
1457  *************************
1458  */
1459
1460 static int
1461 choice_xmconfig(
1462     ABObj    obj
1463 )
1464 {
1465     AB_CHOICE_TYPE type;
1466     ABObj       ch_obj, p_obj;
1467     ABObj       lbl_obj = NULL;
1468     int         num_items;
1469
1470     type = obj->info.choice.type;
1471     num_items = obj_get_num_children(obj);
1472
1473     obj->part_of = obj;
1474     obj_set_class_name(obj, _xmRowColumn);
1475
1476     if (obj_has_label(obj))
1477     {
1478         /* Create Label SubObj */
1479         lbl_obj = obj_create(AB_TYPE_LABEL, NULL);
1480         lbl_obj->part_of = obj;
1481         obj_set_class_name(lbl_obj, _xmLabel);
1482
1483         /* Create Choice SubObj */
1484         ch_obj = obj_create(AB_TYPE_CHOICE, NULL);
1485         ch_obj->part_of = obj;
1486         obj_set_class_name(ch_obj, _xmRowColumn);
1487     }
1488     else /* No Label */
1489         ch_obj = obj;
1490
1491     /* If OptionMenu, must build menu hierarchy for items */
1492     if (type == AB_CHOICE_OPTION_MENU)
1493     {
1494         /* Create Option PulldownMenu SubObj */
1495         /* NOTE: Menu must be FIRST child */
1496         p_obj = obj_create(AB_TYPE_CHOICE, NULL);
1497         p_obj->part_of = obj;
1498         obj_set_class_name(p_obj, _xmPulldownMenu);
1499     }
1500     else /* AB_CHOICE_EXCLUSIVE || AB_CHOICE_NONEXCLUSIVE */
1501         p_obj = ch_obj;
1502
1503     if (p_obj != obj)
1504         obj_move_children(p_obj, obj);
1505
1506     if (type == AB_CHOICE_OPTION_MENU)
1507     {
1508         obj_insert_child(obj, p_obj, 0);
1509         obj_set_unique_name(p_obj,
1510             ab_ident_from_name_and_label(obj_get_name(obj), "menu"));
1511     }
1512
1513     if (lbl_obj) /* Has Label */
1514     {
1515         obj_append_child(obj, lbl_obj);
1516         obj_set_unique_name(lbl_obj,
1517             ab_ident_from_name_and_label(obj_get_name(obj), "label"));
1518
1519         obj_append_child(obj, ch_obj);
1520         obj_set_unique_name(ch_obj,
1521             ab_ident_from_name_and_label(obj_get_name(obj), "choice"));
1522     }
1523     return OK;
1524
1525 }
1526 static int
1527 choice_unconfig(
1528     ABObj       obj
1529 )
1530 {
1531     ABObj       lbl_obj, ch_obj;
1532     ABObj       m_obj = NULL;
1533
1534     if (obj_get_subtype(obj) == AB_CHOICE_OPTION_MENU)
1535         m_obj = obj_get_child(obj, 0);
1536
1537     if (obj_has_label(obj)) /* Has Label */
1538     {
1539         lbl_obj = obj_get_child(obj, m_obj? 1 : 0);
1540         ch_obj  = obj_get_child(obj, m_obj? 2 : 1);
1541
1542         obj_move_children(obj, m_obj? m_obj : ch_obj);
1543
1544         obj_destroy(lbl_obj);
1545         obj_destroy(ch_obj);
1546     }
1547     else if (m_obj) /* No Label */
1548         obj_move_children(obj, m_obj);
1549
1550     if (m_obj)
1551         obj_destroy(m_obj);
1552
1553     return OK;
1554
1555 }
1556
1557 static ABObj
1558 choice_get_config_obj(
1559     ABObj       obj,
1560     AB_CFG_OBJ_TYPE type
1561 )
1562 {
1563     ABObj cfg_obj = NULL;
1564     AB_CHOICE_TYPE choice_type;
1565     BOOL           has_label = TRUE;
1566
1567     choice_type = obj->info.choice.type;
1568     if (!obj_has_label(obj))
1569         has_label = FALSE;
1570
1571     switch(type)
1572     {
1573         case AB_CFG_HELP_OBJ:
1574             cfg_obj = obj;
1575         break;
1576
1577         case AB_CFG_OBJECT_OBJ:
1578         case AB_CFG_SIZE_OBJ:
1579             if (has_label)
1580                 cfg_obj = obj_get_child(obj, choice_type == AB_CHOICE_OPTION_MENU? 2: 1);
1581             else
1582                 cfg_obj = obj;
1583             break;
1584         case AB_CFG_PARENT_OBJ:
1585             if (choice_type == AB_CHOICE_OPTION_MENU)
1586                 cfg_obj = obj_get_child(obj, 0);
1587             else
1588                 cfg_obj = has_label? obj_get_child(obj, 1) : obj;
1589             break;
1590         case AB_CFG_LABEL_OBJ:
1591             if (has_label)
1592                 cfg_obj = obj_get_child(obj, choice_type == AB_CHOICE_OPTION_MENU? 1: 0);
1593             else
1594                 cfg_obj = NULL;
1595             break;
1596         case AB_CFG_POSITION_OBJ:
1597         case AB_CFG_SELECT_OBJ:
1598         case AB_CFG_MENU_PARENT_OBJ:
1599             cfg_obj = obj;
1600             break;
1601         case AB_CFG_DND_OBJ:
1602         case AB_CFG_SCROLLBAR_OBJ:
1603         case AB_CFG_SCROLLING_OBJ:
1604         case AB_CFG_STATUS_OBJ:
1605         case AB_CFG_MENU_OBJ:
1606         case AB_CFG_BORDER_OBJ:
1607             cfg_obj = NULL;
1608             break;
1609         default:
1610             util_dprintf(1, "choice_get_config_obj: unsupported config-type\n");
1611     }
1612
1613     return(cfg_obj);
1614
1615 }
1616
1617 static int
1618 choice_set_args(
1619     ABObj       obj,
1620     OBJXM_CONFIG_TYPE ctype
1621 )
1622 {
1623     AB_CHOICE_TYPE type;
1624     AB_ORIENTATION orient;
1625     ABObj          ch_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1626     ABObj          xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
1627     ABObj          lbl_obj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
1628
1629     objxm_comp_set_label_args(obj, ctype);
1630     objxm_comp_set_lbl_pos_args(obj, ctype);
1631     if (lbl_obj) /* Clear margins on RowColumn */
1632     {
1633         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNmarginHeight, 0);
1634         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNmarginWidth, 0);
1635     }
1636
1637     objxm_obj_set_ui_arg(xy_obj, AB_ARG_BOOLEAN, XmNisHomogeneous, FALSE);
1638     objxm_obj_set_literal_ui_arg(xy_obj, ctype, XmNpacking, XmPACK_TIGHT);
1639
1640     if ((type = (AB_CHOICE_TYPE)obj_get_subtype(obj)) != AB_CHOICE_OPTION_MENU)
1641     {
1642         orient = obj_get_orientation(obj);
1643
1644         switch (orient)
1645         {
1646             case AB_ORIENT_HORIZONTAL:
1647                 objxm_obj_set_literal_ui_arg(ch_obj, ctype, XmNorientation, XmHORIZONTAL);
1648                 if (obj_get_num_columns(obj) > 1)
1649                 {
1650                     objxm_obj_set_literal_ui_arg(xy_obj, ctype, XmNentryVerticalAlignment,
1651                         XmALIGNMENT_BASELINE_BOTTOM);
1652                     if (lbl_obj)
1653                         objxm_obj_set_ui_arg(lbl_obj, AB_ARG_INT, XmNmarginHeight, 8);
1654                 }
1655                 break;
1656             case AB_ORIENT_VERTICAL:
1657                 objxm_obj_set_literal_ui_arg(ch_obj, ctype, XmNorientation,XmVERTICAL);
1658                 objxm_obj_set_literal_ui_arg(xy_obj, ctype, XmNentryVerticalAlignment,
1659                         XmALIGNMENT_BASELINE_BOTTOM);
1660                 if (lbl_obj)
1661                     objxm_obj_set_ui_arg(lbl_obj, AB_ARG_INT, XmNmarginHeight, 8);
1662                 break;
1663         }
1664         if (obj_get_num_columns(obj) > 1)
1665             objxm_obj_set_literal_ui_arg(ch_obj, ctype, XmNpacking, XmPACK_COLUMN);
1666         else
1667             objxm_obj_set_literal_ui_arg(ch_obj, ctype, XmNpacking, XmPACK_TIGHT);
1668         objxm_obj_set_literal_ui_arg(ch_obj, ctype, XmNrowColumnType, XmWORK_AREA);
1669         objxm_obj_set_ui_arg(ch_obj, AB_ARG_INT,     XmNspacing,        0);
1670         objxm_obj_set_ui_arg(ch_obj, AB_ARG_BOOLEAN, XmNisHomogeneous, TRUE);
1671         objxm_obj_set_ui_arg(ch_obj, AB_ARG_INT,     XmNnumColumns, obj_get_num_columns(obj));
1672         objxm_obj_set_ui_arg(ch_obj, AB_ARG_INT,     XmNentryClass, xmToggleButtonWidgetClass);
1673         objxm_obj_set_ui_arg(ch_obj, AB_ARG_BOOLEAN, XmNradioBehavior,
1674                 type == AB_CHOICE_EXCLUSIVE? TRUE : FALSE);
1675     }
1676     else /* AB_CHOICE_OPTION_MENU */
1677     {
1678         ABObj   p_obj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);
1679
1680         objxm_obj_set_ui_arg(ch_obj, AB_ARG_INT, XmNspacing,    0);
1681         objxm_obj_set_literal_ui_arg(ch_obj, ctype, XmNrowColumnType, XmMENU_OPTION);
1682         objxm_obj_set_literal_ui_arg(p_obj, ctype, XmNrowColumnType, XmMENU_PULLDOWN);
1683     }
1684     return 0;
1685
1686 }
1687
1688 static int
1689 choice_post_inst(
1690     ABObj       obj,
1691     OBJXM_CONFIG_TYPE ctype
1692 )
1693 {
1694     /* REMIND: aim - does this do any good?? */
1695     if (ctype == OBJXM_CONFIG_BUILD &&
1696         obj_get_subtype(obj) == AB_CHOICE_OPTION_MENU)
1697     {
1698         Widget widget;
1699         ABObj  chobj;
1700         Position x;
1701
1702         chobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1703         widget = objxm_get_widget(chobj);
1704
1705         XtVaGetValues(widget, XmNx, &x, NULL);
1706         XtVaSetValues(widget, XmNx, x-6, NULL);
1707     }
1708     return 0;
1709
1710 }
1711
1712 /*
1713  *******************************
1714  ** ControlPanel Methods      **
1715  *******************************
1716  */
1717
1718 static int
1719 cpanel_xmconfig(
1720     ABObj    obj
1721 )
1722 {
1723     ABObj       panel_obj;
1724
1725     /* Configure for border-frame */
1726     if ((panel_obj = objxm_comp_config_border_frame(obj)) == NULL)
1727         panel_obj = obj;
1728
1729     /* Configure for Menu */
1730     objxm_comp_config_menu_ref(obj);
1731
1732     obj_set_class_name(panel_obj, _xmForm);
1733
1734     return OK;
1735
1736 }
1737
1738 static int
1739 cpanel_unconfig(
1740     ABObj       obj
1741 )
1742 {
1743     ABObj       mr_obj = NULL;
1744
1745     /* Delete Menu-reference first */
1746     objxm_comp_unconfig_menu_ref(obj);
1747
1748     /* Remove Border Rootobj (collapse) */
1749     objxm_comp_unconfig_border_frame(obj);
1750
1751     return OK;
1752 }
1753
1754 static int
1755 cpanel_set_args(
1756     ABObj       obj,
1757     OBJXM_CONFIG_TYPE ctype
1758 )
1759 {
1760     AB_CONTAINER_TYPE   cont_type;
1761     ABObj               parent;
1762     ABObj               cp_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1763     ABObj               xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
1764     int                 margin = 0;
1765     unsigned char       resize_policy = XmRESIZE_GROW;
1766
1767     objxm_comp_set_border_args(obj, ctype);
1768
1769     cont_type = obj_get_container_type(obj);
1770
1771     switch(cont_type)
1772     {
1773         case AB_CONT_BUTTON_PANEL:
1774             margin = 7;
1775 /*
1776             objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpositionIndex, 1);
1777 */
1778             break;
1779         case AB_CONT_FOOTER:
1780             parent = obj_get_root(obj_get_parent(obj));
1781             if (obj_is_popup_win(parent))
1782             {
1783                 if (objxm_comp_custdlg_get_area(parent, AB_CONT_BUTTON_PANEL) != NULL)
1784                     objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpositionIndex, 2);
1785                 else
1786                     objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpositionIndex, 1);
1787             }
1788             break;
1789         default:
1790             break;
1791     }
1792
1793     objxm_obj_set_ui_arg(cp_obj, AB_ARG_INT, XmNmarginWidth,      margin);
1794     objxm_obj_set_ui_arg(cp_obj, AB_ARG_INT, XmNmarginHeight,     margin);
1795 /*
1796     objxm_obj_set_literal_ui_arg(cp_obj, ctype, XmNresizePolicy, XmRESIZE_GROW);
1797 */
1798     /* For standard ControlPane's with Resize Policy of "Fit Contents", we want
1799      * to use XmRESIZE_ANY, all other cases we want to use XmRESIZE_GROW to ensure
1800      * they don't snap to a zero size if they have no children (because there is
1801      * no way to get it back!).  Only standard ControlPanes can have a height ==
1802      * -1.
1803      */
1804     objxm_obj_set_literal_ui_arg(cp_obj, ctype,  XmNresizePolicy,
1805         obj_get_height(obj) == -1? XmRESIZE_ANY : XmRESIZE_GROW);
1806
1807     /* Need to set additional resources if child of panedWindow */
1808     parent = obj_get_parent(obj);
1809     if ((obj_get_type(parent) == AB_TYPE_CONTAINER) &&
1810         (obj_get_container_type(parent) == AB_CONT_PANED))
1811     {
1812         /* Set PanedWindow Contraint Resources */
1813         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpaneMinimum,
1814                                 obj_get_pane_min(obj));
1815         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpaneMaximum,
1816                                 obj_get_pane_max(obj));
1817     }
1818     return 0;
1819 }
1820
1821 static int
1822 cpanel_post_inst(
1823     ABObj       obj,
1824     OBJXM_CONFIG_TYPE ctype
1825 )
1826 {
1827     AB_CONTAINER_TYPE   cont_type;
1828     ABObj               mwobj;
1829     int                 height;
1830
1831     cont_type = obj_get_container_type(obj);
1832
1833     switch(cont_type)
1834     {
1835         case AB_CONT_FOOTER:
1836         case AB_CONT_BUTTON_PANEL:
1837             if (obj_is_base_win(obj_get_root(obj_get_parent(obj))))
1838             {
1839                 mwobj = obj_get_parent(obj);
1840
1841                 if (ctype == OBJXM_CONFIG_BUILD)
1842                 {
1843                     /* Area must be Managed before MainWindow resource gets set */
1844                     XtManageChild(objxm_get_widget(obj));
1845                     util_dprintf(3, "MANAGING %s\n", obj_get_name(obj));
1846                     XtVaSetValues(objxm_get_widget(mwobj),
1847                         XmNmessageWindow,       objxm_get_widget(obj),
1848                         NULL);
1849                 }
1850                 else
1851                 {
1852                     objxm_obj_set_widget_ui_arg(mwobj, ctype, XmNmessageWindow, obj);
1853                     obj_set_flag(mwobj, AttrChangedFlag);
1854                 }
1855             }
1856             else
1857             {
1858                 height = obj_get_height(obj);
1859
1860                 /* If a height is specified for the pane, use that value, else
1861                  * pass in the object responsible for the size of the pane and
1862                  * let the routine query its widget's size.
1863                  */
1864                 make_pane_fixed_height(obj, height == -1?
1865                         objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ) : NULL,
1866                         height, 0);
1867             }
1868             break;
1869         case AB_CONT_TOOL_BAR:
1870             mwobj = obj_get_parent(obj);
1871
1872             /* Attach Toolbar to MainWindow SubObj */
1873
1874             if (ctype == OBJXM_CONFIG_BUILD)
1875             {
1876                 /* Area must be Managed before MainWindow resource gets set */
1877                 XtManageChild(objxm_get_widget(obj));
1878                 util_dprintf(3, "MANAGING %s\n", obj_get_name(obj));
1879                 XtVaSetValues(objxm_get_widget(mwobj),
1880                         XmNcommandWindow,       objxm_get_widget(obj),
1881                         XmNcommandWindowLocation, XmCOMMAND_ABOVE_WORKSPACE,
1882                         NULL);
1883             }
1884             else
1885             {
1886                 objxm_obj_set_widget_ui_arg(mwobj, ctype, XmNcommandWindow, obj);
1887                 objxm_obj_set_literal_ui_arg(mwobj, ctype, XmNcommandWindowLocation,
1888                         XmCOMMAND_ABOVE_WORKSPACE);
1889                 obj_set_flag(mwobj, AttrChangedFlag);
1890             }
1891             break;
1892         default:
1893             break;
1894     }
1895     return 0;
1896 }
1897
1898 /*
1899  ****************************************************
1900  ** Container Methods (ControlPanel & MenuBar)     **
1901  ****************************************************
1902  */
1903 static ABObj
1904 container_get_config_obj(
1905     ABObj       obj,
1906     AB_CFG_OBJ_TYPE type
1907 )
1908 {
1909     ABObj cfg_obj = NULL;
1910     ABObj mr_obj  = NULL;
1911     ABObj b_obj = NULL;
1912
1913     mr_obj = get_menu_ref(obj);
1914
1915     if (obj_has_border_frame(obj))
1916         b_obj = obj;
1917
1918     switch(type)
1919     {
1920         case AB_CFG_HELP_OBJ:
1921             cfg_obj = obj;
1922         break;
1923
1924         case AB_CFG_POSITION_OBJ:
1925             if (obj_is_layers(obj_get_root(obj_get_parent(obj))))
1926                 cfg_obj = obj_get_root(obj_get_parent(obj));
1927             else
1928                 cfg_obj = obj;
1929             break;
1930         case AB_CFG_DND_OBJ:
1931         case AB_CFG_OBJECT_OBJ:
1932         case AB_CFG_LABEL_OBJ:
1933         case AB_CFG_SELECT_OBJ:
1934         case AB_CFG_SIZE_OBJ:
1935         case AB_CFG_PARENT_OBJ:
1936         case AB_CFG_MENU_PARENT_OBJ:
1937             cfg_obj = (b_obj? obj_get_child(obj, mr_obj? 1 : 0) : obj);
1938             break;
1939         case AB_CFG_BORDER_OBJ:
1940             cfg_obj = b_obj;
1941             break;
1942         case AB_CFG_MENU_OBJ:
1943             cfg_obj = mr_obj;
1944             break;
1945         case AB_CFG_SCROLLBAR_OBJ:
1946         case AB_CFG_SCROLLING_OBJ:
1947         case AB_CFG_STATUS_OBJ:
1948             cfg_obj = NULL;
1949             break;
1950         default:
1951             util_dprintf(1, "container_get_config_obj: unknown type\n");
1952             cfg_obj = NULL;
1953     }
1954
1955     return(cfg_obj);
1956
1957 }
1958 /*
1959  *******************************
1960  * Glyph Methods               *
1961  *******************************
1962  */
1963 static int
1964 layer_xmconfig(
1965     ABObj       obj
1966 )
1967 {
1968     ABObj       pane;
1969     int         i;
1970
1971     obj_set_class_name(obj, _xmForm);
1972
1973     /* Make the first layered-pane the one initially
1974      * visible for editing
1975      */
1976     for(i=0; i < obj_get_num_salient_children(obj); i++)
1977     {
1978         pane = obj_get_salient_child(obj, i);
1979         if (i == 0)
1980             obj_set_flag(pane, VisibleFlag);
1981         else
1982             obj_clear_flag(pane, VisibleFlag);
1983     }
1984     return OK;
1985 }
1986
1987 static int
1988 layer_unconfig(
1989     ABObj       obj
1990 )
1991 {
1992     return OK;
1993 }
1994
1995 static ABObj
1996 layer_get_config_obj(
1997     ABObj       obj,
1998     AB_CFG_OBJ_TYPE type
1999 )
2000 {
2001     ABObj       cfg_obj;
2002
2003     switch(type)
2004     {
2005         case AB_CFG_HELP_OBJ:
2006         case AB_CFG_POSITION_OBJ:
2007         case AB_CFG_OBJECT_OBJ:
2008         case AB_CFG_SIZE_OBJ:
2009         case AB_CFG_PARENT_OBJ:
2010             cfg_obj = obj;
2011             break;
2012
2013         case AB_CFG_DND_OBJ:
2014         case AB_CFG_LABEL_OBJ:
2015         case AB_CFG_SELECT_OBJ:
2016         case AB_CFG_MENU_PARENT_OBJ:
2017         case AB_CFG_BORDER_OBJ:
2018         case AB_CFG_MENU_OBJ:
2019         case AB_CFG_SCROLLBAR_OBJ:
2020         case AB_CFG_SCROLLING_OBJ:
2021         case AB_CFG_STATUS_OBJ:
2022             cfg_obj = NULL;
2023             break;
2024
2025         default:
2026             util_dprintf(1, "layer_get_config_obj: unknown type\n");
2027             cfg_obj = NULL;
2028     }
2029     return cfg_obj;
2030 }
2031
2032 static int
2033 layer_set_args(
2034     ABObj       obj,
2035     OBJXM_CONFIG_TYPE ctype
2036 )
2037 {
2038
2039     objxm_obj_set_literal_ui_arg(obj, ctype, XmNresizePolicy, XmRESIZE_ANY);
2040     return OK;
2041
2042 }
2043
2044 /*
2045  *******************************
2046  ** Group Methods      **
2047  *******************************
2048  */
2049
2050 static int
2051 group_xmconfig(
2052     ABObj    obj
2053 )
2054 {
2055     ABObj       panel_obj;
2056
2057     /* Configure for border-frame */
2058     if ((panel_obj = objxm_comp_config_border_frame(obj)) == NULL)
2059         panel_obj = obj;
2060
2061     obj_set_class_name(panel_obj, _xmForm);
2062
2063     return OK;
2064
2065 }
2066
2067 /* Group Unconfig */
2068
2069 static int
2070 group_unconfig(
2071     ABObj       obj
2072 )
2073 {
2074     ABObj       mr_obj = NULL;
2075
2076     /* Delete Menu-reference first */
2077     objxm_comp_unconfig_menu_ref(obj);
2078
2079     /* Remove Border Rootobj (collapse) */
2080     objxm_comp_unconfig_border_frame(obj);
2081
2082     return OK;
2083 }
2084
2085
2086 static int
2087 group_set_args(
2088     ABObj       obj,
2089     OBJXM_CONFIG_TYPE ctype
2090 )
2091 {
2092     ABObj       g_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2093
2094     objxm_comp_set_border_args(obj, ctype);
2095
2096     objxm_obj_set_ui_arg(g_obj, AB_ARG_INT,     XmNmarginWidth,      0);
2097     objxm_obj_set_ui_arg(g_obj, AB_ARG_INT,     XmNmarginHeight,     0);
2098     objxm_obj_set_literal_ui_arg(g_obj, ctype,  XmNresizePolicy,     XmRESIZE_ANY);
2099
2100     /* REMIND: aim,11/16/93 -do we need to support this row-column stuff? */
2101     if (util_streq(obj_get_class_name(g_obj), _xmRowColumn))
2102     {
2103         switch (obj->info.container.packing)
2104         {
2105             case AB_PACK_NONE:
2106                 objxm_obj_set_literal_ui_arg(g_obj, ctype, XmNpacking, XmPACK_NONE);
2107                 break;
2108             case AB_PACK_TIGHT:
2109                 objxm_obj_set_literal_ui_arg(g_obj, ctype, XmNpacking, XmPACK_TIGHT);
2110                 break;
2111             case AB_PACK_EQUAL:
2112                 objxm_obj_set_literal_ui_arg(g_obj, ctype, XmNpacking, XmPACK_COLUMN);
2113                 break;
2114         }
2115         switch (obj->info.container.group_type)
2116         {
2117             case AB_GROUP_COLUMNS:
2118                 objxm_obj_set_literal_ui_arg(g_obj, ctype, XmNorientation, XmVERTICAL);
2119                 break;
2120             case AB_GROUP_ROWS:
2121                 objxm_obj_set_literal_ui_arg(g_obj, ctype, XmNorientation, XmHORIZONTAL);
2122                 break;
2123         }
2124     }
2125     return 0;
2126 }
2127
2128 /*
2129  *******************************
2130  ** Item  Methods             **
2131  *******************************
2132  */
2133
2134 static int
2135 item_xmconfig(
2136     ABObj    obj
2137 )
2138 {
2139     ABObj       parentobj = obj_get_root(obj_get_parent(obj));
2140
2141     switch(obj_get_subtype(obj))
2142     {
2143         case AB_ITEM_FOR_CHOICE:
2144             if (obj_get_subtype(parentobj) == AB_CHOICE_OPTION_MENU)
2145                 obj_set_class_name(obj, _xmPushButton);
2146             else
2147                 obj_set_class_name(obj, _xmToggleButton);
2148             break;
2149         case AB_ITEM_FOR_MENU:
2150             obj_set_class_name(obj,
2151                 obj_has_menu(obj)? _xmCascadeButton : _xmPushButton);
2152             break;
2153         case AB_ITEM_FOR_MENUBAR:
2154             obj_set_class_name(obj, _xmCascadeButton);
2155             break;
2156         case AB_ITEM_FOR_LIST:
2157             break;
2158      }
2159
2160     objxm_comp_config_menu_ref(obj);
2161
2162     return OK;
2163
2164 }
2165
2166 /* Item Unconfig: simple_unconfig */
2167
2168 static ABObj
2169 item_get_config_obj(
2170     ABObj       obj,
2171     AB_CFG_OBJ_TYPE type
2172 )
2173 {
2174     ABObj cfg_obj;
2175
2176     switch(type)
2177     {
2178         case AB_CFG_HELP_OBJ:
2179         case AB_CFG_OBJECT_OBJ:
2180         case AB_CFG_LABEL_OBJ:
2181             cfg_obj = obj;
2182             break;
2183         case AB_CFG_MENU_PARENT_OBJ:
2184             cfg_obj = obj_get_parent(obj);
2185             break;
2186         case AB_CFG_POSITION_OBJ:
2187         case AB_CFG_SIZE_OBJ:
2188         case AB_CFG_SELECT_OBJ:
2189             cfg_obj = objxm_comp_get_subobj(obj_get_parent(obj), type);
2190             break;
2191         case AB_CFG_MENU_OBJ:
2192             /* Menu-refs are the only possible children */
2193             cfg_obj = (obj_get_num_children(obj) > 0)? obj_get_child(obj, 0) : NULL;
2194             break;
2195         case AB_CFG_BORDER_OBJ:
2196         case AB_CFG_DND_OBJ:
2197         case AB_CFG_PARENT_OBJ:
2198         case AB_CFG_SCROLLBAR_OBJ:
2199         case AB_CFG_SCROLLING_OBJ:
2200         case AB_CFG_STATUS_OBJ:
2201             cfg_obj = NULL;
2202             break;
2203         default:
2204             util_dprintf(1, "item_get_config_obj: unknown config-type\n");
2205             cfg_obj = NULL;
2206     }
2207     return(cfg_obj);
2208 }
2209
2210 static int
2211 item_set_args(
2212     ABObj       obj,
2213     OBJXM_CONFIG_TYPE ctype
2214 )
2215 {
2216     ABObj       i_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2217     STRING      mnemonic, accel, acceltext;
2218
2219     objxm_comp_set_label_args(obj, ctype);
2220
2221     if (obj_is_choice_item(obj))
2222     {
2223         ABObj parentobj = obj_get_parent(obj);
2224         ABObj vobj = obj_get_root(parentobj);
2225
2226         if (vobj->info.choice.type == AB_CHOICE_EXCLUSIVE)
2227             objxm_obj_set_literal_ui_arg(i_obj, ctype, XmNindicatorType, XmONE_OF_MANY);
2228         else if (vobj->info.choice.type == AB_CHOICE_NONEXCLUSIVE)
2229             objxm_obj_set_literal_ui_arg(i_obj, ctype, XmNindicatorType, XmN_OF_MANY);
2230
2231         if (vobj->info.choice.type != AB_CHOICE_OPTION_MENU)
2232             objxm_obj_set_ui_arg(i_obj, AB_ARG_BOOLEAN, XmNset,
2233                     obj_is_initially_selected(i_obj));
2234     }
2235
2236     if ((mnemonic = obj_get_mnemonic(obj)) != NULL)
2237     {
2238         objxm_obj_set_ui_arg(i_obj, AB_ARG_MNEMONIC, XmNmnemonic,
2239                 ctype == OBJXM_CONFIG_BUILD? (XtArgVal)XStringToKeysym(mnemonic) :
2240                 (XtArgVal)istr_create(mnemonic));
2241     }
2242     if ((accel = obj_get_accelerator(obj)) != NULL)
2243     {
2244         acceltext = objxm_accel_to_acceltext(accel);
2245
2246         objxm_obj_set_ui_arg(i_obj, AB_ARG_STRING, XmNaccelerator, accel);
2247         objxm_obj_set_ui_arg(i_obj, AB_ARG_XMSTRING, XmNacceleratorText,
2248                 ctype == OBJXM_CONFIG_BUILD? (XtArgVal)XmStringCreateLocalized(acceltext) :
2249                 (XtArgVal)istr_create(acceltext));
2250     }
2251
2252     return 0;
2253 }
2254
2255 static int
2256 item_post_inst(
2257     ABObj       obj,
2258     OBJXM_CONFIG_TYPE ctype
2259 )
2260 {
2261     /* Ensure the item's select-state gets set correctly */
2262     if (ctype == OBJXM_CONFIG_BUILD)
2263         objxm_comp_set_item_selection(obj);
2264
2265     return 0;
2266 }
2267
2268 /*
2269  **********************************************
2270  ** Pane  Methods (TextPane & GraphicPane)   **
2271  **********************************************
2272  */
2273 static int
2274 pane_xmconfig(
2275     ABObj    obj
2276 )
2277 {
2278     ABObj       root_obj;
2279     ABObj       pane_obj;
2280
2281     /* Configure for border-frame and set root_obj
2282      * to Obj directly under Frame
2283      */
2284     if ((root_obj = objxm_comp_config_border_frame(obj)) == NULL)
2285         root_obj = obj;
2286
2287     if ( obj_has_hscrollbar(obj) || obj_has_vscrollbar(obj) )
2288     {
2289         /* Configure ScrolledWindow */
2290         root_obj->part_of = obj;
2291         obj_set_class_name(root_obj, _xmScrolledWindow);
2292
2293         /* Pane SubObj is child of ScrolledWindow */
2294         pane_obj = objxmP_create_direct_subobj(root_obj, obj->type, "pane");
2295         pane_obj->part_of = obj;
2296
2297         /* If TermPane, we must create the Vertical scrollbar as a
2298          * child of the ScrolledWindow and hook it up later to the
2299          * Term widget
2300          */
2301         if (obj_is_term_pane(obj))
2302         {
2303             ABObj       sbobj;
2304
2305             sbobj = obj_create(AB_TYPE_TERM_PANE, NULL);
2306             sbobj->part_of = obj;
2307             obj_set_class_name(sbobj, _xmScrollBar);
2308             obj_append_child(root_obj, sbobj);
2309             obj_set_unique_name(sbobj,
2310                 ab_ident_from_name_and_label(obj_get_name(obj), "vscrollbar"));
2311         }
2312     }
2313     else /* No Scrolling */
2314         pane_obj = root_obj;
2315
2316     if (obj_is_text_pane(obj))
2317         obj_set_class_name(pane_obj, _xmText);
2318     else if (obj_is_term_pane(obj))
2319         obj_set_class_name(pane_obj, _dtTerm);
2320     else
2321         obj_set_class_name(pane_obj, _xmDrawingArea);
2322
2323     /* Configure Menu-ref if a menu exists */
2324     objxm_comp_config_menu_ref(obj);
2325
2326     return OK;
2327
2328 }
2329
2330 static int
2331 pane_unconfig(
2332     ABObj       obj
2333 )
2334 {
2335     ABObj       pane_obj;
2336
2337     /* Destroy Menu-reference if it exists */
2338     objxm_comp_unconfig_menu_ref(obj);
2339
2340     /* Collapse Frame if it exists */
2341     objxm_comp_unconfig_border_frame(obj);
2342
2343     if (obj_has_vscrollbar(obj) || obj_has_hscrollbar(obj) )
2344     {
2345         pane_obj = obj_get_child(obj, 0);
2346
2347         if (obj_get_num_children(pane_obj) > 0)
2348             obj_move_children(obj, pane_obj);
2349
2350         if (obj_is_term_pane(obj)) /* Destroy Scrollbar SubObj */
2351         {
2352             ABObj       doomedPane = obj_get_child(obj, 1);
2353             obj_destroy(doomedPane);
2354         }
2355
2356         obj_destroy(pane_obj);
2357     }
2358
2359     return OK;
2360
2361 }
2362
2363 static ABObj
2364 pane_get_config_obj(
2365     ABObj       obj,
2366     AB_CFG_OBJ_TYPE type
2367 )
2368 {
2369     ABObj cfg_obj   = NULL;
2370     ABObj pane_obj  = obj;  /* Pane SubObj */
2371     ABObj mr_obj    = NULL; /* Menu-ref SubObj */
2372     ABObj sb_obj    = NULL; /* Scrollbar SubObj */
2373     ABObj b_obj     = NULL; /* Border SubObj */
2374
2375     mr_obj = get_menu_ref(obj);
2376
2377     if (obj_has_border_frame(obj))
2378         b_obj = obj;
2379
2380     if (obj_has_scrollbar(obj))
2381     {
2382         if (b_obj) /* has border frame */
2383             sb_obj = obj_get_child(b_obj, (mr_obj? 1 : 0));
2384         else
2385             sb_obj = obj;
2386     }
2387
2388     if (b_obj) /* has border frame */
2389     {
2390         if (sb_obj) /* has scrolling */
2391             pane_obj = obj_get_child(sb_obj, 0);
2392         else
2393             pane_obj = obj_get_child(b_obj, (mr_obj? 1 : 0));
2394     }
2395     else if (sb_obj) /* has no border frame, but has scrolling */
2396     {
2397         pane_obj = obj_get_child(sb_obj, (mr_obj? 1 : 0));
2398     }
2399     else /* has no border frame and no scrolling */
2400     {
2401         pane_obj = obj;
2402     }
2403
2404     switch(type)
2405     {
2406         case AB_CFG_HELP_OBJ:
2407             cfg_obj = obj;
2408         break;
2409
2410         case AB_CFG_OBJECT_OBJ:
2411         case AB_CFG_MENU_PARENT_OBJ:
2412         case AB_CFG_SELECT_OBJ:
2413             cfg_obj = pane_obj;
2414             break;
2415         case AB_CFG_POSITION_OBJ:
2416             if (obj_is_layers(obj_get_root(obj_get_parent(obj))))
2417                 cfg_obj = obj_get_root(obj_get_parent(obj));
2418             else
2419                 cfg_obj = obj;
2420             break;
2421         case AB_CFG_BORDER_OBJ:
2422             cfg_obj = b_obj;
2423             break;
2424         case AB_CFG_SIZE_OBJ:
2425             cfg_obj = sb_obj? sb_obj : obj;
2426             break;
2427         case AB_CFG_DND_OBJ:
2428         case AB_CFG_PARENT_OBJ:
2429             if (obj_is_text_pane(obj) ||
2430                 obj_is_term_pane(obj))
2431                 cfg_obj = NULL;
2432             else
2433                 cfg_obj = pane_obj;
2434             break;
2435         case AB_CFG_SCROLLBAR_OBJ:
2436             if (obj_is_term_pane(obj) && sb_obj)
2437                 cfg_obj = obj_get_child(sb_obj, b_obj? 1:(mr_obj? 2:1));
2438             break;
2439         case AB_CFG_MENU_OBJ:
2440             cfg_obj = mr_obj;
2441             break;
2442         case AB_CFG_SCROLLING_OBJ:
2443             cfg_obj = sb_obj;
2444             break;
2445         case AB_CFG_LABEL_OBJ:
2446         case AB_CFG_STATUS_OBJ:
2447             break;
2448         default:
2449             util_dprintf(1, "pane_get_config_obj: unknown type\n");
2450     }
2451
2452     return(cfg_obj);
2453 }
2454
2455 static int
2456 drawp_set_args(
2457     ABObj       obj,
2458     OBJXM_CONFIG_TYPE ctype
2459 )
2460 {
2461     ABObj       da_obj = NULL,  /* DrawArea SubObj */
2462                 sw_obj = NULL,  /* ScrolledWin SubObj */
2463                 xy_obj = NULL,  /* Position SubObj */
2464                 parent = NULL;  /* ABObj parent NOT config parent */
2465
2466     objxm_comp_set_border_args(obj, ctype);
2467
2468     da_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2469     xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
2470
2471     if (obj_has_vscrollbar(obj) || obj_has_hscrollbar(obj) )
2472     {
2473         sw_obj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);
2474
2475         objxm_obj_set_literal_ui_arg(sw_obj, ctype, XmNscrollingPolicy, XmAUTOMATIC);
2476         objxm_obj_set_ui_arg(sw_obj, AB_ARG_INT, XmNspacing, 0);
2477
2478         if (obj_get_vscrollbar_policy(obj) == AB_SCROLLBAR_ALWAYS ||
2479             obj_get_hscrollbar_policy(obj) == AB_SCROLLBAR_ALWAYS )
2480             objxm_obj_set_literal_ui_arg(sw_obj, ctype, XmNscrollBarDisplayPolicy, XmSTATIC);
2481         else
2482             objxm_obj_set_literal_ui_arg(sw_obj, ctype, XmNscrollBarDisplayPolicy, XmAS_NEEDED);
2483
2484         /* This sets the TOTAL width/height of the DrawArea (not necessarily
2485          * the 'visible' portion)
2486          */
2487         objxm_obj_set_ui_arg(da_obj, AB_ARG_INT, XmNwidth, obj_get_drawarea_width(obj));
2488         objxm_obj_set_ui_arg(da_obj, AB_ARG_INT, XmNheight, obj_get_drawarea_height(obj));
2489     }
2490
2491     /* Need to set additional resources if child of panedWindow */
2492     parent = obj_get_parent(obj);
2493     if ((obj_get_type(parent) == AB_TYPE_CONTAINER) &&
2494         (obj_get_container_type(parent) == AB_CONT_PANED))
2495     {
2496         /* Set PanedWindow Contraint Resources */
2497         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpaneMinimum,
2498                                 obj_get_pane_min(obj));
2499         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpaneMaximum,
2500                                 obj_get_pane_max(obj));
2501     }
2502     return 0;
2503 }
2504
2505 static int
2506 drawp_post_inst(
2507     ABObj       obj,
2508     OBJXM_CONFIG_TYPE ctype
2509 )
2510 {
2511     ABObj       gp_obj, sw_obj;
2512
2513     if (ctype == OBJXM_CONFIG_BUILD &&
2514         (obj_has_hscrollbar(obj) || obj_has_vscrollbar(obj)))
2515     {
2516         gp_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2517         sw_obj = objxm_comp_get_subobj(obj, AB_CFG_SCROLLING_OBJ);
2518
2519         XmScrolledWindowSetAreas(objxm_get_widget(sw_obj), NULL, NULL,
2520                 objxm_get_widget(gp_obj));
2521     }
2522     return 0;
2523 }
2524
2525 static int
2526 termp_set_args(
2527     ABObj       obj,
2528     OBJXM_CONFIG_TYPE ctype
2529 )
2530 {
2531     ABObj       tp_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2532     ABObj       xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
2533     ABObj       scrolling_obj = objxm_comp_get_subobj(obj, AB_CFG_SCROLLING_OBJ);
2534     ABObj       parent; /* ABObj parent NOT config parent */
2535     String      pstr;
2536     int         value;
2537
2538     objxm_comp_set_border_args(obj, ctype);
2539
2540     if ((value = obj_get_num_rows(obj)) > 0)
2541         objxm_obj_set_ui_arg(tp_obj, AB_ARG_INT, XmNrows, value);
2542
2543     if ((value = obj_get_num_columns(obj)) > 0)
2544         objxm_obj_set_ui_arg(tp_obj, AB_ARG_INT, XmNcolumns, value);
2545
2546     if ((pstr = obj_get_process_string(obj)) != NULL)
2547         objxm_obj_set_ui_arg(tp_obj, AB_ARG_STRING, DtNsubprocessCmd, pstr);
2548
2549     if (obj_has_vscrollbar(obj))
2550     {
2551         ABObj   sb_obj = objxm_comp_get_subobj(obj, AB_CFG_SCROLLBAR_OBJ);
2552
2553         objxm_obj_set_literal_ui_arg(scrolling_obj, ctype, XmNscrollingPolicy, XmAPPLICATION_DEFINED);
2554         objxm_obj_set_literal_ui_arg(scrolling_obj, ctype, XmNvisualPolicy,    XmVARIABLE);
2555
2556         if (obj_get_vscrollbar_policy(obj) == AB_SCROLLBAR_ALWAYS)
2557             objxm_obj_set_literal_ui_arg(scrolling_obj, ctype,
2558                         XmNscrollBarDisplayPolicy, XmSTATIC);
2559         else
2560             objxm_obj_set_literal_ui_arg(scrolling_obj, ctype,
2561                         XmNscrollBarDisplayPolicy, XmAS_NEEDED);
2562
2563         objxm_obj_set_ui_arg(scrolling_obj, AB_ARG_INT, XmNspacing, 0);
2564
2565         objxm_obj_set_literal_ui_arg(sb_obj, ctype, XmNorientation, XmVERTICAL);
2566     }
2567
2568     /* Need to set additional resources if child of panedWindow */
2569     parent = obj_get_parent(obj);
2570     if ((obj_get_type(parent) == AB_TYPE_CONTAINER) &&
2571         (obj_get_container_type(parent) == AB_CONT_PANED))
2572     {
2573         /* Set PanedWindow Contraint Resources */
2574         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpaneMinimum,
2575                                 obj_get_pane_min(obj));
2576         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpaneMaximum,
2577                                 obj_get_pane_max(obj));
2578     }
2579
2580     /* CMVC 3704 - Set the blink rate to 0 to eliminate distractions */
2581     objxm_obj_set_ui_arg(obj, AB_ARG_INT, XmNblinkRate, 0);
2582     return 0;
2583 }
2584
2585 static int
2586 termp_post_inst(
2587     ABObj       obj,
2588     OBJXM_CONFIG_TYPE ctype
2589 )
2590 {
2591     ABObj       paneObj = (ABObj) NULL,
2592                 sbObj = (ABObj) NULL;
2593
2594     /* If Scrollable TermPane, hook up vertical scrollbar to Term widget */
2595     if (obj_has_vscrollbar(obj))
2596     {
2597         sbObj = objxm_comp_get_subobj(obj_get_root(obj), AB_CFG_SCROLLBAR_OBJ);
2598         paneObj = objxm_comp_get_subobj(obj_get_root(obj), AB_CFG_OBJECT_OBJ);
2599
2600         objxm_obj_set_widget_ui_arg(paneObj, ctype, DtNverticalScrollBar, sbObj);
2601         obj_set_flag(obj, AttrChangedFlag);
2602     }
2603
2604     return 0;
2605 }
2606
2607 static int
2608 textp_set_args(
2609     ABObj       obj,
2610     OBJXM_CONFIG_TYPE ctype
2611 )
2612 {
2613     AB_SCROLLBAR_POLICY vsb_policy, hsb_policy;
2614     ABObj               tx_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2615     ABObj               sz_obj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);
2616     ABObj               xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
2617     ABObj               sw_obj;
2618     ABObj               parent; /* ABObj parent NOT config parent */
2619     STRING              strval;
2620     int                 value;
2621
2622     objxm_comp_set_read_only_args(obj, ctype);
2623     objxm_comp_set_border_args(obj, ctype);
2624
2625     if ((value = obj_get_num_rows(obj)) != -1)
2626         objxm_obj_set_ui_arg(tx_obj, AB_ARG_INT, XmNrows, value);
2627
2628     if ((value = obj_get_num_columns(obj)) != -1)
2629         objxm_obj_set_ui_arg(tx_obj, AB_ARG_INT, XmNcolumns, value);
2630
2631     vsb_policy = obj_get_vscrollbar_policy(obj);
2632     hsb_policy = obj_get_hscrollbar_policy(obj);
2633
2634     /* Check vertical scrollbar to determine if scrolling is enabled.
2635      * The presence of a Horizontal scrollbar is then determined based
2636      * on whether word-wrap is set or not.
2637      */
2638     if (obj_has_vscrollbar(obj))
2639     {
2640         objxm_obj_set_ui_arg(tx_obj, AB_ARG_BOOLEAN, XmNscrollVertical,
2641                 vsb_policy != AB_SCROLLBAR_NEVER);
2642         objxm_obj_set_ui_arg(tx_obj, AB_ARG_BOOLEAN, XmNscrollHorizontal,
2643                 hsb_policy != AB_SCROLLBAR_NEVER);
2644
2645         sw_obj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);
2646
2647         objxm_obj_set_literal_ui_arg(sw_obj, ctype,
2648                         XmNscrollingPolicy, XmAPPLICATION_DEFINED);
2649         objxm_obj_set_literal_ui_arg(sw_obj, ctype,
2650                         XmNvisualPolicy,    XmVARIABLE);
2651         objxm_obj_set_literal_ui_arg(sw_obj, ctype,
2652                         XmNscrollBarDisplayPolicy, XmSTATIC);
2653
2654         objxm_obj_set_literal_ui_arg(sw_obj, ctype,
2655                                      XmNwidth, obj_get_textpane_height(sw_obj));
2656         objxm_obj_set_literal_ui_arg(sw_obj, ctype,
2657                                      XmNheight, obj_get_textpane_width(sw_obj));
2658     }
2659
2660     objxm_obj_set_literal_ui_arg(tx_obj, ctype, XmNeditMode, XmMULTI_LINE_EDIT);
2661     objxm_obj_set_ui_arg(tx_obj, AB_ARG_BOOLEAN, XmNwordWrap, obj->info.text.word_wrap);
2662
2663     if ((strval = obj_get_initial_value_string(obj)) != NULL)
2664         objxm_obj_set_ui_arg(tx_obj, AB_ARG_STRING, XmNvalue, strval);
2665     else /* strval == NULL, make sure the text pane is clean */
2666         if (ctype == OBJXM_CONFIG_BUILD)
2667             objxm_obj_set_ui_arg(tx_obj, AB_ARG_STRING, XmNvalue, Util_empty_string);
2668
2669     /* Need to set additional resources if child of panedWindow */
2670     parent = obj_get_parent(obj);
2671     if ((obj_get_type(parent) == AB_TYPE_CONTAINER) &&
2672         (obj_get_container_type(parent) == AB_CONT_PANED))
2673     {
2674         /* Set PanedWindow Contraint Resources */
2675         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpaneMinimum,
2676                                 obj_get_pane_min(obj));
2677         objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNpaneMaximum,
2678                                 obj_get_pane_max(obj));
2679     }
2680     return 0;
2681 }
2682
2683
2684 /*
2685  ***********************
2686  ** List Methods      **
2687  ***********************
2688  */
2689 static int
2690 list_xmconfig(
2691     ABObj    obj
2692 )
2693 {
2694     ABObj       sw_obj, l_obj;
2695     ABObj       lbl_obj = NULL;
2696
2697     obj->part_of = obj;
2698
2699     if (obj_has_label(obj)) /* Has Label */
2700     {
2701         /* Set Container RootObj class */
2702         obj_set_class_name(obj, _xmRowColumn);
2703
2704         /* Create Label SubObj */
2705         lbl_obj = obj_create(AB_TYPE_LABEL, NULL);
2706         lbl_obj->part_of = obj;
2707         obj_set_class_name(lbl_obj, _xmLabel);
2708
2709         /* Create ScrolledWindow SubObj */
2710         sw_obj = obj_create(AB_TYPE_LIST, NULL);
2711         sw_obj->part_of = obj;
2712     }
2713     else /* No Label: Set Container RootObj class */
2714         sw_obj = obj;
2715
2716     obj_set_class_name(sw_obj, _xmScrolledWindow);
2717
2718     /* Create List SubObj */
2719     l_obj = obj_create(AB_TYPE_LIST, NULL);
2720     l_obj->part_of = obj;
2721     obj_set_class_name(l_obj, _xmList);
2722
2723     /* Move Item children to the list SubObj */
2724     obj_move_children(l_obj, obj);
2725
2726     /* Now that Items are moved, parent SubObjs from Root */
2727     if (lbl_obj != NULL)
2728     {
2729         obj_append_child(obj, lbl_obj);
2730         obj_set_unique_name(lbl_obj,
2731             ab_ident_from_name_and_label(obj_get_name(obj), "label"));
2732
2733         obj_append_child(obj, sw_obj);
2734         obj_set_unique_name(sw_obj,
2735             ab_ident_from_name_and_label(obj_get_name(obj), "scrolledwin"));
2736
2737     }
2738     obj_append_child(sw_obj, l_obj);
2739     obj_set_unique_name(l_obj,
2740         ab_ident_from_name_and_label(obj_get_name(obj), "list"));
2741
2742     objxm_comp_config_menu_ref(obj);
2743
2744     return OK;
2745
2746 }
2747
2748 static int
2749 list_unconfig(
2750     ABObj       obj
2751 )
2752 {
2753     ABObj       lbl_obj = NULL;
2754     ABObj       sw_obj  = NULL;
2755     ABObj       l_obj;
2756
2757     objxm_comp_unconfig_menu_ref(obj);
2758
2759     if (obj_has_label(obj))
2760     {
2761         lbl_obj = obj_get_child(obj, 0);
2762         sw_obj  = obj_get_child(obj, 1);
2763         l_obj   = obj_get_child(sw_obj, 0);
2764     }
2765     else /* No Label */
2766         l_obj = obj_get_child(obj, 0);
2767
2768     /* Move children from ListPane SubObj back to Root */
2769     obj_move_children(obj, l_obj);
2770
2771     if (lbl_obj)
2772     {
2773         obj_destroy(lbl_obj);
2774         obj_destroy(sw_obj); /* destroys sw_obj & l_obj */
2775     }
2776     else
2777         obj_destroy(l_obj);
2778
2779     return OK;
2780
2781 }
2782
2783 static ABObj
2784 list_get_config_obj(
2785     ABObj       obj,
2786     AB_CFG_OBJ_TYPE type
2787 )
2788 {
2789     ABObj cfg_obj = NULL;
2790     ABObj l_obj   = NULL;
2791     ABObj lbl_obj = NULL;
2792     ABObj sw_obj  = NULL;
2793     ABObj mr_obj  = NULL;
2794     BOOL  has_label = FALSE;
2795
2796     if (obj_has_label(obj))
2797         has_label = TRUE;
2798
2799     /* Check if 1st child is Menu-ref */
2800     mr_obj = get_menu_ref(obj);
2801
2802     if (has_label)
2803     {
2804         lbl_obj = obj_get_child(obj, mr_obj? 1 : 0);
2805         sw_obj  = obj_get_child(obj, mr_obj? 2 : 1);
2806         l_obj   = obj_get_child(sw_obj, 0);
2807     }
2808     else
2809     {
2810         sw_obj = obj;
2811         l_obj = obj_get_child(sw_obj, mr_obj? 1 : 0);
2812     }
2813
2814     switch(type)
2815     {
2816         case AB_CFG_HELP_OBJ:
2817             cfg_obj = obj;
2818         break;
2819
2820         case AB_CFG_OBJECT_OBJ:
2821         case AB_CFG_PARENT_OBJ:
2822         case AB_CFG_MENU_PARENT_OBJ:
2823             cfg_obj = l_obj;
2824             break;
2825         case AB_CFG_LABEL_OBJ:
2826             cfg_obj = lbl_obj;
2827             break;
2828         case AB_CFG_POSITION_OBJ:
2829         case AB_CFG_SELECT_OBJ:
2830             cfg_obj = obj;
2831             break;
2832         case AB_CFG_MENU_OBJ:
2833             cfg_obj = mr_obj;
2834             break;
2835         case AB_CFG_SCROLLING_OBJ:
2836         case AB_CFG_SIZE_OBJ:
2837             cfg_obj = sw_obj;
2838             break;
2839         case AB_CFG_DND_OBJ:
2840         case AB_CFG_SCROLLBAR_OBJ:
2841         case AB_CFG_STATUS_OBJ:
2842         case AB_CFG_BORDER_OBJ:
2843             cfg_obj = NULL;
2844             break;
2845         default:
2846             util_dprintf(1, "list_get_config_obj: unknown type\n");
2847     }
2848
2849     return(cfg_obj);
2850 }
2851 static int
2852 list_set_args(
2853     ABObj       obj,
2854     OBJXM_CONFIG_TYPE ctype
2855 )
2856 {
2857     int rows;
2858     ABObj       l_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2859     ABObj       sz_obj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);
2860
2861     objxm_comp_set_label_args(obj, ctype);
2862     objxm_comp_set_lbl_pos_args(obj, ctype);
2863
2864     if ((rows = obj_get_num_rows(obj)) != -1)
2865     {
2866         objxm_obj_set_ui_arg(l_obj, AB_ARG_INT, XmNvisibleItemCount, rows);
2867         objxm_obj_remove_ui_arg(sz_obj, XmNheight);
2868     }
2869
2870     objxm_obj_set_selection_arg(l_obj, ctype);
2871
2872     objxm_obj_set_literal_ui_arg(l_obj, ctype, XmNlistSizePolicy,
2873                 obj_get_width(obj) == -1? XmVARIABLE : XmCONSTANT);
2874     objxm_obj_set_literal_ui_arg(l_obj, ctype, XmNscrollBarDisplayPolicy,
2875                 XmSTATIC);
2876 /*
2877     if (obj->width >= 0 && l_obj != NULL)
2878         objxm_obj_set_ui_arg(l_obj, AB_ARG_INT, XmNwidth, (Dimension)obj->width);
2879 */
2880     return 0;
2881 }
2882 static int
2883 list_post_inst(
2884     ABObj       obj,
2885     OBJXM_CONFIG_TYPE ctype
2886 )
2887 {
2888     ABObj       szObj;
2889     ABObj       subObj;
2890
2891     /* If list width is fixed size, we must set it after
2892      * the encompassing ScrolledWindow has been instantiated/managed
2893      */
2894     if (obj_has_label(obj) && obj_get_width(obj) != -1)
2895     {
2896         szObj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);
2897         subObj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2898
2899         if (ctype == OBJXM_CONFIG_BUILD)
2900         {
2901             XtManageChild(objxm_get_widget(subObj));
2902             XtManageChild(objxm_get_widget(szObj));
2903         }
2904
2905         objxm_obj_set_ui_arg(szObj, AB_ARG_INT, XmNwidth,
2906                 (Dimension)obj_get_width(obj));
2907         obj_set_flag(szObj, AttrChangedFlag);
2908     }
2909     return 0;
2910 }
2911
2912
2913 /*
2914  ***********************
2915  ** Menu Methods      **
2916  ***********************
2917  */
2918 static int
2919 menu_xmconfig(
2920     ABObj    obj
2921 )
2922 {
2923     return OK;
2924 }
2925
2926 static int
2927 menu_unconfig(
2928     ABObj       obj
2929 )
2930 {
2931     return OK;
2932 }
2933
2934 static ABObj
2935 menu_get_config_obj(
2936     ABObj       obj,
2937     AB_CFG_OBJ_TYPE type
2938 )
2939 {
2940     ABObj cfg_obj;
2941
2942     switch(type)
2943     {
2944         case AB_CFG_HELP_OBJ:
2945         case AB_CFG_OBJECT_OBJ:
2946         case AB_CFG_POSITION_OBJ:
2947         case AB_CFG_SIZE_OBJ:
2948         case AB_CFG_SELECT_OBJ:
2949         case AB_CFG_PARENT_OBJ:
2950             cfg_obj = obj;
2951             break;
2952         case AB_CFG_DND_OBJ:
2953         case AB_CFG_LABEL_OBJ:
2954         case AB_CFG_MENU_PARENT_OBJ:
2955         case AB_CFG_SCROLLBAR_OBJ:
2956         case AB_CFG_SCROLLING_OBJ:
2957         case AB_CFG_STATUS_OBJ:
2958         case AB_CFG_MENU_OBJ:
2959         case AB_CFG_BORDER_OBJ:
2960             cfg_obj = NULL;
2961             break;
2962         default:
2963             util_dprintf(1, "menu_get_config_obj: unknown type\n");
2964             cfg_obj = NULL;
2965     }
2966     return(cfg_obj);
2967 }
2968
2969 static int
2970 menu_set_args(
2971     ABObj       obj,
2972     OBJXM_CONFIG_TYPE ctype
2973 )
2974 {
2975     ABObj       pobj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);
2976
2977     objxm_obj_set_literal_ui_arg(pobj, ctype, XmNtearOffModel,
2978         obj_get_tearoff(obj)? XmTEAR_OFF_ENABLED : XmTEAR_OFF_DISABLED);
2979
2980     return 0;
2981 }
2982
2983
2984 /*
2985  ***********************
2986  ** MenuBar Methods   **
2987  ***********************
2988  */
2989 static int
2990 menubar_xmconfig(
2991     ABObj    obj
2992 )
2993 {
2994
2995     /* Set MenuShell RootObj class */
2996     obj_set_class_name(obj, _xmRowColumn);
2997
2998     return OK;
2999
3000 }
3001
3002 /* Menubar Unconfig: simple_unconfig */
3003
3004 static int
3005 menubar_set_args(
3006     ABObj       obj,
3007     OBJXM_CONFIG_TYPE ctype
3008 )
3009 {
3010     ABObj       mb_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
3011
3012     objxm_obj_set_literal_ui_arg(mb_obj, ctype, XmNrowColumnType,   XmMENU_BAR);
3013
3014     return 0;
3015 }
3016
3017 static int
3018 menubar_post_inst(
3019     ABObj       obj,
3020     OBJXM_CONFIG_TYPE ctype
3021 )
3022 {
3023     ABObj help_item;
3024     ABObj mwobj = obj_get_parent(obj);
3025
3026     /* Attach Menubar to MainWindow SubObj */
3027     if (ctype == OBJXM_CONFIG_BUILD)
3028     {
3029         /* Area must be Managed before MainWindow resource is set */
3030         XtManageChild(objxm_get_widget(obj));
3031         util_dprintf(3,"MANAGING %s\n", obj_get_name(obj));
3032         XtVaSetValues(objxm_get_widget(mwobj),
3033                 XmNmenuBar,     objxm_get_widget(obj),
3034                 NULL);
3035     }
3036     else
3037     {
3038         objxm_obj_set_widget_ui_arg(mwobj, ctype, XmNmenuBar, obj);
3039         obj_set_flag(mwobj, AttrChangedFlag);
3040     }
3041
3042     /* Find "Help" cascade button and set the resource on the menubar */
3043     if ((help_item = obj_get_menubar_help_item(obj)) != NULL)
3044     {
3045         objxm_obj_set_widget_ui_arg(obj, ctype, XmNmenuHelpWidget, help_item);
3046         obj_set_flag(obj, AttrChangedFlag);
3047     }
3048     return 0;
3049 }
3050
3051
3052 /*
3053  ***********************
3054  ** TextField Methods **
3055  ***********************
3056  */
3057 static int
3058 textf_xmconfig(
3059     ABObj    obj
3060 )
3061 {
3062     objxm_comp_config_labeled_obj(obj, AB_TYPE_TEXT_FIELD, "field", _xmTextField);
3063
3064     return OK;
3065 }
3066
3067 static int
3068 textf_unconfig(
3069     ABObj       obj
3070 )
3071 {
3072     objxm_comp_unconfig_menu_ref(obj);
3073     objxm_comp_unconfig_labeled_obj(obj);
3074
3075     return OK;
3076 }
3077
3078 static ABObj
3079 textf_get_config_obj(
3080     ABObj       obj,
3081     AB_CFG_OBJ_TYPE type
3082 )
3083 {
3084     ABObj cfg_obj;
3085     BOOL  has_label = TRUE;
3086
3087     if (!obj_has_label(obj))
3088         has_label = FALSE;
3089
3090     switch(type)
3091     {
3092         case AB_CFG_HELP_OBJ:
3093             cfg_obj = obj;
3094         break;
3095
3096         case AB_CFG_OBJECT_OBJ:
3097         case AB_CFG_MENU_PARENT_OBJ:
3098         case AB_CFG_SIZE_OBJ:
3099             if (has_label)
3100                 cfg_obj = obj_get_child(obj, 1);
3101             else
3102                 cfg_obj = obj;
3103             break;
3104         case AB_CFG_LABEL_OBJ:
3105             if (has_label)
3106                 cfg_obj = obj_get_child(obj, 0);
3107             else
3108                 cfg_obj = NULL;
3109             break;
3110         case AB_CFG_POSITION_OBJ:
3111         case AB_CFG_SELECT_OBJ:
3112             cfg_obj = obj;
3113             break;
3114         case AB_CFG_DND_OBJ:
3115         case AB_CFG_PARENT_OBJ:
3116         case AB_CFG_SCROLLING_OBJ:
3117         case AB_CFG_STATUS_OBJ:
3118         case AB_CFG_MENU_OBJ:
3119         case AB_CFG_BORDER_OBJ:
3120             cfg_obj = NULL;
3121             break;
3122         default:
3123             util_dprintf(1, "textf_get_config_obj: unknown config-type\n");
3124             cfg_obj = NULL;
3125     }
3126
3127     return(cfg_obj);
3128 }
3129
3130 static int
3131 textf_set_args(
3132     ABObj       obj,
3133     OBJXM_CONFIG_TYPE ctype
3134 )
3135 {
3136     ABObj          tf_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
3137     ABObj          sz_obj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);
3138     int            value;
3139     STRING         valstr;
3140
3141     objxm_comp_set_label_args(obj, ctype);
3142     objxm_comp_set_lbl_pos_args(obj, ctype);
3143     objxm_comp_set_read_only_args(obj, ctype);
3144
3145     if ((value = obj_get_num_columns(obj)) > 0)
3146     {
3147         objxm_obj_set_ui_arg(tf_obj, AB_ARG_INT, XmNcolumns, value);
3148         objxm_obj_remove_ui_arg(sz_obj, XmNwidth);
3149     }
3150     if ((value = obj_get_max_length(obj)) > 0)
3151         objxm_obj_set_ui_arg(tf_obj, AB_ARG_INT, XmNmaxLength, value);
3152
3153     if ((valstr = obj_get_initial_value_string(obj)) != NULL)
3154         objxm_obj_set_ui_arg(tf_obj, AB_ARG_STRING, XmNvalue, valstr);
3155     else /* valstr == NULL, make sure the text field is clean */
3156         if (ctype == OBJXM_CONFIG_BUILD)
3157             objxm_obj_set_ui_arg(tf_obj, AB_ARG_STRING, XmNvalue, Util_empty_string);
3158
3159     return 0;
3160 }
3161
3162 static ABObj
3163 get_menu_ref(
3164     ABObj       obj
3165 )
3166 {
3167     ABObj first_child;
3168
3169     first_child = obj_get_child(obj, 0);
3170     if (first_child && obj_is_menu_ref(first_child))
3171         return first_child;
3172
3173     return NULL;
3174
3175 }
3176
3177
3178 /*
3179  *******************
3180  * Separator methods
3181  *******************
3182  */
3183 static ABObj
3184 separator_get_config_obj(
3185     ABObj       obj,
3186     AB_CFG_OBJ_TYPE type
3187 )
3188 {
3189     ABObj cfg_obj = NULL;
3190
3191     switch(type)
3192     {
3193         case AB_CFG_HELP_OBJ:
3194             cfg_obj = obj;
3195         break;
3196
3197         case AB_CFG_OBJECT_OBJ:
3198         case AB_CFG_POSITION_OBJ:
3199         case AB_CFG_SIZE_OBJ:
3200         case AB_CFG_SCROLLBAR_OBJ:
3201         case AB_CFG_SELECT_OBJ:
3202         case AB_CFG_PARENT_OBJ:
3203         case AB_CFG_BORDER_OBJ:
3204             cfg_obj = obj;
3205             break;
3206
3207         case AB_CFG_DND_OBJ:
3208         case AB_CFG_LABEL_OBJ:
3209         case AB_CFG_MENU_PARENT_OBJ:
3210         case AB_CFG_MENU_OBJ:
3211         case AB_CFG_SCROLLING_OBJ:
3212         case AB_CFG_STATUS_OBJ:
3213             break;
3214
3215         default:
3216             util_dprintf(1, "simple_get_config_obj: unsupported config-type\n");
3217     }
3218
3219     return(cfg_obj);
3220 }
3221
3222
3223 static int
3224 separator_set_args(
3225     ABObj       obj,
3226     OBJXM_CONFIG_TYPE ctype
3227 )
3228 {
3229     ABObj          o_obj;
3230
3231     objxm_comp_set_label_args(obj, ctype);
3232     objxm_comp_set_lbl_pos_args(obj, ctype);
3233
3234     o_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
3235
3236     objxm_obj_set_orientation_arg(obj, ctype);
3237     objxm_obj_set_line_style_arg(obj, ctype);
3238
3239     return 0;
3240 }
3241
3242 /*
3243  *******************
3244  * SpinBox methods
3245  *******************
3246  */
3247 static int
3248 spin_box_xmconfig(
3249     ABObj    obj
3250 )
3251 {
3252     objxm_comp_config_labeled_obj(obj, AB_TYPE_SPIN_BOX, "field", _dtSpinBox);
3253
3254     return OK;
3255 }
3256
3257 static int
3258 spin_box_unconfig(
3259     ABObj       obj
3260 )
3261 {
3262     objxm_comp_unconfig_labeled_obj(obj);
3263
3264     return OK;
3265 }
3266
3267 static ABObj
3268 spin_box_get_config_obj(
3269     ABObj       obj,
3270     AB_CFG_OBJ_TYPE type
3271 )
3272 {
3273     ABObj cfg_obj = NULL;
3274     BOOL  has_label = FALSE;
3275
3276     if (obj_has_label(obj))
3277         has_label = TRUE;
3278
3279     switch(type)
3280     {
3281         case AB_CFG_HELP_OBJ:
3282             cfg_obj = obj;
3283             break;
3284         case AB_CFG_OBJECT_OBJ:
3285         case AB_CFG_SIZE_OBJ:
3286         case AB_CFG_PARENT_OBJ:
3287             cfg_obj = has_label? obj_get_child(obj, 1) : obj;
3288             break;
3289         case AB_CFG_LABEL_OBJ:
3290             cfg_obj = has_label? obj_get_child(obj, 0) : NULL;
3291             break;
3292         case AB_CFG_POSITION_OBJ:
3293         case AB_CFG_SELECT_OBJ:
3294             cfg_obj = obj;
3295             break;
3296         case AB_CFG_DND_OBJ:
3297         case AB_CFG_SCROLLING_OBJ:
3298         case AB_CFG_STATUS_OBJ:
3299         case AB_CFG_MENU_OBJ:
3300         case AB_CFG_BORDER_OBJ:
3301         case AB_CFG_MENU_PARENT_OBJ:
3302             cfg_obj = NULL;
3303             break;
3304         default:
3305             util_dprintf(1, "spin_box_get_config_obj: unsupported config-type\n");
3306     }
3307     return(cfg_obj);
3308 }
3309
3310
3311 static int
3312 spin_box_set_args(
3313     ABObj       obj,
3314     OBJXM_CONFIG_TYPE ctype
3315 )
3316 {
3317     ABObj       sb_obj;
3318     int         num_items;
3319     int         i;
3320
3321     objxm_comp_set_label_args(obj, ctype);
3322     objxm_comp_set_lbl_pos_args(obj, ctype);
3323
3324     sb_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
3325
3326     /* SpinBox Type */
3327     objxm_obj_set_literal_ui_arg(sb_obj, ctype, DtNspinBoxChildType,
3328           obj_get_text_type(obj) == AB_TEXT_NUMERIC? DtNUMERIC : XmSTRING);
3329
3330     /* Arrow Style */
3331     objxm_obj_set_arrow_style_arg(sb_obj, ctype);
3332
3333     if (obj_get_text_type(obj) == AB_TEXT_NUMERIC)
3334     {
3335         /* Value Range */
3336         objxm_obj_set_ui_arg(sb_obj, AB_ARG_INT, DtNminimumValue,
3337                 obj_get_min_value(obj));
3338         objxm_obj_set_ui_arg(sb_obj, AB_ARG_INT, DtNmaximumValue,
3339                 obj_get_max_value(obj));
3340
3341         /* Initial Value */
3342         objxm_obj_set_ui_arg(sb_obj, AB_ARG_INT, DtNposition,
3343                 obj_get_initial_value_int(obj));
3344
3345         /* Increment/Decimal Points */
3346         objxm_obj_set_ui_arg(sb_obj, AB_ARG_INT, DtNincrementValue,
3347                 obj_get_increment(obj));
3348         objxm_obj_set_ui_arg(sb_obj, AB_ARG_INT, XmNdecimalPoints,
3349                 obj_get_decimal_points(obj));
3350     }
3351     else if (ctype == OBJXM_CONFIG_CODEGEN) /* String List */
3352     {
3353         /* Set Initially Selected Item - can only do this for generated code
3354          * because in Build mode, the items might not be created yet!
3355          */
3356         num_items = obj_get_num_items(obj);
3357         for (i = 0; i < num_items; i++)
3358             if (obj_is_initially_selected(obj_get_item(obj, i)))
3359             {
3360                 objxm_obj_set_ui_arg(sb_obj, AB_ARG_INT, DtNposition, i);
3361                 break;
3362             }
3363     }
3364     return 0;
3365 }
3366
3367 /*
3368  *******************
3369  * ComboBox methods
3370  *******************
3371  */
3372 static int
3373 combo_box_xmconfig(
3374     ABObj    obj
3375 )
3376 {
3377     objxm_comp_config_labeled_obj(obj, AB_TYPE_COMBO_BOX, "field", _dtComboBox);
3378
3379     return OK;
3380 }
3381
3382 static int
3383 combo_box_unconfig(
3384     ABObj       obj
3385 )
3386 {
3387     objxm_comp_unconfig_labeled_obj(obj);
3388
3389     return OK;
3390 }
3391
3392 static ABObj
3393 combo_box_get_config_obj(
3394     ABObj       obj,
3395     AB_CFG_OBJ_TYPE type
3396 )
3397 {
3398     ABObj cfg_obj = NULL;
3399     BOOL  has_label = FALSE;
3400
3401     if (obj_has_label(obj))
3402         has_label = TRUE;
3403
3404     switch(type)
3405     {
3406         case AB_CFG_HELP_OBJ:
3407             cfg_obj = obj;
3408         break;
3409
3410         case AB_CFG_OBJECT_OBJ:
3411         case AB_CFG_PARENT_OBJ:
3412         case AB_CFG_SIZE_OBJ:
3413             cfg_obj = has_label? obj_get_child(obj, 1) : obj;
3414             break;
3415         case AB_CFG_LABEL_OBJ:
3416             cfg_obj = has_label? obj_get_child(obj, 0) : NULL;
3417             break;
3418         case AB_CFG_POSITION_OBJ:
3419         case AB_CFG_SELECT_OBJ:
3420             cfg_obj = obj;
3421             break;
3422         case AB_CFG_DND_OBJ:
3423         case AB_CFG_SCROLLING_OBJ:
3424         case AB_CFG_STATUS_OBJ:
3425         case AB_CFG_MENU_OBJ:
3426         case AB_CFG_BORDER_OBJ:
3427         case AB_CFG_MENU_PARENT_OBJ:
3428             cfg_obj = NULL;
3429             break;
3430         default:
3431             util_dprintf(1, "combo_box_get_config_obj: unsupported config-type\n");
3432     }
3433
3434     return(cfg_obj);
3435 }
3436
3437
3438 static int
3439 combo_box_set_args(
3440     ABObj       obj,
3441     OBJXM_CONFIG_TYPE ctype
3442 )
3443 {
3444     objxm_comp_set_label_args(obj, ctype);
3445     objxm_comp_set_lbl_pos_args(obj, ctype);
3446     objxm_comp_set_read_only_args(obj, ctype);
3447
3448     return 0;
3449 }
3450
3451 static int
3452 post_set_size(
3453     ABObj       obj,
3454     OBJXM_CONFIG_TYPE   ctype
3455 )
3456 {
3457     ABObj       szObj;
3458
3459     szObj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);
3460
3461     /* For objects which don't honor size requests at create-time
3462      * (SpinBox, ComboBox), we need to set the size after instantiation...
3463      */
3464     if (obj_get_width(obj) != -1)
3465     {
3466         objxm_obj_set_ui_arg(szObj, AB_ARG_INT, XmNwidth, obj_get_width(obj));
3467         obj_set_flag(szObj, AttrChangedFlag);
3468     }
3469     if (obj_get_height(obj) != -1)
3470     {
3471         objxm_obj_set_ui_arg(szObj, AB_ARG_INT, XmNheight, obj_get_height(obj));
3472         obj_set_flag(szObj, AttrChangedFlag);
3473     }
3474     return 0;
3475
3476 }
3477
3478 /*
3479  *******************
3480  * Slider methods
3481  *******************
3482  */
3483 static int
3484 scale_xmconfig(
3485     ABObj    obj
3486 )
3487 {
3488     objxm_comp_config_labeled_obj(obj, AB_TYPE_SCALE, "scale", _xmScale);
3489
3490     return OK;
3491 }
3492
3493 static int
3494 scale_unconfig(
3495     ABObj       obj
3496 )
3497 {
3498     objxm_comp_unconfig_labeled_obj(obj);
3499
3500     return OK;
3501 }
3502
3503 static ABObj
3504 scale_get_config_obj(
3505     ABObj       obj,
3506     AB_CFG_OBJ_TYPE type
3507 )
3508 {
3509     ABObj cfg_obj = NULL;
3510     BOOL  has_label = FALSE;
3511
3512     if (obj_has_label(obj))
3513         has_label = TRUE;
3514
3515     switch(type)
3516     {
3517         case AB_CFG_HELP_OBJ:
3518             cfg_obj = obj;
3519         break;
3520
3521         case AB_CFG_OBJECT_OBJ:
3522         case AB_CFG_SIZE_OBJ:
3523             cfg_obj = has_label? obj_get_child(obj, 1) : obj;
3524             break;
3525         case AB_CFG_LABEL_OBJ:
3526             cfg_obj = has_label? obj_get_child(obj, 0) : NULL;
3527             break;
3528         case AB_CFG_POSITION_OBJ:
3529         case AB_CFG_SELECT_OBJ:
3530             cfg_obj = obj;
3531             break;
3532
3533         case AB_CFG_DND_OBJ:
3534         case AB_CFG_MENU_PARENT_OBJ:
3535         case AB_CFG_PARENT_OBJ:
3536         case AB_CFG_SCROLLING_OBJ:
3537         case AB_CFG_STATUS_OBJ:
3538         case AB_CFG_MENU_OBJ:
3539         case AB_CFG_BORDER_OBJ:
3540             cfg_obj = NULL;
3541             break;
3542
3543         default:
3544             util_dprintf(1, "scale_get_config_obj: unknown config-type\n");
3545             cfg_obj = NULL;
3546     }
3547
3548     return(cfg_obj);
3549 }
3550
3551 static int
3552 scale_set_args(
3553     ABObj       obj,
3554     OBJXM_CONFIG_TYPE ctype
3555 )
3556 {
3557     ABObj          o_obj;
3558
3559     objxm_comp_set_label_args(obj, ctype);
3560     objxm_comp_set_lbl_pos_args(obj, ctype);
3561     objxm_comp_set_read_only_args(obj, ctype);
3562
3563     o_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
3564
3565     /* Orientation */
3566     objxm_obj_set_orientation_arg(o_obj, ctype);
3567
3568     /* Direction */
3569     objxm_obj_set_direction_arg(o_obj, ctype);
3570
3571     /* Value Range */
3572     objxm_obj_set_ui_arg(o_obj, AB_ARG_INT, XmNminimum, obj_get_min_value(obj));
3573     objxm_obj_set_ui_arg(o_obj, AB_ARG_INT, XmNmaximum, obj_get_max_value(obj));
3574
3575     /* Increment/Decimal Points */
3576     objxm_obj_set_ui_arg(o_obj, AB_ARG_INT, XmNscaleMultiple,
3577                 obj_get_increment(obj));
3578     objxm_obj_set_ui_arg(o_obj, AB_ARG_INT, XmNdecimalPoints,
3579                 obj_get_decimal_points(obj));
3580
3581     /* Initial Value/Show Value */
3582     objxm_obj_set_ui_arg(o_obj, AB_ARG_INT, XmNvalue,
3583                 obj_get_initial_value_int(obj));
3584     objxm_obj_set_ui_arg(o_obj, AB_ARG_BOOLEAN, XmNshowValue,
3585                 obj_get_show_value(obj));
3586
3587     return 0;
3588 }
3589
3590 /*
3591  **********************
3592  * File Chooser methods
3593  **********************
3594  */
3595 static int
3596 fchooser_xmconfig(
3597     ABObj    obj
3598 )
3599 {
3600     ABObj               pwobj, workobj;
3601     ABObj               apobj = NULL;
3602
3603     /* DialogShell */
3604     obj->part_of = obj;
3605     obj_set_class_name(obj, _xmDialogShell);
3606
3607     /* Create PanedWindow SubObj */
3608     pwobj = obj_create(AB_TYPE_CONTAINER, NULL);
3609     pwobj->part_of = obj;
3610     obj_set_class_name(pwobj, _xmPanedWindow);
3611     obj_set_flag(pwobj, NoCodeGenFlag);
3612
3613     /* Create WorkArea (FileSelectionBox) SubObj. Can't make it
3614      * type AB_TYPE_FILE_CHOOSER because it will be parented off
3615      * of AB_toplevel in xm_instantiate_obj(), which we don't
3616      * want.
3617      */
3618     workobj = obj_create(AB_TYPE_CONTAINER, NULL);
3619     workobj->part_of = obj;
3620     obj_append_child(pwobj, workobj);
3621     obj_set_class_name(workobj, _xmFileSelectionBox);
3622
3623     obj_append_child(obj, pwobj);
3624     obj_set_unique_name(pwobj,
3625         ab_ident_from_name_and_label(obj_get_name(obj), "panedwin"));
3626     obj_set_unique_name(workobj,
3627         ab_ident_from_name_and_label(obj_get_name(obj), "fsb"));
3628
3629     xmconfig_window_select_area(obj, pwobj);
3630
3631     return OK;
3632 }
3633
3634 static int
3635 box_unconfig(
3636     ABObj       obj
3637 )
3638 {
3639     ABObj       pwobj;
3640
3641     pwobj = obj_get_child(obj, 0);
3642     obj_destroy(pwobj);
3643
3644     return OK;
3645 }
3646
3647 static ABObj
3648 box_get_config_obj(
3649     ABObj       obj,
3650     AB_CFG_OBJ_TYPE type
3651 )
3652 {
3653     ABObj cfg_obj = NULL;
3654     ABObj modobj = NULL;
3655     ABObj selobj  = NULL;
3656     ABObj pwobj, msgobj, childobj;
3657
3658     pwobj = obj_get_child(obj, 0);
3659
3660     switch(type)
3661     {
3662         case AB_CFG_WINDOW_PW_OBJ:
3663             cfg_obj = pwobj;
3664             break;
3665         case AB_CFG_OBJECT_OBJ:
3666         {
3667             /* Return the FileSelectionBox child */
3668             cfg_obj = obj_get_child(pwobj, 0);
3669             break;
3670         }
3671         case AB_CFG_POSITION_OBJ:
3672         case AB_CFG_LABEL_OBJ:
3673             /* Return the shell object (label = title) */
3674             cfg_obj = obj;
3675             break;
3676         case AB_CFG_SIZE_OBJ:
3677         case AB_CFG_STATUS_OBJ:
3678         case AB_CFG_SELECT_OBJ:
3679         {
3680             int         num_children = 0, i;
3681
3682             if (type == AB_CFG_SIZE_OBJ)
3683                 cfg_obj = pwobj;
3684             else
3685             {
3686                 num_children = obj_get_num_children(pwobj);
3687                 /* Search through immediate children of the Shell-container
3688                  * and find the WorkArea & Status SubObjs if they exist
3689                  */
3690                 for (i = 0; i < num_children; i++)
3691                 {
3692                     childobj = obj_get_child(pwobj, i);
3693                     if (obj_is_label(childobj) && childobj->part_of == obj)
3694                     {
3695                         msgobj = childobj;
3696                         modobj = obj_get_child(msgobj, 0);
3697                         selobj = obj_get_child(msgobj, 1);
3698                     }
3699                 }
3700                 if (type == AB_CFG_SELECT_OBJ)
3701                     cfg_obj = selobj;
3702                 else if (type == AB_CFG_STATUS_OBJ)
3703                     cfg_obj = modobj;
3704
3705             }
3706             break;
3707         }
3708
3709         case AB_CFG_DND_OBJ:
3710         case AB_CFG_HELP_OBJ:
3711         case AB_CFG_MENU_OBJ:
3712         case AB_CFG_BORDER_OBJ:
3713         case AB_CFG_PARENT_OBJ:
3714         case AB_CFG_MENU_PARENT_OBJ:
3715             cfg_obj = NULL;
3716             break;
3717
3718         default:
3719             if (util_get_verbosity() > 0)
3720                 fprintf(stderr,"box_get_config_obj: unsupported config-type\n");
3721             cfg_obj = NULL;
3722     }
3723
3724     return(cfg_obj);
3725 }
3726
3727
3728 static int
3729 fchooser_set_args(
3730     ABObj       obj,
3731     OBJXM_CONFIG_TYPE ctype
3732 )
3733 {
3734     AB_FILE_TYPE_MASK   ftm = AB_FILE_TYPE_MASK_UNDEF;
3735     STRING              label = NULL, str = NULL;
3736     ABObj               fsb_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
3737     ABObj               lbl_obj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
3738     ABObj               pwobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_PW_OBJ);
3739     BOOL                cgen_args;
3740     XtArgVal            valstr;
3741
3742     /* Shell Resources */
3743     if ((label = obj_get_label(obj)) != NULL)
3744         objxm_obj_set_ui_arg(lbl_obj, AB_ARG_STRING, XmNtitle, label);
3745     objxm_obj_set_ui_arg(lbl_obj, AB_ARG_BOOLEAN, XmNallowShellResize, TRUE);
3746
3747     /* PanedWindow Resources */
3748     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNmarginWidth, 0);
3749     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNmarginHeight, 0);
3750     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNspacing, 0);
3751     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNsashHeight, 1);
3752     objxm_obj_set_ui_arg(pwobj, AB_ARG_INT, XmNsashWidth, 1);
3753
3754     cgen_args = (ctype == OBJXM_CONFIG_CODEGEN? TRUE : FALSE);
3755
3756     /* FileSelectionBox Resources */
3757     str = obj_get_filter_pattern(obj);
3758     if (!util_strempty(str))
3759     {
3760         if (cgen_args)
3761             valstr = (XtArgVal) istr_create(str);
3762         else
3763             valstr = (XtArgVal) objxm_str_to_xmstr(ObjxmP_toplevel, str);
3764         objxm_obj_set_ui_arg(fsb_obj, AB_ARG_XMSTRING, XmNpattern, valstr);
3765     }
3766
3767     str = obj_get_directory(obj);
3768     if (!util_strempty(str))
3769     {
3770         if (cgen_args)
3771             valstr = (XtArgVal) istr_create(str);
3772         else
3773             valstr = (XtArgVal) objxm_str_to_xmstr(ObjxmP_toplevel, str);
3774         objxm_obj_set_ui_arg(fsb_obj, AB_ARG_XMSTRING, XmNdirectory, valstr);
3775     }
3776
3777     str = obj_get_ok_label(obj);
3778     if (!util_strempty(str))
3779     {
3780         if (cgen_args)
3781             valstr = (XtArgVal) istr_create(str);
3782         else
3783             valstr = (XtArgVal) objxm_str_to_xmstr(ObjxmP_toplevel, str);
3784         objxm_obj_set_ui_arg(fsb_obj, AB_ARG_XMSTRING, XmNokLabelString, valstr);
3785     }
3786
3787     objxm_obj_set_ui_arg(fsb_obj, AB_ARG_BOOLEAN,
3788         XmNautoUnmanage, obj_get_auto_dismiss(obj)? TRUE : FALSE);
3789
3790     ftm = obj_get_file_type_mask(obj);
3791     switch (ftm)
3792     {
3793         case AB_FILE_REGULAR:
3794             objxm_obj_set_literal_ui_arg(fsb_obj, ctype, XmNfileTypeMask,
3795                                         XmFILE_REGULAR);
3796             break;
3797         case AB_FILE_DIRECTORY:
3798             objxm_obj_set_literal_ui_arg(fsb_obj, ctype, XmNfileTypeMask,
3799                                         XmFILE_DIRECTORY);
3800             break;
3801         case AB_FILE_ANY:
3802             objxm_obj_set_literal_ui_arg(fsb_obj, ctype, XmNfileTypeMask,
3803                                         XmFILE_ANY_TYPE);
3804             break;
3805     }
3806
3807     /* Set the interface name and select-state on the footer */
3808     if (ctype == OBJXM_CONFIG_BUILD)
3809         set_window_select_area_args(obj);
3810
3811     return 0;
3812 }
3813
3814 static int
3815 fchooser_post_inst(
3816     ABObj               obj,
3817     OBJXM_CONFIG_TYPE   ctype
3818 )
3819 {
3820     Widget      dir_list = NULL,
3821                 files_list = NULL,
3822                 fselnbox = NULL;
3823     ABObj       fsb_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
3824
3825     if (ctype == OBJXM_CONFIG_BUILD)
3826     {
3827         post_inst_window_select_area(obj);
3828
3829         fselnbox = objxm_get_widget(fsb_obj);
3830         clear_fchooser_fields(fselnbox);
3831
3832         dir_list = XmFileSelectionBoxGetChild(fselnbox, XmDIALOG_DIR_LIST);
3833         if (dir_list)
3834             XmListDeleteAllItems(dir_list);
3835
3836         files_list = XmFileSelectionBoxGetChild(fselnbox, XmDIALOG_LIST);
3837         if (files_list)
3838             XmListDeleteAllItems(files_list);
3839     }
3840     return 0;
3841 }
3842
3843 static void
3844 clear_fchooser_fields(
3845     Widget      widget
3846 )
3847 {
3848     WidgetList  children = NULL;
3849     Cardinal    numChild = (Cardinal) 0;
3850     int         i;
3851
3852     if (widget == NULL) return;
3853
3854     XtVaGetValues(widget,
3855                         XmNnumChildren, &numChild,
3856                         XmNchildren, &children,
3857                 NULL);
3858
3859     for (i = 0; i < (int)numChild; i++)
3860     {
3861         if (XtClass(children[i]) == xmTextFieldWidgetClass)
3862         {
3863             XmTextFieldSetString(children[i], "");
3864         }
3865         else if (XtIsComposite(children[i]))
3866         {
3867             clear_fchooser_fields(children[i]);
3868         }
3869     }
3870 }
3871
3872 /*
3873  **********************
3874  * Paned Window methods
3875  **********************
3876  */
3877 static ABObj
3878 panedwin_get_config_obj(
3879     ABObj       obj,
3880     AB_CFG_OBJ_TYPE type
3881 )
3882 {
3883     ABObj cfg_obj = NULL;
3884
3885     switch(type)
3886     {
3887         case AB_CFG_OBJECT_OBJ:
3888         case AB_CFG_HELP_OBJ:
3889         case AB_CFG_POSITION_OBJ:
3890         case AB_CFG_SIZE_OBJ:
3891         case AB_CFG_SELECT_OBJ:
3892         case AB_CFG_MENU_PARENT_OBJ:
3893         case AB_CFG_PARENT_OBJ:
3894             cfg_obj = obj;
3895             break;
3896         case AB_CFG_DND_OBJ:
3897         case AB_CFG_LABEL_OBJ:
3898         case AB_CFG_MENU_OBJ:
3899         case AB_CFG_SCROLLBAR_OBJ:
3900         case AB_CFG_SCROLLING_OBJ:
3901         case AB_CFG_STATUS_OBJ:
3902         case AB_CFG_BORDER_OBJ:
3903             break;
3904         default:
3905             util_dprintf(1, "panedwin_get_config_obj: unsupported config-type\n");
3906     }
3907
3908     return(cfg_obj);
3909 }