Debian Codegraph @

gui/GraphLib/libsrc/uimxR5/src/uimxMF.c

raw
1 /*---------------------------------------------------------------------
2 *
3 *
4 * Copyright (c) 1992, Visual Edge Software Ltd.
5 *
6 * ALL RIGHTS RESERVED. Permission to use, copy, modify, and
7 * distribute this software and its documentation for any purpose
8 * and without fee is hereby granted, provided that the above
9 * copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of Visual Edge Software not be
12 * used in advertising or publicity pertaining to distribution of
13 * the software without specific, written prior permission. The year
14 * included in the notice is the year of the creation of the work.
15 *-------------------------------------------------------------------*/
16 /*---------------------------------------------------------------------
17 DESCRIPTION: Motif-specific widget creation support functions.
18 This file is included by <uimx.c> during compilation.
19
20 Special checks are performed during widget creation to
21 determine if dialog or menu shells must be created instead of
22 the normal shells.
23
24 CREATION: 27 July 1989
25
26 090818 last modif
27
28 *--------------------------------------------------------------------*/
29
30 /*--- include files ---*/
31 #include "version.h"
32
33 #include <stdlib.h>
34
35 /******* Included so that the WidgetClass pointers can be used. *******/
36 #include <Xm/MainW.h>
37 #include <Xm/RowColumn.h>
38 #include <Xm/BulletinB.h>
39 #include <Xm/MenuShell.h>
40 #include <Xm/DialogS.h>
41 #include <Xm/Protocols.h>
42 #include <X11/Shell.h>
43
44 #include <X11/Intrinsic.h>
45 #include <X11/IntrinsicP.h>
46 #include <X11/RectObjP.h>
47
48
49 /*--- macro symbolic constants ---*/
50
51 /*--- macro functions ---*/
52
53 /*--- types ---*/
54
55 /*--- external functions ---*/
56
57 extern int UxFindValue();
58
59 extern void XmScrolledWindowSetAreas();
60
61
62 /*--- external variables ---*/
63
64 /*--- global variables ---*/
65
66 /*--- file global variables ---*/
67 M_FILE_VERSION("$Header")
68
69 /*--- forward declaration of static functions ---*/
70 static void InstallMwmCloseCallback();
71 #ifdef decstation
72 static void UpdateShadowThickness ();
73 #endif /* decstation */
74
75 /*------------------------------------------------------------
76 * COMMENT_BOX
77 *-----------------------------------------------------------*/
78
79
80 /******************************************************************************
81 NAME: int NeedsMenuShell (arg_list, size)
82
83 INPUT: ArgList arg_list - widget argument list
84 int size - size of argument list
85 WidgetClass widget_class - class of widget
86
87 RETURN: Boolean
88
89 DESCRIPTION: Checks if the widget is a rowColumn and if its type is set to
90 be a popup or pulldown menu; if these conditions are met, then
91 the rowColumn widget is being used as a menu and needs a
92 menuShell.
93
94 CREATION: Jul 27/1989
95 REVISIONS: --
96 -----------------------------------------------------------------------------*/
97
98 static int NeedsMenuShell (arg_list, size, widget_class)
99 ArgList arg_list;
100 int size;
101 WidgetClass widget_class;
102 {
103 int i;
104
105 /* first compare the class of the widget */
106
107 if (widget_class != xmRowColumnWidgetClass)
108 return 0;
109
110 /* loop through the argument list and search for the rowColumnType
111 property; if it is set to be a popup or pulldown menu, then a
112 menuShell is needed */
113
114 for (i = 0; i < size; i++)
115 {
116 if (strcmp (arg_list[i].name, XmNrowColumnType) == 0
117 && (arg_list[i].value == XmMENU_POPUP
118 || arg_list[i].value == XmMENU_PULLDOWN))
119 return 1;
120 }
121
122 /* no match was found */
123
124 return 0;
125 }
126
127 /******************************************************************************
128 NAME: int IsPopupMenu (arg_list, size, widget_class)
129
130 INPUT: ArgList arg_list - widget argument list
131 int size - size of argument list
132 WidgetClass widget_class - class of widget
133
134 RETURN: Boolean
135
136 DESCRIPTION: Checks if the widget is a rowColumn and if its type is set to
137 be a popup menu.
138
139 CREATION: Aug 16/1989
140 REVISIONS: --
141 -----------------------------------------------------------------------------*/
142
143 static int IsPopupMenu (arg_list, size, widget_class)
144 ArgList arg_list;
145 int size;
146 WidgetClass widget_class;
147 {
148 int i;
149
150 /* first compare the class of the widget */
151
152 if (widget_class != xmRowColumnWidgetClass)
153 return 0;
154
155 /* loop through the argument list and search for the rowColumnType
156 property; if it is set to be a popup menu, then return 'true' */
157
158 for (i = 0; i < size; i++)
159 {
160 if (strcmp (arg_list[i].name, XmNrowColumnType) == 0
161 && arg_list[i].value == XmMENU_POPUP)
162 return 1;
163 }
164
165 /* no match was found */
166
167 return 0;
168 }
169
170 /*----------------------------------------------------------------------------
171 NAME: void UxDealWithShellTitleAndIconName (shl, name)
172 INPUT: Widget shl the shell widget.
173 char *name the name to set.
174 RETURN: void
175 DESCRIPTION: Set the title and iconName of an implicit shell.
176 CREATION: Oct/16/91 fix3059
177 ------------------------------------------------------------------------------*/
178
179 void UxDealWithShellTitleAndIconName (shl, name)
180 Widget shl;
181 char *name;
182 {
183 Arg args[5];
184 int i = 0;
185 /*
186 * For all shells subclass of wmShellWidgetClass
187 * (this excludes overrideShellWidgetClass)
188 * set the title of implicit shell to be
189 * the name of its child by default. For shells
190 * subclass of topLevel shells, also set the
191 * iconName.
192 */
193 if (XtIsSubclass (shl, wmShellWidgetClass)) {
194 XtSetArg (args[i], XtNtitle, name);
195 i++;
196 }
197 if (XtIsSubclass (shl, topLevelShellWidgetClass)) {
198 XtSetArg (args[i], XtNiconName, name);
199 i++;
200 }
201 if (i > 0)
202 XtSetValues (shl, args, i);
203
204 }
205
206 /*******************************************************************************
207 NAME: static swidget CreateImplicitShell (sw, name, class)
208
209 INPUT: swidget sw - swidget
210 char *name - widget name
211 WidgetClass widget_class - class of widget
212
213 RETURN: Widget
214
215 DESCRIPTION: Create implicit shell
216
217 CREATION: July 1990 (see bug710)
218 LAST REV: May 92 fix3571 -- rewrite for pointer swidget type.
219 -----------------------------------------------------------------------------*/
220
221 static Widget CreateImplicitShell(sw, name, shell_class, parent)
222 swidget sw;
223 char *name;
224 WidgetClass shell_class;
225 Widget parent;
226 {
227 char shellname[256];
228 Arg pa[10];
229 Widget rtn;
230 int i=0;
231 XtArgVal value;
232
233 strncpy(shellname, name, 256);
234 strncat(shellname, "_shell", 256);
235
236 /*
237 * Don't set XmShellUnitType if a mainWindow is parented
238 * on a dialogShell.
239 */
240 if (!(shell_class == xmDialogShellWidgetClass &&
241 UxGetClass(sw) == xmMainWindowWidgetClass)) {
242
243 if (UxFindValue (sw, XmNunitType, &value)){
244 if (value != XmPIXELS) {
245 XtSetArg(pa[i], XmNshellUnitType, value);
246 i++;
247 }
248 }
249 }
250
251 if(UxFindValue (sw, XtNx, &value)) {
252 XtSetArg(pa[i], XtNx, value);
253 i++;
254 }
255 if(UxFindValue (sw, XtNy, &value)) {
256 XtSetArg(pa[i], XtNy, value);
257 i++;
258 }
259 if(UxFindValue (sw, XtNheight, &value)) {
260 XtSetArg(pa[i], XtNheight, value);
261 i++;
262 }
263 if(UxFindValue (sw, XtNwidth, &value)) {
264 XtSetArg(pa[i], XtNwidth, value);
265 i++;
266 }
267 if (UxFindValue (sw, XtNallowShellResize, &value)) {
268 XtSetArg(pa[i], XtNallowShellResize, value);
269 i++ ;
270 }
271 rtn = XtCreatePopupShell(shellname, shell_class, parent, pa, i);
272 /*
273 * set the shell title and iconName after creation so
274 * that these values can be set to the appropriate shell
275 * classes.
276 */
277 if (rtn)
278 UxDealWithShellTitleAndIconName (rtn, UxGetName (sw));
279
280 return rtn;
281 }
282
283 /*******************************************************************************
284 NAME: static WidgetClass DetermineImplicitShellClass (sw)
285 INPUT: swidget sw - swidget
286 RETURN: WidgetClass
287 DESCRIPTION: Determine implicit shell class
288 CREATION: July 1990 (see bug710)
289 LAST REV: May 92 fix3571 -- rewrite for pointer swidget type.
290 -----------------------------------------------------------------------------*/
291
292 static WidgetClass DetermineImplicitShellClass(sw)
293 swidget sw;
294 {
295 WidgetClass shell_class;
296
297 if (UxSwidgetGetFlag(sw, UXDIALOG_FLAG))
298 return xmDialogShellWidgetClass;
299 else if ((shell_class = (WidgetClass)UxGetDefaultShell(sw)))
300 return shell_class;
301 else
302 return (WidgetClass)UxUserShell;
303 }
304
305 /*******************************************************************************
306 NAME: static swidget CreateMenuShell (name, pwidget, class, list, sz)
307
308 INPUT: char *name - widget name
309 WidgetClass class - class of widget
310 Widget pwidget - parent
311 ArgList list - argument list
312 int sz - size of argument list
313
314 RETURN: Widget
315
316 DESCRIPTION: create a menu shell
317
318 CREATION: July 1990 (see bug710)
319 REVISIONS: --
320 -----------------------------------------------------------------------------*/
321
322 static Widget CreateMenuShell(name, pwidget, w_class, list, sz)
323 char *name;
324 Widget pwidget;
325 WidgetClass w_class;
326 ArgList list;
327 int sz;
328 {
329 Arg pa[5];
330 int i=0;
331 char shellname[256];
332
333 strncpy(shellname, name, 256);
334 strncat(shellname, "_shell", 256);
335
336 XtSetArg (pa[i], XmNwidth, (Dimension) 1);
337 i++;
338 XtSetArg (pa[i], XmNheight, (Dimension) 1);
339 i++;
340 XtSetArg (pa[i], XmNallowShellResize, TRUE);
341 i++;
342 XtSetArg (pa[i], XmNoverrideRedirect, TRUE);
343 i++;
344
345 if (IsPopupMenu (list, sz, w_class)) {
346 if (! pwidget)
347 pwidget= UxTopLevel;
348 }
349 else if((XtParent(pwidget)) && (XmIsMenuShell(XtParent(pwidget))))
350 pwidget = XtParent (pwidget);
351
352 return XtCreatePopupShell(shellname, xmMenuShellWidgetClass, pwidget, pa, i);
353 }
354 /******************************************************************************
355 NAME: Widget UxCreateWidget(sw)
356
357 INPUT: swidget sw - swidget whose xwidget to create
358
359 RETURN: Widget * - xwidget created from the swidget
360
361 DESCRIPTION: Creates the xwidget using the values from the swidget.
362 Dialogs are given dialog shells, and a check is made for the
363 dialog convenience classes so that the 'dialogType' resource
364 can be set properly.
365
366 CREATION: Mar 14/1989
367 LAST REV: March 93 fix3963 UxIsSwidget now called.
368 -----------------------------------------------------------------------------*/
369
370 Widget UxCreateWidget(sw)
371 swidget sw;
372 {
373 String name;
374 WidgetClass w_class, shell_class;
375 swidget parent;
376 ArgList list;
377 int sz, real_shell = 0, is_menu = 0;
378 int is_parent_dialog=0, needs_implicit_shell=0;
379 char *tr;
380 Widget pwidget;
381 Widget w = UxGetWidget(sw);
382
383 if (w)
384 return w;
385
386 if (UxIsSwidget(sw))
387 {
388 parent = UxGetParent(sw);
389 pwidget = UxGetWidget(parent);
390 w_class = UxGetClass(sw);
391 name = UxGetName(sw);
392 real_shell = UxIsShellClass(w_class);
393 sz = sw->NumValues;
394 list = sw->Values;
395
396 if (real_shell)
397 {
398 w = XtCreatePopupShell(name, w_class,
399 (pwidget ? pwidget : UxTopLevel), list, sz);
400
401 InstallMwmCloseCallback(w);
402 }
403 else
404 {
405 needs_implicit_shell = UxSwidgetGetFlag(sw, UXDIALOG_FLAG)
406 || (!pwidget);
407
408 if ( needs_implicit_shell )
409 {
410 shell_class = DetermineImplicitShellClass(sw);
411 pwidget = CreateImplicitShell(sw, name, shell_class,
412 (pwidget ? pwidget : UxTopLevel));
413
414 InstallMwmCloseCallback(pwidget);
415 RecordWidget(pwidget, sw);
416 }
417
418 /* menu rowColumn widgets need a menuShell */
419 is_menu = NeedsMenuShell (list, sz, w_class);
420 if (is_menu)
421 pwidget = CreateMenuShell(name, pwidget, w_class, list, sz);
422
423 is_parent_dialog=XtIsSubclass(pwidget, xmDialogShellWidgetClass);
424
425 if ( is_menu
426 || is_parent_dialog
427 || (strcmp(UxGetCreateManaged(sw), "false") == 0)
428 )
429 {
430 w = XtCreateWidget (name, w_class, pwidget, list, sz);
431 }
432 else
433 {
434 w = XtCreateManagedWidget (name, w_class, pwidget, list, sz);
435 }
436 }
437
438 sw->ItsWidget = w;
439 RecordWidget(w, sw);
440
441 #ifdef decstation
442 /* Fixes a Motif bug on the decstation where menu buttons are
443 * fat since the default value of the shadowThickness resource is
444 * way too large for unitType other than pixels.
445 */
446 UpdateShadowThickness (sw, list, sz);
447 #endif
448
449 if ((tr = UxGetTranslations(sw)))
450 UxAddTranslations(sw, tr);
451
452 if((tr = UxGetAccelerators(sw)))
453 UxAddAccelerators(sw, tr);
454
455 UxSwidgetFreeArgs(sw);
456 }
457 return w;
458 }
459
460 /******************************************************************************
461 NAME: void PostPopupMenu (w, client_data, event, cont)
462
463 INPUT: Widget w - widget where event occured
464 XtPointer client_data - popup menu widget as closure
465 XEvent *event - pointer X Event structure
466 Boolean *cont - not used
467
468 DESCRIPTION: Post a popup menu by first positioning it, then managing it.
469
470 CREATION: Aug 1/1989
471 -----------------------------------------------------------------------------*/
472
473 static void PostPopupMenu (w, client_data, event, cont)
474 Widget w;
475 XtPointer client_data;
476 XEvent *event;
477 Boolean *cont;
478 {
479 Widget popup = (Widget) client_data;
480 XButtonPressedEvent *button_event = (XButtonPressedEvent *) event;
481 extern WidgetClass xmRowColumnWidgetClass;
482
483 if (popup && (XtClass(popup) == xmRowColumnWidgetClass))
484 {
485 Arg a[1];
486 int which_button;
487 XtSetArg(a[0], XmNwhichButton, &which_button);
488 XtGetValues(popup, a, 1);
489 if(button_event->button != which_button)
490 {
491 return;
492 }
493 }
494 else
495 {
496 if(button_event->button != Button3)
497 {
498 return;
499
500 }
501 }
502 XmMenuPosition (popup, button_event);
503 XtManageChild (popup);
504 }
505
506 /******************************************************************************
507 NAME: void UxRegisterPopupMenuHandler (wid, popup_wid)
508
509 INPUT: Widget wid - menu parent widget
510 popup_wid - popup menu widget
511
512 DESCRIPTION: Adds the popup menu event handler to position and popup the
513 menu on the parent widget.
514
515 CREATION: Aug 1/1989
516 REVISIONS: --
517 -----------------------------------------------------------------------------*/
518
519 void UxRegisterPopupMenuHandler (wid, popup_wid)
520 swidget wid, popup_wid;
521 {
522 XtAddEventHandler (UxGetWidget(wid), ButtonPressMask, False,
523 PostPopupMenu, (XtPointer)UxGetWidget(popup_wid));
524 }
525
526 /*--------------------------------------------------------------------------
527 NAME: UxPostMenu(widget, event, pars, npars)
528 INPUT: Widget widget, XEvent *event, String *pars, Cardinal *npars
529 RETURN:
530 DESCRIPTION: Post a popup menu
531 CREATION: Sept . 15, 89
532 REVISIONS: March 93 fix3963 UxIsSwidget now called.
533 --------------------------------------------------------------------------*/
534
535 static void nothing(widget, event, pars, npars)
536 Widget widget;
537 XEvent *event;
538 String *pars;
539 Cardinal *npars;
540 {
541 }
542
543 static XtActionsRec action_list[]={{"nothing", nothing},
544 {"UxPostMenu", UxPostMenu}};
545
546 static Widget post_widget;
547
548
549 void UxPostMenu(widget, event, pars, npars)
550 Widget widget;
551 XEvent *event;
552 String *pars;
553 Cardinal *npars;
554 {
555 swidget mmgr; /*menu manager*/
556 Widget menu_manager; /*X menu manager*/
557
558
559 post_widget = widget;
560 mmgr = UxFindSwidget(pars[0]);
561
562 if ((UxIsSwidget(mmgr)) && (menu_manager = UxGetWidget(mmgr)) )
563 {
564 XmMenuPosition (menu_manager, (XButtonPressedEvent *) event);
565 XtManageChild (menu_manager);
566 }
567 }
568
569 /*--------------------------------------------------------------------------
570 NAME: UxScrolledWindowSetAreas(mwe, hsb, vsb, ww)
571 INPUT: swidget mwe, hsb, vsb, ww;
572 RETURN:
573 DESCRIPTION: Call the XmScrolledWindowSetAreas function.
574 CREATION: Sept 22, 90
575 REVISIONS: --
576 --------------------------------------------------------------------------*/
577
578 void UxScrolledWindowSetAreas (sw, hsb, vsb, ww)
579 swidget sw, hsb, vsb, ww;
580 {
581 Widget wsw = UxGetWidget(sw);
582
583 if (! wsw)
584 return;
585
586 XmScrolledWindowSetAreas(wsw, UxGetWidget(hsb),
587 UxGetWidget(vsb),
588 UxGetWidget(ww));
589 }
590
591 /*--------------------------------------------------------------------------
592 NAME: UxMainWindowSetMessageWindow(mw, msgw)
593 INPUT: swidget mw, msgw;
594 mw - The Main Window Widget.
595 msgw - The Message Window Widget.
596 RETURN:
597 DESCRIPTION: This function is added to complement UxMainWindowSetAreas
598 Which does not contain a mechanism to add a Message Window
599 to a Main Window. We did not change the UxMainWindowSetAreas
600 to stay compatible with already released UIM/X.
601
602 CREATION: 4 Fevrier 1991 (bug2045)
603 REVISIONS:
604 --------------------------------------------------------------------------*/
605
606 void UxMainWindowSetMessageWindow(mw, msgw)
607 swidget mw, msgw;
608 {
609 Widget wmw = UxGetWidget(mw);
610
611 if (! wmw)
612 return;
613
614 XtVaSetValues(wmw, XmNmessageWindow, UxGetWidget(msgw), NULL); /* 0,NULL); */
615 /* P.Ballester 2012-04-30. The above line must be NULL terminated, not 0,NULL */
616 }
617
618 /*--------------------------------------------------------------------------
619 NAME: UxMainWindowSetAreas(mw, pdm, c, hsb, vsb, ww)
620 INPUT: swidget mw, pdm, cmd, hsp, vsb, ww
621 RETURN:
622 DESCRIPTION: Call the XtMainWindowSetAreas function.
623 CREATION: Sept 26, 89
624 REVISIONS:
625 --------------------------------------------------------------------------*/
626
627 void UxMainWindowSetAreas(mw, pdm, cmd, hsb, vsb, ww)
628 swidget mw, pdm, cmd, hsb, vsb, ww;
629 {
630 Widget wmw = UxGetWidget(mw);
631
632 if (! wmw)
633 return;
634
635 XmMainWindowSetAreas(wmw, UxGetWidget(pdm),
636 UxGetWidget(cmd),
637 UxGetWidget(hsb),
638 UxGetWidget(vsb),
639 UxGetWidget(ww));
640 }
641
642 /*--------------------------------------------------------------------------
643 NAME: void UxAddAccelerators(s, t)
644 INPUT: swidget s, t;
645 RETURN:
646 DESCRIPTION: given swidget s add accelerator property
647 CREATION: 23, Nov. 1989
648 REVISIONS: September 06 1990 -- Call XtParseAcceleratorTable() instead of
649 XtParseTranslationTable().
650 --------------------------------------------------------------------------*/
651
652 void UxAddAccelerators(s, t)
653 swidget s;
654 String t;
655 {
656 Widget w;
657 XtAccelerators acc;
658 Arg arg[2];
659
660 if((w = UxGetWidget(s)) && t){
661 acc = XtParseAcceleratorTable(t);
662 XtSetArg(arg[0], XmNaccelerators, acc);
663 XtSetValues(w, arg, 1);
664 }
665 }
666
667 /******************************************************************************
668 NAME: Widget UxAddTabGroup(sw)
669
670 INPUT: swidget sw - swidget whose xwidget gets
671 XmAddTabGroup'ed
672
673 RETURN: void
674
675 DESCRIPTION: Performs a XmAddTabGroup on the widget associated with the
676 swidget.
677
678 CREATION: Jul 20/1990 (see bug804)
679 REVISIONS:
680 -----------------------------------------------------------------------------*/
681 void UxAddTabGroup(sw)
682 swidget sw;
683 {
684 Widget w = UxGetWidget(sw);
685
686 if (w)
687 XmAddTabGroup(w);
688 }
689
690 /******************************************************************************
691 NAME: Widget UxRemoveTabGroup(sw)
692
693 INPUT: swidget sw - swidget whose xwidget gets
694 XmRemoveTabGroup'ed
695
696 RETURN: void
697
698 DESCRIPTION: Performs a XmRemoveTabGroup on the widget associated with the
699 swidget.
700 CREATION: Jul 20/1990 (see bug804)
701 REVISIONS:
702 -----------------------------------------------------------------------------*/
703
704 void UxRemoveTabGroup(sw)
705 swidget sw;
706 {
707 Widget w = UxGetWidget(sw);
708
709 if (w)
710 XmRemoveTabGroup(w);
711 }
712
713 /******************************************************************************
714 NAME: Atom GetProtocolsAtom()
715
716 RETURN: atom
717
718 DESCRIPTION: Return the WM_PROTOCOLS atom to the caller.
719
720 CREATION: Aug 01/1990
721 REVISIONS: --
722 -----------------------------------------------------------------------------*/
723
724 static Atom GetProtocolsAtom()
725 {
726 static Atom prot;
727 static int init= 0;
728
729 if(!init)
730 { prot= XmInternAtom(UxDisplay, "WM_PROTOCOLS", FALSE);
731 init= 1;
732 }
733
734 return(prot);
735 }
736
737 /******************************************************************************
738 NAME: Atom GetDeleteWindowAtom()
739
740 RETURN: delete atom
741
742 DESCRIPTION: Return the WM_DELETE_WINDOW atom to the caller.
743
744 CREATION: Aug 01/1990
745 REVISIONS: --
746 -----------------------------------------------------------------------------*/
747
748 static Atom GetDeleteWindowAtom()
749 {
750 static Atom del_atom;
751 static int init= 0;
752
753 if(!init)
754 { del_atom= XmInternAtom(UxDisplay, "WM_DELETE_WINDOW", FALSE);
755 init= 1;
756 }
757
758 return(del_atom);
759 }
760
761 /******************************************************************************
762 NAME: void CloseButtonCallback(wid, unused,
763 call_data)
764
765 INPUT: Widget wid - widget
766 void * unused - unused info
767 XmAnyCallbackStruct*call_data - callback data
768
769 DESCRIPTION: Mwm close button callback function.
770
771 CREATION: Aug 01/1990
772 REVISIONS: November 21 1990 [bug1159]
773 -- Get the shell widget from the client data.
774 Some window managers do not pass back the right wid.
775 -----------------------------------------------------------------------------*/
776
777 static void CloseButtonCallback(wid, client_data, call_data)
778 Widget wid;
779 XtPointer client_data;
780 XtPointer call_data;
781 {
782 Atom dwa;
783 Widget shell;
784 XmAnyCallbackStruct *cbstruct = (XmAnyCallbackStruct *) call_data;
785
786 dwa= GetProtocolsAtom();
787 shell = (Widget) client_data;
788
789 if(cbstruct->event->xclient.message_type == dwa)
790 {
791 unsigned char dr;
792 swidget sw;
793
794 if (!XmIsVendorShell(shell))
795 return;
796
797 XtVaGetValues(shell,
798 XmNdeleteResponse, &dr,
799 0,NULL);
800
801
802 sw= UxWidgetToSwidget(shell);
803
804 if (dr == XmDESTROY)
805 { if(XtIsSubclass(shell, applicationShellWidgetClass))
806 exit(0);
807 else
808 UxDestroyInterface(sw);
809 }
810 else if (dr == XmUNMAP)
811 UxPopdownInterface(sw);
812 }
813 }
814
815 /******************************************************************************
816 NAME: void InstallMwmCloseCallback(shell)
817
818 INPUT: Widget shell - shell to add callback to.
819
820 DESCRIPTION: Add a callback for the close button on subclasses of
821 vendor shell.
822
823 CREATION: Aug 01/1990
824 REVISIONS: November 21 1990 [bug1159]
825 -- Pass the shell widget as the client data.
826 -----------------------------------------------------------------------------*/
827
828 static void InstallMwmCloseCallback(shell)
829 Widget shell;
830 {
831 if(XmIsVendorShell(shell))
832 {
833 Atom dwa;
834
835 dwa= GetDeleteWindowAtom();
836
837 XmAddWMProtocols(shell, &dwa, 1);
838 XmAddWMProtocolCallback(shell, dwa, CloseButtonCallback, (XtPointer) shell);
839 }
840 }
841
842
843 /*----------------------------------------------------------------------
844 * NAME: <char *UxGetText (sw)>
845 * DESCRIPTION: <Get the char string of the value resource associated with the
846 * specified widget>
847 A rotating buffer will contain the strings. For the first pass, the buffer
848 is filled up to its size and for the subsequent strings to be stored, the
849 location is first reallocated before the new string takes its place.
850 Every time the buffer index reaches the size of the buffer, it is reset
851 to 0 to create the rotating buffer. This way, we avoid system crashes
852 because the pointer will always point to valid memory addresses but
853 the memory content may not be the right one if the user waited too long
854 (more than <size of buffer> calls to this converter) before using the
855 value returned.
856 * PARAMETERS: Widget sw - swidget to get resource from
857 * RETURN: char * - value resource
858 * EXT REFS: globals_used
859 * EXT EFFECTS: globals or other things altered
860 * ASSUMPTIONS:
861 * REVISIONS: 14/12/90 creation
862 * dd/mm/yy fix# fix_description
863 *--------------------------------------------------------------------*/
864 char *UxGetText (sw)
865 swidget sw;
866 {
867
868 Widget w = UxGetWidget(sw);
869 char *s = 0;
870 static char **RotatingBuffer;
871 static int BufferIndex = -1;
872
873 if (w)
874 {
875 Arg arg[1];
876 XtSetArg (arg[0], XmNvalue, &s);
877 XtGetValues (w, arg, 1);
878 #ifdef _IBMR2
879 s = strdup(s);
880 #endif
881
882 UxUpdateRotatingBuffer(&BufferIndex, &RotatingBuffer, s, XtFree);
883 return(RotatingBuffer[BufferIndex]);
884 }
885 else
886 return (NULL);
887 }
888
889 #ifdef decstation
890 /******************************************************************************
891 NAME: Boolean CheckForPresenceInArgumentList( arg, a, cnt )
892
893 INPUT: char *Argument; The argument we are looking for
894 Arg *a; The argument list
895 int cnt; How many arguments in the list
896
897 DESCRIPTION: Finds out if the arguments (XmNshadowThickness for example)
898 is in the list of values being passed for the creation of this
899 Widget.
900
901 CREATION: 8 Oct 1991 (fix2993)
902 -----------------------------------------------------------------------------*/
903
904 static Boolean CheckForPresenceInArgumentList (Argument, a, cnt)
905 char *Argument;
906 Arg *a;
907 int cnt;
908 {
909 int i=0;
910
911 for (i=0;i<cnt;i++)
912 if (UxStrEqual(Argument, a[i].name))
913 return( True );
914
915 return( False );
916 }
917 #endif /* decstation */
918
919 #ifdef decstation
920 /******************************************************************************
921 NAME: Boolean IsInMenu (w)
922
923 INPUT: Widget w; The widget to apply the test on.
924
925 DESCRIPTION: Finds out if a widget is in a menu.
926
927 CREATION: 8 Oct 1991 fix3033
928 -----------------------------------------------------------------------------*/
929
930 static Boolean IsInMenu (w)
931 Widget w;
932 {
933 unsigned char menuType;
934
935 if (! w)
936 return (False);
937
938 if (XtIsSubclass (w, xmRowColumnWidgetClass)) {
939 XtVaGetValues (w, XmNrowColumnType, &menuType, 0);
940 if (menuType == XmMENU_POPUP ||
941 menuType == XmMENU_BAR ||
942 menuType == XmMENU_OPTION) {
943 return (True);
944 }
945 }
946 return (IsInMenu (XtParent (w)));
947 }
948 #endif /* decstation */
949
950 #ifdef decstation
951 /******************************************************************************
952 NAME: static void UpdateShadowThickness (sw, list, sz)
953
954 INPUT: swidget sw; The swidget to apply the update to.
955 ArgList list; Argument list for the swidget.
956 int sz; Size of the argument list.
957
958 DESCRIPTION: Apply a correction on the buttonShadowThickness resource
959 of all menus and its children if no UxPut calls were made and
960 if the user has not set the resource in a resource file.
961 It fixes a Motif bug on the decstation where menu buttons are
962 fat since the default value of the shadowThickness resource is
963 way too large for unitType values other than pixels.
964
965 CREATION: 8 Oct 1991 fix3033
966 -----------------------------------------------------------------------------*/
967 static void UpdateShadowThickness (sw, list, sz)
968 swidget sw;
969 ArgList list;
970 int sz;
971 {
972 Widget w;
973
974 w = UxGetWidget (sw);
975
976 if (IsInMenu (w))
977 {
978 extern char *UxProgramName;
979
980 /* If the user has not done a UxPut call and
981 * if the resource was not set in a resource file
982 * then change the default value of shadowThickness.
983 */
984 if (CheckForPresenceInArgumentList (
985 XmNshadowThickness, list, sz) == False &&
986 !UxGetResource (UxProgramName, "shadowThickness"))
987 {
988 extern unsigned char UxFindUnitType ();
989
990 /* Set the default value of the ShadowThickness resource */
991 switch (UxFindUnitType (w))
992 {
993 /* Default value for ShadowThickness resource of a
994 * Menu RowColumn and its children is 2 pixels.
995 */
996 case Xm100TH_MILLIMETERS:
997 UxPutShadowThickness (sw, 64);
998 break;
999 case Xm1000TH_INCHES:
1000 UxPutShadowThickness (sw, 26);
1001 break;
1002 case Xm100TH_POINTS:
1003 UxPutShadowThickness (sw, 200);
1004 break;
1005 case Xm100TH_FONT_UNITS:
1006 UxPutShadowThickness (sw, 33);
1007 break;
1008 default:
1009 break;
1010 }
1011 }
1012 }
1013 }
1014 #endif /* decstation */