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
25 * $XConsortium: utils.c /main/3 1995/11/06 18:16:13 rswiston $
27 * @(#)utils.c 3.76 16 Feb 1994 cde_app_builder/src/abmf
29 * RESTRICTED CONFIDENTIAL INFORMATION:
31 * The information in this document is subject to special restrictions in a
32 * confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
33 * Univel. Do not distribute this document outside HP, IBM, Sun, USL, SCO,
34 * or Univel without Sun's specific written approval. This document and all
35 * copies and derivative works thereof must be returned or destroyed at Sun's
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
44 * Main utility functions.
47 #include <sys/param.h>
52 #include <ab_private/XmAll.h>
53 #include <ab/util_types.h>
54 #include <ab_private/istr.h>
55 #include <ab_private/abio.h>
56 #include <ab_private/trav.h>
57 #include <ab_private/objxm.h>
59 #include "motifdefsP.h"
61 #include "write_codeP.h"
62 #include "obj_namesP.h"
67 STRING nlstr2 = "\n\n";
69 static int find_base_file_name(STRING path, int *startPtr, int *lenPtr);
72 * Miscellaneous utility functions.
76 * Return the printed representation of a boolean.
79 abmfP_boolean_string(int i)
81 return i ? "True" : "False";
86 * Check a string to see if contains a legal identifier.
89 abmfP_identifier_ok(STRING s)
91 return ab_c_ident_is_ok(s);
96 * Capitalize the first letter of the given string.
99 abmfP_capitalize_first_char(STRING str)
101 static char name[MAXPATHLEN] = "";
109 if (str != name) /* if we get called w/our own buffer, don't copy */
113 name[0] = toupper(str[0]);
120 * Makes the 1st char lower case
123 abmfP_uncapitalize_first_char(STRING str)
125 static char name[MAXPATHLEN] = "";
133 if (str != name) /* if we get called w/our own buffer, don't copy */
137 name[0] = tolower(str[0]);
144 abmfP_obj_find_codegen_parent(ABObj obj)
146 ABObj cgParent = obj->parent;
147 while ((cgParent != NULL) && obj_has_flag(cgParent, NoCodeGenFlag))
149 cgParent = cgParent->parent;
155 * Return TRUE if all items have the same Widget Class
158 abmfP_items_are_homogeneous(
165 STRING ref_classname;
167 trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ);
168 item = trav_next(&trav);
171 ref_classname = obj_get_class_name(item);
172 for (;(item = trav_next(&trav)) != NULL; )
173 if (util_strcmp(ref_classname, obj_get_class_name(item)) != 0)
184 abmfP_items_have_mnemonics(
190 BOOL has_mnemonics = False;
192 for (trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ);
193 (item = trav_next(&trav)) != NULL;)
194 if (obj_get_mnemonic(item) != NULL)
196 has_mnemonics = True;
200 return has_mnemonics;
204 abmfP_items_have_accelerators(
210 BOOL has_accel = False;
212 for (trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ);
213 (item = trav_next(&trav)) != NULL;)
214 if (obj_get_accelerator(item) != NULL)
225 * Returns TRUE if the objects represent the same UI element.
227 * This shouldn't really be necessary - there should be NO duplicate objects,
228 * just multiple references to the same object.
231 abmfP_obj_is_duplicate(ABObj obj, ABObj dupObj)
233 return (obj == dupObj);
238 abmfP_parent_is_class(ABObj obj, STRING classname)
240 if ((abmfP_parent(obj) == NULL)
241 || (obj_get_class_name(obj) == NULL)
242 || (obj_get_class_name(abmfP_parent(obj)) == NULL))
246 if (util_streq(obj_get_class_name(abmfP_parent(obj)), classname))
250 if (abmfP_parent(obj))
251 return abmfP_parent_is_class(abmfP_parent(obj), classname);
257 * Return the actual control object.
259 * Since most controls have been converted to multiple toolkit objects (e.g., to
260 * add captions) except oblong, menu buttons, get the object that actually
261 * implements the type.
263 * The opposite of this is abmfP_get_container_object.
266 abmfP_get_actual_control(ABObj parent)
268 ABObj obj = objxm_comp_get_subobj(parent, AB_CFG_OBJECT_OBJ);
270 } /* abmfP_get_actual_control */
274 * Gets the object that is or contains all of the subobjects that make up a
275 * particular type of object.
277 * For instance, if a gauge is represented by a container that has a label and a
278 * gauge, this function will return the container object if any of the
279 * subobjects is passed in (or if the container itself is passed in). This
280 * function works on any type of object.
282 * The opposite function is abmfP_get_actual_control
285 abmfP_get_whole_object(ABObj obj)
287 return obj_get_root(obj);
292 * Returns the object that the callback has been "associated with."
293 * Normally the module it is declare in, or the project for cross-module
296 * Returns NULL if the callback is not found.
299 abmfP_find_callback_scope(ABObj obj, STRING callbackName)
301 ABObj scopeObj = NULL;
302 ABObj objModule = obj_get_module(obj);
303 ABObj objProject= obj_get_project(obj);
304 StringList callbackList = NULL;
306 ABObj curModule= NULL;
308 if ((objModule != NULL) && (mfobj_get_module_data(objModule) != NULL))
310 callbackList = mfobj_get_module_data(objModule)->callbacks;
311 if (strlist_str_exists(callbackList, callbackName))
313 scopeObj = objModule;
317 if ((scopeObj == NULL) && (objProject != NULL))
319 for (trav_open(&trav, objProject, AB_TRAV_MODULES);
320 (scopeObj == NULL) && ((curModule = trav_next(&trav)) != NULL); )
322 if (mfobj_get_module_data(curModule) != NULL)
324 callbackList = mfobj_get_module_data(curModule)->callbacks;
325 if (strlist_str_exists(callbackList, callbackName))
327 scopeObj = curModule;
333 if (scopeObj == NULL)
335 callbackList = mfobj_get_proj_data(objProject)->callbacks;
336 if (strlist_str_exists(callbackList, callbackName))
347 find_longest_label(STRING * label)
355 for (; label[i]; i++)
357 len1 = strlen(label[i]);
367 /*************************************************************************
369 ** MEMORY ALLOCATION **
371 *************************************************************************/
374 * Version of calloc() with error checking.
377 abmfP_calloc(size_t n, size_t size)
381 if (p = (STRING) calloc(n, size))
383 util_error(catgets(Dtb_project_catd, 1, 83, "calloc: out of memory"));
388 * Version of malloc() with error checking.
391 abmfP_malloc(size_t size)
395 if (p = malloc(size))
397 util_error(catgets(Dtb_project_catd, 1, 84, "malloc: out of memory"));
402 * Version of realloc() with error checking.
405 abmfP_realloc(void *buf, unsigned int size)
409 if (p = realloc(buf, size))
411 util_error(catgets(Dtb_project_catd, 1, 85, "realloc: out of memory"));
417 * Return the window parent of an object.
420 abmfP_get_window_parent(ABObj obj)
422 if (obj_is_top_level(obj))
424 else if (abmfP_parent(obj) && obj_is_top_level(abmfP_parent(obj)))
425 return abmfP_parent(obj);
426 else if (abmfP_parent(obj))
427 return abmfP_get_window_parent(abmfP_parent(obj));
428 return ((ABObj) NULL);
433 * Return the window pane of an object.
436 abmfP_get_window_pane(ABObj obj)
438 if (abmfP_parent(obj) == NULL)
440 return ((ABObj) NULL);
442 if (obj_is_top_level(obj))
444 else if (obj_is_pane(abmfP_parent(obj)) || obj_is_top_level(abmfP_parent(obj)))
445 return abmfP_parent(obj);
447 return abmfP_get_window_pane(abmfP_parent(obj));
452 * Copy one file to another.
455 abmfP_filecopy(STRING file1, STRING file2)
461 if ((inp = util_fopen_locked(file1, "r")) == NULL ||
462 (outp = util_fopen_locked(file2, "w")) == NULL)
465 while ((c = fgetc(inp)) != EOF)
474 * assigns names to object without them. This is a safty measure.
477 abmfP_assign_widget_names(ABObj root)
488 for (trav_open(&trav, root, AB_TRAV_WINDOWS), i = 1;
489 (win_obj = trav_next(&trav)) != NULL;)
491 if (obj_get_name(win_obj) == NULL)
492 { /* Only assign once */
493 sprintf(Buf, "%s%d", "widget", i);
494 obj_set_name(win_obj, Buf);
503 abmfP_tree_set_written(ABObj root, BOOL written)
508 for (trav_open(&trav, root, AB_TRAV_ALL);
509 (obj = trav_next(&trav)) != NULL;)
511 obj_set_was_written(obj, written);
518 abmfP_obj_set_items_written(ABObj rootObj, BOOL written)
523 for (trav_open(&trav, rootObj, AB_TRAV_ITEMS_FOR_OBJ);
524 (obj = trav_next(&trav)) != NULL;)
526 obj_set_was_written(obj, written);
535 * gets the #define string for the file
538 abmfP_get_define_from_file_name(STRING fileName)
540 static char define[MAX_NAME_SIZE];
541 int fileNameLen= strlen(fileName);
544 char fileNameChar= 0;
548 for (iFileName= 0; iFileName < fileNameLen; ++iFileName)
550 fileNameChar= fileName[iFileName];
551 if (isalnum(fileNameChar))
553 define[iDefine++]= toupper(fileNameChar);
557 if (define[iDefine-1] != '_')
559 define[iDefine++]= '_';
563 if ((iDefine > 0) && (define[iDefine-1] != '_'))
565 define[iDefine++]= '_';
573 abmfP_file_name_is_bitmap(STRING fileName)
575 return util_file_name_has_extension(fileName, "xbm");
580 abmfP_file_name_is_xpm(STRING fileName)
582 return util_file_name_has_extension(fileName, "pm");
587 abmfP_cvt_file_name_to_bitmap_data_vars(
590 STRING *heightVarPtr,
594 #define widthVar (*widthVarPtr)
595 #define heightVar (*heightVarPtr)
596 #define bitsVar (*bitsVarPtr)
597 static char widthVarBuf[256];
598 static char heightVarBuf[256];
599 static char bitsVarBuf[256];
602 char *nameStart = NULL;
604 widthVar = heightVar = bitsVar = NULL;
606 find_base_file_name(path, &baseIndex, &baseLen);
607 nameStart = &(path[baseIndex]);
609 strncpy(widthVarBuf, nameStart, baseLen);
610 widthVarBuf[baseLen]= 0;
611 strcpy(heightVarBuf, widthVarBuf);
612 strcpy(bitsVarBuf, widthVarBuf);
614 strcat(widthVarBuf, "_width");
615 strcpy(widthVarBuf, ab_make_valid_c_ident(widthVarBuf));
617 strcat(heightVarBuf, "_height");
618 strcpy(heightVarBuf, ab_make_valid_c_ident(heightVarBuf));
620 strcat(bitsVarBuf, "_bits");
621 strcpy(bitsVarBuf, ab_make_valid_c_ident(bitsVarBuf));
623 widthVar = widthVarBuf;
624 heightVar = heightVarBuf;
625 bitsVar = bitsVarBuf;
635 abmfP_cvt_file_name_to_xpm_data_var(STRING path)
637 static char varName[256];
642 find_base_file_name(path, &baseStart, &baseLen);
645 strncpy(varName, path+baseStart, baseLen);
647 strcat(varName, "_pm");
649 return ab_make_valid_c_ident(varName);
654 abmfP_obj_set_subobjs_written(ABObj obj, BOOL written)
659 for (trav_open(&trav, obj, AB_TRAV_ALL);
660 (subObj= trav_next(&trav)) != NULL; )
663 || (obj_get_root(subObj) != obj))
667 obj_set_was_written(subObj, written);
675 abmfP_objs_in_same_struct(ABObj obj1, ABObj obj2)
677 ABObj structObj1= abmfP_obj_get_struct_obj(obj1);
678 ABObj structObj2= abmfP_obj_get_struct_obj(obj2);
679 return ((structObj1 != NULL) && (structObj1 == structObj2));
684 abmfP_objs_in_same_substruct(ABObj obj1, ABObj obj2)
686 ABObj structObj1 = abmfP_obj_get_substruct_obj(obj1);
687 ABObj structObj2 = abmfP_obj_get_substruct_obj(obj2);
688 return ((structObj1 != NULL) && (structObj1 == structObj2));
693 * We have two types of structures:
694 * - one structure for each window
695 * - one structure for all the menus in an interface
698 abmfP_obj_get_struct_obj(ABObj obj)
700 ABObj structObj = NULL;
702 if (mfobj_has_flags(obj, CGenFlagStructObjValid))
707 for (structObj = obj;
708 structObj != NULL && !abmfP_obj_is_struct_obj(structObj);
709 structObj = abmfP_parent(structObj)
715 mfobj_set_flags(obj, CGenFlagStructObjValid);
716 mfobj_data(obj)->struct_obj = structObj;
719 return mfobj_data(obj)->struct_obj;
724 * Currently, only items go in substructs. List items don't however,
725 * because they don't cause widgets to be created.
728 abmfP_obj_get_substruct_obj(ABObj obj)
730 ABObj substructObj = NULL;
732 if (mfobj_has_flags(obj, CGenFlagSubstructObjValid))
737 if (obj_is_item(obj))
739 ABObj parent = abmfP_parent(obj);
742 substructObj = obj_get_root(parent);
744 if ( (substructObj != NULL)
745 && (!abmfP_obj_is_substruct_obj(substructObj)) )
754 mfobj_set_flags(obj, CGenFlagSubstructObjValid);
755 mfobj_data(obj)->substruct_obj = substructObj;
758 return mfobj_data(obj)->substruct_obj;
763 abmfP_get_num_substruct_fields(ABObj obj)
766 ABObj substruct = abmfP_obj_get_substruct_obj(obj);
773 for (trav_open(&trav, substruct, AB_TRAV_UI);
774 (subobj = trav_next(&trav)) != NULL; )
776 if (abmfP_obj_has_substruct_field(subobj))
782 else if (abmfP_obj_get_substruct_obj(subobj) == obj)
794 abmfP_convert_wclass_ptr_to_name(WidgetClass wclass)
796 STRING wclass_name= NULL;
798 if (wclass == xmCascadeButtonWidgetClass)
800 wclass_name= istr_string(abmfP_xmCascadeButton);
802 else if (wclass == xmScrolledWindowWidgetClass)
804 wclass_name= istr_string(abmfP_xmScrolledWindow);
806 else if (wclass == xmToggleButtonWidgetClass)
808 wclass_name= istr_string(abmfP_xmToggleButton);
816 * Finds the primary window for the application.
817 * Finds the base window whose name is alphabetically first
820 abmfP_get_root_window(ABObj project)
822 static ABObj root_window= NULL;
826 if (root_window != NULL)
831 if (obj_get_root_window(project) == NULL)
833 for (trav_open(&trav, project, AB_TRAV_WINDOWS);
834 (window= trav_next(&trav)) != NULL; )
836 if (!obj_is_base_win(window))
840 if (root_window == NULL)
842 root_window = window;
846 if ( (!obj_is_initially_visible(root_window))
847 && (obj_is_initially_visible(window)) )
849 root_window = window;
851 else if (util_strcmp(
852 obj_get_name(window), obj_get_name(root_window)) < 0)
859 } /* root_window == NULL */
861 if (obj_get_root_window(project) != NULL)
863 root_window= obj_get_root_window(project);
871 * Essentially, all salient UI objects have create procs.
873 * The exceptions are:
874 * - MENU references not salient, but have create procs
875 * - ITEMs are salient, but do not have create procs
876 * (they are created in their parent's proc)
879 abmfP_obj_has_create_proc(ABObj obj)
881 if (obj_is_menu(obj))
884 * menus are considered virtual, in that the "menu" doesn't
885 * actually exist - the menu references do. We write a create
886 * proc for each menu reference.
888 return (obj_is_ref(obj) && (abmfP_obj_get_struct_obj(obj) != NULL));
890 if (obj_is_virtual(obj))
892 /* virtual objects never get written */
895 if (obj_is_item(obj))
900 return obj_is_salient_ui(obj);
905 * create procs take a pointer to the struct we're going to fill in.
908 abmfP_obj_get_create_proc_instance_param_type(ABObj obj)
910 ABObj structObj = NULL;
912 structObj = abmfP_obj_get_struct_obj(obj);
913 if (structObj == NULL)
918 return abmfP_get_c_struct_ptr_type_name(structObj);
923 abmfP_obj_create_proc_has_instance_param(ABObj obj)
930 abmfP_obj_create_proc_has_name_param(ABObj obj)
937 * - topmost object in structure requires a parent from client
938 * - menus need parents because, if they are shared, each instance
939 * will have a different parent
942 abmfP_obj_create_proc_has_parent_param(ABObj obj)
949 abmfP_obj_get_num_create_proc_return_widgets(ABObj obj)
960 * which_param is 0..n-1 params
963 abmfP_obj_get_create_proc_return_widget_name(ABObj obj, int which_param)
965 STRING paramName = NULL;
972 if (abmfP_obj_is_substruct_obj(obj))
974 return abmfP_get_c_substruct_ptr_type_name(obj);
976 else if (abmfP_obj_is_struct_obj(obj))
978 return abmfP_get_c_struct_ptr_type_name(obj);
986 abmfP_obj_create_proc_has_submenu_params(ABObj obj)
989 /* return (abmfP_obj_has_menu(obj) || abmfP_obj_has_item_with_menu(obj)); */
994 abmfP_get_num_cp_submenu_params(ABObj obj)
1000 int numSubmenus = 0;
1002 if (abmfP_obj_has_menu(obj))
1007 for (trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ);
1008 (item = trav_next(&trav)) != NULL; )
1010 if (abmfP_obj_has_menu(item))
1023 abmfP_get_cp_submenu_param_name(ABObj obj, int whichParam)
1025 ABObj paramObj = abmfP_get_cp_submenu_param_obj(obj, whichParam);
1026 if (paramObj == NULL)
1030 return abmfP_get_c_field_name(paramObj);
1035 abmfP_get_cp_submenu_param_type_name(ABObj obj, int whichParam)
1037 return abmfP_str_widget;
1042 abmfP_get_cp_submenu_param_obj(ABObj obj, int whichParam)
1046 ABObj paramObj = NULL;
1050 if ((menu = obj_get_menu(obj)) != NULL)
1053 if (curParam == whichParam)
1060 for (trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ);
1061 (item = trav_next(&trav)) != NULL; )
1063 if ((menu = obj_get_menu(item)) != NULL)
1066 if (curParam == whichParam)
1081 abmfP_obj_has_menu(ABObj obj)
1083 return (obj_get_menu(obj) != NULL);
1088 abmfP_obj_has_item_with_menu(ABObj obj)
1090 BOOL itemHasMenu = FALSE;
1094 for (trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ);
1095 (item = trav_next(&trav)) != NULL; )
1097 if (abmfP_obj_has_menu(item))
1110 abmfP_module_has_menu_struct(ABObj obj)
1112 static ABObj lastModule = NULL;
1113 static BOOL lastModuleHadMenuStruct = FALSE;
1114 ABObj module = obj_get_module(obj);
1115 BOOL hasMenuStruct = FALSE;
1117 if (module == lastModule)
1119 hasMenuStruct = lastModuleHadMenuStruct;
1123 hasMenuStruct = (trav_count(module, AB_TRAV_MENUS) > 0);
1124 lastModule = module;
1125 lastModuleHadMenuStruct = hasMenuStruct;
1128 return hasMenuStruct;
1134 abmfP_obj_has_glyph_label(ABObj obj)
1136 return ( (obj_get_label(obj) != NULL)
1137 && (obj_get_label_type(obj) == AB_LABEL_GLYPH));
1142 abmfP_obj_has_item_with_glyph_label(ABObj obj)
1146 BOOL doesIt = FALSE;
1148 for (trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ);
1149 (item = trav_next(&trav)) != NULL; )
1151 if (abmfP_obj_has_glyph_label(item))
1164 abmfP_obj_has_string_label(ABObj obj)
1166 return ( (obj_get_label(obj) != NULL)
1167 && (obj_get_label_type(obj) == AB_LABEL_STRING));
1172 abmfP_obj_has_item_with_string_label(ABObj obj)
1176 BOOL doesIt = FALSE;
1178 for (trav_open(&trav, obj, AB_TRAV_ITEMS_FOR_OBJ);
1179 (item = trav_next(&trav)) != NULL; )
1181 if (abmfP_obj_has_string_label(item))
1193 abmfP_proj_needs_session_save(ABObj proj)
1195 AB_SESSIONING_METHOD ss_mthd;
1200 if (!obj_is_project(proj))
1202 proj = obj_get_project(proj);
1204 if (!proj || !obj_is_project(proj))
1208 ss_mthd = obj_get_sessioning_method(proj);
1211 case AB_SESSIONING_UNDEF:
1212 case AB_SESSIONING_NONE:
1214 case AB_SESSIONING_CMDLINE:
1215 case AB_SESSIONING_FILE:
1216 case AB_SESSIONING_CMDLINE_AND_FILE:
1226 abmfP_proj_needs_session_restore(ABObj proj)
1228 AB_SESSIONING_METHOD ss_mthd;
1233 if (!obj_is_project(proj))
1235 proj = obj_get_project(proj);
1237 if (!proj || !obj_is_project(proj))
1241 ss_mthd = obj_get_sessioning_method(proj);
1244 case AB_SESSIONING_UNDEF:
1245 case AB_SESSIONING_NONE:
1246 case AB_SESSIONING_CMDLINE:
1248 case AB_SESSIONING_FILE:
1249 case AB_SESSIONING_CMDLINE_AND_FILE:
1257 abmfP_obj_needs_centering_handler(ABObj obj)
1259 AB_ATTACH_TYPE left_attach_type,
1265 left_attach_type = obj_get_attach_type(obj, AB_CP_WEST);
1266 top_attach_type = obj_get_attach_type(obj, AB_CP_NORTH);
1268 if ((left_attach_type == AB_ATTACH_CENTER_GRIDLINE) ||
1269 (top_attach_type == AB_ATTACH_CENTER_GRIDLINE))
1276 abmfP_obj_get_centering_type(ABObj obj)
1278 AB_ATTACH_TYPE left_attach_type,
1281 if (!obj || !abmfP_obj_needs_centering_handler(obj))
1282 return("DTB_CENTER_NONE");
1284 left_attach_type = obj_get_attach_type(obj, AB_CP_WEST);
1285 top_attach_type = obj_get_attach_type(obj, AB_CP_NORTH);
1287 if ((left_attach_type == AB_ATTACH_CENTER_GRIDLINE) &&
1288 (top_attach_type != AB_ATTACH_CENTER_GRIDLINE))
1289 return("DTB_CENTER_POSITION_VERT");
1291 if ((left_attach_type != AB_ATTACH_CENTER_GRIDLINE) &&
1292 (top_attach_type == AB_ATTACH_CENTER_GRIDLINE))
1293 return("DTB_CENTER_POSITION_HORIZ");
1295 if ((left_attach_type == AB_ATTACH_CENTER_GRIDLINE) &&
1296 (top_attach_type == AB_ATTACH_CENTER_GRIDLINE))
1297 return("DTB_CENTER_POSITION_BOTH");
1301 abmfP_obj_needs_align_handler(ABObj obj)
1305 if (!obj || !obj_is_group(obj))
1308 type = obj_get_group_type(obj);
1310 if (type != AB_GROUP_IGNORE)
1317 abmfP_obj_get_group_type(ABObj obj)
1322 if (!obj || !abmfP_obj_needs_align_handler(obj))
1323 return("DTB_GROUP_NONE");
1325 type = obj_get_group_type(obj);
1329 case AB_GROUP_IGNORE:
1330 return("DTB_GROUP_NONE");
1332 return("DTB_GROUP_ROWS");
1333 case AB_GROUP_COLUMNS:
1334 return("DTB_GROUP_COLUMNS");
1335 case AB_GROUP_ROWSCOLUMNS:
1336 return("DTB_GROUP_ROWSCOLUMNS");
1341 abmfP_obj_get_row_align_type(ABObj obj)
1343 AB_GROUP_TYPE group_type;
1344 AB_ALIGNMENT align_type;
1347 return("DTB_ALIGN_NONE");
1349 group_type = obj_get_group_type(obj);
1351 if ((group_type == AB_GROUP_COLUMNS) || (group_type == AB_GROUP_IGNORE))
1352 return("DTB_ALIGN_NONE");
1354 align_type = obj_get_row_align(obj);
1359 return("DTB_ALIGN_TOP");
1360 case AB_ALIGN_HCENTER:
1361 return("DTB_ALIGN_HCENTER");
1362 case AB_ALIGN_BOTTOM:
1363 return("DTB_ALIGN_BOTTOM");
1365 return("DTB_ALIGN_NONE");
1370 abmfP_obj_get_col_align_type(ABObj obj)
1372 AB_GROUP_TYPE group_type;
1373 AB_ALIGNMENT align_type;
1376 return("DTB_ALIGN_NONE");
1378 group_type = obj_get_group_type(obj);
1380 if ((group_type == AB_GROUP_ROWS) || (group_type == AB_GROUP_IGNORE))
1381 return("DTB_ALIGN_NONE");
1383 align_type = obj_get_col_align(obj);
1388 return("DTB_ALIGN_LEFT");
1389 case AB_ALIGN_LABELS:
1390 return("DTB_ALIGN_LABELS");
1391 case AB_ALIGN_VCENTER:
1392 return("DTB_ALIGN_VCENTER");
1393 case AB_ALIGN_RIGHT:
1394 return("DTB_ALIGN_RIGHT");
1396 return("DTB_ALIGN_NONE");
1402 * Returns the starting index and length of the base file name
1403 * sans leading path and trailing extension.
1407 find_base_file_name(STRING path, int *startPtr, int *lenPtr)
1409 #define start (*startPtr)
1410 #define len (*lenPtr)
1411 char *slashPtr = NULL;
1412 char *dotPtr = NULL;
1416 slashPtr = strrchr(path, '/');
1417 if (slashPtr != NULL)
1420 * handle strings of the form subdir//x.ext
1422 while (((*slashPtr) == '/') && ((*slashPtr) != 0))
1426 --slashPtr; /* point to last slash */
1427 slashChar = *slashPtr;
1432 if (slashPtr != NULL)
1434 start = ((int)(slashPtr - path)) + 1;
1437 dotPtr = strrchr(&(path[start]), '.');
1444 len = strlen(&path[start]);
1447 * Restore the string
1449 if (slashPtr != NULL)
1451 *slashPtr = (char)slashChar;
1455 *dotPtr = (char)dotChar;
1464 abmfP_proj_has_message(ABObj proj)
1466 ABObj obj = (ABObj) NULL;
1469 BOOL hasMsg = FALSE;
1474 if (!obj_is_project(proj))
1476 proj = obj_get_project(proj);
1478 if (!proj || !obj_is_project(proj))
1482 for (trav_open(&trav, proj, AB_TRAV_SALIENT_UI);
1483 ((obj = trav_next(&trav)) != NULL) && !hasMsg; )
1485 if (obj_is_message(obj))
1494 ** 4/30/95 bfreeman - Temporary. This is obj_get_refs_to's territory! But, I
1495 ** wasn't able to get the refs to menu items out of obj_get_refs_to()...the
1496 ** objects just aren't there.
1498 ** Returns an ABObjList containing all of the references to obj
1502 ** ABObjList refList = abmfP_find_refs_to(obj);
1503 ** ABObj refObj = NULL;
1504 ** int numRefs = objlist_get_num_objs(refList);
1507 ** if ((refList != NULL) && (numRefs > 0))
1509 ** for (i = 0; i < numRefs; ++i)
1511 ** refObj = objlist_get_obj(refList, i, NULL);
1513 ** --- use refObj, it refers to obj ---
1517 ** objlist_destroy(refList);
1520 ** Note: May return NULL and it is the responsibility of the caller to
1521 ** destroy the ABObjList.
1524 abmfP_find_refs_to(ABObj obj)
1526 AB_TRAVERSAL moduleTrav;
1527 ABObjList refList = NULL;
1528 ABObj refObj = NULL;
1533 refList = objlist_create();
1535 for (trav_open(&moduleTrav, obj_get_module(obj), AB_TRAV_UI);
1536 ((refObj = trav_next(&moduleTrav)) != NULL); )
1538 if (obj_is_ref(refObj) && (refObj->ref_to == obj))
1540 objlist_add_obj(refList, refObj, NULL);
1543 trav_close(&moduleTrav);