Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
XCOMM $XConsortium: Imakefile /main/8 1996/10/09 14:03:32 drk $
XCOMM
XCOMM RESTRICTED CONFIDENTIAL INFORMATION:
XCOMM
XCOMM The information in this document is subject to special
XCOMM restrictions in a confidential disclosure agreement between
XCOMM HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
XCOMM document outside HP, IBM, Sun, USL, SCO, or Univel without
XCOMM Sun's specific written approval. This document and all copies
XCOMM and derivative works thereof must be returned or destroyed at
XCOMM Sun's request.
XCOMM
XCOMM (c) Copyright 1996 Digital Equipment Corporation.
XCOMM (c) Copyright 1996 Hewlett-Packard Company.
XCOMM (c) Copyright 1996 International Business Machines Corp.
XCOMM (c) Copyright 1993,1996 Sun Microsystems, Inc.
XCOMM (c) Copyright 1996 Novell, Inc.
XCOMM (c) Copyright 1996 FUJITSU LIMITED.
XCOMM (c) Copyright 1996 Hitachi.
#define DoNormalLib YES
#define DoSharedLib NO
#define DoDebugLib NO
#define DoProfileLib NO
#define LibName ABobjXm
#define LibHeaders NO
#define LibInstall NO
#include "../ab.tmpl"
#include "../ab.rules"
INCLUDES = -I. -I$(ABINCLUDES)
DEFINES =
SOURCES.h.shipped=
SOURCES.h.shared= \
objxm.h
SOURCES.h.unshared = \
objxmP.h
SRCS = objxm_args.c objxm_config.c objxm_conn.c \
objxm_inst.c objxm_objects.c objxm_strs.c \
objxm_util.c
OBJS = objxm_args.o objxm_config.o objxm_conn.o \
objxm_inst.o objxm_objects.o objxm_strs.o \
objxm_util.o
SYS_LIBRARIES = -lm $(ICONVSYSLIB) $(DYNLIBSYSLIB) $(REGEXSYSLIB)
#ifdef SunArchitecture
WAITTARGET = .WAIT
#endif /* SunArchitecture */
LINTLIBS = $(XINPUTLIB) $(DTHELPLIB) $(DTSVCLIB) $(TTLIB)) $(XMLIB) $(XTOOLLIB) $(XLIB)
LOCAL_LIBRARIES = $(XINPUTLIB) $(DTHELPLIB) $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB)
#include <Library.tmpl>
DependTarget()
LinkFileList(shared_includes,$(SOURCES.h.shared),../include/ab_private,../../libABobjXm)
includes:: shared_includes $(WAITTARGET)
sdtgilcvt:
dtcodegen: libABobjXm.a
dtbuilder: libABobjXm.a

View File

@@ -0,0 +1,16 @@
XCOMM $XConsortium: README.src /main/3 1996/04/23 20:03:57 drk $
Library: libABobjXm
Description: Implements motif-specific functionality
for the libABobj object data structures
-------------------------------------------------------
-------------------------------------------------------
Module Prefix Description
------ ------ -----------------------
Object-Motif objxm_ provides mechanism to
manipulate the libABobj
data structures for
the Motif toolkit.

View File

@@ -0,0 +1,32 @@
$ $XConsortium: libABobjXm.msg /main/3 1995/11/06 18:43:44 rswiston $
$ ========================================================================
$ = Message source text file for App Builder's libABobjXm utility library.
$ = @(#)libABobjXm.msg 1.5 24 Apr 1995 dtappbuilder/src/libABobjXm
$ ========================================================================
$quote "
$ The set number set below must be syncronized with the #define in objxmP.h
$set 203
1 "WARNING: %s : could not convert filename[%s] to pixmap\n"
2 "WARNING: %s : No glyph filename specified\n"
3 "ERROR: %s: NULL Object attachment\n"
4 "Instantiation ERROR: %s: widget-ID for parent is NULL\n"
5 "Instantiation ERROR: %s: could not instantiate menu\n"
6 "Instantiation ERROR: Object must have a valid name\n"
7 "Instantiation ERROR: %s: Object must have widget class\n"
8 "INTERNAL ERROR: salient counts don't match.\n"
9 "ERROR: objxm_comp_get_subobj - object not xmconfigured: %s\n"
10 "Folders"
11 "Filter"
12 "Enter Filename"
13 "Update"
14 "Warning: %s :\n"
15 "Graphic File base '%s'\ncould not be converted to a Pixmap because\n"
16 "File base is an empty string."
17 "None of the following files could be converted to a Pixmap:\n"
18 "filenames too long to display\n"
19 "%s.pm\n%s.xpm\n%s.bm\n%s.xbm\n"
20 "The graphic file name specified could not be converted\ninto a pixmap. App Builder searches for a file of the\nform Filename.pm, Filename.xpm, Filename.bm, and\nFilename.xbm.\n\nEither none of those files exists in the directory specified\n(via the Graphic Filename field or if no path was specified,\nthen the current working directory), or a file exists but may\nbe corrupt."
21 "WARNING: Object '%s'\nCould not allocate Background color \"%s\".\nObject's Background will default to white."
22 "WARNING: Object '%s'\nCould not allocate Foreground color \"%s\".\nObject's Foreground will default to black."

View File

@@ -0,0 +1,891 @@
/*
* $XConsortium: objxm.h /main/3 1995/11/06 18:43:58 rswiston $
*
* @(#)objxm.h 1.73 24 Apr 1995
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* objxm.h - Handle Motif-specific mechanism for obj structure
*
*/
#ifndef _OBJXM_H_
#define _OBJXM_H_
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <ab_private/obj.h>
#include <ab_private/istr.h>
/*
* Define Flags for Color Args
*/
#define ObjxmNone 0x00
#define ObjxmForeground 0x01
#define ObjxmBackground 0x02
/*
* OBJXM Configuration Types
* The difference between the 2 types of XmConfiguring is in
* how the Obj's Resource ArgLists are constructed:
*
* For Build-mode, resource values are converted to the
* correct 'type' for a real "SetValues" or "Create" call.
* (e.g. For XmNbackground, the value is converted to a Pixel)
*
* For Codegen-mode, resource values are converted to what
* should be *written-out* in code.
* (e.g. For XmNbackground, the value is the color-name string,
* NOT a Pixel)
*
*/
typedef enum
{
OBJXM_CONFIG_BUILD,
OBJXM_CONFIG_CODEGEN,
OBJXM_CONFIG_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
/* ANSI: no comma after last enum item! */
} OBJXM_CONFIG_TYPE;
/*
* Type of "objects" in an XmConfigured hierarchy
*/
typedef enum
{
/* Required by all XmConfigured objs */
AB_CFG_UNDEF = 0,
AB_CFG_OBJECT_OBJ, /* Object SubObj */
AB_CFG_LABEL_OBJ, /* Label SubObj */
AB_CFG_SIZE_OBJ, /* SubObj responsible for Sizing */
AB_CFG_POSITION_OBJ, /* SubObj responsible for Positioning*/
AB_CFG_PARENT_OBJ, /* SubObj for parenting children */
AB_CFG_SELECT_OBJ, /* SubObj for displaying Select feedback */
/* Optional for XmConfigured objs */
AB_CFG_BORDER_OBJ, /* SubObj for displaying border */
AB_CFG_DND_OBJ, /* drag from/drop on this object */
AB_CFG_HELP_OBJ, /* where we attach help */
AB_CFG_STATUS_OBJ, /* SubObj for status display */
AB_CFG_MENU_PARENT_OBJ, /* SubObj for parenting menus */
AB_CFG_SCROLLBAR_OBJ, /* Scrollbar SubObj */
AB_CFG_SCROLLING_OBJ, /* Scrolling container SubObj */
AB_CFG_MENU_OBJ, /* Menu (reference) SubObj */
AB_CFG_WINDOW_BB_OBJ, /* Dialog internal BulletinBoard SubObj */
AB_CFG_WINDOW_PW_OBJ, /* Window internal PanedWindow SubObj */
AB_CFG_WINDOW_MW_OBJ, /* Window internal MainWindow SubObj */
AB_CFG_OBJ_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
} AB_CFG_OBJ_TYPE;
typedef int ObjxmFilenameToPixmapFuncRec(
Widget widget,
STRING filename,
Pixmap *pixmap_out
);
typedef ObjxmFilenameToPixmapFuncRec *ObjxmFilenameToPixmapFunc;
typedef int ObjxmPostInstantiateFuncRec(
ABObj obj
);
typedef ObjxmPostInstantiateFuncRec *ObjxmPostInstantiateFunc;
/*
* define types for Xm-Configure object "methods"
*/
typedef int (*XmConfigProc) (
ABObj obj
);
typedef int (*XmUnconfigProc) (
ABObj obj
);
typedef BOOL (*XmConfigIsaFunc) (
ABObj obj
);
typedef int (*XmConfigSetArgProc) (
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
typedef int (*XmConfigPostInstProc) (
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
typedef ABObj (*XmConfigGetObjProc) (
ABObj obj,
AB_CFG_OBJ_TYPE type
);
/*
* XmConfigInfo Structure - one for each type of object supported
*/
typedef struct _XM_CONFIG_INFO_REC {
/* Methods...*/
XmConfigProc xmconfig; /* configures obj hierarchy */
XmUnconfigProc xmunconfig; /* unconfigures obj */
XmConfigGetObjProc get_config_obj;/* returns config obj */
XmConfigSetArgProc set_args; /* sets appropriate resources */
XmConfigPostInstProc post_instantiate; /* does any post-instantiation stuff*/
XmConfigIsaFunc is_a_test; /* "is a" test */
} XM_CONFIG_INFO_REC, XmConfigInfoRec, *XmConfigInfo;
/*
* Xm String Cache Data structures & defines
*/
/*
* ABXm XmCreateFunc structure
*/
typedef Widget (*XmCreateFunc) (
Widget parent,
String name,
ArgList args,
Cardinal arg_count
);
/*
* Widget Classes
*/
extern char * const _applicationShell;
extern char * const _dtComboBox;
extern char * const _dtMenuButton;
extern char * const _dtSpinBox;
extern char * const _dtTerm;
extern char * const _group;
extern char * const _topLevelShell;
extern char * const _xmArrowButton;
extern char * const _xmBulletinBoard;
extern char * const _xmCascadeButton;
extern char * const _xmCommand;
extern char * const _xmDialogShell;
extern char * const _xmDrawingArea;
extern char * const _xmDrawnButton;
extern char * const _xmFileSelectionBox;
extern char * const _xmForm;
extern char * const _xmFrame;
extern char * const _xmLabel;
extern char * const _xmLabelGadget;
extern char * const _xmList;
extern char * const _xmMainWindow;
extern char * const _xmManager;
extern char * const _xmMenuShell;
extern char * const _xmMessageBox;
extern char * const _xmPanedWindow;
extern char * const _xmPopupMenu;
extern char * const _xmPrimitive;
extern char * const _xmPulldownMenu;
extern char * const _xmPushButton;
extern char * const _xmRowColumn;
extern char * const _xmScale;
extern char * const _xmScrollBar;
extern char * const _xmScrolledList;
extern char * const _xmScrolledWindow;
extern char * const _xmSelectionBox;
extern char * const _xmSeparator;
extern char * const _xmSeparatorGadget;
extern char * const _xmText;
extern char * const _xmTextField;
extern char * const _xmToggleButton;
extern char * const _xmToggleButtonGadget;
/*
* XmConfigure Routines
*/
/* Function to initialize objxm
*/
extern int objxm_init(
Widget toplevel
);
/*
* Hook to add routine to convert filenames to callbacks.
* NULL callback reinstates default conversion method.
*/
extern int objxm_set_cvt_filename_to_pixmap_callback(
ObjxmFilenameToPixmapFunc filename_to_pixmap_cb
);
/*
* Hook to add routine to do additional post instantiate
* stuff
* by default, this callback is NULL, so nothing is called
*/
extern int objxm_set_post_instantiate_callback(
ObjxmPostInstantiateFunc post_instantiate_cb
);
/* Function to register XmConfigInfo
* for a single object type
*/
extern void objxm_register_config_info(
XmConfigInfo cfginfo
);
/* Function which XmConfigures an object
* into it's appropriate Composite object
* hierarchy
*/
extern int objxm_obj_configure(
ABObj obj,
OBJXM_CONFIG_TYPE ctype,
BOOL set_args
);
/* Function which XmConfigures an entire tree
*/
extern int objxm_tree_configure(
ABObj root,
OBJXM_CONFIG_TYPE ctype
);
/* Function which UnConfigures an object
* NOTE: does NOT destroy associated widgets!
*/
extern int objxm_obj_unconfigure(
ABObj obj
);
/* Function which UnConfigures an entire tree
* NOTE: does NOT destroy associated widgets!
*/
extern int objxm_tree_unconfigure(
ABObj root
);
/* Function which returns the correct
* Composite SubObj corresponding to 'type'
*/
extern ABObj objxm_comp_get_subobj(
ABObj obj,
AB_CFG_OBJ_TYPE type
);
/* Function which configures an object with the
* the standard labeled-structure (container
* managing Label & Main-object)
*/
extern int objxm_comp_config_labeled_obj(
ABObj obj,
AB_OBJECT_TYPE obj_type,
STRING obj_suffix,
STRING obj_classname
);
/* Function which collapses a labeled object
* back down into a single Main-object
*/
extern int objxm_comp_unconfig_labeled_obj(
ABObj obj
);
/* Function which builds a Menu-reference object
* if "menu_name" is non-NULL
*/
extern ABObj objxm_comp_config_menu_ref(
ABObj obj
);
/* Function which finds & destroys a Menu-reference
* object if one exists
*/
extern int objxm_comp_unconfig_menu_ref(
ABObj obj
);
/* Function which makes the RootObj a "Frame" and
* creates a new SubObj directly underneath to
* represent the actual Obj.
*/
extern ABObj objxm_comp_config_border_frame(
ABObj obj
);
/* Function that collapses a Composite Obj configured
* with a Frame as the Root, back down to an Obj
* without a Frame.
*/
extern int objxm_comp_unconfig_border_frame(
ABObj obj
);
/*
* Xm Instantiation/Change/Destruction routines
*/
/* Instantiate widgets for an entire tree
* NOTE: for instantiating large trees at once
* (like loading BIL or UIL, set "manage_last" to
* TRUE! (if instantiating a single object or small
* group of objects, set it to FALSE).
*/
extern int objxm_tree_instantiate(
ABObj root,
BOOL manage_last
);
/* Destroy Widgets in a tree and set ui_handles=NULL
* NOTE: this does NOT destroy the Objs
*/
extern int objxm_tree_uninstantiate(
ABObj root,
BOOL top_most
);
/* Destroy Widgets AND Objs for an entire tree
*/
extern int objxm_tree_destroy(
ABObj root
);
/* Instantiate any changes made to the
* Composite-obj
* Return whether or not New widgets were
* created as a result of the changes
*/
extern int objxm_comp_instantiate_changes(
ABObj obj,
BOOL *new_widgets
);
extern int objxm_tree_instantiate_changes(
ABObj obj,
BOOL *new_widgets
);
extern int objxm_comp_set_item_selection(
ABObj obj
);
/*
* Routines to Temporarily Instantiate/Destroy Menus
*/
extern int objxm_instantiate_menus(
ABObj root
);
extern int objxm_destroy_menus(
ABObj root
);
extern int objxm_create_popup_menu_title(
ABObj menu_ref,
OBJXM_CONFIG_TYPE ctype,
STRING title
);
/*
* Routines to Store default Translations & Obj pointer
* inside widget's userData
*/
extern int objxm_store_obj_and_actions(
Widget w,
ABObj obj
);
extern int objxm_free_obj_and_actions(
Widget w
);
extern ABObj objxm_get_obj_from_widget(
Widget w
);
extern XtTranslations
objxm_get_actions_from_widget(
Widget w
);
/*
* Xm Map/Unmap routine
*/
extern int objxm_tree_map(
ABObj root,
BOOL map
);
/*
* Object-specific methods
*/
extern ABObj objxm_comp_mainwin_get_area(
ABObj obj,
AB_CONTAINER_TYPE area_type
);
extern ABObj objxm_comp_custdlg_get_area(
ABObj obj,
AB_CONTAINER_TYPE area_type
);
/*
* Xm Resource-setting routines
*/
/* Set Xm resource lists for entire tree
*/
extern int objxm_tree_set_ui_args(
ABObj root,
OBJXM_CONFIG_TYPE ctype,
BOOL replace
);
/* Remove Xm resource lists for entire tree */
extern int objxm_tree_remove_ui_args(
ABObj root,
OBJXM_CONFIG_TYPE ctype
);
/* Set Xm resource list for a Composite object
* hierarchy
*/
extern int objxm_comp_set_ui_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype,
BOOL replace
);
/* Set Xm resources that can only be set AFTER
* ALL WIDGETS have been instantiated
*/
extern int objxm_tree_set_post_inst_args(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
extern int objxm_obj_set_post_inst_args(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
/* Set Xm resource list corresponding to
* attachment properties for a Composite object
* hierarchy
*/
extern int objxm_comp_set_attachment_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype
);
/* Set Xm resource list corresponding to
* attachment properties for a single object
*/
extern int objxm_obj_set_attachment_args(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
/* Set Xm resource list corresponding to
* color properties for a Composite object
* hierarchy
*/
extern int objxm_comp_set_color_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype,
unsigned int flag
);
/* Set Xm resources for "default button" within a
* dialog's button-panel
*/
extern int objxm_comp_set_default_button_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype
);
/* Set the Label type/value resources
* for a Composite object hierarchy
*/
extern int objxm_comp_set_label_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype
);
/* Set Xm resource list corresponding to
* label alignment properties for a
* Composite object hierarchy
*/
extern int objxm_comp_set_lbl_align_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype
);
/* Set Xm resource list correspondin gto
* label positioning for a Composite object
* hierarchy
*/
extern int objxm_comp_set_lbl_pos_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype
);
extern int objxm_comp_set_icon_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype
);
/* Set Xm resource list corresponding to
* Border-frame style for a Composite object
* hierarchy
*/
extern int objxm_comp_set_border_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype
);
extern int objxm_comp_set_read_only_args(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype
);
/* Set Xm resource list corresponding to
* the MessageBox object's buttons.
*/
extern int objxm_comp_set_msgbox_button_arg(
ABObj comproot,
OBJXM_CONFIG_TYPE ctype,
unsigned char which_btn
);
extern int objxm_obj_set_arrow_style_arg(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
extern int objxm_obj_set_direction_arg(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
extern int objxm_obj_set_line_style_arg(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
extern int objxm_obj_set_orientation_arg(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
extern int objxm_obj_set_selection_arg(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
extern Widget objxm_set_widget(
ABObj obj,
Widget widget
);
extern Widget objxm_get_widget(
ABObj obj
);
extern WidgetClass
objxm_get_class_ptr(
STRING class_name
);
/*
* Connections stuff
*/
extern ABObj objxm_comp_get_source_for_when(
ABObj sourceObj,
AB_WHEN when
);
extern ABObj objxm_comp_get_target_for_builtin_action(
ABObj targetObj,
AB_BUILTIN_ACTION builtin_action
);
extern STRING objxm_get_resource_for_when(
ABObj sourceObj,
AB_WHEN when
);
extern STRING objxm_get_resource_for_builtin_action(
ABObj targetObj,
AB_BUILTIN_ACTION builtin_action
);
/* Return number of resource args presently
* set in ArgList
*/
extern int objxm_get_num_args(
ArgList arglist
);
/* Return number of resource args presently in object's
* ui_arg_list
*/
extern int objxm_obj_get_num_ui_args(
ABObj obj
);
/* Return default motif widget-class name
* for a given object's type
*/
extern STRING objxm_obj_get_default_motif_class(
ABObj obj
);
/* Return to Motif Create function for
* the Obj
*/
extern XmCreateFunc
objxm_obj_get_xmcreate_func(
ABObj obj
);
/* Set resource (name/value) in ArgList
*/
extern int objxm_set_arg(
ArgList *p_arglist,
AB_ARG_TYPE type,
String name,
XtArgVal value
);
/* Set a Literal type (name/value) in ArgList
*/
extern int objxm_set_literal_arg(
OBJXM_CONFIG_TYPE ctype,
ArgList *p_arglist,
String name,
unsigned char literal
);
/* Set a Widget type (name/value) in ArgList
*/
extern int objxm_set_widget_arg(
OBJXM_CONFIG_TYPE ctype,
ArgList *p_arglist,
String name,
ABObj w_obj
);
/* Set resource (name/value) in ArgList
* only if not already present
*/
extern int objxm_set_arg_if_new(
ArgList *p_arglist,
AB_ARG_TYPE type,
String name,
XtArgVal value
);
/* Remove resource (name/value) from ArgList
*/
extern int objxm_remove_arg(
ArgList *p_arglist,
String name
);
/* Remove all resources from ArgList
*/
extern void objxm_remove_all_args(
ArgList *p_arglist,
OBJXM_CONFIG_TYPE ctype
);
extern Arg *objxm_get_arg(
ArgList arglist,
char *name
);
/* FOR DEBUG PURPOSES ONLY */
extern int objxm_dump_arglist(
ABObj obj,
ArgList args,
int num_args
);
extern int objxm_dump_arglist_indented(
ABObj obj,
ArgList args,
int num_args,
int spaces
);
/* FOR DEBUG PURPOSES ONLY */
extern int objxm_dump_widget_geometry(
Widget widget
);
/*
* Xm String cache routines
*/
/* Load internal resource tables with
* required Xt/Xm resources/enums/createfuncs
*/
extern void objxm_strs_init(
);
/* return "strname" corresponding to xmname
*/
extern ISTRING objxm_get_res_strname(
String xmname
);
/* return "xmname" corresponding to strname
*/
extern String objxm_get_res_xmname(
ISTRING strname
);
/* return type corresponding to resource strname
*/
extern AB_ARG_TYPE objxm_get_istr_res_type(
ISTRING strname
);
/* return type corresponding to resource xmname
*/
extern AB_ARG_TYPE objxm_get_res_type(
String xmname
);
/* return arg class corresponding to resource strname
*/
extern AB_ARG_CLASS objxm_get_istr_res_class(
ISTRING strname
);
/* return arg class corresponding to resource xmname
*/
extern AB_ARG_CLASS objxm_get_res_class(
String xmname
);
/* return whether or not the value is defined as the
* "default" for that resource
*/
extern BOOL objxm_res_value_is_default(
String xmname,
WidgetClass wclass,
XtArgVal value
);
/* return "strdef" corresponding to xmdef
*/
extern ISTRING objxm_get_enum_strdef(
String xmname,
unsigned char xmdef
);
/* return "xmdef" corresponding to strdef
*/
extern unsigned char
objxm_get_enum_xmdef(
String xmname,
ISTRING strdef
);
/* return "ftnstr" corresponding to ftn
*/
extern ISTRING objxm_get_xmcreate_ftnstr(
XmCreateFunc ftn
);
/* return "ftn" corresponding to ftnstr
*/
XmCreateFunc objxm_get_xmcreate_xmdef(
ISTRING ftnstr
);
/*
* Xm Utility routines
*/
extern BOOL objxm_color_exists(
String colorname
);
extern int objxm_name_to_pixel(
Widget widget,
String colorname,
Pixel *pixel_p
);
extern int objxm_filebase_to_pixmap(
Widget widget,
String filebase,
Pixmap *pixmap_p
);
extern STRING objxm_pixmap_conversion_error_msg(
ABObj obj,
STRING filebase,
int status
);
extern XFontStruct *
objxm_fontlist_to_font(
XmFontList fontlist
);
extern XmString objxm_str_to_xmstr(
Widget widget,
String string
);
extern STRING objxm_xmstr_to_str(
XmString xmstr
);
extern String objxm_accel_to_acceltext(
String accelstr
);
extern unsigned char
objxm_linestyle_to_enum(
AB_LINE_TYPE linestyle
);
extern BOOL objxm_is_menu_widget(
Widget widget
);
/*
* Debugging functions
*/
int objxm_print(ABObj obj);
int objxm_print_indented(ABObj obj, int spaces, int verbosity);
int objxm_tree_print(ABObj obj);
int objxm_tree_print_indented(ABObj obj, int spaces, int verbosity);
/*
* Xm Resource Setting macros
*/
#define objxm_obj_set_ui_arg(obj, type, name, val) \
objxm_set_arg((ArgList*)&((obj)->ui_args), type, name, (XtArgVal)val)
#define objxm_obj_set_literal_ui_arg(obj, ctype, name, enum) \
objxm_set_literal_arg(ctype, (ArgList*)&((obj)->ui_args), name, enum)
#define objxm_obj_set_widget_ui_arg(obj, ctype, name, w_obj) \
objxm_set_widget_arg(ctype, (ArgList*)&((obj)->ui_args), name, w_obj)
#define objxm_obj_remove_ui_arg(obj, name) \
objxm_remove_arg((ArgList*)&((obj)->ui_args), name)
#define objxm_obj_remove_all_ui_args(obj, t) objxm_remove_all_args((ArgList*)&((obj)->ui_args), t)
#define objxm_obj_get_ui_args(obj) ((ArgList)((obj)->ui_args))
#define objxm_obj_get_num_ui_args(obj) \
(objxm_get_num_args(objxm_obj_get_ui_args(obj)))
#define objxm_obj_get_ui_arg(obj,name) \
(objxm_get_arg(objxm_obj_get_ui_args(obj),(name)))
/*************************************************************************
** **
** INLINE IMPLEMENTATION **
** **
*************************************************************************/
#define objxm_set_widget(obj,w) ((obj)->ui_handle = ((void *)(w)))
#define objxm_get_widget(obj) ((Widget)((obj)->ui_handle))
#endif /* _OBJXM_H_ */

View File

@@ -0,0 +1,163 @@
/*
* $XConsortium: objxmP.h /main/3 1995/11/06 18:44:17 rswiston $
*
* @(#)objxmP.h 1.21 15 Feb 1994 cde_app_builder/src/libABobjXm
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* objxmP.h - Implements private component of objxm module
*
*/
#ifndef _OBJXM_P_H_
#define _OBJXM_P_H_
#include <X11/Intrinsic.h>
#include <nl_types.h>
#include <ab_private/obj_notify.h>
#include <ab_private/objxm.h>
/*
** I18N defines: Which message set are our messages in? This must be in sync
** with the 'set N' definition in the libABobjXm.msg message source text file.
**
** And what global variable are we expecting as our opened catalog descriptor?
*/
#define OBJXM_MESSAGE_CATD Dtb_project_catd
#define OBJXM_MESSAGE_SET 203
extern nl_catd OBJXM_MESSAGE_CATD;
/*
* Objxm Enum structure
*/
typedef struct _OBJXM_ENUM{
unsigned char xmdef; /* i.e. XmWORK_AREA */
ISTRING strdef;/* i.e. "XmWORK_AREA" */
} ObjxmEnum;
/*
* EnumTable structure
*/
typedef struct _OBJXM_ENUM_TABLE {
ObjxmEnum *enums;
int count;
} ObjxmEnumTable;
/*
* Function type for calculating Resource Default value
* based on the associated WidgetClass
*/
typedef XtArgVal (*ObjxmResDefaultFunc) (
WidgetClass
);
/*
* Objxm Resource structure
*/
typedef struct _OBJXM_RES {
ISTRING xmname; /* e.g. XmNfoo ("foo") */
ISTRING strname; /* e.g. "XmNfoo" ISTRING*/
AB_ARG_TYPE type; /* e.g. AB_ARG_STRING */
AB_ARG_CLASS arg_class; /* e.g. AB_ARG_CLASS_COLOR */
ObjxmEnumTable *enum_table; /* points to table of Enum values */
XtArgVal default_val; /* default value for resource */
ObjxmResDefaultFunc default_func; /* default value calculation function */
} ObjxmRes;
typedef struct _OBJXM_CREATE_FUNC {
XmCreateFunc ftn; /* i.e. XmCreateFrame */
ISTRING ftnstr; /* i.e. "XmCreateFrame" */
} ObjxmCreateFunc;
/*
* Structure to store ABObj & XtTranslations for a widget
*/
typedef struct _OBJXM_WIDGET_INFO {
ABObj obj;
XtTranslations translations;
} ObjxmWidgetInfo;
/*
* Declare module-private functions
*/
/* Called when an object is being
* destroyed
*/
extern int objxmP_destroy(
ObjEvDestroyInfo info
);
/* Function which returns XmConfigInfo
* ptr for an object
*/
extern XmConfigInfo
objxmP_get_config_info(
ABObj obj
);
/* Create a SubObj directly under the root and
* move the root's children under the new SubObj
*/
extern ABObj objxmP_create_direct_subobj(
ABObj root,
AB_OBJECT_TYPE type,
STRING subname
);
/* Function which re-configures attachments after
* objects have been xmconfigured
*/
extern int objxmP_obj_config_attachments(
ABObj obj
);
extern int objxmP_obj_set_attachment_arg(
ABObj obj,
OBJXM_CONFIG_TYPE ctype,
ABObj parent_obj,
AB_COMPASS_POINT dir
);
extern int objxmP_comp_set_type_args(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
extern int objxmP_comp_type_post_instantiate(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
);
extern int objxmP_merge_arg(
ArgList *p_arglist,
Arg *arg
);
extern ArgList objxmP_merge_arglists(
ArgList args1,
int num_args1,
ArgList args2,
int num_args2
);
extern Widget ObjxmP_toplevel;
extern int ObjxmP_visual_depth;
extern ObjxmFilenameToPixmapFunc ObjxmP_filename_to_pixmap_cb;
extern ObjxmPostInstantiateFunc ObjxmP_post_instantiate_cb;
#endif /* _OBJXM_P_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,695 @@
/*
* $XConsortium: objxm_config.c /main/4 1995/11/06 18:45:06 rswiston $
*
* @(#)objxm_config.c 1.27 15 Feb 1994 cde_app_builder/src/libABobjXm
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* objxm_config.c - Implements configuring an object into the
* appropriate Motif hierarchy
*/
#include <stdlib.h>
#include <stdio.h>
#include <Xm/Xm.h>
#include <ab_private/trav.h>
#include "objxmP.h"
#define MAX_XMCONFIG_INFOS 35
/*************************************************************************
** **
** Private Data **
** **
**************************************************************************/
static XmConfigInfo config_info_table[MAX_XMCONFIG_INFOS];
static int config_info_count = 0;
/*************************************************************************
** **
** Private Function Declarations **
** **
**************************************************************************/
static int xm_configure_tree(
ABObj root,
OBJXM_CONFIG_TYPE ctype
);
static int xm_configure_tree_attachments(
ABObj root
);
static int config_attachment(
ABObj obj,
ABObj parent_obj,
AB_COMPASS_POINT dir
);
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
/*
* Add XmConfigure info for a given object type to the XmConfigInfo table
*/
void
objxm_register_config_info(
XmConfigInfo cfginfo
)
{
int i;
Boolean exists = FALSE;
/* Search to make sure it doesn't already exist in the table */
for (i = 0; i < config_info_count; i++)
if (config_info_table[i] == cfginfo)
{
exists = TRUE;
break;
}
if (!exists)
{
if (config_info_count < MAX_XMCONFIG_INFOS)
config_info_table[config_info_count++] = cfginfo;
else
{
if (util_get_verbosity() > 0)
fprintf(stderr,"objxm_register_config_info: config_info table full\n");
return;
}
}
}
/*
* return the XmConfigInfo corresponding to the Object
*/
XmConfigInfo
objxmP_get_config_info(
ABObj obj
)
{
int i;
XmConfigInfo cfginfo = NULL;
ABObj vobj;
vobj = obj_get_root(obj);
for (i=0; i < config_info_count; i++)
if ((*config_info_table[i]->is_a_test)(vobj))
{
cfginfo = config_info_table[i];
break;
}
return(cfginfo);
}
/*
* XmConfigure an Object into its Composite Object hierarchy
*/
int
objxm_obj_configure(
ABObj obj,
OBJXM_CONFIG_TYPE ctype,
BOOL set_args
)
{
int iReturn = OK;
XmConfigInfo cfginfo;
if (!obj_has_flag(obj, XmConfiguredFlag))
{
obj = obj_get_root(obj);
if (obj_is_project(obj) ||
obj_is_module(obj) || obj_is_message(obj))
obj_set_flag(obj, XmConfiguredFlag);
else
{
cfginfo = objxmP_get_config_info(obj);
if (cfginfo != NULL && cfginfo->xmconfig != NULL)
iReturn = (*cfginfo->xmconfig)(obj);
else
iReturn = -1;
if (iReturn == OK)
{
obj_comp_set_flag(obj, XmConfiguredFlag);
/*
if (set_args)
objxm_comp_set_ui_args(obj, ctype, TRUE);
*/
}
}
}
return iReturn;
}
/*
* Collapse a Composite Object hierarchy back into a SINGLE
* UnConfigured object
*/
int
objxm_obj_unconfigure(
ABObj obj
)
{
int iReturn= -1;
XmConfigInfo cfginfo;
if (obj_has_flag(obj, XmConfiguredFlag))
{
obj = obj_get_root(obj);
if (obj_is_project(obj) || obj_is_module(obj))
{
obj_clear_flag(obj, XmConfiguredFlag);
iReturn = 0;
}
else
{
cfginfo = objxmP_get_config_info(obj);
if (cfginfo != NULL && cfginfo->xmunconfig != NULL)
iReturn = (*cfginfo->xmunconfig)(obj);
if (iReturn == OK) /* Reset common fields */
{
obj->part_of = NULL;
obj_set_class_name(obj, NULL);
obj_clear_flag(obj, XmConfiguredFlag);
}
}
}
else if (util_get_verbosity() > 2)
{
fprintf(stderr,"objxm_obj_unconfigure: %s not XmConfigured\n",
util_strsafe(obj_get_name(obj)));
}
return iReturn;
}
/*
* XmConfigures all salient objects in the tree. Objects already
* configured are ignored.
*/
int
objxm_tree_configure(
ABObj root,
OBJXM_CONFIG_TYPE ctype
)
{
/* Phase I */
xm_configure_tree(root, ctype);
/* Phase II (Phase I *MUST* happen first)*/
xm_configure_tree_attachments(root);
/* Phase III */
objxm_tree_set_ui_args(root, ctype, TRUE);
/* Phase IV (ONLY happens here for Code-generation! */
if (ctype == OBJXM_CONFIG_CODEGEN)
objxm_tree_set_post_inst_args(root, ctype);
return 0;
}
/*
* Collapses all salient Objects back down into their
* UnConfigured state
*/
int
objxm_tree_unconfigure(
ABObj root
)
{
int iRetVal= 0;
AB_TRAVERSAL trav;
ABObj obj= NULL;
/* MUST be BOTTOM-UP Traversal */
for (trav_open(&trav, root, AB_TRAV_CHILDREN);
(obj= trav_next(&trav)) != NULL; )
objxm_tree_unconfigure(obj);
if (obj_is_salient(root))
objxm_obj_unconfigure(root);
trav_close(&trav);
return 0;
}
static int
xm_configure_tree(
ABObj root,
OBJXM_CONFIG_TYPE ctype
)
{
int iRetVal= 0;
AB_TRAVERSAL trav;
ABObj obj= NULL;
int numSalientObjs= 0;
int configCount= 0;
/* Must be TOP-DOWN traversal */
numSalientObjs= trav_count(root, AB_TRAV_SALIENT);
for (trav_open(&trav, root,
AB_TRAV_SALIENT | AB_TRAV_MOD_PARENTS_FIRST | AB_TRAV_MOD_SAFE);
(obj= trav_next(&trav)) != NULL; )
{
++configCount;
objxm_obj_configure(obj, ctype, FALSE);
}
trav_close(&trav);
if (configCount!= numSalientObjs)
{
fprintf(stderr,
catgets(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 8,
"INTERNAL ERROR: salient counts don't match.\n") );
iRetVal= -1;
goto epilogue;
}
epilogue:
return iRetVal;
}
static int
xm_configure_tree_attachments(
ABObj root
)
{
AB_TRAVERSAL trav;
ABObj obj;
for (trav_open(&trav, root, AB_TRAV_UI);
(obj= trav_next(&trav)) != NULL; )
if (obj->attachments)
objxmP_obj_config_attachments(obj);
trav_close(&trav);
return 0;
}
/*
* Call method for setting object-type specific Resources
* for a Composite Object hierarchy
*/
int
objxmP_comp_set_type_args(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
)
{
XmConfigInfo cfginfo;
if (obj_has_flag(obj, XmConfiguredFlag))
{
cfginfo = objxmP_get_config_info(obj);
if (cfginfo != NULL && cfginfo->set_args != NULL)
return((*cfginfo->set_args)(obj_get_root(obj),ctype));
}
return -1;
}
/*
* Call method for Post-instantiation-handling specific
* to an object-type
*/
int
objxmP_comp_type_post_instantiate(
ABObj obj,
OBJXM_CONFIG_TYPE ctype
)
{
XmConfigInfo cfginfo;
cfginfo = objxmP_get_config_info(obj);
if (cfginfo != NULL && cfginfo->post_instantiate != NULL)
return((*cfginfo->post_instantiate)(obj_get_root(obj), ctype));
return -1;
}
/*
* Convert Attachment fields for an UnConfigured object
* into Attachments appropriate for its XmConfigured
* Composite Object hierarchy
*/
int
objxmP_obj_config_attachments(
ABObj obj
)
{
ABObj parent_obj = obj_get_parent(obj);
if (obj->attachments)
{
config_attachment(obj, parent_obj, AB_CP_NORTH);
config_attachment(obj, parent_obj, AB_CP_WEST);
config_attachment(obj, parent_obj, AB_CP_EAST);
config_attachment(obj, parent_obj, AB_CP_SOUTH);
}
return 0;
}
static int
config_attachment(
ABObj obj,
ABObj parent_obj,
AB_COMPASS_POINT dir
)
{
ABObj attobj;
ABAttachment *attachment;
switch(dir)
{
case AB_CP_NORTH:
attachment = &(obj->attachments->north);
break;
case AB_CP_WEST:
attachment = &(obj->attachments->west);
break;
case AB_CP_EAST:
attachment = &(obj->attachments->east);
break;
case AB_CP_SOUTH:
attachment = &(obj->attachments->south);
break;
}
if (attachment->type == AB_ATTACH_OBJ)
{
attobj = (ABObj)(attachment->value);
if (attobj == obj_get_root(parent_obj))
{
attobj = objxm_comp_get_subobj(attobj, AB_CFG_PARENT_OBJ);
attachment->value = (void*)attobj;
}
}
return OK;
}
/*
* Call method for object-type which retreives the Composite
* Object's SubObj responsible for 'AB_CFG_OBJ_TYPE' (ie. SIZE,
* POSITION, etc)
*/
ABObj
objxm_comp_get_subobj(
ABObj obj,
AB_CFG_OBJ_TYPE type
)
{
XmConfigInfo cfginfo;
ABObj cfgobj = NULL;
if (obj_has_flag(obj, XmConfiguredFlag))
{
cfginfo = objxmP_get_config_info(obj);
if (cfginfo != NULL && cfginfo->get_config_obj != NULL)
cfgobj=
((*cfginfo->get_config_obj)(obj_get_root(obj), type));
}
else if (util_get_verbosity() >= 3)
{
char name[256];
obj_get_safe_name(obj, name, 256);
fprintf(stderr,
catgets(OBJXM_MESSAGE_CATD, OBJXM_MESSAGE_SET, 9,
"ERROR: objxm_comp_get_subobj - object not xmconfigured: %s\n"),
name);
}
return cfgobj;
}
ABObj
objxmP_create_direct_subobj(
ABObj root,
AB_OBJECT_TYPE type,
STRING subname
)
{
ABObj subobj;
subobj = obj_create(type, NULL);
subobj->part_of = root;
/* Move children from root to immediate SubObj */
/* NOTE: obj must NOT have a MenuRef SubObj at this
* point!
*/
if (obj_get_num_children(root) > 0)
obj_move_children(subobj, root);
obj_append_child(root, subobj);
/*
obj_set_name_from_parent(subobj, subname);
*/
obj_set_unique_name(subobj,
ab_ident_from_name_and_label(obj_get_name(root), subname));
return subobj;
}
/*
* If the Obj should have a border-frame, sets the RootObj
* to be a Frame and creates a SubObj directly under the Obj
* to represent the actual Object inside the Frame, and
* returns a handle to the SubObj
* If the Obj does not have a border-frame, return NULL
*/
ABObj
objxm_comp_config_border_frame(
ABObj obj
)
{
ABObj subobj = NULL;
if (obj_has_border_frame(obj))
{
/* Make the RootObj the Frame */
obj->part_of = obj;
obj_set_class_name(obj, _xmFrame);
/* Create a SubObj directly under the Frame */
subobj = objxmP_create_direct_subobj(obj, AB_TYPE_CONTAINER, "obj");
}
return subobj;
}
/*
* If Obj is XmConfigured with a Frame, collapse it
* back down to remove the Frame
*/
int
objxm_comp_unconfig_border_frame(
ABObj obj
)
{
ABObj subobj;
if (obj_has_border_frame(obj))
{
subobj = obj_get_child(obj, 0);
/* If First child is Menu-ref, then SubObj
* should be next child
*/
if (obj_is_menu_ref(subobj))
subobj = obj_get_child(obj, 1);
if (subobj)
{
if (obj_get_num_children(subobj) > 0)
obj_move_children(obj, subobj);
obj_destroy(subobj);
}
else if (util_get_verbosity() > 2)
{
fprintf(stderr,"objxm_comp_unconfig_border_frame: %s : can't find SubObj\n",
util_strsafe(obj_get_name(obj)));
}
}
return 0;
}
int
objxm_comp_config_labeled_obj(
ABObj obj,
AB_OBJECT_TYPE obj_type,
STRING obj_suffix,
STRING obj_classname
)
{
ABObj lbl_obj = NULL;
ABObj real_obj;
if (obj_has_label(obj))
{
obj->part_of = obj;
/* Set Container RootObj class */
obj_set_class_name(obj, _xmRowColumn);
/* Create Label SubObj */
lbl_obj = obj_create(AB_TYPE_LABEL, NULL);
lbl_obj->part_of = obj;
obj_set_unique_name(lbl_obj,
ab_ident_from_name_and_label(obj_get_name(obj), "label"));
obj_set_class_name(lbl_obj, _xmLabel);
/* Create Real *Object* SubObj */
real_obj = obj_create(obj_type, NULL);
real_obj->part_of = obj;
obj_set_unique_name(real_obj,
ab_ident_from_name_and_label(obj_get_name(obj), obj_suffix));
obj_set_class_name(real_obj, obj_classname);
if (obj_get_num_children(obj) > 0)
obj_move_children(real_obj, obj);
obj_append_child(obj, lbl_obj);
obj_append_child(obj, real_obj);
}
else
obj_set_class_name(obj, obj_classname);
return OK;
}
int
objxm_comp_unconfig_labeled_obj(
ABObj obj
)
{
ABObj lbl_obj;
ABObj real_obj;
if (obj_has_label(obj)) /* Has Label */
{
/* Destroy Label & Field SubObjs */
lbl_obj = obj_get_child(obj, 0);
real_obj = obj_get_child(obj, 1);
if (obj_get_num_children(obj) > 0)
obj_move_children(obj, real_obj);
obj_destroy(lbl_obj);
obj_destroy(real_obj);
}
return OK;
}
/*
* If the Obj has a Menu, create a Menu-reference SubObj
* as the FIRST child of the Obj and return a handle to
* the Menu-reference. If Obj has no menu, or the menu
* is not found, return NULL.
*/
ABObj
objxm_comp_config_menu_ref(
ABObj obj
)
{
ABObj menu_obj;
ABObj menu_ref = NULL;
STRING menuname = obj_get_menu_name(obj);
if (menuname != NULL)
{
/* Make sure Virtual Menu obj exists in module */
if ((menu_obj = obj_find_menu_by_name(obj_get_module(obj), menuname)) != NULL)
{
/* ALWAYS make Menu Reference FIRST child! */
menu_ref = obj_create_ref(menu_obj);
obj_insert_child(obj, menu_ref, 0);
/*
REMIND: aim, 9/13/94 - The Menu Ref should not really be a "part of" an object
But, leaving this in (commented out) for now in case change
causes problems
menu_ref->part_of = obj;
*/
/* Menu Reference must point to Virtual menu object */
obj_set_unique_name(menu_ref,
ab_ident_from_name_and_label(obj_get_name(obj), menuname));
/*
** Set the object class of the Menu Reference to be that of the
** virtual menu object to which it refers. This makes it easier
** later on to figure out some of the aspects of handling the Menu
** Reference.
*/
if(obj_is_menubar_item(obj) || obj_is_menu_item(obj)) {
obj_set_class_name(menu_ref, _xmPulldownMenu);
}
else {
obj_set_class_name(menu_ref, _xmPopupMenu);
}
}
}
return menu_ref;
}
/*
* If Obj has a Menu-ref, remove it
*/
int
objxm_comp_unconfig_menu_ref(
ABObj obj
)
{
ABObj menu_ref;
if (obj_has_menu(obj))
{
menu_ref = objxm_comp_get_subobj(obj, AB_CFG_MENU_OBJ);
if (obj_is_ref(menu_ref))
obj_destroy(menu_ref);
}
return 0;
}

View File

@@ -0,0 +1,120 @@
/*
* $XConsortium: objxm_configP.h /main/3 1995/11/06 18:45:23 rswiston $
*
* %W% %G% cde_app_builder/src/libABobjXm
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* abxm_config.h - implements the configuring of an object
* into the appropriate Motif obj hierarchy
*
* An XmConfigured Object consists of a tree of objects which
* matches the required Motif widget hierarchy for that object
* type. For Example, an XmConfigured TextField will look like:
*
* obj (RootObj)
* (XmRowColumn)
* |
* ------------------
* | |
* obj (SubObj) obj (SubObj)
* (XmLabel) (XmTextField)
*
*
*/
#ifndef _ABXM_CONFIG_H_
#define _ABXM_CONFIG_H_
#include <X11/Intrinsic.h>
typedef struct _XM_CONFIG_INFO_REC XmConfigInfoRec;
typedef struct _XM_CONFIG_INFO_REC *XmConfigInfo;
/*
* define types for Xm-Configure object "methods"
*/
typedef int (*XmConfigProc) (
ABObj obj
);
typedef BOOL (*XmConfigIsaFunc) (
ABObj obj
);
typedef ABObj (*XmConfigGetObjProc) (
ABObj obj,
AB_CFG_OBJ_TYPE type
);
/*
* XmConfigInfo Structure - one for each type of object supported
*/
typedef struct _XM_CONFIG_INFO_REC {
/* Methods...*/
XmConfigProc xmconfig; /* configures obj hierarchy */
XmConfigGetObjProc get_config_obj;/* returns config obj */
XmConfigIsaFunc is_a_test; /* "is a" test */
} XM_CONFIG_INFO_REC;
/* Function to initialize XmConfigInfo for all AB object types
*/
extern int abxm_init_obj_config_info(
);
/* Function to register XmConfigInfo for a single object type
*/
extern void abxm_register_config_info(
XmConfigInfo cfginfo
);
/* Function which returns XmConfigInfo ptr for an object
*/
extern XmConfigInfo
abxm_get_config_info(
ABObj obj
);
/* Function which XmConfigures an object
*/
extern int abxm_configure_obj(
ABObj obj
);
/* Function which XmConfigures an entire tree
*/
extern int abxm_configure_tree(
ABObj root
);
/* Function which re-configures attachments after
* objects have been xmconfigured
*/
extern int abxm_configure_attachments(
ABObj obj
);
/* Function which returns the correct Composite SubObj corresponding
* to 'type'.
*/
extern ABObj abxm_get_config_obj(
ABObj obj,
AB_CFG_OBJ_TYPE type
);
#endif /* _ABXM_CONFIG_H_ */

View File

@@ -0,0 +1,572 @@
/*
* $XConsortium: objxm_conn.c /main/4 1995/11/06 18:45:37 rswiston $
*
* @(#)objxm_conn.c 1.23 04 May 1995 cde_app_builder/src/libABobjXm
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* objxm_conn.c - handles connections stuff
*
*/
#include <assert.h>
#include <ab_private/objxm.h>
#include <Dt/SpinBox.h>
#include <Dt/ComboBox.h>
/*************************************************************************
** **
** Private Function Declarations **
** **
**************************************************************************/
static STRING get_resource_for_set_value(ABObj compObj, ABObj obj);
static STRING get_resource_for_set_text(ABObj compObj, ABObj obj);
static STRING get_resource_for_set_label(ABObj compObj, ABObj obj);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
#define ObjWClassIs(obj, class_name) \
(util_streq(obj_get_class_name(obj), class_name))
#define ObjWClassIsApplicationShell(obj) \
(ObjWClassIs((obj), _applicationShell))
#define ObjWClassIsArrowButton(obj) \
(ObjWClassIs((obj), _xmArrowButton))
#define ObjWClassIsBulletinBoard(obj) \
(ObjWClassIs((obj), _xmBulletinBoard))
#define ObjWClassIsCascadeButton(obj) \
(ObjWClassIs((obj), _xmCascadeButton))
#define ObjWClassIsDialogShell(obj) \
(ObjWClassIs((obj), _xmDialogShell))
#define ObjWClassIsDrawingArea(obj) \
(ObjWClassIs((obj), _xmDrawingArea))
#define ObjWClassIsDrawnButton(obj) \
(ObjWClassIs((obj), _xmDrawnButton))
#define ObjWClassIsFileChooserShell(obj) \
(ObjWClassIs((obj), _xmFileSelectionBox))
#define ObjWClassIsForm(obj) \
(ObjWClassIs((obj), _xmForm))
#define ObjWClassIsLabel(obj) \
(ObjWClassIs((obj), _xmLabel))
#define ObjWClassIsList(obj) \
(ObjWClassIs((obj), _xmList))
#define ObjWClassIsMainWindow(obj) \
(ObjWClassIs((obj), _xmMainWindow))
#define ObjWClassIsMenuButton(obj) \
(ObjWClassIs((obj), _dtMenuButton))
#define ObjWClassIsMenuShell(obj) \
(ObjWClassIs((obj), _xmMenuShell))
#define ObjWClassIsPanedWindow(obj) \
(ObjWClassIs((obj), _xmPanedWindow))
#define ObjWClassIsPrimitive(obj) \
(ObjWClassIs((obj), _xmPrimitive))
#define ObjWClassIsPushButton(obj) \
(ObjWClassIs((obj), _xmPushButton))
#define ObjWClassIsRowColumn(obj) \
(ObjWClassIs((obj), _xmRowColumn))
#define ObjWClassIsScrolledWindow(obj) \
(ObjWClassIs((obj), _xmScrolledWindow))
#define ObjWClassIsTextField(obj) \
(ObjWClassIs((obj), _xmTextField))
#define ObjWClassIsText(obj) \
(ObjWClassIs((obj), _xmText))
#define ObjWClassIsToggleButton(obj) \
(ObjWClassIs((obj), _xmToggleButton))
#define ObjWClassIsBaseWinShell(obj) \
(ObjWClassIsApplicationShell(obj))
#define ObjWClassIsScale(obj) \
(ObjWClassIs((obj), _xmScale))
#define ObjWClassIsSpinBox(obj) \
(ObjWClassIs((obj), _dtSpinBox))
/*
* Complex checks
*/
#define ObjWClassIsShell(obj) \
( (ObjWClassIsBaseWinShell(obj)) \
|| (ObjWClassIsDialogShell(obj)) \
|| (ObjWClassIsFileChooserShell(obj)) \
|| (ObjWClassIsMenuShell(obj)) \
)
STRING
objxm_get_resource_for_when(
ABObj obj,
AB_WHEN when
)
{
STRING res= NULL;
/********** GET "DEFAULT" RESOURCE NAME *********/
switch (when)
{
case AB_WHEN_DESTROYED: res= XmNdestroyCallback;
break;
}
/********** GET TYPE-SPECIFIC RESOURCE NAME *********/
switch (obj_get_type(obj))
{
case AB_TYPE_BASE_WINDOW:
switch (when)
{
case AB_WHEN_HIDDEN: res= XmNpopdownCallback;
break;
case AB_WHEN_SHOWN: res= XmNpopupCallback;
break;
}
break;
case AB_TYPE_BUTTON:
switch (when)
{
case AB_WHEN_ACTIVATED: res= XmNactivateCallback;
break;
}
break;
case AB_TYPE_CHOICE:
break;
case AB_TYPE_COMBO_BOX:
if (when == AB_WHEN_ITEM_SELECTED)
res = DtNselectionCallback;
break;
case AB_TYPE_CONTAINER:
break;
case AB_TYPE_DIALOG:
switch (when)
{
case AB_WHEN_HIDDEN: res= XmNpopdownCallback;
break;
case AB_WHEN_SHOWN: res= XmNpopupCallback;
break;
}
break;
case AB_TYPE_DRAWING_AREA:
switch (when)
{
case AB_WHEN_REPAINT_NEEDED: res= XmNexposeCallback;
break;
case AB_WHEN_AFTER_RESIZED: res= XmNresizeCallback;
break;
}
break;
case AB_TYPE_FILE_CHOOSER:
switch (when)
{
case AB_WHEN_OK: res = XmNokCallback;
break;
case AB_WHEN_CANCEL: res = XmNcancelCallback;
break;
case AB_WHEN_HIDDEN: res= XmNpopdownCallback;
break;
case AB_WHEN_SHOWN: res= XmNpopupCallback;
break;
}
break;
case AB_TYPE_ITEM:
switch (obj_get_item_type(obj))
{
case AB_ITEM_FOR_CHOICE:
switch (when)
{
/* For optionmenu items */
case AB_WHEN_ACTIVATED:
if (ObjWClassIsPushButton(obj))
{
res = XmNactivateCallback;
}
break;
/* For checkbox/radiobox items */
case AB_WHEN_TOGGLED:
res = XmNvalueChangedCallback;
break;
}
break;
case AB_ITEM_FOR_LIST:
break;
case AB_ITEM_FOR_MENUBAR:
/*
switch (when)
{
case AB_WHEN_BEFORE_POST_MENU:
res = XmNcascadingCallback;
break;
}
*/
break;
case AB_ITEM_FOR_MENU:
switch (when)
{
case AB_WHEN_ACTIVATED:
res = XmNactivateCallback;
break;
}
break;
}
break;
case AB_TYPE_LABEL:
break;
case AB_TYPE_LAYERS:
break;
case AB_TYPE_LIST:
switch (when)
{
case AB_WHEN_ITEM_SELECTED:
switch (obj_get_selection_mode(obj))
{
case AB_SELECT_SINGLE:
res = XmNsingleSelectionCallback;
break;
case AB_SELECT_BROWSE:
res = XmNbrowseSelectionCallback;
break;
case AB_SELECT_MULTIPLE:
res = XmNmultipleSelectionCallback;
break;
case AB_SELECT_BROWSE_MULTIPLE:
res = XmNextendedSelectionCallback;
break;
}
break;
case AB_WHEN_DOUBLE_CLICKED_ON:
res = XmNdefaultActionCallback;
break;
}
break;
case AB_TYPE_MENU:
switch (when)
{
case AB_WHEN_POPPED_UP: res= XmNpopupCallback;
break;
case AB_WHEN_POPPED_DOWN: res= XmNpopdownCallback;
break;
}
break;
case AB_TYPE_SEPARATOR:
break;
case AB_TYPE_SPIN_BOX:
if (when == AB_WHEN_VALUE_CHANGED)
res = XmNvalueChangedCallback;
break;
case AB_TYPE_SCALE:
switch (when)
{
case AB_WHEN_VALUE_CHANGED: res= XmNvalueChangedCallback;
break;
case AB_WHEN_DRAGGED: res = XmNdragCallback;
break;
}
break;
case AB_TYPE_TERM_PANE:
break;
case AB_TYPE_TEXT_FIELD:
case AB_TYPE_TEXT_PANE:
switch (when)
{
case AB_WHEN_BEFORE_TEXT_CHANGED:
res= XmNmodifyVerifyCallback;
break;
case AB_WHEN_TEXT_CHANGED:
res= XmNvalueChangedCallback;
break;
}
break;
} /* switch obj_get_type() */
return res;
}
/*
* The parameter 'obj' is the actual subobject (probably from
* objxm_comp_get_target_for_builtin_action()) that the resource
* will be set on.
*
*/
STRING
objxm_get_resource_for_builtin_action(
ABObj obj,
AB_BUILTIN_ACTION builtin_action
)
{
ABObj compObj = obj_get_root(obj);
STRING resource = NULL;
switch (builtin_action)
{
case AB_STDACT_DISABLE:
case AB_STDACT_ENABLE:
resource = XmNsensitive;
break;
case AB_STDACT_HIDE:
case AB_STDACT_SHOW:
/* This is not handled through a resource directly, but through
* a convenience function. So, this case isn't really necessary, but
* is here for completeness.
*/
resource = XmNmappedWhenManaged;
break;
case AB_STDACT_SET_LABEL:
resource = get_resource_for_set_label(compObj, obj);
break;
case AB_STDACT_SET_TEXT:
resource = get_resource_for_set_text(compObj, obj);
break;
case AB_STDACT_SET_VALUE:
resource = get_resource_for_set_value(compObj, obj);
break;
}
return resource;
}
ABObj
objxm_comp_get_source_for_when(ABObj subObj, AB_WHEN when)
{
ABObj source = NULL;
ABObj compObj = obj_get_root(subObj);
switch (when)
{
case AB_WHEN_POPPED_UP:
case AB_WHEN_POPPED_DOWN:
/* If this object is an optionmenu or a menu
* we need to get a handle for the pulldown
* menu, so that we can add a callback to
* its menuShell.
*/
/*
if (obj_is_option_menu(compObj))
{
source = objxm_comp_get_subobj(compObj, AB_CFG_PARENT_OBJ);
}
else if (obj_is_menu_ref(subObj))
{
source = subObj;
}
*/
if (obj_is_menu_ref(subObj))
{
source = subObj;
}
break;
default:
source = objxm_comp_get_subobj(compObj, AB_CFG_OBJECT_OBJ);
}
return source;
}
ABObj
objxm_comp_get_target_for_builtin_action(ABObj subObj, AB_BUILTIN_ACTION action)
{
ABObj compObj = obj_get_root(subObj);
ABObj actualTarget = NULL;
BOOL useObjectObj = FALSE;
/*
* Adjust the actual "to" object
*/
switch (action)
{
case AB_STDACT_ENABLE:
case AB_STDACT_DISABLE:
actualTarget = compObj;
break;
case AB_STDACT_HIDE:
case AB_STDACT_SHOW:
if (obj_is_popup_win(compObj))
{
actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_WINDOW_BB_OBJ);
}
else if (obj_is_base_win(compObj))
{
actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_OBJECT_OBJ);
}
else if (obj_is_file_chooser(compObj))
{
actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_OBJECT_OBJ);
}
else
{
actualTarget = compObj;
}
break;
case AB_STDACT_SET_LABEL:
actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_LABEL_OBJ);
break;
default:
useObjectObj = TRUE;
break;
}
if (actualTarget == NULL)
{
if (useObjectObj)
{
actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_OBJECT_OBJ);
}
}
return actualTarget;
}
/*
* the set-label connections we support:
*
* button
* choice
* combobox
* label
* scale
* spinbox
* textfield
* item (choice, menu, menubar)
*/
static STRING
get_resource_for_set_label(ABObj compObj, ABObj obj)
{
STRING resource = NULL;
assert(!ObjWClassIsArrowButton(obj)); /* not supported */
if (ObjWClassIsShell(obj))
{
resource = XmNtitleString;
}
else if ( ObjWClassIsCascadeButton(obj)
|| ObjWClassIsDrawnButton(obj)
|| ObjWClassIsMenuButton(obj)
|| ObjWClassIsPushButton(obj)
|| ObjWClassIsToggleButton(obj)
|| ObjWClassIsLabel(obj) )
{
if (obj_get_label_type(compObj) == AB_LABEL_GLYPH)
{
resource = XmNlabelPixmap;
}
else
{
resource = XmNlabelString;
}
}
return resource;
}
static STRING
get_resource_for_set_text(ABObj compObj, ABObj obj)
{
STRING resource = NULL;
compObj = compObj; /* avoid warning */
if (ObjWClassIsSpinBox(obj))
{
resource = DtNposition;
}
else
{
resource = XmNvalue;
}
return resource;
}
static STRING
get_resource_for_set_value(ABObj compObj, ABObj obj)
{
STRING resource = NULL;
compObj = compObj; /* avoid warning */
if (ObjWClassIsScale(obj))
resource = XmNvalue;
else if (ObjWClassIsSpinBox(obj))
resource = DtNposition;
return resource;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
/*
* $XConsortium: objxm_names.h /main/3 1995/11/06 18:46:37 rswiston $
*
* @(#)objxm_names.h 1.11 17 May 1994 cde_app_builder/src/libABobjXm
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* objxm_names.h - motif defines and stuff
*/
#ifndef _OBJXM_NAMES_H_
#define _OBJXM_NAMES_H_
#include <Xm/Xm.h>
/*************************************************************************
** **
** Automatically generated widgets **
** **
*************************************************************************/
#define AB_WRAP_TOP_LEVEL "AB_Toplevel"
#define AB_WRAP_SCR_WIN "AB_Scr_Win"
#define AB_WRAP_FOOTER "AB_Footer"
#define AB_WRAP_FOOTER_CH "AB_Footer_ch"
#define AB_WRAP_RUBBER "AB_Rubber"
#define AB_WRAP_ABBREV "AB_Abbrev"
#define AB_WRAP_LABEL "AB_Label"
#define AB_WRAP_MAIN_WINDOW "AB_Mainwin"
#define AB_WRAP_MENU_BAR "AB_Menubar"
#define AB_WRAP_TEXT "AB_Text"
#define AB_WRAP_EXCL "AB_Excl"
#define AB_WRAP_NONEXCL "AB_Nonexcl"
#define AB_WRAP_NUMERIC_FLD "AB_Numfield"
#define AB_WRAP_CTL_AREA "AB_Ctlarea"
#define AB_WRAP_BULLETIN "AB_Bulletin"
#define AB_WRAP_PULLDOWN "AB_Pulldown"
#define AB_WRAP_ROWCOL "AB_Rowcol"
/*************************************************************************
** **
** Class Names **
** **
*************************************************************************/
char * const _applicationShell = "applicationShellWidgetClass";
char * const _dtComboBox = "dtComboBoxWidgetClass";
char * const _dtMenuButton = "dtMenuButtonWidgetClass";
char * const _dtSpinBox = "dtSpinBoxWidgetClass";
char * const _dtTerm = "dtTermWidgetClass";
char * const _group = "groupWidgetClass";
/* char * const _topLevelShell = "topLevelShellWidgetClass"; */
char * const _xmArrowButton = "xmArrowButtonWidgetClass";
char * const _xmBulletinBoard = "xmBulletinBoardWidgetClass";
char * const _xmCascadeButton = "xmCascadeButtonWidgetClass";
char * const _xmCommand = "xmCommandWidgetClass";
char * const _xmDialogShell = "xmDialogShellWidgetClass";
char * const _xmDrawingArea = "xmDrawingAreaWidgetClass";
char * const _xmDrawnButton = "xmDrawnButtonWidgetClass";
char * const _xmFileSelectionBox = "xmFileSelectionBoxWidgetClass";
char * const _xmForm = "xmFormWidgetClass";
char * const _xmFrame = "xmFrameWidgetClass";
char * const _xmLabel = "xmLabelWidgetClass";
char * const _xmLabelGadget = "xmLabelGadgetWidgetClass";
char * const _xmList = "xmListWidgetClass";
char * const _xmMainWindow = "xmMainWindowWidgetClass";
char * const _xmManager = "xmManagerWidgetClass";
char * const _xmMenuShell = "xmMenuShellWidgetClass";
char * const _xmMessageBox = "xmMessageBoxWidgetClass";
char * const _xmPanedWindow = "xmPanedWindowWidgetClass";
char * const _xmPopupMenu = "xmPopupMenuPsuedoClass";
char * const _xmPrimitive = "xmPrimitiveWidgetClass";
char * const _xmPulldownMenu = "xmPulldownMenuPsuedoClass";
char * const _xmPushButton = "xmPushButtonWidgetClass";
char * const _xmRowColumn = "xmRowColumnWidgetClass";
char * const _xmScale = "xmScaleWidgetClass";
char * const _xmScrollBar = "xmScrollBarWidgetClass";
char * const _xmScrolledList = "xmScrolledListPsuedoClass";
char * const _xmScrolledWindow ="xmScrolledWindowWidgetClass";
char * const _xmSelectionBox = "xmSelectionBoxWidgetClass";
char * const _xmSeparator = "xmSeparatorWidgetClass";
char * const _xmSeparatorGadget="xmSeparatorGadgetWidgetClass";
char * const _xmText = "xmTextWidgetClass";
char * const _xmTextField = "xmTextFieldWidgetClass";
char * const _xmToggleButton = "xmToggleButtonWidgetClass";
char * const _xmToggleButtonGadget = "xmToggleButtonGadgetWidgetClass";
#endif /* _OBJXM_NAMES_H_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,595 @@
/*
* $XConsortium: objxm_util.c /main/4 1995/11/06 18:47:59 rswiston $
*
* @(#)objxm_util.c 1.23 15 Feb 1994 cde_app_builder/src/libABobjXm
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
***********************************************************************
* objxm_util.c - general Motif utility routines
*
*
***********************************************************************
*/
#include <stdio.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/MenuShell.h>
#include <Dt/xpm.h>
#include <ab_private/obj.h>
#include <ab_private/trav.h>
#include "objxmP.h"
#define BUF_SIZE 512
#define LG_BUF_SIZE 1024
/*
* Public symbols
*/
ObjxmFilenameToPixmapFunc ObjxmP_filename_to_pixmap_cb = NULL;
/*
* Post instantiate func, which can be registered via
*/
ObjxmPostInstantiateFunc ObjxmP_post_instantiate_cb = NULL;
/*************************************************************************
** **
** Private Function Declarations **
** **
*************************************************************************/
static int indent(
FILE *file, int spaces
);
static int convert_filebase_to_pixmap(
Widget widget,
STRING filebase,
Pixmap *pixmap_p
);
static int convert_file_to_pixmap(
Widget widget,
STRING filename,
Pixmap *pixmap_p
);
static int load_pixmap(
Widget widget,
STRING filebase,
STRING ext,
Pixmap *pixmap_p
);
/*************************************************************************
** **
** Function Definitions **
** **
*************************************************************************/
/*
* Hook to add routine to convert filenames to callbacks.
* NULL callback reinstates default conversion method.
*/
extern int
objxm_set_cvt_filename_to_pixmap_callback(
ObjxmFilenameToPixmapFunc filename_to_pixmap_cb
)
{
ObjxmP_filename_to_pixmap_cb = filename_to_pixmap_cb;
return 0;
}
/*
* Hook to add post instantiate routine
* NULL callback reinstates default conversion method.
*/
extern int
objxm_set_post_instantiate_callback(
ObjxmPostInstantiateFunc post_instantiate_cb
)
{
ObjxmP_post_instantiate_cb = post_instantiate_cb;
return 0;
}
/*
* Determine if a color name exists in the rgb database
*/
BOOL
objxm_color_exists(
String colorname
)
{
static Colormap colormap = NULL;
static Display *display = NULL;
XColor color;
XColor exact_color;
if (display == NULL) /* dtbuilder doesn't handle multiple displays */
{
display = XtDisplay(ObjxmP_toplevel);
colormap = XDefaultColormap(display, XDefaultScreen(display));
}
return(XLookupColor(display, colormap, colorname, &exact_color, &color));
}
/*
* Use the Xt Resource converter to convert a colorname to a pixel.
* This has the advantage of caching the value and automatically
* taking care to Free the pixel when the associated widget is
* destroyed.
*/
int
objxm_name_to_pixel(
Widget widget,
String colorname,
Pixel *pixel_p
)
{
XrmValue src, dst;
src.size = strlen(colorname) + 1;
src.addr = (XPointer)colorname;
dst.size = sizeof(Pixel);
dst.addr = (XPointer)pixel_p;
if (XtConvertAndStore(widget, XtRString, &src, XtRPixel, &dst))
return OK;
else
return ERR;
}
int
objxm_filebase_to_pixmap(
Widget widget,
STRING filebase,
Pixmap *pixmap_p
)
{
int status = 0; /* return code */
if (util_strempty(filebase))
return ERR_BAD_PARAM2;
*pixmap_p = NULL;
/* Use Pixmap conversion callback if it exists */
if (ObjxmP_filename_to_pixmap_cb != NULL)
{
return(ObjxmP_filename_to_pixmap_cb(widget, filebase, pixmap_p));
}
else /* Use internal conversion routine */
return (convert_filebase_to_pixmap(widget, filebase, pixmap_p));
}
STRING
objxm_pixmap_conversion_error_msg(
ABObj obj,
STRING filebase,
int status
)
{
char static buf[LG_BUF_SIZE];
char buf2[BUF_SIZE];
char file_buf[BUF_SIZE];
if (obj != NULL)
sprintf(buf, catgets(OBJXM_MESSAGE_CATD, 203, 14,
"Warning: %s :\n"), util_strsafe(obj_get_name(obj)));
else
strcpy(buf, "");
sprintf(buf2, catgets(OBJXM_MESSAGE_CATD, 203, 15,
"Graphic File base '%s'\ncould not be converted to a Pixmap because\n"), filebase);
strcat(buf, buf2);
if (status == ERR_BAD_PARAM2)
strcat(buf, catgets(OBJXM_MESSAGE_CATD, 203, 16,
"File base is an empty string."));
else
{
strcat(buf, catgets(OBJXM_MESSAGE_CATD, 203, 17,
"None of the following files could be converted to a Pixmap:\n"));
if ((int)(strlen(buf) + (4 * (strlen(filebase) + 4))) > LG_BUF_SIZE)
strcat(buf, catgets(OBJXM_MESSAGE_CATD, 203, 18,
"filenames too long to display\n"));
else
{
sprintf(file_buf,"%s.pm\n%s.xpm\n%s.bm\n%s.xbm\n",
filebase, filebase, filebase, filebase);
strcat(buf, file_buf);
}
}
util_set_help_data(catgets(OBJXM_MESSAGE_CATD, 203, 20,
"The graphic file name specified could not be converted\ninto a pixmap. App Builder searches for a file of the\nform Filename.pm, Filename.xpm, Filename.bm, and\nFilename.xbm.\n\nEither none of those files exists in the directory specified\n(via the Graphic Filename field or if no path was specified,\nthen the current working directory), or a file exists but may\nbe corrupt."), NULL, NULL);
return(buf);
}
/*
* Given the 'base' graphic filename, attempt to load in an appropriate
* Pixmap with the following rules:
* If display is color (depth > 1), try loading the following filenames
* in sequence until 1 succeeds:
* base.pm, base.xpm (XPM), base.bm, base.xbm (Bitmap)
*
* If display is monochrome, try loading in the following sequence
* until 1 succeeds:
* base.bm, base.xbm (Bitmap), base.pm, base.xpm (XPM)
*
*/
static int
convert_filebase_to_pixmap(
Widget widget,
STRING filebase,
Pixmap *pixmap_p
)
{
int status;
if (ObjxmP_visual_depth > 1) /* Color - Try XPM First */
{
if ((status = load_pixmap(widget, filebase, ".pm", pixmap_p)) != OK)
if ((status = load_pixmap(widget, filebase, ".xpm", pixmap_p)) != OK)
if ((status = load_pixmap(widget, filebase, ".bm", pixmap_p)) != OK)
status = load_pixmap(widget, filebase, ".xbm", pixmap_p);
}
else /* Monochrome - Try Bitmap First */
{
if ((status = load_pixmap(widget, filebase, ".bm", pixmap_p)) != OK)
if ((status = load_pixmap(widget, filebase, ".xbm", pixmap_p)) != OK)
if ((status = load_pixmap(widget, filebase, ".pm", pixmap_p)) != OK)
status = load_pixmap(widget, filebase, ".xpm", pixmap_p);
}
return status;
}
/*
* Attempt to dynamically read a bitmap file and load it into a Pixmap
*/
static int
convert_file_to_pixmap(
Widget widget,
STRING filename,
Pixmap *pixmap_p
)
{
int rc = 0; /* return code */
Screen *screen = NULL;
Pixel fgPixel = 0;
Pixel bgPixel = 0;
*pixmap_p = NULL;
/*
* Get default values
*/
screen = XtScreen(widget);
fgPixel = WhitePixelOfScreen(screen);
bgPixel = BlackPixelOfScreen(screen);
/*
* Get proper colors for widget
*/
XtVaGetValues(widget,
XmNforeground, &fgPixel,
XmNbackground, &bgPixel,
NULL);
/*
* In CDE, XmGetPixmap handles .xpm files, as well.
*/
*pixmap_p = XmGetPixmap(screen, filename, fgPixel, bgPixel);
if ((*pixmap_p == NULL) || (*pixmap_p == XmUNSPECIFIED_PIXMAP))
{
return -1;
}
return 0;
}
static int
load_pixmap(
Widget widget,
STRING filebase,
STRING ext,
Pixmap *pixmap_p
)
{
char filename[BUF_SIZE];
int status;
if ((int)(strlen(filebase) + strlen(ext) + 1) > BUF_SIZE)
return ERR;
strcpy(filename, filebase);
strcat(filename, ext);
return(status = convert_file_to_pixmap(widget, filename, pixmap_p));
}
XFontStruct *
objxm_fontlist_to_font(
XmFontList fontlist
)
{
XmFontContext context;
XFontStruct *font;
XmStringCharSet charset;
if (!fontlist)
return NULL;
XmFontListInitFontContext(&context, fontlist);
if (XmFontListGetNextFont(context, &charset, &font))
{
XmFontListFreeFontContext(context);
XtFree(charset);
return(font);
}
else if (util_get_verbosity() > 0)
{
util_puts_err("objxm_fontlist_to_font: could not convert fontlist\n");
}
XmFontListFreeFontContext(context);
return NULL;
}
XmString
objxm_str_to_xmstr(
Widget widget,
String string
)
{
XrmValue src, dst;
XmString xmstr;
if (util_strempty(string))
return((XmString)NULL);
src.size = strlen(string) + 1;
src.addr = (XPointer)string;
dst.size = sizeof(XmString);
dst.addr = (XPointer)&xmstr;
if (XtConvertAndStore(widget, XtRString, &src, XmRXmString, &dst))
return(xmstr);
else
return((XmString)NULL);
}
STRING
objxm_xmstr_to_str(
XmString xmstr
)
{
XmStringContext context;
XmStringCharSet char_set_tag;
XmStringDirection dir;
Boolean sep;
Boolean status = FALSE;
char buf[MAXPATHLEN], *seg, *p;
p = buf;
if (XmStringInitContext(&context, xmstr))
{
while(XmStringGetNextSegment(context, &seg,
&char_set_tag, &dir, &sep))
{
p += (strlen(strcpy(p, seg)));
if (sep == TRUE)
{
*p++ = '\n';
*p = '\0';
}
XtFree(seg);
}
XmStringFreeContext(context);
return((STRING)XtNewString(buf));
}
if (util_get_verbosity() > 0)
{
util_puts_err("objxm_xmstr_to_str: could not convert xmstring\n");
}
return NULL;
}
/*
* Given an Accelerator String (translation Table syntax), return
* the string that should be displayed inside the item containing the
* accelerator
*/
String
objxm_accel_to_acceltext(
String accelstr
)
{
char buf[128];
static char acceltext[128];
char *p;
if (util_strempty(accelstr))
return NULL;
strcpy(buf, accelstr);
p = strtok(buf, "<");
if (p != NULL)
{
strcpy(acceltext, p);
while(p != NULL)
{
/* Replace any "<..>" with "+" */
p = strtok(NULL, ">");
if (p != NULL)
{
strcat(acceltext,"+");
p = strtok(NULL, "<");
if (p != NULL)
strcat(acceltext, p);
}
}
}
return acceltext;
}
unsigned char
objxm_linestyle_to_enum(
AB_LINE_TYPE linestyle
)
{
unsigned char value;
switch(linestyle)
{
case AB_LINE_SINGLE_LINE:
value = XmSINGLE_LINE;
break;
case AB_LINE_DOUBLE_LINE:
value = XmDOUBLE_LINE;
break;
case AB_LINE_SINGLE_DASHED_LINE:
value = XmSINGLE_DASHED_LINE;
break;
case AB_LINE_DOUBLE_DASHED_LINE:
value = XmDOUBLE_DASHED_LINE;
break;
case AB_LINE_NONE:
value = XmNO_LINE;
break;
case AB_LINE_ETCHED_IN:
value = XmSHADOW_ETCHED_IN;
break;
case AB_LINE_ETCHED_OUT:
value = XmSHADOW_ETCHED_OUT;
break;
case AB_LINE_ETCHED_IN_DASH:
value = XmSHADOW_ETCHED_IN_DASH;
break;
case AB_LINE_ETCHED_OUT_DASH:
value = XmSHADOW_ETCHED_OUT_DASH;
break;
default:
return (unsigned char)-1;
}
return value;
}
BOOL
objxm_is_menu_widget(
Widget widget
)
{
/* If MenuShell OR MenuPane, return TRUE..*/
if (XtIsSubclass(widget, xmMenuShellWidgetClass) ||
XtIsSubclass(XtParent(widget), xmMenuShellWidgetClass))
return TRUE;
return FALSE;
}
/*
***********************************************************************
*
* Debugging routines
*
***********************************************************************
*/
int
objxm_print(ABObj obj)
{
return objxm_print_indented(obj, 0, util_get_verbosity());
}
int
objxm_print_indented(ABObj obj, int spaces, int verbosity)
{
obj_print_indented(obj, spaces, verbosity);
if (verbosity >= 4)
{
ArgList args= objxm_obj_get_ui_args(obj);
int num_args= objxm_get_num_args(args);
objxm_dump_arglist_indented(obj, args, num_args, spaces);
util_dprintf(0, "\n");
}
return 0;
}
int
objxm_tree_print(ABObj obj)
{
objxm_tree_print_indented(obj, 0, util_get_verbosity());
util_dprintf(0,"\n");
return 0;
}
int
objxm_tree_print_indented(ABObj obj, int spaces, int verbosity)
{
AB_TRAVERSAL trav;
ABObj child = NULL;
objxm_print_indented(obj, spaces, verbosity);
for (trav_open(&trav, obj, AB_TRAV_CHILDREN);
(child= trav_next(&trav)) != NULL; )
{
objxm_tree_print_indented(child, spaces+4, verbosity);
}
trav_close(&trav);
return 0;
}
static int
indent (FILE *file, int spaces)
{
int i= 0;
for (i= 0; i < spaces; ++i)
{
fputc(' ', file);
}
return 0;
}

View File

@@ -0,0 +1,74 @@
/*
* $XConsortium: template.c /main/4 1995/11/06 18:48:12 rswiston $
*
* %W% %G% cde_app_builder/src/libABobjXm
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
/*
* template .c file
*
*/
#include "template.h"
#define FOO_DEFINES "here"
const char *foo_consts = "also here";
/*************************************************************************
** **
** Private Function Declarations **
** **
**************************************************************************/
static int foo(
int foo_int,
char *foo_char,
);
/*************************************************************************
** **
** Data **
** **
**************************************************************************/
extern int extern_foo;
static int private_foo;
/*************************************************************************
** **
** Function Definitions **
** **
**************************************************************************/
int
ab_foo(
char *foo_char
)
{
}
static int
foo(
int foo_int,
char *foo_char
)
{
}

View File

@@ -0,0 +1,32 @@
/*
* $XConsortium: template.h /main/3 1995/11/06 18:48:24 rswiston $
*
* @(#)template.h 1.1 03 Feb 1994 cde_app_builder/src/libABobjXm
*
* RESTRICTED CONFIDENTIAL INFORMATION:
*
* The information in this document is subject to special
* restrictions in a confidential disclosure agreement between
* HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
* document outside HP, IBM, Sun, USL, SCO, or Univel without
* Sun's specific written approval. This document and all copies
* and derivative works thereof must be returned or destroyed at
* Sun's request.
*
* Copyright 1993 Sun Microsystems, Inc. All rights reserved.
*
*/
#ifndef _ABOBJXM_TEMPLATE_H_
#define _ABOBJXM_TEMPLATE_H_
/*
* Template.h - template header file
*/
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE 1 /* we want to be POSIX-compliant */
#endif
#endif /* _ABOBJXM_TEMPLATE_H_ */