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 librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: prop.c /main/5 1996/08/08 17:57:58 mustafa $
26 * @(#)prop.c 1.89 26 Feb 1994
28 * RESTRICTED CONFIDENTIAL INFORMATION:
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
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
44 *****************************************************************
45 * prop.c - Implements all common property sheet functionality
47 *****************************************************************
50 #define _POSIX_SOURCE 1
56 #include <Dt/ComboBox.h>
57 #include <Xm/BulletinB.h>
58 #include <Xm/CascadeB.h>
63 #include <Xm/MessageB.h>
65 #include <Xm/RowColumn.h>
66 #include <Xm/Separator.h>
69 #include <Xm/ToggleB.h>
70 #include <ab_private/trav.h>
71 #include <ab_private/obj_notify.h>
72 #include <ab_private/objxm.h>
73 #include <ab_private/ab.h>
74 #include <ab_private/prop.h>
75 #include <ab_private/propP.h>
76 #include <ab_private/proj.h>
77 #include <ab_private/abobj.h>
78 #include <ab_private/abobj_set.h>
79 #include <ab_private/abobj_list.h>
80 #include <ab_private/ui_util.h>
81 #include <ab_private/x_util.h>
82 #include <ab_private/conn.h>
83 #include <ab_private/help.h>
84 #include <ab_private/color_chooser.h>
85 #include <ab_private/attch_ed.h>
86 #include "dtbuilder.h"
87 #include "revolv_ui.h"
89 char *LabelForString = NULL;
90 char *LabelForGraphic = NULL;
91 char *NoneItem = NULL;
93 char *XFieldStr = NULL;
94 char *YFieldStr = NULL;
95 char *WFieldStr = NULL;
96 char *HFieldStr = NULL;
97 char *OffsetFieldStr = NULL;
98 char *PercentageFieldStr = NULL;
99 char *RowColFieldStr = NULL;
100 char *VertSpacingFieldStr = NULL;
101 char *HorizSpacingFieldStr = NULL;
103 static char *menu_strs[4];
104 static char *menu_names[] = {"none_item", "new_menu_item", "menus_item", "edit_item"};
106 static const char *Name_ok_test="_";
108 typedef struct _PROP_STATE_INFO {
109 PalItemInfo *palitem;
116 /*************************************************************************
118 ** Private Function Declarations **
120 *************************************************************************/
121 /* Revolving Dialog Functions
123 static void revolv_dialog_init(
126 static void revolv_objectspane_init(
127 DtbRevolvPropDialogInfo cgen
129 static void revolv_basicframe_init(
130 DtbRevolvPropDialogInfo cgen
133 revolv_set_prop_type(
134 PalItemInfo* palitem,
137 static void revolv_change_prop_frame(
142 PalItemInfo *palitem,
147 /* Fixed Dialog Functions
154 /* General Prop Manipulation Functions
156 static int apply_props(
160 static int apply_prop_changes(
165 static DTB_MODAL_ANSWER
168 PropStateInfo *pstate,
169 PalItemInfo *new_palitem,
173 static PropStateInfo *
177 static void init_prop_state_info(
179 PalItemInfo *palitem,
183 static void load_props(
185 PropStateInfo *pstate,
188 static void create_obj_option_item(
189 PropObjOptionsSetting pos,
194 /* Object List Manipulation Functions
196 static int objlist_delete_obj(
198 PalItemInfo *palitem,
199 ObjEvDestroyInfo info
201 static void objlist_ensure_selection(
204 static void objlist_load(
206 PropStateInfo *pstate
208 static int objlist_rename_obj(
210 PalItemInfo *palitem,
211 ObjEvAttChangeInfo info
213 static int objlist_show_or_hide_obj(
215 PalItemInfo *palitem,
218 static BOOL objlist_test_func(
226 static int obj_renamedOCB(
227 ObjEvAttChangeInfo info
229 static int obj_shown_or_hiddenOCB(
232 static int obj_geom_changedOCB(
233 ObjEvAttChangeInfo info
235 static int obj_destroyedOCB(
236 ObjEvDestroyInfo info
242 /* General Prop Callbacks
244 static void apply_propsCB(
246 XtPointer clientdata,
249 static void cancel_propsCB(
251 XtPointer clientdata,
254 static void change_objecttypeCB(
256 XtPointer clientdata,
259 static void close_propsCB(
261 XtPointer clientdata,
264 static void invoke_attach_editorCB(
269 static void invoke_connectionsCB(
274 static void invoke_help_editorCB(
279 static void objlist_selectCB(
281 XtPointer client_data,
282 XmListCallbackStruct *listdata
284 static void ok_propsCB(
286 XtPointer clientdata,
289 static void reset_propsCB(
291 XtPointer clientdata,
294 static void tearoff_propsCB(
296 XtPointer clientdata,
300 /* Color Field Callbacks
302 static void color_chooserCB(
304 XtPointer clientdata,
307 static void color_noneCB(
309 XtPointer clientdata,
313 /* Menu Name Setting Callbacks
315 static void menu_newCB(
317 XtPointer client_data,
320 static void menu_editCB(
322 XtPointer client_data,
325 static void menu_edit_set_stateCB(
327 XtPointer client_data,
330 static void menulist_buildCB(
332 XtPointer client_data,
335 static void menulist_destroyCB(
337 XtPointer client_data,
340 static void menuname_clearCB(
342 XtPointer clientdata,
345 static void menuname_setCB(
347 XtPointer client_data,
350 static void menu_field_chgCB(
352 XtPointer client_data,
356 static void obj_options_buildCB(
358 XtPointer client_data,
365 static void find_submenu_owners(
372 static BOOL is_submenu_of(
376 static BOOL menu_in_list(
382 static void strings_init(
386 /*************************************************************************
388 ** Data Declarations **
390 *************************************************************************/
391 extern PalItemInfo* palette_item[];
392 extern int palette_item_cnt;
393 extern PalItemInfo *ab_menu_palitem;
394 extern PalItemInfo *ab_group_palitem;
396 static PalItemInfo *cur_list_palitem = NULL;
397 static Widget revolv_current_frame = NULL;
398 static Widget revolv_optionmenu = NULL;
399 static BOOL apply_in_progress = False;
401 static char Buf[512];
403 /*************************************************************************
405 ** Function Definitions **
407 *************************************************************************/
411 * Create Revolving Prop dialog
412 * Add callbacks for object rename & destroy
421 revolv_dialog_init(toplevel);
423 obj_add_rename_callback(obj_renamedOCB, "PROPS");
424 obj_add_update_callback(obj_shown_or_hiddenOCB, "PROPS");
425 obj_add_geometry_change_callback(obj_geom_changedOCB, "PROPS");
426 obj_add_destroy_callback(obj_destroyedOCB, "PROPS");
430 * Popup the Revolving Prop dialog.
431 * If an object is currently selected, Set the
432 * corresponding revolving prop-type and Load the object
437 XtPointer client_data,
442 PalItemInfo *palitem = NULL;
443 PropStateInfo *pstate;
445 ab_set_busy_cursor(TRUE);
447 abobj_get_selected(proj_get_project(), FALSE, FALSE, &sel);
450 palitem = pal_get_item_info(sel.list[0]);
453 /* If no objects selected, set to First type */
455 palitem = palette_item[0];
457 revolv_invoke_props(palitem, NULL);
458 pstate = get_prop_state_info(AB_rev_prop_dialog);
459 objlist_ensure_selection(pstate->objlist);
461 ab_set_busy_cursor(FALSE);
465 * Popup the Fixed Prop dialog for the specified
473 PropStateInfo *pstate;
475 ab_set_busy_cursor(TRUE);
477 fixed_invoke_props(palitem);
478 pstate = get_prop_state_info(palitem->fix_prop_dialog);
479 objlist_ensure_selection(pstate->objlist);
481 ab_set_busy_cursor(FALSE);
485 * Popup the Fixed Prop dialog for Menus
488 prop_show_menu_props(
490 XtPointer client_data,
494 prop_show_fixed(ab_menu_palitem);
498 * Popup the Fixed Group dialog for menus.
501 prop_show_group_props(
503 XtPointer client_data,
508 prop_show_fixed(ab_group_palitem);
513 * Load an object into the Prop dialog of the
514 * specified prop type (Revolving or Fixed).
522 PalItemInfo *palitem;
523 PalItemInfo *viz_palitem;
525 PropStateInfo *pstate;
526 STRING modname = NULL;
528 if (obj_is_module(obj) || obj_is_project(obj))
531 ab_set_busy_cursor(TRUE);
533 if (obj_is_item(obj))
534 obj = obj_get_parent(obj);
536 obj = obj_get_root(obj);
538 if ((viz_palitem = palitem = pal_get_item_info(obj)) != NULL)
540 if (ptype == AB_PROP_REVOLVING)
542 viz_palitem = revolv_invoke_props(palitem, obj);
543 dialog = AB_rev_prop_dialog;
545 else /* AB_PROP_FIXED */
547 fixed_invoke_props(palitem);
548 dialog = palitem->fix_prop_dialog;
551 pstate = get_prop_state_info(dialog);
552 modname = abobj_get_moduled_name(obj);
555 util_dprintf(1,"prop_load_obj: %s : could not get Palette info\n",
556 util_strsafe(obj_get_name(obj)));
558 ab_set_busy_cursor(FALSE);
560 if (dialog != NULL && modname != NULL && viz_palitem == palitem)
562 ui_list_select_item(pstate->objlist, modname, TRUE);
568 prop_fixed_dialog_init(
569 PalItemInfo *palitem,
574 Widget shell = XtParent(dialog);
576 init_prop_state_info(dialog, palitem, objlist, NULL);
578 /* The initial position of a Fixed Prop dialog is dependent on
579 * how it is invoked and whether the Revolving Prop editor is up,
580 * so don't specify an initial position relative to the palette.
582 ab_register_window(dialog, AB_WIN_DIALOG, WindowHidden,
583 NULL, AB_WPOS_UNSPECIFIED,
584 close_propsCB, (XtPointer)AB_PROP_FIXED);
586 /* Store current-object in List (init to NULL) */
587 XtVaSetValues(objlist,
588 XmNselectionPolicy, XmBROWSE_SELECT,
592 XtAddCallback(objlist, XmNbrowseSelectionCallback,
593 (XtCallbackProc)objlist_selectCB, (XtPointer)AB_PROP_FIXED);
598 prop_activate_panel_init(
600 PalItemInfo *palitem,
604 Widget cancel_button,
610 /* Ensure "Apply" is default button */
611 dialog = ui_get_ancestor_dialog(apply_button);
612 XtVaSetValues(dialog, XmNdefaultButton, apply_button, NULL);
614 XtVaSetValues(apply_button,
615 XmNshowAsDefault, True,
616 XmNdefaultButtonShadowThickness, 1,
618 XtVaSetValues(ok_button,
619 XmNdefaultButtonShadowThickness, 1,
621 XtVaSetValues(reset_button,
622 XmNdefaultButtonShadowThickness, 1,
624 XtVaSetValues(cancel_button,
625 XmNdefaultButtonShadowThickness, 1,
627 if (help_button != NULL)
628 XtVaSetValues(help_button,
629 XmNdefaultButtonShadowThickness, 1,
632 XtAddCallback(apply_button, XmNactivateCallback, apply_propsCB, (XtPointer)type);
633 XtAddCallback(reset_button, XmNactivateCallback, reset_propsCB, (XtPointer)type);
634 XtAddCallback(ok_button, XmNactivateCallback, ok_propsCB, (XtPointer)type);
635 XtAddCallback(cancel_button,XmNactivateCallback, cancel_propsCB,(XtPointer)type);
640 prop_editors_panel_init(
642 PalItemInfo *palitem,
643 Widget attach_ed_button,
644 Widget conn_ed_button,
645 Widget help_ed_button
648 if (attach_ed_button)
650 XtAddCallback(attach_ed_button, XmNactivateCallback,
651 invoke_attach_editorCB, (XtPointer)type);
656 XtAddCallback(conn_ed_button, XmNactivateCallback,
657 invoke_connectionsCB, (XtPointer)type);
662 XtAddCallback(help_ed_button, XmNactivateCallback,
663 invoke_help_editorCB, (XtPointer)type);
672 PropCheckboxSetting pcs,
683 /* Store Widget-IDs */
685 pcs->checkbox = checkbox;
686 pcs->changebar = changebar;
688 propP_changebar_init(changebar, checkbox);
690 for (i=0; i < num_items; i++)
692 XtVaSetValues(items[i], XmNuserData, (XtArgVal)item_keys[i], NULL);
693 XtAddCallback(items[i], XmNvalueChangedCallback,
694 propP_setting_chgCB, (XtPointer)changebar);
699 prop_checkbox_set_value(
700 PropCheckboxSetting pcs,
706 int num_children = 0;
707 WidgetList children = NULL;
711 XtVaGetValues(pcs->checkbox,
712 XtNnumChildren, &num_children,
713 XtNchildren, &children,
716 for (i=0; i < num_children; i++)
718 XtVaGetValues(children[i], XmNuserData, &childkey, NULL);
719 if (childkey == itemkey) /* Found it */
721 XmToggleButtonSetState(children[i], value, trip_changebar? TRUE : FALSE);
725 /* Item not found in checkbox */
726 util_dprintf(1,"prop_checkbox_set_value: invalid item key\n");
731 prop_checkbox_get_value(
732 PropCheckboxSetting pcs,
736 int num_children = 0;
737 WidgetList children = NULL;
741 XtVaGetValues(pcs->checkbox,
742 XtNnumChildren, &num_children,
743 XtNchildren, &children,
746 for (i=0; i < num_children; i++)
748 XtVaGetValues(children[i], XmNuserData, &childkey, NULL);
749 if (childkey == itemkey) /* Found it */
750 return((BOOL)XmToggleButtonGetState(children[i]));
753 /* itemkey was not found */
754 util_dprintf(1, "prop_checkbox_get_value: invalid item key\n");
759 prop_colorfield_init(
760 PropColorSetting pcs,
769 Pixel contrast_pix, default_pix;
770 char swatch_name[128];
772 /* Store Widget-IDs */
773 pcs->menubutton = menubutton;
774 pcs->swatch = swatch;
776 pcs->changebar = changebar;
778 XtAddCallback(chooser_item, XmNactivateCallback,
779 color_chooserCB, (XtPointer)pcs);
781 XtAddCallback(none_item, XmNactivateCallback,
782 color_noneCB, (XtPointer)pcs);
784 /* Determine whether this is a foreground or background color field
785 * and store the corresponding color-default in user-data.
787 strcpy(swatch_name, XtName(swatch));
788 if (strstr(swatch_name, "bg"))
789 default_pix = WhitePixelOfScreen(XtScreen(swatch));
791 default_pix = BlackPixelOfScreen(XtScreen(swatch));
793 /* Ensure Swatch's border is contrast to prop sheet */
794 XtVaGetValues(XtParent(changebar),
795 XmNforeground, &contrast_pix,
797 XtVaSetValues(swatch,
798 XmNborderColor, (XtArgVal)contrast_pix,
799 XmNborderWidth, (XtArgVal)1,
800 XmNuserData, (XtArgVal)default_pix,
801 XmNrecomputeSize, (XtArgVal)False,
804 strcpy(swatch_name, XtName(swatch));
806 /* Setup Prop Sheet changebar mechanism */
807 propP_changebar_init(changebar, menubutton);
809 XtAddCallback(field, XmNvalueChangedCallback,
810 propP_field_chgCB, (XtPointer)changebar);
815 prop_colorfield_get_value(
821 value = ui_field_get_string(pcs->field);
827 prop_colorfield_set_value(
828 PropColorSetting pcs,
835 if (util_strempty(colorname)) /* no color - swatch is 'invisible' */
836 XtVaGetValues(XtParent(pcs->swatch), XmNbackground, &pixel, NULL);
838 else if (objxm_name_to_pixel(AB_toplevel, colorname, &pixel) != OK)
840 if (objxm_color_exists(colorname)) /* color couldn't be allocated */
842 /* Set swatch color to default black or white */
843 XtVaGetValues(pcs->swatch, XmNuserData, &pixel, NULL);
845 else /* Invalid color name - this should not happen */
847 util_dprintf(1, "prop_colorfield_set_value: \"%s\" is not an existing color name.\n",
852 XtVaSetValues(pcs->swatch,
853 XmNbackground, (XtArgVal)pixel,
857 /* Set state so changebar is not triggered */
858 XtVaSetValues(pcs->field, XmNuserData, (XtArgVal)PROP_LOAD, NULL);
860 /* Set field value */
861 ui_field_set_string(pcs->field, colorname);
865 XtVaSetValues(pcs->field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
872 prop_obj_combobox_init(
873 PropObjComboboxSetting pcs,
877 ABObj *current_obj_ptr
881 /* Store Widget-IDs */
883 pcs->combobox = combobox;
884 pcs->changebar = changebar;
885 pcs->list = ui_combobox_get_list_widget(combobox);
886 pcs->current_obj_ptr = current_obj_ptr;
888 /* Setup Prop Sheet changebar mechanism */
889 propP_changebar_init(changebar, combobox);
891 /* Load "None" Item */
892 prop_obj_combobox_load(pcs, NULL, NULL);
894 XtAddCallback(combobox, DtNselectionCallback, propP_combobox_chgCB,
900 prop_obj_combobox_get_value(
901 PropObjComboboxSetting pcs
906 XmStringTable selected;
907 int select_count = 0;
909 XtVaGetValues(pcs->list,
910 XmNselectedItems, &selected,
911 XmNselectedItemCount, &select_count,
914 if (select_count == 0)
916 util_dprintf(1, "prop_obj_combobox_get_value: No items select in List\n");
919 name = objxm_xmstr_to_str(selected[0]);
921 if (util_strcmp(name, NoneItem) != 0)
922 obj = obj_find_by_name(obj_get_module(*pcs->current_obj_ptr), name);
924 obj = NULL; /* "None" was selected */
932 prop_obj_combobox_set_value(
933 PropObjComboboxSetting pcs,
938 ui_combobox_select_item(pcs->combobox,
939 (STRING)(obj? obj_get_name(obj) : NoneItem));
940 prop_set_changebar(pcs->changebar, trip_changebar? PROP_CB_ON : PROP_CB_OFF);
946 prop_obj_combobox_load(
947 PropObjComboboxSetting pcs,
949 ABObjTestFunc obj_test_func
955 ui_combobox_clear(pcs->combobox);
956 ui_combobox_add_item(pcs->combobox, (STRING)NoneItem, 0, False);
960 for (trav_open(&trav, root, AB_TRAV_SALIENT_UI);
961 (obj= trav_next(&trav)) != NULL; )
962 if ((*obj_test_func)(obj) == True)
963 ui_combobox_add_item(pcs->combobox, obj_get_name(obj), 0, False);
971 PropFieldSetting pfs,
977 /* Store Widget-IDs */
980 pfs->changebar = changebar;
982 /* Setup Prop Sheet changebar mechanism */
983 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
984 propP_changebar_init(changebar, field);
986 XtAddCallback(field, XmNvalueChangedCallback,
987 propP_field_chgCB, (XtPointer)changebar);
992 prop_field_get_value(
998 value = ui_field_get_string(pfs->field);
1004 prop_field_set_value(
1005 PropFieldSetting pfs,
1010 return(propP_field_set_value(pfs->field, value, trip_changebar));
1014 prop_field_get_numeric_value(
1015 PropFieldSetting pfs
1021 value = ui_field_get_string(pfs->field);
1022 num = prop_str_to_int(value);
1029 prop_field_set_numeric_value(
1030 PropFieldSetting pfs,
1037 if (!trip_changebar)
1038 /* Set state so changebar is not triggered */
1039 XtVaSetValues(pfs->field, XmNuserData, (XtArgVal)PROP_LOAD, NULL);
1041 /* Convert int to string */
1042 sprintf(valstr, "%d", value);
1043 ui_field_set_string(pfs->field, valstr);
1045 if (!trip_changebar)
1047 XtVaSetValues(pfs->field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
1054 PropFooterSetting pfs,
1066 /* Store Widget-IDs */
1068 pfs->checkbox = checkbox;
1070 pfs->changebar = changebar;
1072 /* Setup Prop Sheet changebar mechanism */
1073 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
1074 propP_changebar_init(changebar, checkbox);
1076 XtAddCallback(field, XmNvalueChangedCallback,
1077 propP_field_chgCB, (XtPointer)changebar);
1079 for (i=0; i < num_items; i++)
1081 XtVaSetValues(items[i], XmNuserData, (XtArgVal)item_keys[i], NULL);
1082 XtAddCallback(items[i], XmNvalueChangedCallback,
1083 propP_setting_chgCB, (XtPointer)changebar);
1089 prop_geomfield_init(
1090 PropGeometrySetting pgs,
1103 /* Store Widget-IDs */
1105 pgs->x_label = x_label;
1106 pgs->x_field = x_field;
1107 pgs->y_label = y_label;
1108 pgs->y_field = y_field;
1109 pgs->w_label = w_label;
1110 pgs->w_field = w_field;
1111 pgs->h_label = h_label;
1112 pgs->h_field = h_field;
1113 pgs->changebar = changebar;
1115 /* Setup Prop Sheet changebar mechanism */
1116 propP_changebar_init(changebar,
1117 x_field? x_field : (y_field? y_field : (w_field? w_field : h_field)));
1119 if (x_field != NULL)
1121 XtVaSetValues(x_field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
1122 XtAddCallback(x_field, XmNvalueChangedCallback,
1123 propP_field_chgCB, (XtPointer)changebar);
1125 if (y_field != NULL)
1127 XtVaSetValues(y_field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
1128 XtAddCallback(y_field, XmNvalueChangedCallback,
1129 propP_field_chgCB, (XtPointer)changebar);
1131 if (h_field != NULL)
1133 XtVaSetValues(h_field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
1134 XtAddCallback(h_field, XmNvalueChangedCallback,
1135 propP_field_chgCB, (XtPointer)changebar);
1137 if (w_field != NULL)
1139 XtVaSetValues(w_field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
1140 XtAddCallback(w_field, XmNvalueChangedCallback,
1141 propP_field_chgCB, (XtPointer)changebar);
1147 prop_geomfield_get_value(
1148 PropGeometrySetting pgs,
1159 field = pgs->x_field;
1162 field = pgs->y_field;
1165 field = pgs->w_field;
1168 field = pgs->h_field;
1175 value = ui_field_get_string(field);
1176 gvalue = prop_str_to_int(value);
1183 prop_geomfield_set_value(
1184 PropGeometrySetting pgs,
1195 field = pgs->x_field;
1198 field = pgs->y_field;
1201 field = pgs->w_field;
1204 field = pgs->h_field;
1210 propP_field_set_numeric_value(field, gvalue, trip_changebar);
1216 prop_load_obj_position(
1218 PropGeometrySetting pgs
1221 BOOL movable = abobj_is_movable(obj);
1223 prop_geomfield_set_value(pgs, GEOM_X, abobj_get_comp_x(obj), False);
1224 prop_geomfield_set_value(pgs, GEOM_Y, abobj_get_comp_y(obj), False);
1226 ui_set_active(pgs->x_field, movable);
1227 ui_set_active(pgs->x_label, movable);
1228 ui_set_active(pgs->y_field, movable);
1229 ui_set_active(pgs->y_label, movable);
1235 PropGeometrySetting pgs
1242 prop_geomfield_set_value(pgs, GEOM_WIDTH, abobj_get_comp_width(obj), False);
1243 resizable = abobj_width_resizable(obj);
1244 ui_set_active(pgs->w_field, resizable);
1245 ui_set_active(pgs->w_label, resizable);
1249 prop_geomfield_set_value(pgs, GEOM_HEIGHT, abobj_get_comp_height(obj), False);
1250 resizable = abobj_height_resizable(obj);
1251 ui_set_active(pgs->h_field, resizable);
1252 ui_set_active(pgs->h_label, resizable);
1259 XtPointer clientdata,
1263 XmToggleButtonCallbackStruct *state = (XmToggleButtonCallbackStruct*)calldata;
1264 PropGeometrySetting pgs = (PropGeometrySetting)clientdata;
1266 BOOL active = False;
1270 XtVaGetValues(w, XmNuserData, &value, NULL);
1271 active = (value == SIZE_FIXED_KEY);
1273 ui_set_active(pgs->w_label, active);
1275 ui_set_active(pgs->w_field, active);
1277 ui_set_active(pgs->h_label, active);
1279 ui_set_active(pgs->h_field, active);
1290 PropMenunameSetting pms,
1295 Widget owner_name_field,
1297 PropFieldSetting menu_title_pfs,
1298 ABObj *current_obj_ptr,
1303 Widget menu_items[4];
1306 pms->prop_type = ptype;
1308 pms->menubutton = menubutton;
1310 pms->owner_name_field = owner_name_field;
1311 pms->changebar = changebar;
1312 pms->menu_title_pfs = menu_title_pfs;
1313 pms->current_obj_ptr = current_obj_ptr;
1315 /* Setup Prop Sheet changebar mechanism */
1316 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
1317 propP_changebar_init(changebar, field);
1319 XtAddCallback(field, XmNvalueChangedCallback,
1320 propP_field_chgCB, (XtPointer)changebar);
1322 /* Build Menu and Setup Callbacks */
1323 XtVaGetValues(menubutton, XmNsubMenuId, &submenu, NULL);
1325 for (i=0; i < XtNumber(menu_items); i++)
1327 menu_items[i] = XtVaCreateManagedWidget(menu_names[i],
1328 xmCascadeButtonWidgetClass,
1330 XtVaTypedArg, XmNlabelString, XtRString,
1331 menu_strs[i], strlen(menu_strs[i])+1,
1336 XtAddCallback(menu_items[NO_MENU], XmNactivateCallback, menuname_clearCB,
1340 XtDestroyWidget(menu_items[NEW_MENU]);
1342 XtAddCallback(menu_items[NEW_MENU], XmNactivateCallback, menu_newCB,
1345 /* Set up callback to dynamically build "Menus" submenu */
1346 XtAddCallback(menubutton, XmNcascadingCallback, menulist_buildCB,
1347 (XtPointer)menu_items[MENUS]);
1348 XtVaGetValues(menubutton, XmNsubMenuId, &submenu, NULL);
1349 XtAddCallback(XtParent(submenu), XtNpopdownCallback, menulist_destroyCB,
1350 (XtPointer)submenu);
1352 /* Set up "Edit Current" menu item */
1353 XtAddCallback(menubutton, XmNcascadingCallback, menu_edit_set_stateCB,
1354 (XtPointer)menu_items[EDIT_MENU]);
1355 XtAddCallback(menu_items[EDIT_MENU], XmNactivateCallback, menu_editCB,
1358 /* Menu Title field should not be active until a Menu is connected */
1361 XtAddCallback(field, XmNvalueChangedCallback,
1362 menu_field_chgCB, (XtPointer)pms);
1363 ui_set_active(menu_title_pfs->label, False);
1364 ui_set_active(menu_title_pfs->field, False);
1370 prop_menuname_get_value(
1371 PropMenunameSetting pms
1376 value = ui_field_get_string(pms->field);
1382 prop_menuname_set_value(
1383 PropMenunameSetting pms,
1388 return(propP_field_set_value(pms->field, value, trip_changebar));
1393 PropOptionsSetting pos,
1399 XtPointer *item_values,
1405 /* Store Widget-IDs */
1407 pos->optionbox = optionbox;
1409 pos->changebar = changebar;
1411 /* Setup Prop Sheet changebar mechanism */
1412 propP_changebar_init(changebar, optionbox);
1414 for (i=0; i < num_items; i++)
1416 XtVaSetValues(items[i], XmNuserData, (XtArgVal)item_values[i], NULL);
1417 XtAddCallback(items[i], XmNactivateCallback,
1418 propP_setting_chgCB, (XtPointer)changebar);
1419 XtAddCallback(items[i], XmNactivateCallback,
1420 propP_options_itemCB, (XtPointer)menu);
1423 /* Initialize Current-value to First Item in Option Menu */
1425 prop_options_set_value(pos, (XtPointer)item_values[0], False);
1429 prop_options_get_value(PropOptionsSetting pos)
1431 XtArgVal value = -1;
1433 XtVaGetValues(pos->menu, XmNuserData, &value, NULL);
1435 return ((XtPointer)value);
1439 prop_options_set_value(
1440 PropOptionsSetting pos,
1446 WidgetList children;
1450 XtVaGetValues(pos->menu,
1451 XtNnumChildren, &num_children,
1452 XtNchildren, &children,
1455 for (i = 0; i < num_children; i++)
1457 XtVaGetValues(children[i],
1458 XmNuserData, &child_val,
1461 if (child_val == (XtArgVal) value)
1463 XtVaSetValues(pos->optionbox, XmNmenuHistory, children[i], NULL);
1464 XtVaSetValues(pos->menu, XmNuserData, (XtArgVal)child_val, NULL);
1467 prop_set_changebar(pos->changebar, PROP_CB_ON);
1472 /* value doesn't exist as an option */
1473 util_dprintf(1, "prop_optionmenu_set_value: invalid option\n");
1478 * prop_options_remove_value()
1479 * Unmanages item corresponding to 'value'
1482 prop_options_remove_value(
1483 PropOptionsSetting pos,
1489 WidgetList children;
1494 XtVaGetValues(pos->menu,
1495 XtNnumChildren, &num_children,
1496 XtNchildren, &children,
1499 for (i = 0; i < num_children; i++)
1501 XtVaGetValues(children[i],
1502 XmNuserData, &child_val,
1505 if (child_val == (XtArgVal)value)
1509 cur_val = (XtArgVal)prop_options_get_value(pos);
1512 * Found value to remove. We need to do:
1513 * - if current setting value is the same as the one we are
1514 * deleting, set the setting value to be the previous item
1515 * (if that is not the deleted one)
1516 * - unmanage item widget
1519 if (cur_val == (XtArgVal)value)
1521 if ((i == 0) && (num_children != 1))
1523 XtVaGetValues(children[1],
1524 XmNuserData, &reset_val,
1526 prop_options_set_value(pos, (XtPointer)reset_val, trip_changebar);
1530 prop_options_set_value(pos, (XtPointer)reset_val, trip_changebar);
1533 XtUnmanageChild(children[i]);
1536 prop_set_changebar(pos->changebar, PROP_CB_ON);
1542 * Remember previous child value
1544 reset_val = child_val;
1547 /* value doesn't exist as an option */
1548 util_dprintf(1, "prop_optionmenu_set_value: invalid option\n");
1553 prop_obj_options_init(
1554 PropObjOptionsSetting pos,
1560 XtPointer *item_values,
1562 BOOL display_module,
1563 ABObj *current_obj_ptr,
1564 ABObjTestFunc obj_test_func
1569 prop_options_init(&(pos->options), label, optionbox, menu,
1570 num_items, items, item_values, changebar);
1571 pos->display_module = display_module;
1572 pos->current_obj_ptr = current_obj_ptr;
1573 pos->obj_test_func = obj_test_func;
1574 pos->search_root = NULL;
1576 /* Setup callback to dynamically build Object list when Menu is popped up */
1577 shell = ui_get_ancestor_shell(menu);
1578 XtAddCallback(shell, XtNpopupCallback, obj_options_buildCB, (XtPointer)pos);
1583 prop_obj_options_get_value(
1584 PropObjOptionsSetting pos
1587 return((ABObj)prop_options_get_value(&(pos->options)));
1591 prop_obj_options_set_value(
1592 PropObjOptionsSetting pos,
1597 return(prop_options_set_value(&(pos->options), (XtPointer)obj, trip_changebar));
1601 prop_obj_options_load(
1602 PropObjOptionsSetting pos,
1611 /* Clear Object OptionMenu */
1612 XtVaGetValues(pos->options.menu,
1613 XmNchildren, &items,
1614 XmNnumChildren, &num_items,
1617 /* Unmanage all but the First ("None") items */
1619 XtUnmanageChildren(&(items[1]), num_items - 1);
1623 /* Load OptionMenu with objects passing "test" */
1624 pos->search_root = search_root;
1625 if (pos->search_root != NULL)
1627 for (trav_open(&trav, pos->search_root, AB_TRAV_SALIENT_UI);
1628 (obj= trav_next(&trav)) != NULL; )
1629 if ((*(pos->obj_test_func))(obj) == True)
1631 /* Either create new item or use existing one */
1632 create_obj_option_item(pos, i < num_items? items[i] : NULL, obj);
1637 XtVaGetValues(pos->options.menu,
1638 XmNchildren, &items,
1641 /* Manage all eligible items */
1643 XtManageChildren(&(items[1]), i - 1);
1648 PropRadioSetting prs,
1653 XtPointer *item_values,
1659 /* Store Widget-IDs */
1661 prs->radiobox = radiobox;
1662 prs->changebar = changebar;
1664 /* Setup Prop Sheet changebar mechanism */
1665 propP_changebar_init(changebar, radiobox);
1667 for (i=0; i < num_items; i++)
1669 XtVaSetValues(items[i], XmNuserData, (XtArgVal)item_values[i], NULL);
1670 XtAddCallback(items[i], XmNvalueChangedCallback,
1671 propP_setting_chgCB, (XtPointer*)changebar);
1672 XtAddCallback(items[i], XmNvalueChangedCallback,
1673 propP_radiobox_itemCB, (XtPointer)item_values[i]);
1675 /* Ensure Radiobox has a default Value set */
1678 XtVaSetValues(items[i], XmNset, True, NULL);
1679 XtVaSetValues(radiobox, XmNuserData, (XtArgVal)item_values[i], NULL);
1686 prop_radiobox_get_value(
1687 PropRadioSetting prs
1692 XtVaGetValues(prs->radiobox, XmNuserData, &value, NULL);
1698 prop_radiobox_set_value(
1699 PropRadioSetting prs,
1704 int num_children = 0;
1705 WidgetList children = NULL;
1706 XtArgVal childval = 0;
1707 Boolean found = FALSE;
1710 XtVaGetValues(prs->radiobox,
1711 XtNnumChildren, &num_children,
1712 XtNchildren, &children,
1715 for (i = 0; i < num_children; i++)
1717 XtVaGetValues(children[i], XmNuserData, &childval, NULL);
1718 XmToggleButtonSetState(children[i], childval == (XtArgVal)value? TRUE : FALSE, FALSE);
1719 if (childval == (XtArgVal)value)
1722 XtVaSetValues(prs->radiobox, XmNuserData, (XtArgVal)value, NULL);
1724 prop_set_changebar(prs->changebar, PROP_CB_ON);
1729 util_dprintf(1,"prop_radio_set_value: invalid value\n");
1736 prop_label_field_init(
1737 PropFieldSetting label_pfs,
1738 Widget graphic_hint,
1739 WidgetList labeltype_items,
1745 if (label_pfs->label != NULL && graphic_hint != NULL)
1746 XtVaSetValues(label_pfs->label,
1747 XmNuserData, (XtArgVal)graphic_hint,
1748 XmNrecomputeSize, False,
1751 for(i=0; i < num_items; i++)
1752 XtAddCallback(labeltype_items[i], XmNactivateCallback,
1753 (XtCallbackProc)propP_labeltypeCB, (XtPointer)label_pfs);
1758 prop_setup_label_field(
1759 PropFieldSetting label_pfs,
1760 PropOptionsSetting label_line_style_pos,
1761 AB_LABEL_TYPE ltype,
1763 AB_LINE_TYPE line_style
1766 Widget graphic_hint = NULL;
1768 XtVaGetValues(label_pfs->label, XmNuserData, &graphic_hint, NULL);
1772 case AB_LABEL_STRING:
1773 case AB_LABEL_GLYPH:
1774 ui_set_label_string(label_pfs->label,
1775 (STRING)(ltype == AB_LABEL_STRING? LabelForString : LabelForGraphic));
1777 ui_set_active(graphic_hint, (ltype == AB_LABEL_GLYPH));
1778 ui_set_active(label_pfs->label, True);
1779 ui_field_set_editable(label_pfs->field, True);
1781 if (label_line_style_pos)
1783 ui_set_active(label_line_style_pos->label, False);
1784 ui_set_active(label_line_style_pos->optionbox, False);
1787 case AB_LABEL_SEPARATOR:
1788 ui_set_active(label_pfs->label, False);
1789 ui_field_set_string(label_pfs->field, "");
1790 ui_field_set_editable(label_pfs->field, False);
1791 ui_set_active(label_line_style_pos->label, True);
1792 ui_set_active(label_line_style_pos->optionbox, True);
1794 ui_set_active(graphic_hint, False);
1797 if (field_val != NULL)
1799 XtVaSetValues(label_pfs->field, XmNuserData, (XtArgVal)PROP_LOAD, NULL);
1800 ui_field_set_string(label_pfs->field, field_val);
1801 XtVaSetValues(label_pfs->field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
1803 if (line_style != AB_LINE_UNDEF)
1804 prop_options_set_value(label_line_style_pos, (XtPointer)line_style, False);
1806 /* WORKAROUND: for Motif bug */
1807 XtVaSetValues(label_pfs->label, XmNalignment, XmALIGNMENT_END, NULL);
1812 * return TRUE if changebar is "on"
1821 XtVaGetValues(changebar, XmNuserData, &cb_state, NULL);
1823 if (cb_state == PROP_CB_ON)
1831 * Get the running-count of changebars that are "ON"
1834 prop_changebars_pending(
1838 XtArgVal change_count;
1840 XtVaGetValues(prop_sheet, XmNuserData, &change_count, NULL);
1842 if (change_count > 0)
1850 * Set the running-count of changebars that are "ON" to 0
1853 prop_changebars_cleared(
1857 XtVaSetValues(prop_sheet, XmNuserData, (XtArgVal)0, NULL);
1861 * Set changebar to desired state: on or off
1862 * Also keep a running count of the number of changebars
1863 * that are "ON" in the userData of the changebars' parent
1874 prop_sheet = XtParent(changebar);
1876 if (mode == PROP_CB_ON)
1879 REMIND: aim - workaround for Motif problem with Prop textfield
1882 if (!prop_changed(changebar))
1885 XtVaGetValues(XtParent(changebar),
1886 XmNforeground, &bar_pixel,
1889 XtVaSetValues(changebar,
1890 XmNbackground, bar_pixel,
1891 XmNforeground, bar_pixel,
1892 XmNuserData, (XtArgVal)PROP_CB_ON,
1896 XtVaSetValues(prop_sheet, XmNuserData, (XtArgVal)1, NULL);
1901 else /* PROP_CB_OFF */
1904 if (prop_changed(changebar))
1907 XtVaGetValues(XtParent(changebar), XmNbackground, &bar_pixel, NULL);
1908 XtVaSetValues(changebar,
1909 XmNbackground, bar_pixel,
1910 XmNforeground, bar_pixel,
1911 XmNuserData, (XtArgVal)PROP_CB_OFF,
1920 * Verify that the colorname entered is valid
1930 colorname = ui_field_get_string(field);
1932 /* No color is OK */
1933 if (util_strempty(colorname))
1936 if (!objxm_color_exists(colorname))
1939 catgets(Dtb_project_catd, 100, 112, "%s is not a valid color."),
1941 util_set_help_data(catgets(Dtb_project_catd, 100, 113,
1942 "The color that was specified is not recognized\nas a valid color name."), NULL, NULL);
1945 propP_popup_message(field, Buf, False);
1947 util_free(colorname);
1953 * Verify that the Glyph filename entered is valid
1956 prop_graphic_filename_ok(
1968 filename = ui_field_get_string(field);
1970 if (util_strempty(filename))
1973 valid = True; /* No Filename is valid */
1976 util_set_help_data(catgets(Dtb_project_catd, 100, 115,
1977 "If Graphic is specified as the Label Type for\nthe object whose properties are being modified,\nthen a pixmap (.pm, .xpm) or bitmap (.bm, .xbm)\nfile name must be specified in the Graphic Filename\nfield."), NULL, NULL);
1979 propP_popup_message(field,
1980 catgets(Dtb_project_catd, 100, 114,
1981 "The \"Graphic Filename\" field cannot be empty."), False);
1986 strcpy(filebase, filename);
1987 /* Look to see if user typed in the full filename for the Graphic.
1988 * If so, strip off the extension and mark stripped to be True.
1990 if (util_file_name_has_extension(filename, "pm") ||
1991 util_file_name_has_extension(filename, "xpm") ||
1992 util_file_name_has_extension(filename, "bm") ||
1993 util_file_name_has_extension(filename, "xbm"))
1995 ext = strrchr(filebase, '.');
1996 ext[0] = '\0'; /* strip off extenstion */
1998 util_set_help_data(catgets(Dtb_project_catd, 100, 117,
1999 "The graphic file name extension should not be included\nwhen it is specified in the Graphic Filename field."), NULL, NULL);
2001 propP_popup_message(field,
2002 catgets(Dtb_project_catd, 100, 116,
2003 "\"Graphic Filename\" field expects the filename\nbase only (no extensions: .pm .xpm .bm .xbm).\nStripping off the extension."), True);
2004 ui_field_set_string(field, filebase);
2006 status = objxm_filebase_to_pixmap(field, filebase, &pixmap);
2010 XmDestroyPixmap(XtScreen(field), pixmap);
2013 propP_popup_message(field,
2014 objxm_pixmap_conversion_error_msg(NULL, filebase, status), False);
2017 util_free(filename);
2030 BOOL exists = FALSE;
2036 XmNitemCount, &num_items,
2037 XmNuserData, &iobj_list,
2040 /* Search through cascades, looking for another configured
2041 * to be the "Help" cascade
2043 for (i = 0; i < num_items; i++)
2045 if (obj_is_help_item(iobj_list[i]) == TRUE &&
2046 item_obj != iobj_list[i])
2054 util_set_help_data(catgets(Dtb_project_catd, 100, 119,
2055 "Two Menubar items cannot both be specified as the\nHelp cascade. To specify a different Menubar item,\nyou must first clear the item that is currently set\nto be the Help cascade, then select the new Menubar\nitem to be the Help cascade."), NULL, NULL);
2057 sprintf(Buf, catgets(Dtb_project_catd, 100, 118,
2058 "There can only be one Help cascade per Menubar.Item\n\"%s\" is already configured to be the Help cascade,\ntherefore Item \"%s\" cannot also be the Help cascade."),
2059 obj_get_label(iobj_list[i]), obj_get_label(item_obj));
2061 propP_popup_message(list, Buf, False);
2070 * Verify that identifier string only contains valid chars
2077 return(prop_string_ok(field, Name_ok_test, TRUE));
2083 * verify that the name entered is valid & unique
2091 ABObj module = obj_get_module(obj);
2098 newname = ui_field_get_string(field);
2099 oldname = obj_get_name(obj);
2101 if (!newname || !*newname)
2103 util_set_help_data(catgets(Dtb_project_catd, 100, 121,
2104 "A string must be entered in the Object Name field."),
2106 propP_popup_message( field, catgets(Dtb_project_catd, 100, 120,
2107 "A name is required."), False);
2110 else if (!prop_identifier_ok(field))
2116 ((other = obj_find_by_name(module, newname)) != NULL))
2120 util_set_help_data(catgets(Dtb_project_catd, 100, 123,
2121 "The name specified in the Object Name field is not\na unique name in the module. You must specify a unique\nname for the object."),
2124 sprintf(Buf, catgets(Dtb_project_catd, 100, 122,
2125 "Another object in Module \"%s\"\nhas the name \"%s\".\nPlease enter a unique name."), util_strsafe(obj_get_name(module)),newname);
2126 propP_popup_message(field, Buf, False);
2150 string = ui_field_get_string(field);
2153 if ((s != NULL) && (*s != '\0'))
2155 (void)strtol(s, &p, 10);
2157 if((s == p) || ((s + strlen(s)) != p))
2159 util_set_help_data(catgets(Dtb_project_catd, 100, 125,
2160 "The field only accepts integers. You must enter\nan integer value."), NULL, NULL);
2161 sprintf(Buf, catgets(Dtb_project_catd, 100, 124,
2162 "\"%s\" must contain an integer."),
2164 propP_popup_message(field, Buf, False);
2168 if (valid) /* is an integer */
2170 value = prop_str_to_int(string);
2171 if (value < min_val || value > max_val)
2173 util_set_help_data(catgets(Dtb_project_catd, 100, 127,
2174 "The numerical value entered into the field is not valid. Specify a value in the given range."), NULL, NULL);
2175 sprintf(Buf, catgets(Dtb_project_catd, 100, 126,
2176 "\"%s\" value (%d) out of\nvalid range [%d - %d]."),
2177 field_name, value, min_val, max_val);
2178 propP_popup_message(field, Buf, False);
2188 * Search the tree beginning at "root" for an object of the specified
2189 * type with the name currently stored in "field"
2190 * Return TRUE if found (or name is "") and FALSE otherwise
2196 AB_OBJECT_TYPE objtype,
2205 objname = ui_field_get_string(field);
2207 /* ObjName can be blank OR the name of an existing obj */
2208 if (util_strcmp(objname, "") == 0)
2210 else if ((target = obj_scoped_find_by_name(root, objname)) != NULL)
2212 if (target->type == objtype)
2216 util_set_help_data(catgets(Dtb_project_catd, 100, 129,
2217 "The object specified is not of the correct type.\nFor example, it is an error to specify a button\nas the Popup Menu for a Control Pane."),
2219 sprintf(msgbuf, catgets(Dtb_project_catd, 100, 128,
2220 "\"%s\" is not an object of type %s."),
2221 objname, objtype_name);
2226 util_set_help_data(catgets(Dtb_project_catd, 100, 136,
2227 "The specified object does not exist or it is\nnot of the correct type."), NULL, NULL);
2229 sprintf(msgbuf, catgets(Dtb_project_catd, 100, 130,
2230 "\"%s\" is not the name of an existing %s."),
2231 objname, objtype_name);
2235 propP_popup_message(field, msgbuf, False);
2244 prop_submenu_name_ok(
2250 ABObj module = obj_get_module(owner);
2253 /* Check to see if Submenu exists first */
2254 if (prop_obj_name_ok(field, module, AB_TYPE_MENU, "Menu"))
2258 /* Check that the submenu name specified will not cause a circular
2259 * menu (if the submenu is one that is in the owner's ancestory)
2261 if (obj_is_menu(owner))
2263 ABObj menu, *menus, *ineligible_menus;
2265 int ineligible_count = 0;
2268 menu_name = ui_field_get_string(field);
2269 abobj_build_menus_array(module, &menus, &menu_count);
2271 /* Build list of any menus in the ancestory of "owner" menu
2272 * since these are not valid submenus
2274 ineligible_menus = (ABObj*)util_malloc(menu_count*sizeof(ABObj));
2275 ineligible_menus[ineligible_count++] = owner;
2276 find_submenu_owners(owner, menus, menu_count,
2277 ineligible_menus, &ineligible_count);
2279 /* Check to see if the specified submenu is in the ineligible list */
2280 menu = obj_scoped_find_by_name(module, menu_name);
2281 if (menu_in_list(ineligible_menus, ineligible_count, menu))
2283 STRING fmtStr = NULL;
2284 STRING help_buf = NULL;
2288 fmtStr = XtNewString(catgets(Dtb_project_catd,
2289 100, 132, "Menu \"%s\" is attached as a sub-menu\nto \"%s\". You cannot create a circular\nreference within menus."));
2291 help_buf = (STRING) util_malloc(strlen(fmtStr) +
2292 strlen(obj_get_name(owner)) + strlen(menu_name) +1);
2293 sprintf(help_buf, fmtStr, obj_get_name(owner), menu_name);
2295 util_set_help_data(help_buf, NULL, NULL);
2296 sprintf(msgbuf, catgets(Dtb_project_catd, 100, 131,
2297 "Menu \"%s\" is an ancestor of \"%s\"\ntherefore it cannot be attached as a Sub-menu."), menu_name, obj_get_name(owner));
2298 propP_popup_message(field, msgbuf, False);
2301 util_free(help_buf);
2304 util_free(ineligible_menus);
2305 util_free(menu_name);
2321 if ((s != NULL) && (*s != '\0'))
2323 val = (int)strtol(s, &p, 10);
2325 if ((s == p) || ((s + strlen(s)) != p))
2335 * verify that a string contains only valid characters
2347 string = ui_field_get_string(field);
2350 while(s && *s != '\0')
2352 if (!isalnum(*s) && (strchr(chars, *s) == NULL))
2356 util_set_help_data(catgets(Dtb_project_catd, 10, 69,
2357 "Object names are used by the code generator to\ncreate C identifier names. C identifiers must\nbe composed of letters, digits, or underscores.\nTherefore, object names in App Builder must also\nfollow that rule."),
2359 sprintf(Buf, catgets(Dtb_project_catd, 100, 133,
2360 "Only letters, digits, and [%s] allowed."), chars);
2361 propP_popup_message(field, Buf, False);
2374 *****************************************************************
2375 * Module Private Functions
2376 *****************************************************************
2380 * Set Changebar's geometry so that it is aligned with and equal in height to,
2381 * it's corresponding setting. This must be done dynamically because fonts
2382 * and localization could cause these metrics to change at dtbuilder invocation.
2387 XtPointer client_data,
2389 Boolean *cont_dispatch
2392 Widget setting, changebar;
2393 Widget setting_p, changebar_p;
2394 Position setting_y, delta_y;
2395 Dimension setting_h;
2396 Widget *wlist = (Widget*)client_data;
2398 if (event->type == MapNotify)
2400 changebar = wlist[0];
2403 XtVaGetValues(setting,
2404 XmNheight, &setting_h,
2408 changebar_p = XtParent(changebar);
2409 setting_p = setting;
2411 /* Calculate the setting's overall y position relative to the
2412 * entire property sheet by walking up the setting's ancestry
2413 * and accumulating the relative y offsets.
2415 while (setting_p && XtParent(setting_p) != changebar_p)
2417 setting_p = XtParent(setting_p);
2418 XtVaGetValues(setting_p, XmNy, &delta_y, NULL);
2419 setting_y += delta_y;
2422 /* Align the changebar up with the setting */
2423 XtVaSetValues(changebar,
2424 XmNheight, setting_h - 2,
2425 XmNy, setting_y + 1,
2426 XmNtopOffset, setting_y + 1,
2429 /* Only need to do this once per changebar! */
2430 XtRemoveEventHandler(shell, StructureNotifyMask, False,
2431 set_changebar_size, (XtPointer)wlist);
2438 * Initialize the changebar
2441 propP_changebar_init(
2446 Widget shell = ui_get_ancestor_shell(changebar);
2448 unsigned char changebar_top_att;
2450 XtVaSetValues(changebar, XmNuserData, (XtArgVal)PROP_CB_ON, NULL);
2451 prop_set_changebar(changebar, PROP_CB_OFF);
2453 /* If changebar already has attachment, let's not mess with it */
2454 XtVaGetValues(changebar, XmNtopAttachment, &changebar_top_att, NULL);
2455 if (changebar_top_att != XmATTACH_FORM)
2458 wlist = (Widget*)util_malloc(2*sizeof(Widget));
2462 wlist[0] = changebar;
2465 /* Once the shell is mapped we'll need to calculate the appropriate
2466 * changebar size/position to match its corrsponding setting
2467 * (which could change dynamically due to fonts/localization)
2469 XtAddEventHandler(shell, StructureNotifyMask, False,
2470 set_changebar_size, (XtPointer)wlist);
2474 * Callback: textfield value has changed...turnon changebar
2475 * if operation is not a "load"
2479 propP_combobox_chgCB(
2481 XtPointer clientdata,
2485 PropObjComboboxSetting pcs = (PropObjComboboxSetting)clientdata;
2487 prop_set_changebar(pcs->changebar, PROP_CB_ON);
2493 XtPointer clientdata,
2497 Widget changebar = (Widget)clientdata;
2498 XtArgVal field_mode, cb_state;
2500 XtVaGetValues(widget, XmNuserData, &field_mode, NULL);
2502 REMIND: aim - workaround for Motif problem with Prop textfield
2505 XtVaGetValues(changebar, XmNuserData, &cb_state, NULL);
2507 if (field_mode == PROP_EDIT && cb_state == PROP_CB_OFF)
2509 if (field_mode == PROP_EDIT)
2510 prop_set_changebar(changebar, PROP_CB_ON);
2515 propP_field_set_value(
2521 if (!trip_changebar)
2522 /* Set state so changebar is not triggered */
2523 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_LOAD, NULL);
2525 /* Set field value */
2526 ui_field_set_string(field, value);
2528 if (!trip_changebar)
2530 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
2536 propP_field_set_numeric_value(
2544 if (!trip_changebar)
2545 /* Set state so changebar is not triggered */
2546 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_LOAD, NULL);
2548 /* Convert int to string */
2549 sprintf(valstr, "%d", val);
2550 ui_field_set_string(field, valstr);
2552 if (!trip_changebar)
2554 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_EDIT, NULL);
2563 XtPointer clientdata,
2567 AB_LABEL_TYPE label_type = AB_LABEL_UNDEF;
2568 PropFieldSetting label_pfs = (PropFieldSetting)clientdata;
2570 XtVaGetValues(item, XmNuserData, &label_type, NULL);
2571 prop_setup_label_field(label_pfs, NULL, label_type, NULL, AB_LINE_UNDEF);
2572 ui_field_select_string(label_pfs->field, True);
2576 propP_options_itemCB(
2578 XtPointer client_data,
2582 Widget optionmenu = (Widget)client_data;
2585 XtVaGetValues(item, XmNuserData, &value, NULL);
2587 XtVaSetValues(optionmenu, XmNuserData, (XtArgVal)value, NULL);
2592 * popup Error Dialog displaying passed in message
2595 propP_popup_message(
2601 DtbObjectHelpDataRec help_data;
2602 STRING help_text = NULL;
2603 STRING help_vol = NULL;
2604 STRING help_loc = NULL;
2605 XmString xm_buf = XmStringCreateLocalized(msg);
2607 dtb_revolv_wrn_msg_initialize(&dtb_revolv_wrn_msg);
2609 util_get_help_data(&help_text, &help_vol, &help_loc);
2610 if (!util_strempty(help_text))
2612 help_data.help_text = help_text ? (STRING) XtNewString(help_text) : NULL;
2613 help_data.help_volume = help_vol ? (STRING) XtNewString(help_vol) : NULL;
2614 help_data.help_locationID = help_loc ? (STRING) XtNewString(help_loc) : NULL;
2618 /* If there is no help text to display,
2619 * then remove the Help button.
2621 dtb_revolv_wrn_msg.help_button = False;
2624 if (!util_strempty(help_text))
2626 dtb_show_message(parent,
2627 &dtb_revolv_wrn_msg, xm_buf, &help_data);
2630 * Free help data strings
2632 if (help_data.help_text);
2633 XtFree(help_data.help_text);
2634 if (help_data.help_volume);
2635 XtFree(help_data.help_volume);
2636 if (help_data.help_locationID);
2637 XtFree(help_data.help_locationID);
2640 dtb_show_message(parent,
2641 &dtb_revolv_wrn_msg, xm_buf, NULL);
2643 XmStringFree(xm_buf);
2647 * Callback: choice value has changed...turnon changebar
2650 propP_setting_chgCB(
2652 XtPointer clientdata,
2656 Widget changebar = (Widget)clientdata;
2659 XtVaGetValues(changebar, XmNuserData, &cb_state, NULL);
2661 if (cb_state == PROP_CB_OFF)
2662 prop_set_changebar(changebar, PROP_CB_ON);
2667 * Callback: item in exclusive choice has been set...store it's
2668 * value in the parent radiobox
2671 propP_radiobox_itemCB(
2673 XtPointer clientdata,
2677 XmToggleButtonCallbackStruct *state = (XmToggleButtonCallbackStruct*)calldata;
2678 XtArgVal value = (XtArgVal)clientdata;
2679 Widget excl_setting;
2683 excl_setting = XtParent(item);
2684 XtVaSetValues(excl_setting, XmNuserData, value, NULL);
2690 *****************************************************************
2692 *****************************************************************
2700 DtbRevolvPropDialogInfo cgen = &dtb_revolv_prop_dialog; /* Codegen structure */
2702 if (dtb_revolv_prop_dialog_initialize(cgen, parent) == 0)
2704 AB_rev_prop_dialog = cgen->prop_dialog_shellform;
2706 XtVaSetValues(cgen->prop_dialog_form,
2707 XmNresizePolicy, XmRESIZE_ANY,
2708 XmNallowResize, True,
2709 XmNautoUnmanage, False,
2712 revolv_objectspane_init(cgen);
2713 revolv_basicframe_init(cgen);
2714 prop_activate_panel_init(AB_PROP_REVOLVING, NULL,
2715 cgen->ok_button, cgen->apply_button,
2716 cgen->reset_button, cgen->cancel_button,
2719 init_prop_state_info(AB_rev_prop_dialog, NULL, cgen->objlist, NULL);
2721 ab_register_window(AB_rev_prop_dialog, AB_WIN_DIALOG,
2722 WindowHidden, AB_toplevel, AB_WPOS_TILE_HORIZONTAL,
2723 close_propsCB, (XtPointer)AB_PROP_REVOLVING);
2728 * In order to get the automatically generated dtbuilder
2729 * resource file to work with our Revolving Props cloning
2730 * mechanism, we need to name each Revolving prop sheet
2731 * frame to be the SAME as the dialog shellform within
2732 * the Fixed version (to ensure the attribute settings
2733 * resources are picked up in the Revolving version).
2736 get_prop_frame_name(
2737 PalItemInfo *palitem
2740 switch (palitem->type)
2742 case AB_TYPE_BASE_WINDOW:
2743 return "dtb_mainwin_prop_dialog_shellform";
2744 case AB_TYPE_DIALOG:
2745 return "dtb_custdlg_prop_dialog_shellform";
2746 case AB_TYPE_FILE_CHOOSER:
2747 return "dtb_fchooser_prop_dialog_shellform";
2748 case AB_TYPE_CONTAINER:
2749 if (util_streq(palitem->name, "Control Pane"))
2750 return "dtb_cpanel_prop_dialog_shellform";
2751 else if (util_streq(palitem->name, "Group"))
2752 return "dtb_group_prop_dialog_shellform";
2753 else if (util_streq(palitem->name, "Menubar"))
2754 return "dtb_menubar_prop_dialog_shellform";
2756 return "dtb_panedwin_ed_prop_dialog_shellform";
2757 case AB_TYPE_DRAWING_AREA:
2758 return "dtb_drawp_prop_dialog_shellform";
2759 case AB_TYPE_TEXT_PANE:
2760 return "dtb_textp_prop_dialog_shellform";
2761 case AB_TYPE_TERM_PANE:
2762 return "dtb_termp_prop_dialog_shellform";
2763 case AB_TYPE_BUTTON:
2764 return "dtb_button_prop_dialog_shellform";
2765 case AB_TYPE_CHOICE:
2766 return "dtb_choice_prop_dialog_shellform";
2767 case AB_TYPE_COMBO_BOX:
2768 return "dtb_combobox_prop_dialog_shellform";
2770 return "dtb_label_prop_dialog_shellform";
2772 return "dtb_list_prop_dialog_shellform";
2774 return "dtb_menu_prop_dialog_shellform";
2776 return "dtb_scale_prop_dialog_shellform";
2777 case AB_TYPE_SEPARATOR:
2778 return "dtb_sep_prop_dialog_shellform";
2779 case AB_TYPE_SPIN_BOX:
2780 return "dtb_spinbox_prop_dialog_shellform";
2781 case AB_TYPE_TEXT_FIELD:
2782 return "dtb_textf_prop_dialog_shellform";
2784 return "revolv_prop_frame";
2789 revolv_basicframe_init(
2790 DtbRevolvPropDialogInfo cgen
2797 /* Destroy dummy frame & controlpanel */
2798 XtDestroyWidget(cgen->attrs_ctrlpanel_frame);
2800 /* Create Form to manage all revolving frames */
2801 rev_form = XtVaCreateManagedWidget("revolving_dialog_form",
2803 cgen->prop_dialog_form,
2804 XmNtopAttachment, XmATTACH_WIDGET,
2805 XmNtopWidget, cgen->objlist_panel,
2806 XmNrightAttachment, XmATTACH_FORM,
2807 XmNleftAttachment, XmATTACH_FORM,
2808 XmNbottomAttachment, XmATTACH_FORM,
2809 XmNresizePolicy, XmRESIZE_ANY,
2814 * Create frame for each object on the palette...
2816 for (i = 0; i < palette_item_cnt; i++)
2818 rev_frame = cgen->attrs_ctrlpanel_frame =
2819 XtVaCreateWidget(get_prop_frame_name(palette_item[i]),
2822 XmNshadowType, XmSHADOW_IN,
2823 XmNtopAttachment, XmATTACH_FORM,
2824 XmNrightAttachment, XmATTACH_FORM,
2825 XmNleftAttachment, XmATTACH_FORM,
2826 XmNbottomAttachment, XmATTACH_FORM,
2829 (*(palette_item[i]->prop_initialize))(rev_frame, AB_PROP_REVOLVING);
2830 palette_item[i]->rev_prop_frame = rev_frame;
2832 /* Make sure Frame is not initially managed */
2833 XtUnmanageChild(rev_frame);
2839 PalEditableObjInfo *ed_obj_info
2842 return (ed_obj_info->palitem != NULL);
2846 revolv_objectspane_init(
2847 DtbRevolvPropDialogInfo cgen
2851 revolv_optionmenu = cgen->objtype_opmenu;
2853 /* Destroy dummy Option menu item */
2854 XtDestroyWidget(cgen->objtype_opmenu_items.object_type_item);
2856 /* Build up Object Type Option Menu */
2857 pal_add_editable_obj_menu_items(cgen->objtype_opmenu_menu,
2858 change_objecttypeCB, editable_obj_test);
2861 * Configure Revolving Behavior
2863 XtAddCallback(cgen->tearoff_button, XmNactivateCallback,
2864 tearoff_propsCB, NULL);
2866 XtAddCallback(cgen->objlist, XmNbrowseSelectionCallback,
2867 (XtCallbackProc)objlist_selectCB,
2868 (XtPointer)AB_PROP_REVOLVING);
2870 /* Setup Object List Label */
2871 XtVaSetValues(cgen->objlist_label2,
2872 XmNalignment, XmALIGNMENT_END,
2873 XmNrightAttachment, XmATTACH_WIDGET,
2874 XmNrightWidget, cgen->objlist_scrolledwin,
2876 XmNleftAttachment, XmATTACH_POSITION,
2878 XmNbottomAttachment, XmATTACH_NONE,
2884 * Switch the Revolving-prop frame to display the pane
2885 * matching the specified Palette Item type.
2888 revolv_change_prop_frame(
2889 PalItemInfo *palitem
2892 Widget newframe = NULL;
2893 PropStateInfo *pstate;
2895 if (palitem->rev_prop_frame != NULL)
2897 newframe = palitem->rev_prop_frame;
2898 XtManageChild(newframe);
2900 if (newframe != NULL)
2902 if (revolv_current_frame != NULL)
2903 XtUnmanageChild(revolv_current_frame);
2904 revolv_current_frame = newframe;
2906 pstate = get_prop_state_info(AB_rev_prop_dialog);
2907 pstate->palitem = palitem;
2908 objlist_load(AB_PROP_REVOLVING, pstate);
2913 * Attempt to change the Type of Props being edited
2914 * in the Revolving Prop dialog to the specified
2915 * Palette Item type. IF there are currently un-applied
2916 * edits pending, handle "auto apply".
2918 static PalItemInfo *
2919 revolv_set_prop_type(
2920 PalItemInfo *new_palitem,
2924 PalItemInfo *viz_palitem = new_palitem;
2925 PropStateInfo *pstate;
2927 if (revolv_current_frame != new_palitem->rev_prop_frame)
2929 pstate = get_prop_state_info(AB_rev_prop_dialog);
2931 if (pstate->palitem &&
2932 (*pstate->palitem->prop_pending)(AB_PROP_REVOLVING) == TRUE)
2933 handle_auto_apply(AB_PROP_REVOLVING, pstate,
2934 new_palitem, load_obj, &viz_palitem);
2936 revolv_change_prop_frame(new_palitem);
2939 /* Return current visible Palette Item type (might be different
2940 * than one requested if user canceled load operation during
2943 return(viz_palitem);
2948 * Invoke Revolving Property Dialog (create if it doesn't exist)
2949 * and set it's revolving-type to the Palette Item type
2950 * corrsponding to the loadobj's type (if loadobj == NULL, then
2951 * no specific object is being loaded).
2953 static PalItemInfo *
2954 revolv_invoke_props(
2955 PalItemInfo *palitem,
2959 PalItemInfo *viz_palitem;
2961 if (!AB_rev_prop_dialog)
2962 revolv_dialog_init(AB_toplevel);
2964 viz_palitem = revolv_set_prop_type(palitem, load_obj);
2966 ab_show_window(AB_rev_prop_dialog);
2968 ui_optionmenu_change_label(revolv_optionmenu, viz_palitem->name);
2970 return(viz_palitem);
2976 PalItemInfo *palitem
2980 PropStateInfo *pstate;
2982 static BOOL first_time = True;
2984 if (palitem->fix_prop_dialog == NULL)
2986 prop_dialog = (*(palitem->prop_initialize))(AB_toplevel, AB_PROP_FIXED);
2988 if (prop_dialog != NULL)
2990 palitem->fix_prop_dialog = prop_dialog;
2991 pstate = get_prop_state_info(palitem->fix_prop_dialog);
2993 /* Load all current objects of this type into the list */
2994 objlist_load(AB_PROP_FIXED, pstate);
2998 prop_dialog = palitem->fix_prop_dialog;
3000 if (prop_dialog != NULL)
3004 ab_position_window(prop_dialog,
3005 ab_window_is_open(AB_rev_prop_dialog)?
3006 AB_rev_prop_dialog : AB_toplevel,
3007 AB_WPOS_TILE_HORIZONTAL);
3011 ab_show_window(prop_dialog);
3014 util_dprintf(1, "fixed_invoke_props: could not initialize Properties for %s\n",
3025 PropStateInfo *pstate;
3027 pstate = get_prop_state_info(dialog);
3029 if (pstate->loaded_obj == NULL) /* no object currently loaded */
3032 return(apply_prop_changes(type, pstate->loaded_obj, pstate->palitem));
3037 * Apply Prop changes to an object
3043 PalItemInfo *palitem
3046 Widget alt_dialog = NULL;
3047 AB_PROP_TYPE alt_type;
3048 PropStateInfo *alt_pstate;
3051 apply_in_progress = True;
3052 result = (*(palitem->prop_apply))(type);
3053 apply_in_progress = False;
3055 /* If same object is also loaded into alternate prop dialog,
3056 * propagate the changes to the alternate dialog.
3058 if (type == AB_PROP_REVOLVING && palitem->fix_prop_dialog != NULL)
3060 alt_type = AB_PROP_FIXED;
3061 alt_dialog = palitem->fix_prop_dialog;
3063 else if (type == AB_PROP_FIXED &&
3064 palitem->rev_prop_frame == revolv_current_frame)
3066 alt_type = AB_PROP_REVOLVING;
3067 alt_dialog = AB_rev_prop_dialog;
3072 alt_pstate = get_prop_state_info(alt_dialog);
3073 if (alt_pstate->loaded_obj == obj)
3074 (*(palitem->prop_load))(obj, alt_type, LoadAll);
3081 * Handle Auto-apply:
3082 * Another object is being loaded into a Prop dialog
3083 * however another object has edits pending;
3084 * Post a Modal Message asking the user to Apply the
3085 * changes or Cancel the Load operation.
3086 * Return the resulting Palette Item type which is
3087 * showing after the user makes a choice.
3089 static DTB_MODAL_ANSWER
3091 AB_PROP_TYPE prop_type,
3092 PropStateInfo *pstate,
3093 PalItemInfo *new_palitem,
3095 PalItemInfo **result
3098 DTB_MODAL_ANSWER answer = DTB_ANSWER_NONE;
3100 BOOL changing_types = FALSE;
3102 DtbObjectHelpData help_data = NULL;
3104 if (pstate->loaded_obj == NULL) /* something's wrong */
3106 util_dprintf(1,"handle_auto_apply: NULL previous obj!??\n");
3111 if (new_palitem != pstate->palitem)
3112 changing_types = TRUE;
3115 help_data = (DtbObjectHelpData) util_malloc(sizeof(DtbObjectHelpDataRec));
3116 help_data->help_volume = NULL;
3117 help_data->help_locationID = NULL;
3119 if (dtb_app_resource_rec.implied_apply == True)
3121 answer = DTB_ANSWER_ACTION1;
3125 XmString xm_buf = (XmString) NULL;
3126 STRING loadedObjName = obj_get_name(pstate->loaded_obj);
3128 if (new_obj == NULL)
3132 sprintf(Buf, catgets(Dtb_project_catd, 100, 34,
3133 "Properties for \"%s\" have been modified but not Applied.\
3134 \nApply Changes or Cancel Change-ObjectType operation."),
3137 help_data->help_text = catgets(Dtb_project_catd, 100,95,
3138 "Click Apply Changes to apply the changes to the\ncurrent object and display the new object type.\n\nClick Cancel if you don't want to apply the\nchanges to the current object. You can then\nclick Reset to undo the changes before changing\nto a different object type.");
3142 sprintf(Buf, catgets(Dtb_project_catd, 100, 35,
3143 "Properties for \"%s\" have been modified but not Applied.\
3144 \nApply Changes or Cancel Close operation."),
3147 help_data->help_text = catgets(Dtb_project_catd, 100,96,
3148 "Click Apply Changes to apply the changes to the\ncurrent object and close the Property Editor.\n\nClick Cancel if you don't want to apply the\nchanges to the current object and want the\nProperty Editor to remain displayed. You can\nthen click Reset to undo the changes before\nclosing the Property Editor.");
3153 STRING newObjName = obj_get_name(new_obj);
3155 sprintf(Buf, catgets(Dtb_project_catd, 100, 36,
3156 "Properties for \"%s\" have been modified but not Applied.\
3157 \nApply Changes or Cancel Load operation for \"%s\"."),
3158 loadedObjName, newObjName);
3160 help_data->help_text = catgets(Dtb_project_catd, 100,93,
3161 "Click Apply Changes to apply the changes to the\ncurrent object and load the selected object.\n\nClick Cancel if you don't want to apply the\nchanges to the current object. You can then\nclick Reset to undo the changes before loading\nthe selected object.");
3164 /* Popup Modal Message and wait for answer */
3165 xm_buf = XmStringCreateLocalized(Buf);
3166 dtb_revolv_prop_pend_msg_initialize(&dtb_revolv_prop_pend_msg);
3167 answer = dtb_show_modal_message(pstate->objlist,
3168 &dtb_revolv_prop_pend_msg, xm_buf, help_data, NULL);
3170 util_free(help_data);
3171 XmStringFree(xm_buf);
3176 case DTB_ANSWER_ACTION1: /* Apply Changes */
3178 * If Apply was not successful (value verification failed), then
3179 * do not change to the new Prop sheet.
3181 if (apply_prop_changes(prop_type, pstate->loaded_obj, pstate->palitem) != OK)
3183 *result = pstate->palitem;
3184 answer = DTB_ANSWER_CANCEL;
3188 if (!changing_types)
3189 load_props(prop_type, pstate, new_obj);
3191 revolv_change_prop_frame(new_palitem);
3193 *result = new_palitem;
3197 case DTB_ANSWER_CANCEL: /* Cancel Load */
3199 ui_optionmenu_change_label(revolv_optionmenu, pstate->palitem->name);
3200 modname = abobj_get_moduled_name(pstate->loaded_obj);
3201 ui_list_select_item(pstate->objlist, modname, FALSE);
3203 *result = pstate->palitem;
3209 static PropStateInfo *
3210 get_prop_state_info(
3215 PropStateInfo *pstate;
3217 dialog = ui_get_ancestor_dialog(widget);
3219 XtVaGetValues(dialog, XmNuserData, &pstate, NULL);
3227 init_prop_state_info(
3229 PalItemInfo *palitem,
3234 PropStateInfo *pstate;
3236 pstate = (PropStateInfo*)util_malloc(sizeof(PropStateInfo));
3238 pstate->palitem = palitem;
3239 pstate->objlist = objlist;
3240 pstate->loaded_obj = loaded_obj;
3242 XtVaSetValues(dialog, XmNuserData, (XtArgVal)pstate, NULL);
3248 * Load an object into the Revolving or Fixed Prop dialog
3253 PropStateInfo *pstate,
3257 pstate->loaded_obj = obj;
3259 /* Load obj's props */
3260 (*(pstate->palitem->prop_load))(obj, type, LoadAll);
3266 PalItemInfo *palitem,
3267 ObjEvDestroyInfo info
3271 PropStateInfo *pstate;
3273 int first_viz, last_viz;
3275 if (type == AB_PROP_REVOLVING)
3276 dialog = AB_rev_prop_dialog;
3278 dialog = palitem->fix_prop_dialog;
3280 pstate = get_prop_state_info(dialog);
3282 cur_list_palitem = palitem;
3283 abobj_list_obj_destroyed(pstate->objlist, info->obj, objlist_test_func);
3285 ui_list_get_info(pstate->objlist, &num_items, &first_viz, &last_viz);
3287 if (num_items == 0) /* Deleted Last one...*/
3289 /* Clear Prop Sheet & Make it Inactive */
3290 (*(palitem->prop_clear))(type);
3291 (*(palitem->prop_activate))(type, FALSE);
3292 pstate->loaded_obj = NULL;
3294 else if (info->obj == pstate->loaded_obj) /* Deleted "Current" one...*/
3296 /* If there are pending edits on the deleted object, first clear
3297 * those edits via a reset before making another object "current"
3300 if ((*(palitem->prop_pending))(type) == True)
3301 (*(palitem->prop_load))(NULL, type, LoadAll);
3303 ui_list_select_pos(pstate->objlist, 1, TRUE);
3309 * Ensure an item is selected in the Prop dialog list
3312 objlist_ensure_selection(
3317 int num_selected = 0;
3319 XtVaGetValues(objlist,
3320 XmNitemCount, &num_items,
3321 XmNselectedItemCount, &num_selected,
3324 if (num_selected == 0 && num_items > 0)
3325 ui_list_select_pos(objlist, 1, TRUE);
3330 * Traverse the project and load all objects matching the
3331 * Palette Item type into the Prop dialog list
3336 PropStateInfo *pstate
3339 ABObj proj = proj_get_project();
3342 if (proj == NULL || pstate->objlist == NULL)
3345 /* Reset Loaded-obj to NULL */
3346 pstate->loaded_obj = NULL;
3348 cur_list_palitem = pstate->palitem;
3349 num_items = abobj_list_load(pstate->objlist, proj, objlist_test_func);
3351 /* If there are items in the list, activate the Props,
3352 * else de-activate them.
3354 ((*pstate->palitem->prop_activate)(type, num_items > 0? TRUE : FALSE));
3361 PalItemInfo *palitem,
3362 ObjEvAttChangeInfo info
3366 PropStateInfo *pstate;
3368 if (type == AB_PROP_REVOLVING)
3369 dialog = AB_rev_prop_dialog;
3371 dialog = palitem->fix_prop_dialog;
3373 pstate = get_prop_state_info(dialog);
3375 cur_list_palitem = palitem;
3376 abobj_list_obj_renamed(pstate->objlist, info->obj,
3377 istr_string(info->old_name),
3385 objlist_show_or_hide_obj(
3387 PalItemInfo *palitem,
3388 ObjEvUpdateInfo info
3392 PropStateInfo *pstate;
3393 int orig_num_items = 0;
3395 int first_vis, last_vis;
3397 if (type == AB_PROP_REVOLVING)
3398 dialog = AB_rev_prop_dialog;
3400 dialog = palitem->fix_prop_dialog;
3402 pstate = get_prop_state_info(dialog);
3404 ui_list_get_info(pstate->objlist, &orig_num_items, &first_vis, &last_vis);
3406 cur_list_palitem = palitem;
3407 abobj_list_obj_updated(pstate->objlist, info, objlist_test_func);
3409 ui_list_get_info(pstate->objlist, &num_items, &first_vis, &last_vis);
3411 if (orig_num_items == 0 && num_items > 0)
3412 (*(palitem->prop_activate))(type, TRUE);
3414 if (num_items == 0) /* Hid Last one...*/
3416 /* Clear Prop Sheet & Make it Inactive */
3417 (*(palitem->prop_clear))(type);
3418 (*(palitem->prop_activate))(type, FALSE);
3419 pstate->loaded_obj = NULL;
3421 else if (!(pstate->loaded_obj != NULL &&
3422 obj_has_flag(obj_get_module(pstate->loaded_obj), MappedFlag)) ||
3424 /* Make sure 1 is selected */
3425 ui_list_select_pos(pstate->objlist, 1, True);
3431 * Test whether an object should be loaded into the
3432 * Prop Dialog object list
3439 if ((obj_get_module(test_obj) != NULL) &&
3440 obj_is_defined(test_obj) &&
3441 obj_is_salient_ui(test_obj) &&
3442 obj_has_flag(test_obj, MappedFlag))
3444 if (cur_list_palitem != NULL)
3445 return((*cur_list_palitem->is_a_test)(test_obj));
3452 create_obj_option_item(
3453 PropObjOptionsSetting pos,
3459 STRING modname = NULL;
3464 name = (String)NoneItem;
3465 else if (pos->display_module)
3466 modname = abobj_get_moduled_name(obj);
3468 name = obj_get_name(obj);
3470 xmitem = XmStringCreateLocalized(modname? modname : name);
3474 /* Create new item */
3475 newitem = XtVaCreateWidget(modname? modname : name,
3476 xmPushButtonWidgetClass,
3478 XmNlabelString, xmitem,
3479 XmNuserData, (XtArgVal)obj,
3482 XtAddCallback(newitem, XmNactivateCallback,
3483 propP_setting_chgCB, (XtPointer)pos->options.changebar);
3484 XtAddCallback(newitem, XmNactivateCallback,
3485 propP_options_itemCB, (XtPointer)pos->options.menu);
3487 else /* Use existing item */
3489 XmNlabelString, xmitem,
3490 XmNuserData, (XtArgVal)obj,
3493 XmStringFree(xmitem);
3500 ******************************************************************
3502 ******************************************************************
3506 * obj-callback: object name has changed - update Prop Dialog lists
3510 ObjEvAttChangeInfo info
3513 PalItemInfo *palitem;
3516 if (!obj_is_salient(info->obj) ||
3517 obj_get_parent(info->obj) == NULL ||
3518 obj_is_item(info->obj))
3521 util_dprintf(3, "obj_renamedOCB: from %s to %s\n", istr_string_safe(info->old_name),
3522 obj_get_name(info->obj));
3524 if (obj_is_module(info->obj)) /* Module name changed */
3526 /* Need to update ALL Prop Dialog object lists...*/
3527 for (i = 0; i < palette_item_cnt; i++)
3529 palitem = cur_list_palitem = palette_item[i];
3531 if (palitem->rev_prop_frame == revolv_current_frame)
3532 objlist_rename_obj(AB_PROP_REVOLVING, palitem, info);
3534 if (palitem->fix_prop_dialog != NULL)
3535 objlist_rename_obj(AB_PROP_FIXED, palitem, info);
3538 else if ((palitem = pal_get_item_info(info->obj)) != NULL) /* Object name changed */
3540 /* If obj's type is currently loaded in Revolving props, update the list */
3541 if (AB_rev_prop_dialog != NULL && revolv_current_frame == palitem->rev_prop_frame)
3542 objlist_rename_obj(AB_PROP_REVOLVING, palitem, info);
3544 /* If Fixed Props for obj's type exists, update its list */
3545 if (palitem->fix_prop_dialog != NULL)
3546 objlist_rename_obj(AB_PROP_FIXED, palitem, info);
3552 * obj-callback: object geometry has changed - update Prop sheet if necessary
3555 obj_geom_changedOCB(
3556 ObjEvAttChangeInfo info
3559 PalItemInfo *palitem;
3560 PropStateInfo *pstate;
3561 unsigned long geomflag = 0;
3563 /* If "apply_in_progress" is True, then this update is being called
3564 * during the apply of geometry changes within a prop sheet, and we
3565 * DO not want to update prop fields in this case because it could
3566 * interfere with the apply.
3568 if (!obj_is_salient(info->obj) ||
3569 obj_get_parent(info->obj) == NULL ||
3570 obj_is_item(info->obj) ||
3574 /* If a layers's position changes, then we need to update the
3575 * position attrs of any of its panes which are currently loaded
3576 * in props (since, in props, their x,y position is displayed as the
3577 * entire layers's position, even though the panes' *real* position
3578 * within the layers object is 0,0).
3580 if (info->atts & OBJEV_ATT_POSITION &&
3581 obj_is_layers(info->obj))
3583 ABObj layers = info->obj;
3585 int num_panes = obj_get_num_children(layers);
3588 for (i=0; i < num_panes; i++)
3590 /* Use recursion to call this geometry callback for each
3591 * pane in the layers object
3593 pane = obj_get_child(layers, i);
3595 obj_geom_changedOCB(info);
3597 info->obj = layers; /* reset back to original obj */
3600 if ((palitem = pal_get_item_info(info->obj)) != NULL)
3602 util_dprintf(3, "obj_geom_changedOCB: %s's geometry changed to %d,%d %dx%d\n",
3603 obj_get_name(info->obj), obj_get_x(info->obj), obj_get_y(info->obj),
3604 obj_get_width(info->obj), obj_get_height(info->obj));
3606 if (info->atts & OBJEV_ATT_POSITION)
3607 geomflag |= LoadPosition;
3608 if (info->atts & OBJEV_ATT_SIZE)
3609 geomflag |= LoadSize;
3611 /* If modified obj is currently loaded in the Revolving prop editor, update
3612 * only its geometry attributes in the prop sheet
3614 if (AB_rev_prop_dialog != NULL && revolv_current_frame == palitem->rev_prop_frame)
3616 pstate = get_prop_state_info(AB_rev_prop_dialog);
3617 if (pstate->loaded_obj == info->obj)
3618 (*(palitem->prop_load))(NULL, AB_PROP_REVOLVING, geomflag);
3621 /* If modified obj is currently loaded in its Fixed prop editor, update
3622 * only its geometry attributes in the prop sheet
3624 if (palitem->fix_prop_dialog != NULL)
3626 pstate = get_prop_state_info(palitem->fix_prop_dialog);
3627 if (pstate->loaded_obj == info->obj)
3628 (*(palitem->prop_load))(NULL, AB_PROP_FIXED, geomflag);
3635 * obj-callback: object is being destroyed - remove from Prop dialog lists
3639 ObjEvDestroyInfo info
3642 PalItemInfo *palitem;
3644 if (!obj_is_salient(info->obj) ||
3645 obj_get_parent(info->obj) == NULL ||
3646 obj_is_item(info->obj))
3652 util_dprintf(3, "obj_destroyedOCB: %s\n",
3653 obj_get_safe_name(info->obj, buf, 1024));
3657 if ((palitem = pal_get_item_info(info->obj)) != NULL) /* Object being destroyed */
3659 /* If obj's type is currently loaded in Revolving props, update the list */
3660 if (AB_rev_prop_dialog != NULL && revolv_current_frame == palitem->rev_prop_frame)
3661 objlist_delete_obj(AB_PROP_REVOLVING, palitem, info);
3663 /* If Fixed Props for obj's type exists, update its list */
3664 if (palitem->fix_prop_dialog != NULL)
3665 objlist_delete_obj(AB_PROP_FIXED, palitem, info);
3671 * obj-callback: object being shown or hidden - modify Prop dialog lists
3674 obj_shown_or_hiddenOCB(
3675 ObjEvUpdateInfo info
3678 PalItemInfo *palitem;
3681 if (!obj_is_salient(info->obj) ||
3682 obj_get_parent(info->obj) == NULL ||
3683 obj_is_item(info->obj))
3686 util_dprintf(3, "obj_shown_or_hiddenOCB: %s\n",
3687 obj_get_name(info->obj));
3689 if (obj_is_module(info->obj))
3691 /* Need to update ALL Prop Dialog object lists...*/
3692 for (i = 0; i < palette_item_cnt; i++)
3694 palitem = palette_item[i];
3696 if (palitem->rev_prop_frame == revolv_current_frame)
3697 objlist_show_or_hide_obj(AB_PROP_REVOLVING, palitem, info);
3699 if (palitem->fix_prop_dialog != NULL)
3700 objlist_show_or_hide_obj(AB_PROP_FIXED, palitem, info);
3703 else if ((palitem = pal_get_item_info(info->obj)) != NULL) /* Object being Updated */
3705 cur_list_palitem = palitem;
3707 /* If obj's type is currently loaded in Revolving props, update the list */
3708 if (AB_rev_prop_dialog != NULL && revolv_current_frame == palitem->rev_prop_frame)
3709 objlist_show_or_hide_obj(AB_PROP_REVOLVING, palitem, info);
3711 /* If Fixed Props for obj's type exists, update its list */
3712 if (palitem->fix_prop_dialog != NULL)
3713 objlist_show_or_hide_obj(AB_PROP_FIXED, palitem, info);
3719 ******************************************************************
3721 ******************************************************************
3725 * Callback: apply properties for current object
3730 XtPointer client_data,
3734 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3735 PropStateInfo *pstate;
3738 if (type == AB_PROP_REVOLVING)
3739 dialog = AB_rev_prop_dialog;
3740 else /* AB_PROP_FIXED */
3742 pstate = get_prop_state_info(widget);
3743 dialog = pstate->palitem->fix_prop_dialog;
3746 apply_props(type, dialog);
3756 XtPointer client_data,
3760 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3761 PropStateInfo *pstate;
3764 pstate = get_prop_state_info(widget);
3766 if (type == AB_PROP_REVOLVING)
3767 dialog = AB_rev_prop_dialog;
3769 else /* AB_PROP_FIXED */
3770 dialog = pstate->palitem->fix_prop_dialog;
3772 (*(pstate->palitem->prop_load))(NULL,type,LoadAll);
3774 ui_win_show(dialog, False, XtGrabNone);
3779 * Callback: a new object has been selected off object menu
3782 change_objecttypeCB(
3784 XtPointer client_data,
3788 PalEditableObjInfo *ed_obj_info = (PalEditableObjInfo*)client_data;
3789 PalItemInfo *viz_palitem;
3790 PropStateInfo *pstate;
3792 viz_palitem = revolv_set_prop_type(ed_obj_info->palitem, NULL);
3794 if (viz_palitem == ed_obj_info->palitem)
3796 /* Object-type change was successful */
3797 pstate = get_prop_state_info(AB_rev_prop_dialog);
3798 objlist_ensure_selection(pstate->objlist);
3801 /* Object-type change rejected; reset object-type */
3802 ui_optionmenu_change_label(revolv_optionmenu, viz_palitem->name);
3808 * Callback: Prop dialog has been closed -- check for pending changes
3813 XtPointer client_data,
3817 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3818 DTB_MODAL_ANSWER answer;
3819 PalItemInfo *palitem = NULL;
3820 PropStateInfo *pstate;
3821 WidgetList shell_child;
3824 /* Get Immediate child of Shell */
3825 XtVaGetValues(widget,
3826 XmNchildren, &shell_child,
3829 dialog = shell_child[0];
3830 pstate = get_prop_state_info(dialog);
3832 if ((*(pstate->palitem->prop_pending))(type) == TRUE)
3833 /* An Object is loaded with pending changes...*/
3834 answer = handle_auto_apply(type, pstate, pstate->palitem, NULL, &palitem);
3836 if (answer != DTB_ANSWER_CANCEL)
3842 * Callback: popup Attachment Editor
3845 invoke_attach_editorCB(
3847 XtPointer client_data,
3851 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3852 PropStateInfo *pstate;
3854 pstate = get_prop_state_info(widget);
3856 if (pstate->loaded_obj == NULL)
3859 attch_ed_show_dialog(pstate->loaded_obj);
3863 * Callback: popup Connections Editor
3866 invoke_connectionsCB(
3868 XtPointer client_data,
3872 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3873 PropStateInfo *pstate;
3875 pstate = get_prop_state_info(widget);
3877 if (pstate->loaded_obj == NULL)
3880 conn_set_source(pstate->loaded_obj);
3881 conn_set_target(NULL);
3882 conn_popup_dialog(widget, (XtPointer)0, NULL);
3886 * Callback: popup Help Editor Dialog
3889 invoke_help_editorCB(
3891 XtPointer client_data,
3895 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3896 PropStateInfo *pstate;
3898 pstate = get_prop_state_info(widget);
3900 if (pstate->loaded_obj == NULL)
3903 ab_set_help_obj(pstate->loaded_obj);
3904 ab_popup_help(widget,(XtPointer)0,NULL);
3910 XtPointer client_data,
3911 XmListCallbackStruct *listdata
3914 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3915 PropStateInfo *pstate;
3916 PalItemInfo *palitem = NULL;
3921 pstate = get_prop_state_info(widget);
3923 name = objxm_xmstr_to_str(listdata->item);
3926 abobj_moduled_name_extract(name, &module, &selected_obj);
3929 /* If the object selected in the list is the one already
3930 * loaded, then don't do anything.
3932 if (selected_obj && selected_obj != pstate->loaded_obj)
3934 if ((*(pstate->palitem->prop_pending))(type) == TRUE)
3935 /* An Object is loaded with pending changes...*/
3936 handle_auto_apply(type, pstate, pstate->palitem, selected_obj, &palitem);
3938 load_props(type, pstate, selected_obj);
3945 * Callback: apply properties for current object & take down dialog
3950 XtPointer client_data,
3954 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3955 PropStateInfo *pstate;
3958 if (type == AB_PROP_REVOLVING)
3959 dialog = AB_rev_prop_dialog;
3961 else /* AB_PROP_FIXED */
3963 pstate = get_prop_state_info(widget);
3964 dialog = pstate->palitem->fix_prop_dialog;
3967 if (apply_props(type, dialog) == OK)
3968 ui_win_show(dialog, False, XtGrabNone);
3973 * Callback: reset properties for current object
3978 XtPointer client_data,
3982 AB_PROP_TYPE type = (AB_PROP_TYPE)client_data;
3983 PropStateInfo *pstate;
3985 pstate = get_prop_state_info(widget);
3987 (*(pstate->palitem->prop_load))(NULL,type,LoadAll);
3997 XtPointer client_data,
4001 PropStateInfo *pstate;
4003 pstate = get_prop_state_info(AB_rev_prop_dialog);
4005 if (pstate->loaded_obj != NULL)
4006 prop_load_obj(pstate->loaded_obj, AB_PROP_FIXED);
4008 fixed_invoke_props(pstate->palitem);
4015 XtPointer clientdata,
4019 PropColorSetting pcs = (PropColorSetting)clientdata;
4020 String color_choice;
4024 color_choice = display_color_chooser();
4026 if (color_choice[0] != 0)
4028 /* This should never error since the chooser enforces choosing
4029 * a valid & available color, but check just to be sure.
4031 if ((status = objxm_name_to_pixel(w, color_choice, &c)) == OK)
4033 XtVaSetValues(pcs->swatch,
4036 XmTextSetString(pcs->field, color_choice);
4044 XtPointer clientdata,
4048 PropColorSetting pcs = (PropColorSetting)clientdata;
4050 /* Reset Swatch to appear transparent */
4051 prop_colorfield_set_value(pcs, "", True);
4058 XtPointer client_data,
4062 PropMenunameSetting pms = (PropMenunameSetting)client_data;
4063 PropStateInfo *pstate;
4064 AB_PROP_TYPE alt_prop_type = AB_PROP_FIXED;
4072 /* Build a menu-name based on the menu-owner's name or label */
4073 if (pms->owner_name_field != NULL)
4075 /* Use owner's name as prefix */
4076 base = ui_field_get_string(pms->owner_name_field);
4079 module = obj_get_module(*(pms->current_obj_ptr));
4080 name = (base? ab_ident_from_name_and_label(base, "menu") : "menu");
4081 menu_name = strdup(name);
4082 unique_name = obj_alloc_unique_name_for_child(module, menu_name, -1);
4084 /* We want to create/load the new menu in a separate editor if
4085 * possible so that the user can view both the new menu AND the
4086 * object which owns it simultaneously. However, if we are currently
4087 * in the Fixed Menu Props dialog and there is an object loaded in
4088 * the Revolving Prop dialog which has *pending* edits, don't try
4089 * to use it (suddently changing it's type & object will probably
4090 * confuse the user!).
4092 if (pms->prop_type == AB_PROP_FIXED)
4094 prop_dialog = ui_get_ancestor_dialog(pms->owner_name_field);
4096 /* Try using the Revolving Prop Editor if either we are currently
4097 * in the Menu Fixed Props, or if the Menu Fixed Props has
4100 if (prop_dialog == ab_menu_palitem->fix_prop_dialog ||
4101 (ab_menu_palitem->fix_prop_dialog &&
4102 (*ab_menu_palitem->prop_pending)(AB_PROP_FIXED) == True))
4104 pstate = get_prop_state_info(AB_rev_prop_dialog);
4106 if (pstate->palitem &&
4107 (*pstate->palitem->prop_pending)(AB_PROP_REVOLVING) == False)
4109 alt_prop_type = AB_PROP_REVOLVING;
4110 revolv_invoke_props(ab_menu_palitem, NULL);
4115 if (alt_prop_type == AB_PROP_FIXED)
4116 prop_show_fixed(ab_menu_palitem);
4118 /* Insert the new menu name into the owner's field, UNLESS we
4119 * happen to be inside the Fixed Menu Prop dialog AND are also
4120 * creating the new menu in the Fixed Menu Prop dialog.
4122 if (pal_create_menu(alt_prop_type, module, unique_name, NULL) == 0 &&
4123 !(prop_dialog == ab_menu_palitem->fix_prop_dialog &&
4124 alt_prop_type == AB_PROP_FIXED))
4125 ui_field_set_string(pms->field, unique_name);
4128 util_free(menu_name);
4129 util_free(unique_name);
4134 STRING submenu_name,
4140 BOOL is_sub = False;
4142 for(trav_open(&trav, menu, AB_TRAV_ITEMS);
4143 (item = trav_next(&trav)) != NULL; )
4145 if (util_strcmp(obj_get_menu_name(item), submenu_name) == 0)
4156 find_submenu_owners(
4164 STRING submenu_name;
4167 submenu_name = obj_get_name(submenu);
4168 for(i = 0; i < menu_count; i++)
4170 if (submenu != menulist[i] &&
4171 is_submenu_of(submenu_name, menulist[i]))
4173 i_menulist[(*i_count_ptr)++] = menulist[i];
4174 find_submenu_owners(menulist[i], menulist, menu_count,
4175 i_menulist, i_count_ptr);
4189 for(i = 0; i < menu_count; i++)
4190 if (menulist[i] == target_menu)
4199 XtPointer client_data,
4203 PropMenunameSetting pms;
4206 ABObj *ineligible_menus = NULL;
4208 int ineligible_count = 0;
4210 Widget menus_item = (Widget)client_data;
4211 Widget menus_menu = NULL;
4212 Widget menus_menuitem;
4218 XtVaGetValues(widget, XmNsubMenuId, &submenu, NULL);
4219 XtVaGetValues(menus_item, XmNuserData, &pms, NULL);
4221 current_obj = *(pms->current_obj_ptr);
4223 abobj_build_menus_array(obj_get_module(current_obj), &menus, &num_menus);
4227 if (obj_is_menu(current_obj)) /* Need to prevent circular menus */
4229 /* Build up a list of menus that belong to the current menu's
4230 * ancestory (if it's a submenu) - these menus will not be eligible
4231 * for selection as a submenu off the current menu.
4233 ineligible_menus = (ABObj*)util_malloc(num_menus*sizeof(ABObj));
4234 ineligible_menus[ineligible_count++] = current_obj;
4235 find_submenu_owners(current_obj, menus, num_menus,
4236 ineligible_menus, &ineligible_count);
4239 for (j = 0; j < num_menus; j++)
4241 if (menus_menu == NULL)
4242 menus_menu = XmCreatePulldownMenu(submenu, "menus_menu", NULL, 0);
4244 menu_name = obj_get_name(menus[j]);
4246 menus_menuitem = XtVaCreateManagedWidget("menus_menuitem",
4247 xmCascadeButtonWidgetClass,
4249 XtVaTypedArg, XmNlabelString, XtRString,
4250 menu_name, strlen(menu_name)+1,
4253 /* If Menu is ineligible to be a Submenu, make it inactive */
4254 if (menu_in_list(ineligible_menus, ineligible_count, menus[j]))
4255 ui_set_active(menus_menuitem, False);
4257 XtAddCallback(menus_menuitem, XmNactivateCallback,
4258 menuname_setCB, (XtPointer)pms->field);
4261 ui_set_active(menus_item, TRUE);
4262 XtVaSetValues(menus_item, XmNsubMenuId, menus_menu, NULL);
4263 XtVaSetValues(submenu, XmNuserData, (XtArgVal)menus_menu, NULL);
4266 util_free(ineligible_menus);
4268 else /* No Menus - inactivate the item */
4270 ui_set_active(menus_item, FALSE);
4271 XtVaSetValues(submenu, XmNuserData, (XtArgVal)NULL, NULL);
4276 * Callback: destroy the Menu->Names submenu after it pops down
4281 XtPointer client_data,
4285 Widget submenu = (Widget)client_data;
4288 XtVaGetValues(submenu, XmNuserData, &menus_menu, NULL);
4290 if (menus_menu != NULL)
4291 XtDestroyWidget(menus_menu);
4295 menu_edit_set_stateCB(
4297 XtPointer client_data,
4301 PropMenunameSetting pms;
4302 Widget edit_item = (Widget)client_data;
4303 STRING current_menuname = NULL;
4305 /* Set the "Edit Current" item to be active ONLY if there is a
4306 * menu name in the field
4308 XtVaGetValues(edit_item, XmNuserData, &pms, NULL);
4309 current_menuname = ui_field_get_string(pms->field);
4310 ui_set_active(edit_item, !util_strempty(current_menuname));
4311 util_free(current_menuname);
4316 * Callback: Clear Menu Name field
4321 XtPointer client_data,
4325 PropMenunameSetting pms = (PropMenunameSetting)client_data;
4326 ui_field_set_string(pms->field, "");
4331 * Callback: an item off the Menu->Names submenu was selected:
4332 * Set the value of the menu textfield to its label
4337 XtPointer client_data,
4341 Widget menu_field = (Widget)client_data;
4342 XmString xm_menuname;
4345 XtVaGetValues(w, XmNlabelString, &xm_menuname, NULL);
4346 menu_name = objxm_xmstr_to_str(xm_menuname);
4347 ui_field_set_string(menu_field, menu_name);
4348 util_free(menu_name);
4354 XtPointer client_data,
4358 PropMenunameSetting pms = (PropMenunameSetting)client_data;
4359 STRING current_menuname = NULL;
4363 current_menuname = ui_field_get_string(pms->field);
4364 module = obj_get_module(*(pms->current_obj_ptr));
4366 if (!util_strempty(current_menuname))
4368 if ((menu = obj_find_by_name(module, current_menuname)) != NULL)
4369 prop_load_obj(menu, pms->prop_type == AB_PROP_FIXED?
4370 AB_PROP_REVOLVING : AB_PROP_FIXED);
4373 STRING fmtStr = NULL;
4374 STRING help_buf = NULL;
4377 fmtStr = XtNewString(catgets(Dtb_project_catd, 100, 135,
4378 "The menu with the name \"%s\" does not exist in\nthe module \"%s\". Specify a valid menu name."));
4380 help_buf = (STRING) util_malloc(strlen(fmtStr) +
4381 strlen(current_menuname) + strlen(obj_get_name(module)) +1);
4382 sprintf(help_buf, fmtStr, current_menuname, obj_get_name(module));
4384 util_set_help_data(help_buf, NULL, NULL);
4385 sprintf(Buf, catgets(Dtb_project_catd, 100, 134,
4386 "Could not find menu \"%s\" in module \"%s\"."),
4387 current_menuname, obj_get_name(module));
4388 propP_popup_message(pms->field, Buf, False);
4391 util_free(help_buf);
4394 util_free(current_menuname);
4400 XtPointer client_data,
4404 PropMenunameSetting pms = (PropMenunameSetting)client_data;
4406 BOOL menu_there = False;
4408 if (pms->menu_title_pfs)
4410 /* If a non-empty string in in Menu field, make Title active */
4411 value = ui_field_get_string(pms->field);
4412 menu_there = (!util_strempty(value));
4413 ui_set_active(pms->menu_title_pfs->label, menu_there);
4414 ui_set_active(pms->menu_title_pfs->field, menu_there);
4421 prop_geomfield_clear(
4422 PropGeometrySetting pgs,
4426 Widget field = NULL;
4431 field = pgs->x_field;
4434 field = pgs->y_field;
4437 field = pgs->w_field;
4440 field = pgs->h_field;
4448 /* Set state so changebar is not triggered */
4449 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_LOAD,NULL);
4451 /* Convert int to string */
4452 ui_field_set_string(field, NULL);
4455 XtVaSetValues(field, XmNuserData, (XtArgVal)PROP_EDIT,NULL);
4462 obj_options_buildCB(
4464 XtPointer client_data,
4468 PropObjOptionsSetting pos = (PropObjOptionsSetting)client_data;
4470 prop_obj_options_load(pos, pos->search_root);
4478 XtNewString(catgets(Dtb_project_catd, 100, 215, "Label:"));
4480 XtNewString(catgets(Dtb_project_catd, 100, 216, "Graphic Filename:"));
4482 XtNewString(catgets(Dtb_project_catd, 100, 217, "None"));
4484 XtNewString(catgets(Dtb_project_catd, 100, 218, "X Field"));
4486 XtNewString(catgets(Dtb_project_catd, 100, 219, "Y Field"));
4488 XtNewString(catgets(Dtb_project_catd, 100, 220, "Width Field"));
4490 XtNewString(catgets(Dtb_project_catd, 100, 221, "Height Field"));
4492 XtNewString(catgets(Dtb_project_catd, 100, 222, "Offset Field"));
4493 PercentageFieldStr =
4494 XtNewString(catgets(Dtb_project_catd, 100, 223, "Percentage Field"));
4496 XtNewString(catgets(Dtb_project_catd, 100, 224, "None"));
4498 XtNewString(catgets(Dtb_project_catd, 100, 225, "Create New Menu..."));
4500 XtNewString(catgets(Dtb_project_catd, 100, 226, "Menus"));
4502 XtNewString(catgets(Dtb_project_catd, 100, 227, "Edit Current..."));
4504 XtNewString(catgets(Dtb_project_catd, 100, 250, "Rows/Columns Field"));
4505 VertSpacingFieldStr =
4506 XtNewString(catgets(Dtb_project_catd, 100, 251, "Vertical Spacing Field"));
4507 HorizSpacingFieldStr =
4508 XtNewString(catgets(Dtb_project_catd, 100, 252, "Horizontal Spacing Field"));