2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
25 * $XConsortium: objxm_args.c /main/5 1996/10/02 15:33:46 drk $
27 * @(#)objxm_args.c 1.99 28 Apr 1995
29 * RESTRICTED CONFIDENTIAL INFORMATION:
31 * The information in this document is subject to special
32 * restrictions in a confidential disclosure agreement between
33 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
34 * document outside HP, IBM, Sun, USL, SCO, or Univel without
35 * Sun's specific written approval. This document and all copies
36 * and derivative works thereof must be returned or destroyed at
39 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
45 ***********************************************************************
46 * objxm_args.c - routines to manage Motif Resource ArgLists
48 ***********************************************************************
53 #include <X11/Intrinsic.h>
54 #include <Xm/ToggleB.h>
56 #include <Xm/MessageB.h>
57 #include <Dt/SpinBox.h>
58 #include <Dt/ComboBox.h>
59 #include <ab_private/trav.h>
62 /*************************************************************************
64 ** Private Function Declarations **
66 *************************************************************************/
68 int objxmP_set_attachment_arg(
70 OBJXM_CONFIG_TYPE ctype,
75 /*************************************************************************
77 ** Public Function Definitions **
79 *************************************************************************/
82 * Create Resource arglists for all objects in a tree
86 objxm_tree_set_ui_args(
88 OBJXM_CONFIG_TYPE ctype,
96 * We only need to call set_args on salient objects,
97 * so we're going to skip the others to improve speed
99 for (trav_open(&trav, root, AB_TRAV_SALIENT);
100 (obj= trav_next(&trav)) != NULL; )
102 if (!obj_has_flag(obj, CreateAttrsFlag))
103 objxm_comp_set_ui_args(obj, ctype, replace);
110 * Remove Resource arglists for all objects in a tree
114 objxm_tree_remove_ui_args(
116 OBJXM_CONFIG_TYPE ctype
123 * We only need to call set_args on salient objects,
124 * so we're going to skip the others to improve speed
126 for (trav_open(&trav, root, AB_TRAV_SALIENT);
127 (obj= trav_next(&trav)) != NULL; )
129 objxm_obj_remove_all_ui_args(obj, ctype);
130 obj_clear_flag(obj, CreateAttrsFlag);
137 * Create Resource arglists for a Composite Object hierarchy
139 * Assumes: obj is a composite root
142 objxm_comp_set_ui_args(
144 OBJXM_CONFIG_TYPE ctype,
148 ABObj xy_obj = NULL, /* position object */
149 s_obj = NULL; /* size object */
150 assert(obj_is_root(obj));
152 /* projects, modules and composite-subobjs not allowed */
153 if ((!obj_is_ui(obj)) || obj_is_project(obj) || obj_is_module(obj) ||
154 obj_is_message(obj) || obj_is_sub(obj))
158 "Building Resource List for %s\n", util_strsafe(obj_get_name(obj)));
160 xy_obj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
161 s_obj = objxm_comp_get_subobj(obj, AB_CFG_SIZE_OBJ);
163 /* Set resources common to all object types
166 objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNx, obj->x);
169 objxm_obj_set_ui_arg(xy_obj, AB_ARG_INT, XmNy, obj->y);
171 if (obj->width >= 0 && s_obj != NULL)
172 objxm_obj_set_ui_arg(s_obj, AB_ARG_INT, XmNwidth, (Dimension)obj->width);
174 if (obj->height >= 0)
175 objxm_obj_set_ui_arg(s_obj, AB_ARG_INT, XmNheight, (Dimension)obj->height);
177 /* If widget is already instantiated, set colors now, else wait until
178 * the post-instantiate phase so that the correct widget-id gets associated
179 * with the allocated colors in the Xt resource cache.
181 if (objxm_get_widget(obj) != NULL)
182 objxm_comp_set_color_args(obj, ctype, ObjxmBackground | ObjxmForeground);
184 /* Only Set XmNsensitive if it is False */
186 * CMVC#6399 - XmNsensitive is getting set on the menu, rather than
187 * on the insensitive item. The position config obj for the item is
188 * considered to be the parent of the item, which does not work in
189 * this case. In general, I think the position config obj should not
190 * be the parent, but the item, itself. -dunn 3/3/95
192 if (ctype == OBJXM_CONFIG_CODEGEN)
194 if (!obj_is_initially_active(obj))
196 objxm_obj_set_ui_arg(obj, AB_ARG_BOOLEAN, XmNsensitive, False);
200 /* Call method which sets resources specific to the object-type
202 objxmP_comp_set_type_args(obj, ctype);
204 /* Code Generation also requires that Attachment Args and
205 * Post-instantiation arg are generated on the first pass
207 if (ctype == OBJXM_CONFIG_CODEGEN)
209 objxm_comp_set_attachment_args(obj, ctype);
210 objxmP_comp_type_post_instantiate(obj, ctype);
211 obj_comp_clear_flag(obj, XmCfgForBuildFlag);
212 obj_comp_set_flag(obj, XmCfgForCodeFlag);
216 obj_comp_clear_flag(obj, XmCfgForCodeFlag);
217 obj_comp_set_flag(obj, XmCfgForBuildFlag);
219 obj_comp_set_flag(obj, CreateAttrsFlag);
225 objxm_tree_set_post_inst_args(
227 OBJXM_CONFIG_TYPE ctype
233 for (trav_open(&trav, root, AB_TRAV_UI);
234 (obj= trav_next(&trav)) != NULL; )
236 objxm_obj_set_post_inst_args(obj, ctype);
243 objxm_obj_set_post_inst_args(
245 OBJXM_CONFIG_TYPE ctype
248 if (obj_is_salient(obj))
250 objxmP_comp_type_post_instantiate(obj, ctype);
252 /* Want to ensure allocated color is associated with correct widget-id
253 * in Xt string-to-pixel converter cache, so need to set color resources
254 * AFTER widget is instantiated.
256 objxm_comp_set_color_args(obj, ctype, ObjxmBackground | ObjxmForeground);
259 if (obj->attachments != NULL)
260 objxm_obj_set_attachment_args(obj, ctype);
275 num_args = objxm_get_num_args(arglist);
277 for (i = 0; i < num_args; i++)
279 if (strcmp(arglist[i].name, name) == 0)
281 argptr = &(arglist[i]);
290 objxm_set_literal_arg(
291 OBJXM_CONFIG_TYPE ctype,
294 unsigned char literal
299 enum_value = (ctype == OBJXM_CONFIG_CODEGEN?
300 (XtArgVal)objxm_get_enum_strdef(name, literal) :
303 objxm_set_arg(p_arglist, AB_ARG_LITERAL, name, enum_value);
309 objxm_set_widget_arg(
310 OBJXM_CONFIG_TYPE ctype,
319 * REMIND: free this ISTRING when the arg is destroyed!
321 w_value = (ctype == OBJXM_CONFIG_CODEGEN?
322 (XtArgVal)(istr_create(w_obj? obj_get_name(w_obj) : "NULL")):
323 (XtArgVal)(w_obj? w_obj->ui_handle : NULL));
325 objxm_set_arg(p_arglist, AB_ARG_WIDGET, name, w_value);
343 argtype = objxm_get_res_type(name);
345 XtSetArg(newarg, name, (XtArgVal)value);
347 if ((oldarg = objxm_get_arg(*p_arglist, name)) != NULL)
349 /* replace existing arg */
353 objxmP_merge_arg(p_arglist, &newarg);
361 * sets the argument only if it doesn't already exist in the arglist
362 * returns 0 if the arg is set, negative if not
365 objxm_set_arg_if_new(
374 old_arg = objxm_get_arg(*p_arglist, name);
380 return objxm_set_arg(p_arglist, type, name, value);
384 objxm_remove_all_args(
386 OBJXM_CONFIG_TYPE ctype
395 /* Free any allocated XmStrings... */
396 if (*p_arglist != NULL)
399 num_args = objxm_get_num_args(args);
400 for (i = 0; i < num_args; i++)
402 type = objxm_get_res_type(args[i].name);
403 if (type == AB_ARG_XMSTRING && args[i].value)
405 util_dprintf(3, "%s: Freeing XmString\n", args[i].name);
406 if (ctype == OBJXM_CONFIG_BUILD)
407 XmStringFree((XmString)args[i].value);
408 else /* CONFIG_CODEGEN */
410 istr = (ISTRING)args[i].value;
415 XtFree((char *)*p_arglist);
425 ArgList args = arglist;
428 for ( ; (args != (ArgList)NULL) && (args->name != NULL);
436 * Remove the specified arg from the args and re-arrange
448 if (*p_arglist == NULL)
452 nargs = objxm_get_num_args(*p_arglist);
456 *p_arglist = (ArgList)NULL;
457 for (i = 0; i < nargs ; i++)
459 if (args[i].name && (strcmp(args[i].name, name) == 0))
461 objxmP_merge_arg(p_arglist, &args[i]);
464 /** LOA (void)free((STRING )args); **/
471 /******************************************************************
472 * Functions that set Resource args on an entire Composite Obj
473 ******************************************************************/
476 * Set attachment Resources for a Composite Object hierarchy
478 objxm_comp_set_attachment_args(
480 OBJXM_CONFIG_TYPE ctype
484 static ABObj comp_root = NULL;
485 ABObj comp_sub = NULL;
487 objxm_obj_set_attachment_args(obj, ctype);
489 if (obj->part_of == NULL) /* No SubObjs */
492 if (comp_root == NULL) /* Set Root */
495 for (trav_open(&trav, obj, AB_TRAV_CHILDREN);
496 (comp_sub= trav_next(&trav)) != NULL; )
498 if (comp_sub->part_of == comp_root)
499 objxm_comp_set_attachment_args(comp_sub, ctype);
503 if (obj == comp_root)
504 comp_root = NULL; /* Reset */
511 objxm_comp_set_color_args(
513 OBJXM_CONFIG_TYPE ctype,
517 static ABObj rootObj = NULL;
518 static XtArgVal fgvalue;
519 static XtArgVal bgvalue;
520 static BOOL cgen_args;
529 if (rootObj == NULL) /* First time */
532 cgen_args = (ctype == OBJXM_CONFIG_CODEGEN? TRUE : FALSE);
534 widget = (objxm_get_widget(obj)? objxm_get_widget(obj) : ObjxmP_toplevel);
536 if (flag & ObjxmBackground)
538 if (util_strempty(obj_get_bg_color(rootObj)))
539 flag &= ~ObjxmBackground;
544 status = objxm_name_to_pixel(widget, obj_get_bg_color(rootObj), &pixel);
546 if (status == ERR) /* Color couldn't be allocated! */
548 obj_get_safe_name(rootObj, name, 256);
549 util_printf_err(catgets(OBJXM_MESSAGE_CATD,
550 OBJXM_MESSAGE_SET, 21,
551 "WARNING: Object '%s'\nCould not allocate Background color \"%s\".\n\
552 Object's Background will default to white."),
553 name, obj_get_bg_color(rootObj));
554 pixel = WhitePixelOfScreen(XtScreen(ObjxmP_toplevel));
556 bgvalue = (XtArgVal)pixel;
558 else /* Generating Code */
559 bgvalue= (XtArgVal)istr_create(obj_get_bg_color(rootObj));
562 if (flag & ObjxmForeground)
564 if (util_strempty(obj_get_fg_color(obj)))
565 flag &= ~ObjxmForeground;
570 status = objxm_name_to_pixel(widget, obj_get_fg_color(rootObj), &pixel);
572 if (status == ERR) /* Color couldn't be allocated! */
574 obj_get_safe_name(rootObj, name, 256);
575 util_printf_err(catgets(OBJXM_MESSAGE_CATD,
576 OBJXM_MESSAGE_SET, 22,
577 "WARNING: Object '%s'\nCould not allocate Foreground color \"%s\".\n\
578 Object's Foreground will default to black."),
579 name, obj_get_fg_color(rootObj));
580 pixel = BlackPixelOfScreen(XtScreen(ObjxmP_toplevel));
582 fgvalue = (XtArgVal)pixel;
584 else /* Generating Code */
585 fgvalue = (XtArgVal)istr_create(obj_get_fg_color(rootObj));
588 if (flag == ObjxmNone) /* No Colors to Set */
595 /* If in Build-mode, set value to Pixel, else (CodeGen-mode)
596 * set the value to the color-name
598 if (flag & ObjxmBackground &&
599 /* Don't set background on Window Footer SubObjs */
600 !obj_has_flag(obj, NoCodeGenFlag) &&
601 !util_streq(obj_get_class_name(obj), _xmScrolledWindow))
603 objxm_obj_set_ui_arg(obj, AB_ARG_PIXEL, XmNbackground, bgvalue);
604 obj_set_flag(obj, AttrChangedFlag);
607 if (flag & ObjxmForeground &&
608 /* Don't set foreground on Window Select SubObj */
609 !(obj_is_label(obj) && obj_is_window(obj_get_root(obj)) &&
610 obj == objxm_comp_get_subobj(obj, AB_CFG_SELECT_OBJ)) &&
611 !(util_streq(obj_get_class_name(obj), _xmScrolledWindow)))
613 objxm_obj_set_ui_arg(obj, AB_ARG_PIXEL, XmNforeground, fgvalue);
614 obj_set_flag(obj, AttrChangedFlag);
617 * set args recursively for any "sub-objs" of this obj
619 for (trav_open(&trav, obj, AB_TRAV_CHILDREN);
620 (subObj = trav_next(&trav)) != NULL; )
622 if (subObj->part_of == rootObj)
623 objxm_comp_set_color_args(subObj, ctype, flag);
627 /* If we've recursed back up to the root obj, then we're done.
636 objxm_comp_set_default_button_args(
638 OBJXM_CONFIG_TYPE ctype
642 ABObj bbobj, defaultb, child, button;
646 defaultb = obj_get_default_act_button(obj);
648 if (defaultb == NULL) /* No Default Button specified */
651 if (ctype == OBJXM_CONFIG_CODEGEN)
652 return 0; /* don't bother setting it */
654 bbobj = objxm_comp_get_subobj(obj, AB_CFG_WINDOW_BB_OBJ);
656 objxm_obj_set_widget_ui_arg(bbobj, ctype, XmNdefaultButton, defaultb);
657 obj_set_flag(bbobj, AttrChangedFlag);
659 button_panel = objxm_comp_custdlg_get_area(obj, AB_CONT_BUTTON_PANEL);
661 /* If Dialog has a Button Panel, set all it's button DefaultShadowThickness */
662 if (button_panel != NULL)
664 for (trav_open(&trav, button_panel, AB_TRAV_SALIENT_UI);
665 (child= trav_next(&trav)) != NULL; )
667 if (obj_is_button(child))
669 button = objxm_comp_get_subobj(child, AB_CFG_OBJECT_OBJ);
670 objxm_obj_set_ui_arg(button, AB_ARG_INT,
671 XmNdefaultButtonShadowThickness, thickness);
672 obj_set_flag(button, AttrChangedFlag);
681 objxm_comp_set_label_args(
683 OBJXM_CONFIG_TYPE ctype
686 ABObj subObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
695 cgen_args = (ctype == OBJXM_CONFIG_CODEGEN? TRUE : FALSE);
696 label = obj_get_label(obj);
698 switch (obj->label_type)
700 case AB_LABEL_STRING:
701 if (obj_is_window(obj))
702 objxm_obj_set_ui_arg(subObj, AB_ARG_STRING, XmNtitle, label);
707 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNlabelType, XmSTRING);
709 /* If in Build-mode, convert label to XmString, else (CodeGen-mode)
713 valstr = (XtArgVal)istr_create(label);
716 /* NOTE:This XmString is freed in objxm_remove_all_args() */
717 util_dprintf(3, "%s : allocating XmString\n", XmNlabelString);
718 valstr = (XtArgVal)objxm_str_to_xmstr(ObjxmP_toplevel, label);
720 objxm_obj_set_ui_arg(subObj, AB_ARG_XMSTRING, XmNlabelString, valstr);
724 if (!util_strempty(label))
728 status = objxm_filebase_to_pixmap(ObjxmP_toplevel, label, &label_pm);
730 util_printf_err(objxm_pixmap_conversion_error_msg(obj, label, status));
734 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNlabelType, XmPIXMAP);
735 objxm_obj_set_ui_arg(subObj, AB_ARG_PIXMAP, XmNlabelPixmap,
736 cgen_args? (XtArgVal)istr_create(obj_get_label(obj)):
741 case AB_LABEL_ARROW_DOWN:
742 obj_set_class_name(subObj, _xmArrowButton);
743 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNarrowDirection, XmARROW_DOWN);
745 case AB_LABEL_ARROW_UP:
746 obj_set_class_name(subObj, _xmArrowButton);
747 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNarrowDirection, XmARROW_UP);
749 case AB_LABEL_ARROW_RIGHT:
750 obj_set_class_name(subObj, _xmArrowButton);
751 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNarrowDirection, XmARROW_RIGHT);
753 case AB_LABEL_ARROW_LEFT:
754 obj_set_class_name(subObj, _xmArrowButton);
755 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNarrowDirection,XmARROW_LEFT);
757 case AB_LABEL_SEPARATOR:
758 obj_set_class_name(subObj, _xmSeparator);
759 objxm_obj_set_line_style_arg(subObj, ctype);
763 obj_set_flag(subObj, AttrChangedFlag);
768 objxm_comp_set_lbl_align_args(
770 OBJXM_CONFIG_TYPE ctype
773 ABObj subObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
776 switch(obj_get_label_alignment(obj))
779 value = XmALIGNMENT_END;
782 value = XmALIGNMENT_BEGINNING;
784 case AB_ALIGN_CENTER:
785 value = XmALIGNMENT_CENTER;
790 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNalignment, value);
791 obj_set_flag(subObj, AttrChangedFlag);
797 objxm_comp_set_lbl_pos_args(
799 OBJXM_CONFIG_TYPE ctype
802 ABObj subObj = objxm_comp_get_subobj(obj, AB_CFG_POSITION_OBJ);
804 if (!obj_has_label(obj))
807 switch (obj_get_label_position(obj))
810 objxm_obj_set_literal_ui_arg(subObj, ctype,
811 XmNorientation, XmHORIZONTAL);
812 objxm_obj_set_literal_ui_arg(subObj, ctype,
813 XmNentryAlignment, XmALIGNMENT_END);
816 objxm_obj_set_literal_ui_arg(subObj, ctype,
817 XmNorientation, XmVERTICAL);
818 objxm_obj_set_literal_ui_arg(subObj, ctype,
819 XmNentryAlignment, XmALIGNMENT_BEGINNING);
824 objxm_obj_set_ui_arg(subObj, AB_ARG_INT, XmNmarginHeight, 0);
825 objxm_obj_set_ui_arg(subObj, AB_ARG_INT, XmNmarginWidth, 0);
826 objxm_obj_set_ui_arg(subObj, AB_ARG_INT, XmNspacing, 0);
827 objxm_obj_set_ui_arg(subObj, AB_ARG_BOOLEAN, XmNadjustLast, True);
828 obj_set_flag(subObj, AttrChangedFlag);
834 objxm_comp_set_icon_args(
836 OBJXM_CONFIG_TYPE ctype
839 ABObj shobj; /* Shell SubObj */
840 STRING icon, mask, icon_label;
841 Pixmap icon_pm, mask_pm;
844 if (!obj_is_base_win(obj))
847 shobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
849 if (ctype == OBJXM_CONFIG_CODEGEN)
850 objxm_obj_set_literal_ui_arg(shobj, ctype, XmNinitialState,
851 obj_is_initially_iconic(obj)? IconicState : NormalState);
853 /* Setup Icon Pixmap */
854 if ((icon = obj_get_icon(obj)) != NULL)
856 if (ctype != OBJXM_CONFIG_CODEGEN)
858 status = objxm_filebase_to_pixmap(ObjxmP_toplevel, icon, &icon_pm);
860 util_printf_err(objxm_pixmap_conversion_error_msg(obj, icon, status));
863 objxm_obj_set_ui_arg(shobj, AB_ARG_PIXMAP, XmNiconPixmap,
864 ctype == OBJXM_CONFIG_CODEGEN? (XtArgVal)istr_create(icon) : icon_pm);
866 else if (ctype == OBJXM_CONFIG_BUILD)
867 objxm_obj_set_ui_arg(shobj, AB_ARG_PIXMAP, XmNiconPixmap, NULL);
869 if ((mask = obj_get_icon_mask(obj)) != NULL)
871 if (ctype != OBJXM_CONFIG_CODEGEN)
873 status = objxm_filebase_to_pixmap(ObjxmP_toplevel, mask, &mask_pm);
875 util_printf_err(objxm_pixmap_conversion_error_msg(obj, mask, status));
878 objxm_obj_set_ui_arg(shobj, AB_ARG_PIXMAP, XmNiconMask,
879 ctype == OBJXM_CONFIG_CODEGEN? (XtArgVal)istr_create(mask) : mask_pm);
881 else if (ctype == OBJXM_CONFIG_BUILD)
882 objxm_obj_set_ui_arg(shobj, AB_ARG_PIXMAP, XmNiconMask, NULL);
884 /* Setup Icon Label */
885 if ((icon_label = obj_get_icon_label(obj)) != NULL)
886 objxm_obj_set_ui_arg(shobj, AB_ARG_STRING, XmNiconName, icon_label);
888 obj_set_flag(shobj, AttrChangedFlag);
894 objxm_comp_set_read_only_args(
896 OBJXM_CONFIG_TYPE ctype
902 read_only = obj_get_read_only(obj);
903 subObj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
907 case AB_TYPE_COMBO_BOX:
908 objxm_obj_set_literal_ui_arg(subObj, ctype, DtNcomboBoxType,
909 read_only? DtDROP_DOWN_LIST : DtDROP_DOWN_COMBO_BOX);
912 objxm_obj_set_ui_arg(subObj, AB_ARG_INT, "slidingMode",
915 case AB_TYPE_TEXT_PANE:
916 case AB_TYPE_TEXT_FIELD:
917 objxm_obj_set_ui_arg(subObj, AB_ARG_BOOLEAN, XmNeditable,
918 read_only? False : True);
919 objxm_obj_set_ui_arg(subObj, AB_ARG_BOOLEAN, XmNcursorPositionVisible,
920 read_only? False : True);
926 obj_set_flag(subObj, AttrChangedFlag);
932 objxm_comp_set_border_args(
934 OBJXM_CONFIG_TYPE ctype
940 if ((b_obj = objxm_comp_get_subobj(obj, AB_CFG_BORDER_OBJ)) == NULL)
943 switch(obj_get_border_frame(obj))
945 case AB_LINE_SHADOW_IN:
946 bstyle = XmSHADOW_IN;
948 case AB_LINE_SHADOW_OUT:
949 bstyle = XmSHADOW_OUT;
951 case AB_LINE_ETCHED_IN:
952 bstyle = XmSHADOW_ETCHED_IN;
954 case AB_LINE_ETCHED_OUT:
955 bstyle = XmSHADOW_ETCHED_OUT;
962 objxm_obj_set_literal_ui_arg(b_obj, ctype, XmNshadowType, bstyle);
963 obj_set_flag(b_obj, AttrChangedFlag);
970 objxm_comp_set_msgbox_button_arg(
972 OBJXM_CONFIG_TYPE ctype,
973 unsigned char which_btn
976 ABObj msgbox_obj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
978 Widget msgbox, button;
979 BOOL (*func)(ABObj obj)= NULL;
981 msgbox = objxm_get_widget(msgbox_obj);
984 case XmDIALOG_OK_BUTTON:
985 func = obj_has_action1_button;
987 case XmDIALOG_CANCEL_BUTTON:
988 func = obj_has_cancel_button;
990 case XmDIALOG_HELP_BUTTON:
991 func = obj_has_help_button;
994 button = XmMessageBoxGetChild(msgbox, which_btn);
995 cgen_args = (ctype == OBJXM_CONFIG_CODEGEN? TRUE : FALSE);
999 if (!XtIsManaged(button))
1001 XtManageChild(button);
1006 /* Unmanage the button */
1007 XtUnmanageChild(button);
1009 obj_set_flag(msgbox_obj, AttrChangedFlag);
1015 /***********************************************************
1016 * Functions that set Resource args on a SINGLE SubObj
1017 ***********************************************************/
1020 objxm_obj_set_arrow_style_arg(
1022 OBJXM_CONFIG_TYPE ctype
1025 unsigned char value;
1027 switch(obj_get_arrow_style(obj_get_root(subObj)))
1029 case AB_ARROW_FLAT_BEGIN:
1030 value = DtARROWS_FLAT_BEGINNING;
1032 case AB_ARROW_FLAT_END:
1033 value = DtARROWS_FLAT_END;
1035 case AB_ARROW_BEGIN:
1036 value = DtARROWS_BEGINNING;
1039 value = DtARROWS_END;
1041 case AB_ARROW_SPLIT:
1042 value = DtARROWS_SPLIT;
1047 objxm_obj_set_literal_ui_arg(subObj, ctype, DtNarrowLayout, value);
1048 obj_set_flag(subObj, AttrChangedFlag);
1054 objxm_obj_set_attachment_args(
1056 OBJXM_CONFIG_TYPE ctype
1064 if (obj->attachments != NULL)
1066 parent_obj = obj_get_parent(obj);
1068 objxmP_set_attachment_arg(obj, ctype, parent_obj, AB_CP_NORTH);
1069 objxmP_set_attachment_arg(obj, ctype, parent_obj, AB_CP_WEST);
1070 objxmP_set_attachment_arg(obj, ctype, parent_obj, AB_CP_EAST);
1071 objxmP_set_attachment_arg(obj, ctype, parent_obj, AB_CP_SOUTH);
1079 objxm_obj_set_direction_arg(
1081 OBJXM_CONFIG_TYPE ctype
1084 unsigned char value;
1086 switch(obj_get_direction(obj_get_root(subObj)))
1088 case AB_DIR_LEFT_TO_RIGHT:
1089 value = XmMAX_ON_RIGHT;
1091 case AB_DIR_RIGHT_TO_LEFT:
1092 value = XmMAX_ON_LEFT;
1094 case AB_DIR_TOP_TO_BOTTOM:
1095 value = XmMAX_ON_BOTTOM;
1097 case AB_DIR_BOTTOM_TO_TOP:
1098 value = XmMAX_ON_TOP;
1103 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNprocessingDirection, value);
1104 obj_set_flag(subObj, AttrChangedFlag);
1110 objxm_obj_set_line_style_arg(
1112 OBJXM_CONFIG_TYPE ctype
1115 unsigned char value;
1117 value = objxm_linestyle_to_enum(obj_get_line_style(obj_get_root(subObj)));
1119 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNseparatorType, value);
1120 obj_set_flag(subObj, AttrChangedFlag);
1126 objxm_obj_set_orientation_arg(
1128 OBJXM_CONFIG_TYPE ctype
1131 unsigned char value;
1133 switch (obj_get_orientation(obj_get_root(subObj)))
1135 case AB_ORIENT_HORIZONTAL:
1136 value = XmHORIZONTAL;
1138 case AB_ORIENT_VERTICAL:
1144 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNorientation, value);
1145 obj_set_flag(subObj, AttrChangedFlag);
1151 objxm_obj_set_selection_arg(
1153 OBJXM_CONFIG_TYPE ctype
1156 unsigned char value;
1158 switch (obj_get_selection_mode(obj_get_root(subObj)))
1160 case AB_SELECT_BROWSE:
1161 value = XmBROWSE_SELECT;
1163 case AB_SELECT_MULTIPLE:
1164 value = XmMULTIPLE_SELECT;
1166 case AB_SELECT_BROWSE_MULTIPLE:
1167 value = XmEXTENDED_SELECT;
1169 case AB_SELECT_SINGLE:
1170 value = XmSINGLE_SELECT;
1175 objxm_obj_set_literal_ui_arg(subObj, ctype, XmNselectionPolicy, value);
1176 obj_set_flag(subObj, AttrChangedFlag);
1182 objxm_obj_get_default_motif_class(
1187 AB_BUTTON_TYPE btype;
1191 case AB_TYPE_BASE_WINDOW:
1192 cn= _applicationShell;
1194 case AB_TYPE_BUTTON:
1195 btype = (AB_BUTTON_TYPE)obj_get_subtype(obj);
1196 if (btype == AB_BUT_PUSH)
1198 else if (btype == AB_BUT_DRAWN)
1200 else /* AB_BUT_MENU */
1203 case AB_TYPE_DRAWING_AREA:
1206 case AB_TYPE_CONTAINER:
1207 if (obj_get_container_type(obj) == AB_CONT_PANED)
1208 cn = _xmPanedWindow;
1210 cn= _xmBulletinBoard;
1212 case AB_TYPE_COMBO_BOX:
1215 case AB_TYPE_FILE_CHOOSER:
1216 cn= _xmFileSelectionBox;
1218 case AB_TYPE_MESSAGE:
1222 if (obj_get_subtype(obj) == AB_MENU_PULLDOWN)
1223 cn = _xmPulldownMenu; /* Psuedo-class */
1225 cn = _xmPopupMenu; /* Psuedo-class */
1228 switch (obj->info.item.type)
1230 case AB_ITEM_FOR_MENU:
1231 if (obj_get_label(obj) == NULL)
1237 cn= _xmCascadeButton;
1241 case AB_ITEM_FOR_CHOICE:
1242 cn= _xmToggleButton;
1245 case AB_ITEM_FOR_MENUBAR:
1246 cn= _xmCascadeButton;
1249 case AB_ITEM_FOR_LIST:
1250 /* no class for list items (strings) */
1257 case AB_TYPE_DIALOG:
1261 cn= _xmScrolledList; /* Psuedo-class */
1263 case AB_TYPE_CHOICE:
1266 case AB_TYPE_SEPARATOR:
1272 case AB_TYPE_SPIN_BOX:
1275 case AB_TYPE_LAYERS:
1278 case AB_TYPE_TERM_PANE:
1281 case AB_TYPE_TEXT_FIELD:
1283 if (obj_get_num_rows(obj) > 1)
1288 case AB_TYPE_TEXT_PANE:
1297 /*************************************************************************
1298 * Utility Functions to dump out Resource Arg Values *
1299 *************************************************************************/
1308 util_dprintf(0,"Resources for: %s\n", obj_get_safe_name(obj, name, 256));
1309 objxm_dump_arglist_indented(obj, args, num_args, 4);
1311 util_dprintf(0,"\n");
1317 objxm_dump_arglist_indented(
1326 String valstr= NULL;
1327 AB_ARG_TYPE arg_type= AB_ARG_UNDEF;
1329 BOOL cgen_args = FALSE;
1331 if (obj_has_flag(obj, XmCfgForCodeFlag))
1334 for (i = 0; i < num_args; i++)
1337 for (space_count= 0; space_count < spaces; ++space_count)
1339 util_dprintf(0, " ");
1342 util_dprintf(0,"XmN%s = ", args[i].name);
1343 arg_type = objxm_get_res_type(args[i].name);
1347 util_dprintf(0,"%d ", (int)args[i].value);
1350 util_dprintf(0,"%s ", (char*)args[i].value);
1355 util_dprintf(0,"%s ",
1356 istr_string((ISTRING)(args[i].value)));
1360 util_dprintf(0,"(Pixel)%ld ", (long)args[i].value);
1363 case AB_ARG_XMSTRING:
1365 valstr = (String)istr_string((ISTRING)(args[i].value));
1367 valstr = arg->value?
1368 (String)objxm_xmstr_to_str((XmString)arg->value): "NULL";
1369 util_dprintf(0,"%s ", util_strsafe(valstr));
1371 case AB_ARG_BOOLEAN:
1372 util_dprintf(0,"%s ", args[i].value? "TRUE" :"FALSE");
1374 case AB_ARG_LITERAL:
1376 valstr = (String)istr_string((ISTRING)(args[i].value));
1378 valstr = istr_string(objxm_get_enum_strdef(args[i].name,
1379 (unsigned char)args[i].value));
1380 util_dprintf(0,"%s ", util_strsafe(valstr));
1385 util_dprintf(0,"%s ", args[i].value != 0?
1386 istr_string((ISTRING)(args[i].value)) : "NULL");
1390 util_dprintf(0,"%lx = %s ",
1391 (Widget)args[i].value,
1392 args[i].value ? XtName((Widget)args[i].value) : "NULL");
1398 util_dprintf(0,"(Pixmap File)%s ",
1399 istr_string((ISTRING)(args[i].value)));
1403 util_dprintf(0,"(Pixmap)%ld ", (long)args[i].value);
1407 util_dprintf(0,"%d ", args[i].value);
1409 } /* switch arg_type */
1411 util_dprintf(0,"%s\n",
1412 objxm_res_value_is_default(args[i].name,
1413 objxm_get_class_ptr(obj_get_class_name(obj)), args[i].value)? "(Default)":"");
1425 objxm_dump_widget_geometry(
1430 Dimension width, height;
1431 unsigned char attach[4];
1436 BOOL parent_is_form = FALSE;
1437 char *attach_str[] = {"XmNtopAttachment ", "XmNbottomAttachment",
1438 "XmNleftAttachment ", "XmNrightAttachment "};
1439 char *widget_str[] = {"XmNtopWidget", "XmNbottomWidget",
1440 "XmNleftWidget", "XmNrightWidget"};
1441 char *pos_str[] = {"XmNtopPosition", "XmNbottomPosition",
1442 "XmNleftPosition", "XmNrightPosition"};
1443 char *offset_str[] = {"XmNtopOffset", "XmNbottomOffset",
1444 "XmNleftOffset", "XmNrightOffset"};
1449 parent_is_form = XtIsSubclass(XtParent(w), xmFormWidgetClass);
1458 XmNtopAttachment, &(attach[A_TOP]),
1459 XmNbottomAttachment, &(attach[A_BOTTOM]),
1460 XmNleftAttachment, &(attach[A_LEFT]),
1461 XmNrightAttachment, &(attach[A_RIGHT]),
1462 XmNtopWidget, &(widget[A_TOP]),
1463 XmNbottomWidget, &(widget[A_BOTTOM]),
1464 XmNleftWidget, &(widget[A_LEFT]),
1465 XmNrightWidget, &(widget[A_RIGHT]),
1466 XmNtopPosition, &(position[A_TOP]),
1467 XmNbottomPosition, &(position[A_BOTTOM]),
1468 XmNleftPosition, &(position[A_LEFT]),
1469 XmNrightPosition, &(position[A_RIGHT]),
1470 XmNtopOffset, &(offset[A_TOP]),
1471 XmNbottomOffset, &(offset[A_BOTTOM]),
1472 XmNleftOffset, &(offset[A_LEFT]),
1473 XmNrightOffset, &(offset[A_RIGHT]),
1487 util_dprintf(0,"Widget %s is %s\n",
1489 XtIsRealized(w) ? "realized" : "not realized");
1490 util_dprintf(0,"Widget %s is %s\n",
1492 XtIsManaged(w) ? "managed" : "not managed");
1493 util_dprintf(0,"Geometry for %s -->\n", XtName(w));
1494 util_dprintf(0," x,y = %d,%d\n", x, y);
1495 util_dprintf(0," Width x Height = %d x %d\n", width, height);
1499 for(i=0; i < 4; i++)
1501 util_dprintf(0," %s = ", attach_str[i]);
1505 util_dprintf(0,"XmATTACH_NONE\n");
1508 util_dprintf(0,"XmATTACH_FORM, Form=%s, %s=%d\n",
1509 XtName(XtParent(w)), offset_str[i], offset[i]);
1511 case XmATTACH_WIDGET:
1512 util_dprintf(0,"XmATTACH_WIDGET, %s=%s, %s=%d\n",
1513 widget_str[i], XtName(widget[i]),
1514 offset_str[i], offset[i]);
1516 case XmATTACH_POSITION:
1517 util_dprintf(0,"XmATTACH_POSITION, %s=%d, %s=%d\n",
1518 pos_str[i], position[i],
1519 offset_str[i], offset[i]);
1532 /*************************************************************************
1534 ** Private Function Definitions **
1536 *************************************************************************/
1538 * To this routine just pass in 'Arg *' and the arglist in the ABObj,
1539 * it will merge with existing args for obj and stick it back in the arglist
1551 if ((nargs = objxm_get_num_args(*p_arglist)) == 0)
1552 { /* first time ever */
1553 result = objxmP_merge_arglists(arg, 1, (ArgList)NULL, 0);
1554 *p_arglist = result;
1557 { /* merge with existing args */
1558 result = objxmP_merge_arglists(arg, 1, *p_arglist, nargs);
1559 XtFree((char *)*p_arglist);
1560 *p_arglist = result;
1567 objxmP_merge_arglists(
1574 ArgList result, args;
1575 Arg nullarg = {NULL, 0};
1577 result = (ArgList)XtMalloc((unsigned) (num_args1 + num_args2 + 1) *
1579 for (args = result; num_args1 != 0; num_args1--)
1581 for ( ; num_args2 != 0; num_args2--)
1584 /* ensure last arg is NULL */
1590 objxmP_set_attachment_arg(
1592 OBJXM_CONFIG_TYPE ctype,
1594 AB_COMPASS_POINT dir
1597 String att_side_resource;
1598 String att_widget_resource;
1599 String att_offset_resource;
1600 String att_pos_resource;
1601 AB_ATTACH_TYPE type;
1609 att_side_resource = XmNtopAttachment;
1610 att_widget_resource = XmNtopWidget;
1611 att_offset_resource = XmNtopOffset;
1612 att_pos_resource = XmNtopPosition;
1615 att_side_resource = XmNleftAttachment;
1616 att_widget_resource = XmNleftWidget;
1617 att_offset_resource = XmNleftOffset;
1618 att_pos_resource = XmNleftPosition;
1621 att_side_resource = XmNrightAttachment;
1622 att_widget_resource = XmNrightWidget;
1623 att_offset_resource = XmNrightOffset;
1624 att_pos_resource = XmNrightPosition;
1627 att_side_resource = XmNbottomAttachment;
1628 att_widget_resource = XmNbottomWidget;
1629 att_offset_resource = XmNbottomOffset;
1630 att_pos_resource = XmNbottomPosition;
1635 type = obj_get_attach_type(obj, dir);
1636 value = obj_get_attach_value(obj, dir);
1637 offset = obj_get_attach_offset(obj, dir);
1640 case AB_ATTACH_POINT:
1641 objxm_obj_set_literal_ui_arg(obj, ctype, att_side_resource, XmATTACH_FORM);
1642 objxm_obj_set_ui_arg(obj, AB_ARG_INT, att_offset_resource, offset);
1645 case AB_ATTACH_ALIGN_OBJ_EDGE:
1646 att_obj = (ABObj)value;
1649 /* If has an attachment to a widget which isn't generated in
1650 * code(window status area), then move the attachment to its parent
1652 if (ctype == OBJXM_CONFIG_CODEGEN && obj_has_flag(att_obj, NoCodeGenFlag))
1653 att_obj = parent_obj;
1655 if (att_obj == parent_obj)
1656 objxm_obj_set_literal_ui_arg(obj, ctype, att_side_resource,
1657 (type==AB_ATTACH_OBJ? XmATTACH_FORM : XmATTACH_OPPOSITE_FORM));
1660 objxm_obj_set_literal_ui_arg(obj, ctype, att_side_resource,
1661 (type==AB_ATTACH_OBJ? XmATTACH_WIDGET : XmATTACH_OPPOSITE_WIDGET));
1662 objxm_obj_set_widget_ui_arg(obj, ctype, att_widget_resource, att_obj);
1664 objxm_obj_set_ui_arg(obj, AB_ARG_INT, att_offset_resource, offset);
1666 else if (util_get_verbosity() > 0)
1669 obj_get_safe_name(obj, name, 256);
1670 util_printf_err(catgets(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 3,
1671 "ERROR: %s: NULL Object attachment\n"), name);
1675 case AB_ATTACH_GRIDLINE:
1676 case AB_ATTACH_CENTER_GRIDLINE:
1677 objxm_obj_set_literal_ui_arg(obj, ctype, att_side_resource, XmATTACH_POSITION);
1678 objxm_obj_set_ui_arg(obj, AB_ARG_INT, att_pos_resource, value);
1679 objxm_obj_set_ui_arg(obj, AB_ARG_INT, att_offset_resource, offset);
1682 case AB_ATTACH_NONE:
1684 objxm_obj_set_literal_ui_arg(obj, ctype, att_side_resource, XmATTACH_NONE);
1687 obj_set_flag(obj, AttrChangedFlag);