2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: objxm.h /main/3 1995/11/06 18:43:58 rswiston $
26 * @(#)objxm.h 1.73 24 Apr 1995
28 * RESTRICTED CONFIDENTIAL INFORMATION:
30 * The information in this document is subject to special
31 * restrictions in a confidential disclosure agreement between
32 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
33 * document outside HP, IBM, Sun, USL, SCO, or Univel without
34 * Sun's specific written approval. This document and all copies
35 * and derivative works thereof must be returned or destroyed at
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
43 * objxm.h - Handle Motif-specific mechanism for obj structure
49 #include <X11/Intrinsic.h>
51 #include <ab_private/obj.h>
52 #include <ab_private/istr.h>
56 * Define Flags for Color Args
58 #define ObjxmNone 0x00
59 #define ObjxmForeground 0x01
60 #define ObjxmBackground 0x02
63 * OBJXM Configuration Types
64 * The difference between the 2 types of XmConfiguring is in
65 * how the Obj's Resource ArgLists are constructed:
67 * For Build-mode, resource values are converted to the
68 * correct 'type' for a real "SetValues" or "Create" call.
69 * (e.g. For XmNbackground, the value is converted to a Pixel)
71 * For Codegen-mode, resource values are converted to what
72 * should be *written-out* in code.
73 * (e.g. For XmNbackground, the value is the color-name string,
81 OBJXM_CONFIG_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
82 /* ANSI: no comma after last enum item! */
86 * Type of "objects" in an XmConfigured hierarchy
90 /* Required by all XmConfigured objs */
92 AB_CFG_OBJECT_OBJ, /* Object SubObj */
93 AB_CFG_LABEL_OBJ, /* Label SubObj */
94 AB_CFG_SIZE_OBJ, /* SubObj responsible for Sizing */
95 AB_CFG_POSITION_OBJ, /* SubObj responsible for Positioning*/
96 AB_CFG_PARENT_OBJ, /* SubObj for parenting children */
97 AB_CFG_SELECT_OBJ, /* SubObj for displaying Select feedback */
99 /* Optional for XmConfigured objs */
100 AB_CFG_BORDER_OBJ, /* SubObj for displaying border */
101 AB_CFG_DND_OBJ, /* drag from/drop on this object */
102 AB_CFG_HELP_OBJ, /* where we attach help */
103 AB_CFG_STATUS_OBJ, /* SubObj for status display */
104 AB_CFG_MENU_PARENT_OBJ, /* SubObj for parenting menus */
105 AB_CFG_SCROLLBAR_OBJ, /* Scrollbar SubObj */
106 AB_CFG_SCROLLING_OBJ, /* Scrolling container SubObj */
107 AB_CFG_MENU_OBJ, /* Menu (reference) SubObj */
108 AB_CFG_WINDOW_BB_OBJ, /* Dialog internal BulletinBoard SubObj */
109 AB_CFG_WINDOW_PW_OBJ, /* Window internal PanedWindow SubObj */
110 AB_CFG_WINDOW_MW_OBJ, /* Window internal MainWindow SubObj */
111 AB_CFG_OBJ_TYPE_NUM_VALUES /* number of valid values - MUST BE LAST */
115 typedef int ObjxmFilenameToPixmapFuncRec(
120 typedef ObjxmFilenameToPixmapFuncRec *ObjxmFilenameToPixmapFunc;
122 typedef int ObjxmPostInstantiateFuncRec(
125 typedef ObjxmPostInstantiateFuncRec *ObjxmPostInstantiateFunc;
128 * define types for Xm-Configure object "methods"
130 typedef int (*XmConfigProc) (
134 typedef int (*XmUnconfigProc) (
138 typedef BOOL (*XmConfigIsaFunc) (
142 typedef int (*XmConfigSetArgProc) (
144 OBJXM_CONFIG_TYPE ctype
147 typedef int (*XmConfigPostInstProc) (
149 OBJXM_CONFIG_TYPE ctype
152 typedef ABObj (*XmConfigGetObjProc) (
158 * XmConfigInfo Structure - one for each type of object supported
160 typedef struct _XM_CONFIG_INFO_REC {
162 XmConfigProc xmconfig; /* configures obj hierarchy */
163 XmUnconfigProc xmunconfig; /* unconfigures obj */
164 XmConfigGetObjProc get_config_obj;/* returns config obj */
165 XmConfigSetArgProc set_args; /* sets appropriate resources */
166 XmConfigPostInstProc post_instantiate; /* does any post-instantiation stuff*/
167 XmConfigIsaFunc is_a_test; /* "is a" test */
168 } XM_CONFIG_INFO_REC, XmConfigInfoRec, *XmConfigInfo;
171 * Xm String Cache Data structures & defines
174 * ABXm XmCreateFunc structure
176 typedef Widget (*XmCreateFunc) (
186 extern char * const _applicationShell;
187 extern char * const _dtComboBox;
188 extern char * const _dtMenuButton;
189 extern char * const _dtSpinBox;
190 extern char * const _dtTerm;
191 extern char * const _group;
192 extern char * const _topLevelShell;
193 extern char * const _xmArrowButton;
194 extern char * const _xmBulletinBoard;
195 extern char * const _xmCascadeButton;
196 extern char * const _xmCommand;
197 extern char * const _xmDialogShell;
198 extern char * const _xmDrawingArea;
199 extern char * const _xmDrawnButton;
200 extern char * const _xmFileSelectionBox;
201 extern char * const _xmForm;
202 extern char * const _xmFrame;
203 extern char * const _xmLabel;
204 extern char * const _xmLabelGadget;
205 extern char * const _xmList;
206 extern char * const _xmMainWindow;
207 extern char * const _xmManager;
208 extern char * const _xmMenuShell;
209 extern char * const _xmMessageBox;
210 extern char * const _xmPanedWindow;
211 extern char * const _xmPopupMenu;
212 extern char * const _xmPrimitive;
213 extern char * const _xmPulldownMenu;
214 extern char * const _xmPushButton;
215 extern char * const _xmRowColumn;
216 extern char * const _xmScale;
217 extern char * const _xmScrollBar;
218 extern char * const _xmScrolledList;
219 extern char * const _xmScrolledWindow;
220 extern char * const _xmSelectionBox;
221 extern char * const _xmSeparator;
222 extern char * const _xmSeparatorGadget;
223 extern char * const _xmText;
224 extern char * const _xmTextField;
225 extern char * const _xmToggleButton;
226 extern char * const _xmToggleButtonGadget;
229 * XmConfigure Routines
231 /* Function to initialize objxm
233 extern int objxm_init(
239 * Hook to add routine to convert filenames to callbacks.
240 * NULL callback reinstates default conversion method.
242 extern int objxm_set_cvt_filename_to_pixmap_callback(
243 ObjxmFilenameToPixmapFunc filename_to_pixmap_cb
247 * Hook to add routine to do additional post instantiate
249 * by default, this callback is NULL, so nothing is called
251 extern int objxm_set_post_instantiate_callback(
252 ObjxmPostInstantiateFunc post_instantiate_cb
256 /* Function to register XmConfigInfo
257 * for a single object type
259 extern void objxm_register_config_info(
263 /* Function which XmConfigures an object
264 * into it's appropriate Composite object
267 extern int objxm_obj_configure(
269 OBJXM_CONFIG_TYPE ctype,
273 /* Function which XmConfigures an entire tree
275 extern int objxm_tree_configure(
277 OBJXM_CONFIG_TYPE ctype
280 /* Function which UnConfigures an object
281 * NOTE: does NOT destroy associated widgets!
283 extern int objxm_obj_unconfigure(
287 /* Function which UnConfigures an entire tree
288 * NOTE: does NOT destroy associated widgets!
290 extern int objxm_tree_unconfigure(
294 /* Function which returns the correct
295 * Composite SubObj corresponding to 'type'
297 extern ABObj objxm_comp_get_subobj(
302 /* Function which configures an object with the
303 * the standard labeled-structure (container
304 * managing Label & Main-object)
306 extern int objxm_comp_config_labeled_obj(
308 AB_OBJECT_TYPE obj_type,
313 /* Function which collapses a labeled object
314 * back down into a single Main-object
316 extern int objxm_comp_unconfig_labeled_obj(
320 /* Function which builds a Menu-reference object
321 * if "menu_name" is non-NULL
323 extern ABObj objxm_comp_config_menu_ref(
327 /* Function which finds & destroys a Menu-reference
328 * object if one exists
330 extern int objxm_comp_unconfig_menu_ref(
334 /* Function which makes the RootObj a "Frame" and
335 * creates a new SubObj directly underneath to
336 * represent the actual Obj.
338 extern ABObj objxm_comp_config_border_frame(
342 /* Function that collapses a Composite Obj configured
343 * with a Frame as the Root, back down to an Obj
346 extern int objxm_comp_unconfig_border_frame(
351 * Xm Instantiation/Change/Destruction routines
353 /* Instantiate widgets for an entire tree
354 * NOTE: for instantiating large trees at once
355 * (like loading BIL or UIL, set "manage_last" to
356 * TRUE! (if instantiating a single object or small
357 * group of objects, set it to FALSE).
359 extern int objxm_tree_instantiate(
364 /* Destroy Widgets in a tree and set ui_handles=NULL
365 * NOTE: this does NOT destroy the Objs
367 extern int objxm_tree_uninstantiate(
372 /* Destroy Widgets AND Objs for an entire tree
374 extern int objxm_tree_destroy(
378 /* Instantiate any changes made to the
380 * Return whether or not New widgets were
381 * created as a result of the changes
383 extern int objxm_comp_instantiate_changes(
387 extern int objxm_tree_instantiate_changes(
392 extern int objxm_comp_set_item_selection(
397 * Routines to Temporarily Instantiate/Destroy Menus
399 extern int objxm_instantiate_menus(
403 extern int objxm_destroy_menus(
407 extern int objxm_create_popup_menu_title(
409 OBJXM_CONFIG_TYPE ctype,
414 * Routines to Store default Translations & Obj pointer
415 * inside widget's userData
417 extern int objxm_store_obj_and_actions(
422 extern int objxm_free_obj_and_actions(
426 extern ABObj objxm_get_obj_from_widget(
430 extern XtTranslations
431 objxm_get_actions_from_widget(
436 * Xm Map/Unmap routine
438 extern int objxm_tree_map(
444 * Object-specific methods
446 extern ABObj objxm_comp_mainwin_get_area(
448 AB_CONTAINER_TYPE area_type
451 extern ABObj objxm_comp_custdlg_get_area(
453 AB_CONTAINER_TYPE area_type
457 * Xm Resource-setting routines
460 /* Set Xm resource lists for entire tree
462 extern int objxm_tree_set_ui_args(
464 OBJXM_CONFIG_TYPE ctype,
468 /* Remove Xm resource lists for entire tree */
469 extern int objxm_tree_remove_ui_args(
471 OBJXM_CONFIG_TYPE ctype
474 /* Set Xm resource list for a Composite object
477 extern int objxm_comp_set_ui_args(
479 OBJXM_CONFIG_TYPE ctype,
482 /* Set Xm resources that can only be set AFTER
483 * ALL WIDGETS have been instantiated
485 extern int objxm_tree_set_post_inst_args(
487 OBJXM_CONFIG_TYPE ctype
489 extern int objxm_obj_set_post_inst_args(
491 OBJXM_CONFIG_TYPE ctype
494 /* Set Xm resource list corresponding to
495 * attachment properties for a Composite object
498 extern int objxm_comp_set_attachment_args(
500 OBJXM_CONFIG_TYPE ctype
503 /* Set Xm resource list corresponding to
504 * attachment properties for a single object
506 extern int objxm_obj_set_attachment_args(
508 OBJXM_CONFIG_TYPE ctype
511 /* Set Xm resource list corresponding to
512 * color properties for a Composite object
515 extern int objxm_comp_set_color_args(
517 OBJXM_CONFIG_TYPE ctype,
521 /* Set Xm resources for "default button" within a
522 * dialog's button-panel
524 extern int objxm_comp_set_default_button_args(
526 OBJXM_CONFIG_TYPE ctype
529 /* Set the Label type/value resources
530 * for a Composite object hierarchy
532 extern int objxm_comp_set_label_args(
534 OBJXM_CONFIG_TYPE ctype
537 /* Set Xm resource list corresponding to
538 * label alignment properties for a
539 * Composite object hierarchy
541 extern int objxm_comp_set_lbl_align_args(
543 OBJXM_CONFIG_TYPE ctype
546 /* Set Xm resource list correspondin gto
547 * label positioning for a Composite object
550 extern int objxm_comp_set_lbl_pos_args(
552 OBJXM_CONFIG_TYPE ctype
554 extern int objxm_comp_set_icon_args(
556 OBJXM_CONFIG_TYPE ctype
559 /* Set Xm resource list corresponding to
560 * Border-frame style for a Composite object
563 extern int objxm_comp_set_border_args(
565 OBJXM_CONFIG_TYPE ctype
567 extern int objxm_comp_set_read_only_args(
569 OBJXM_CONFIG_TYPE ctype
571 /* Set Xm resource list corresponding to
572 * the MessageBox object's buttons.
574 extern int objxm_comp_set_msgbox_button_arg(
576 OBJXM_CONFIG_TYPE ctype,
577 unsigned char which_btn
580 extern int objxm_obj_set_arrow_style_arg(
582 OBJXM_CONFIG_TYPE ctype
584 extern int objxm_obj_set_direction_arg(
586 OBJXM_CONFIG_TYPE ctype
588 extern int objxm_obj_set_line_style_arg(
590 OBJXM_CONFIG_TYPE ctype
592 extern int objxm_obj_set_orientation_arg(
594 OBJXM_CONFIG_TYPE ctype
596 extern int objxm_obj_set_selection_arg(
598 OBJXM_CONFIG_TYPE ctype
601 extern Widget objxm_set_widget(
606 extern Widget objxm_get_widget(
618 extern ABObj objxm_comp_get_source_for_when(
622 extern ABObj objxm_comp_get_target_for_builtin_action(
624 AB_BUILTIN_ACTION builtin_action
626 extern STRING objxm_get_resource_for_when(
630 extern STRING objxm_get_resource_for_builtin_action(
632 AB_BUILTIN_ACTION builtin_action
636 /* Return number of resource args presently
639 extern int objxm_get_num_args(
643 /* Return number of resource args presently in object's
646 extern int objxm_obj_get_num_ui_args(
650 /* Return default motif widget-class name
651 * for a given object's type
653 extern STRING objxm_obj_get_default_motif_class(
656 /* Return to Motif Create function for
660 objxm_obj_get_xmcreate_func(
664 /* Set resource (name/value) in ArgList
666 extern int objxm_set_arg(
672 /* Set a Literal type (name/value) in ArgList
674 extern int objxm_set_literal_arg(
675 OBJXM_CONFIG_TYPE ctype,
678 unsigned char literal
680 /* Set a Widget type (name/value) in ArgList
682 extern int objxm_set_widget_arg(
683 OBJXM_CONFIG_TYPE ctype,
689 /* Set resource (name/value) in ArgList
690 * only if not already present
692 extern int objxm_set_arg_if_new(
699 /* Remove resource (name/value) from ArgList
701 extern int objxm_remove_arg(
706 /* Remove all resources from ArgList
708 extern void objxm_remove_all_args(
710 OBJXM_CONFIG_TYPE ctype
713 extern Arg *objxm_get_arg(
718 /* FOR DEBUG PURPOSES ONLY */
719 extern int objxm_dump_arglist(
725 extern int objxm_dump_arglist_indented(
731 /* FOR DEBUG PURPOSES ONLY */
732 extern int objxm_dump_widget_geometry(
738 * Xm String cache routines
740 /* Load internal resource tables with
741 * required Xt/Xm resources/enums/createfuncs
743 extern void objxm_strs_init(
746 /* return "strname" corresponding to xmname
748 extern ISTRING objxm_get_res_strname(
752 /* return "xmname" corresponding to strname
754 extern String objxm_get_res_xmname(
757 /* return type corresponding to resource strname
759 extern AB_ARG_TYPE objxm_get_istr_res_type(
762 /* return type corresponding to resource xmname
764 extern AB_ARG_TYPE objxm_get_res_type(
768 /* return arg class corresponding to resource strname
770 extern AB_ARG_CLASS objxm_get_istr_res_class(
773 /* return arg class corresponding to resource xmname
775 extern AB_ARG_CLASS objxm_get_res_class(
778 /* return whether or not the value is defined as the
779 * "default" for that resource
781 extern BOOL objxm_res_value_is_default(
787 /* return "strdef" corresponding to xmdef
789 extern ISTRING objxm_get_enum_strdef(
794 /* return "xmdef" corresponding to strdef
797 objxm_get_enum_xmdef(
801 /* return "ftnstr" corresponding to ftn
803 extern ISTRING objxm_get_xmcreate_ftnstr(
807 /* return "ftn" corresponding to ftnstr
809 XmCreateFunc objxm_get_xmcreate_xmdef(
815 * Xm Utility routines
818 extern BOOL objxm_color_exists(
822 extern int objxm_name_to_pixel(
828 extern int objxm_filebase_to_pixmap(
834 extern STRING objxm_pixmap_conversion_error_msg(
841 objxm_fontlist_to_font(
845 extern XmString objxm_str_to_xmstr(
850 extern STRING objxm_xmstr_to_str(
854 extern String objxm_accel_to_acceltext(
860 objxm_linestyle_to_enum(
861 AB_LINE_TYPE linestyle
864 extern BOOL objxm_is_menu_widget(
870 * Debugging functions
872 int objxm_print(ABObj obj);
873 int objxm_print_indented(ABObj obj, int spaces, int verbosity);
874 int objxm_tree_print(ABObj obj);
875 int objxm_tree_print_indented(ABObj obj, int spaces, int verbosity);
879 * Xm Resource Setting macros
881 #define objxm_obj_set_ui_arg(obj, type, name, val) \
882 objxm_set_arg((ArgList*)&((obj)->ui_args), type, name, (XtArgVal)val)
884 #define objxm_obj_set_literal_ui_arg(obj, ctype, name, enum) \
885 objxm_set_literal_arg(ctype, (ArgList*)&((obj)->ui_args), name, enum)
887 #define objxm_obj_set_widget_ui_arg(obj, ctype, name, w_obj) \
888 objxm_set_widget_arg(ctype, (ArgList*)&((obj)->ui_args), name, w_obj)
890 #define objxm_obj_remove_ui_arg(obj, name) \
891 objxm_remove_arg((ArgList*)&((obj)->ui_args), name)
893 #define objxm_obj_remove_all_ui_args(obj, t) objxm_remove_all_args((ArgList*)&((obj)->ui_args), t)
895 #define objxm_obj_get_ui_args(obj) ((ArgList)((obj)->ui_args))
897 #define objxm_obj_get_num_ui_args(obj) \
898 (objxm_get_num_args(objxm_obj_get_ui_args(obj)))
900 #define objxm_obj_get_ui_arg(obj,name) \
901 (objxm_get_arg(objxm_obj_get_ui_args(obj),(name)))
904 /*************************************************************************
906 ** INLINE IMPLEMENTATION **
908 *************************************************************************/
910 #define objxm_set_widget(obj,w) ((obj)->ui_handle = ((void *)(w)))
911 #define objxm_get_widget(obj) ((Widget)((obj)->ui_handle))
913 #endif /* _OBJXM_H_ */