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: objxm_conn.c /main/4 1995/11/06 18:45:37 rswiston $
27 * @(#)objxm_conn.c 1.23 04 May 1995 cde_app_builder/src/libABobjXm
29 * RESTRICTED CONFIDENTIAL INFORMATION:
31 * The information in this document is subject to special
32 * restrictions in a confidential disclosure agreement between
33 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
34 * document outside HP, IBM, Sun, USL, SCO, or Univel without
35 * Sun's specific written approval. This document and all copies
36 * and derivative works thereof must be returned or destroyed at
39 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
45 * objxm_conn.c - handles connections stuff
49 #include <ab_private/objxm.h>
50 #include <Dt/SpinBox.h>
51 #include <Dt/ComboBox.h>
53 /*************************************************************************
55 ** Private Function Declarations **
57 **************************************************************************/
58 static STRING get_resource_for_set_value(ABObj compObj, ABObj obj);
59 static STRING get_resource_for_set_text(ABObj compObj, ABObj obj);
60 static STRING get_resource_for_set_label(ABObj compObj, ABObj obj);
63 /*************************************************************************
67 **************************************************************************/
69 /*************************************************************************
71 ** Function Definitions **
73 **************************************************************************/
75 #define ObjWClassIs(obj, class_name) \
76 (util_streq(obj_get_class_name(obj), class_name))
78 #define ObjWClassIsApplicationShell(obj) \
79 (ObjWClassIs((obj), _applicationShell))
81 #define ObjWClassIsArrowButton(obj) \
82 (ObjWClassIs((obj), _xmArrowButton))
84 #define ObjWClassIsBulletinBoard(obj) \
85 (ObjWClassIs((obj), _xmBulletinBoard))
87 #define ObjWClassIsCascadeButton(obj) \
88 (ObjWClassIs((obj), _xmCascadeButton))
90 #define ObjWClassIsDialogShell(obj) \
91 (ObjWClassIs((obj), _xmDialogShell))
93 #define ObjWClassIsDrawingArea(obj) \
94 (ObjWClassIs((obj), _xmDrawingArea))
96 #define ObjWClassIsDrawnButton(obj) \
97 (ObjWClassIs((obj), _xmDrawnButton))
99 #define ObjWClassIsFileChooserShell(obj) \
100 (ObjWClassIs((obj), _xmFileSelectionBox))
102 #define ObjWClassIsForm(obj) \
103 (ObjWClassIs((obj), _xmForm))
105 #define ObjWClassIsLabel(obj) \
106 (ObjWClassIs((obj), _xmLabel))
108 #define ObjWClassIsList(obj) \
109 (ObjWClassIs((obj), _xmList))
111 #define ObjWClassIsMainWindow(obj) \
112 (ObjWClassIs((obj), _xmMainWindow))
114 #define ObjWClassIsMenuButton(obj) \
115 (ObjWClassIs((obj), _dtMenuButton))
117 #define ObjWClassIsMenuShell(obj) \
118 (ObjWClassIs((obj), _xmMenuShell))
120 #define ObjWClassIsPanedWindow(obj) \
121 (ObjWClassIs((obj), _xmPanedWindow))
123 #define ObjWClassIsPrimitive(obj) \
124 (ObjWClassIs((obj), _xmPrimitive))
126 #define ObjWClassIsPushButton(obj) \
127 (ObjWClassIs((obj), _xmPushButton))
129 #define ObjWClassIsRowColumn(obj) \
130 (ObjWClassIs((obj), _xmRowColumn))
132 #define ObjWClassIsScrolledWindow(obj) \
133 (ObjWClassIs((obj), _xmScrolledWindow))
135 #define ObjWClassIsTextField(obj) \
136 (ObjWClassIs((obj), _xmTextField))
138 #define ObjWClassIsText(obj) \
139 (ObjWClassIs((obj), _xmText))
141 #define ObjWClassIsToggleButton(obj) \
142 (ObjWClassIs((obj), _xmToggleButton))
144 #define ObjWClassIsBaseWinShell(obj) \
145 (ObjWClassIsApplicationShell(obj))
147 #define ObjWClassIsScale(obj) \
148 (ObjWClassIs((obj), _xmScale))
150 #define ObjWClassIsSpinBox(obj) \
151 (ObjWClassIs((obj), _dtSpinBox))
156 #define ObjWClassIsShell(obj) \
157 ( (ObjWClassIsBaseWinShell(obj)) \
158 || (ObjWClassIsDialogShell(obj)) \
159 || (ObjWClassIsFileChooserShell(obj)) \
160 || (ObjWClassIsMenuShell(obj)) \
165 objxm_get_resource_for_when(
172 /********** GET "DEFAULT" RESOURCE NAME *********/
176 case AB_WHEN_DESTROYED: res= XmNdestroyCallback;
181 /********** GET TYPE-SPECIFIC RESOURCE NAME *********/
183 switch (obj_get_type(obj))
185 case AB_TYPE_BASE_WINDOW:
188 case AB_WHEN_HIDDEN: res= XmNpopdownCallback;
190 case AB_WHEN_SHOWN: res= XmNpopupCallback;
198 case AB_WHEN_ACTIVATED: res= XmNactivateCallback;
206 case AB_TYPE_COMBO_BOX:
207 if (when == AB_WHEN_ITEM_SELECTED)
208 res = DtNselectionCallback;
211 case AB_TYPE_CONTAINER:
217 case AB_WHEN_HIDDEN: res= XmNpopdownCallback;
219 case AB_WHEN_SHOWN: res= XmNpopupCallback;
224 case AB_TYPE_DRAWING_AREA:
227 case AB_WHEN_REPAINT_NEEDED: res= XmNexposeCallback;
229 case AB_WHEN_AFTER_RESIZED: res= XmNresizeCallback;
234 case AB_TYPE_FILE_CHOOSER:
237 case AB_WHEN_OK: res = XmNokCallback;
239 case AB_WHEN_CANCEL: res = XmNcancelCallback;
241 case AB_WHEN_HIDDEN: res= XmNpopdownCallback;
243 case AB_WHEN_SHOWN: res= XmNpopupCallback;
249 switch (obj_get_item_type(obj))
251 case AB_ITEM_FOR_CHOICE:
254 /* For optionmenu items */
255 case AB_WHEN_ACTIVATED:
256 if (ObjWClassIsPushButton(obj))
258 res = XmNactivateCallback;
262 /* For checkbox/radiobox items */
263 case AB_WHEN_TOGGLED:
264 res = XmNvalueChangedCallback;
268 case AB_ITEM_FOR_LIST:
270 case AB_ITEM_FOR_MENUBAR:
274 case AB_WHEN_BEFORE_POST_MENU:
275 res = XmNcascadingCallback;
280 case AB_ITEM_FOR_MENU:
283 case AB_WHEN_ACTIVATED:
284 res = XmNactivateCallback;
300 case AB_WHEN_ITEM_SELECTED:
301 switch (obj_get_selection_mode(obj))
303 case AB_SELECT_SINGLE:
304 res = XmNsingleSelectionCallback;
306 case AB_SELECT_BROWSE:
307 res = XmNbrowseSelectionCallback;
309 case AB_SELECT_MULTIPLE:
310 res = XmNmultipleSelectionCallback;
312 case AB_SELECT_BROWSE_MULTIPLE:
313 res = XmNextendedSelectionCallback;
318 case AB_WHEN_DOUBLE_CLICKED_ON:
319 res = XmNdefaultActionCallback;
327 case AB_WHEN_POPPED_UP: res= XmNpopupCallback;
329 case AB_WHEN_POPPED_DOWN: res= XmNpopdownCallback;
334 case AB_TYPE_SEPARATOR:
337 case AB_TYPE_SPIN_BOX:
338 if (when == AB_WHEN_VALUE_CHANGED)
339 res = XmNvalueChangedCallback;
345 case AB_WHEN_VALUE_CHANGED: res= XmNvalueChangedCallback;
348 case AB_WHEN_DRAGGED: res = XmNdragCallback;
353 case AB_TYPE_TERM_PANE:
356 case AB_TYPE_TEXT_FIELD:
357 case AB_TYPE_TEXT_PANE:
360 case AB_WHEN_BEFORE_TEXT_CHANGED:
361 res= XmNmodifyVerifyCallback;
364 case AB_WHEN_TEXT_CHANGED:
365 res= XmNvalueChangedCallback;
369 } /* switch obj_get_type() */
376 * The parameter 'obj' is the actual subobject (probably from
377 * objxm_comp_get_target_for_builtin_action()) that the resource
382 objxm_get_resource_for_builtin_action(
384 AB_BUILTIN_ACTION builtin_action
387 ABObj compObj = obj_get_root(obj);
388 STRING resource = NULL;
390 switch (builtin_action)
392 case AB_STDACT_DISABLE:
393 case AB_STDACT_ENABLE:
394 resource = XmNsensitive;
399 /* This is not handled through a resource directly, but through
400 * a convenience function. So, this case isn't really necessary, but
401 * is here for completeness.
403 resource = XmNmappedWhenManaged;
406 case AB_STDACT_SET_LABEL:
407 resource = get_resource_for_set_label(compObj, obj);
410 case AB_STDACT_SET_TEXT:
411 resource = get_resource_for_set_text(compObj, obj);
414 case AB_STDACT_SET_VALUE:
415 resource = get_resource_for_set_value(compObj, obj);
424 objxm_comp_get_source_for_when(ABObj subObj, AB_WHEN when)
427 ABObj compObj = obj_get_root(subObj);
431 case AB_WHEN_POPPED_UP:
432 case AB_WHEN_POPPED_DOWN:
433 /* If this object is an optionmenu or a menu
434 * we need to get a handle for the pulldown
435 * menu, so that we can add a callback to
439 if (obj_is_option_menu(compObj))
441 source = objxm_comp_get_subobj(compObj, AB_CFG_PARENT_OBJ);
443 else if (obj_is_menu_ref(subObj))
448 if (obj_is_menu_ref(subObj))
455 source = objxm_comp_get_subobj(compObj, AB_CFG_OBJECT_OBJ);
463 objxm_comp_get_target_for_builtin_action(ABObj subObj, AB_BUILTIN_ACTION action)
465 ABObj compObj = obj_get_root(subObj);
466 ABObj actualTarget = NULL;
467 BOOL useObjectObj = FALSE;
470 * Adjust the actual "to" object
474 case AB_STDACT_ENABLE:
475 case AB_STDACT_DISABLE:
476 actualTarget = compObj;
481 if (obj_is_popup_win(compObj))
483 actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_WINDOW_BB_OBJ);
485 else if (obj_is_base_win(compObj))
487 actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_OBJECT_OBJ);
489 else if (obj_is_file_chooser(compObj))
491 actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_OBJECT_OBJ);
495 actualTarget = compObj;
499 case AB_STDACT_SET_LABEL:
500 actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_LABEL_OBJ);
508 if (actualTarget == NULL)
512 actualTarget = objxm_comp_get_subobj(compObj, AB_CFG_OBJECT_OBJ);
521 * the set-label connections we support:
530 * item (choice, menu, menubar)
533 get_resource_for_set_label(ABObj compObj, ABObj obj)
535 STRING resource = NULL;
537 assert(!ObjWClassIsArrowButton(obj)); /* not supported */
538 if (ObjWClassIsShell(obj))
540 resource = XmNtitleString;
542 else if ( ObjWClassIsCascadeButton(obj)
543 || ObjWClassIsDrawnButton(obj)
544 || ObjWClassIsMenuButton(obj)
545 || ObjWClassIsPushButton(obj)
546 || ObjWClassIsToggleButton(obj)
547 || ObjWClassIsLabel(obj) )
549 if (obj_get_label_type(compObj) == AB_LABEL_GLYPH)
551 resource = XmNlabelPixmap;
555 resource = XmNlabelString;
563 get_resource_for_set_text(ABObj compObj, ABObj obj)
565 STRING resource = NULL;
566 compObj = compObj; /* avoid warning */
568 if (ObjWClassIsSpinBox(obj))
570 resource = DtNposition;
582 get_resource_for_set_value(ABObj compObj, ABObj obj)
584 STRING resource = NULL;
585 compObj = compObj; /* avoid warning */
587 if (ObjWClassIsScale(obj))
589 else if (ObjWClassIsSpinBox(obj))
590 resource = DtNposition;