1 /**
2  *
3  * $Header: /cvsroot/lesstif/lesstif/lib/Xm-2.1/BulletinBoard.c,v 1.4 2005/03/19 10:02:24 dannybackx Exp $
4  *
5  * Copyright (C) 1995 Free Software Foundation, Inc.
6  * Copyright � 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 LessTif Development Team
7  *
8  * This file is part of the GNU LessTif Library.
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the Free
22  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  **/
25 
26 static const char rcsid[] = "$Header: /cvsroot/lesstif/lesstif/lib/Xm-2.1/BulletinBoard.c,v 1.4 2005/03/19 10:02:24 dannybackx Exp $";
27 
28 #include <LTconfig.h>
29 
30 #include <XmI/XmI.h>
31 
32 #include <Xm/XmP.h>
33 #include <Xm/BaseClassP.h>
34 #include <Xm/BulletinBP.h>
35 #include <Xm/TransltnsP.h>
36 #include <Xm/DialogS.h>
37 #include <Xm/ArrowB.h>
38 #include <Xm/ArrowBG.h>
39 #include <Xm/LabelP.h>
40 #include <Xm/LabelGP.h>
41 #include <Xm/PushB.h>
42 #include <Xm/PushBG.h>
43 #include <Xm/MwmUtil.h>
44 #include <Xm/VendorSEP.h>
45 
46 #include <Xm/SpecRenderT.h>
47 
48 #include <XmI/DebugUtil.h>
49 
50 /* #defines being used in this file:
51       #ifdef USE_WIDGETS
52 */
53 
54 
55 /* We use a 'private', i.e. non-declared but actually
56    exported call from OpenGroup's Intrinsic sources
57    (lib/Xt/Callback.c) in this file.
58    Note that we don't give the precise type here ...
59  */
60 extern void
61 _XtRemoveAllCallbacks(
62   /* InternalCallbackList *callbacks; */
63  void *callbacks);
64 
65 /* similar for this ... */
66 extern void
67 _XtAddCallback(XtCallbackList *,
68                XtCallbackProc,
69                XtPointer);
70 
71 /* Forward Declarations */
72 static void class_initialize(void);
73 static void class_part_initialize(WidgetClass w_class);
74 static void initialize(Widget request, Widget new_w, ArgList args, Cardinal *num_args);
75 static void destroy(Widget w);
76 static void resize(Widget w);
77 /* static void realize(Widget w, XtValueMask *value_mask, XSetWindowAttributes *attributes); */
78 static XtGeometryResult query_geometry(Widget w,
79 				       XtWidgetGeometry *proposed,
80 				       XtWidgetGeometry *answer);
81 static Boolean set_values(Widget current, Widget request, Widget new_w,
82 			  ArgList args, Cardinal *num_args);
83 static void expose(Widget w, XEvent *event, Region region);
84 static XtGeometryResult geometry_manager(Widget w,
85 					 XtWidgetGeometry *request,
86 					 XtWidgetGeometry *reply);
87 static void change_managed(Widget w);
88 static void insert_child(Widget w);
89 static void delete_child(Widget w);
90 
91 #if 0
92 static void constraint_initialize(Widget request, Widget new_w, Arg *args, Cardinal *nargs);
93 static Boolean constraint_set_values(Widget old, Widget request, Widget new_w,
94 				     Arg *args, Cardinal *nargs);
95 #endif
96 
97 static Boolean _XmBBParentProcess(Widget widget, XmParentProcessData data);
98 static void _XmBulletinBoardDialogStyleDefault(Widget w, int offset, XrmValue *val);
99 static XmRenderTable GetRenderTable(Widget w, XtEnum renderTableType);
100 
101 /*
102  * Resources for the Bulletin board class
103  */
104 #define Offset(field) XtOffsetOf(XmBulletinBoardRec, bulletin_board.field)
105 #define MGR_Offset(field) XtOffsetOf(XmBulletinBoardRec, manager.field)
106 static XtResource resources[] =
107 {
108     {
109 	XmNshadowType, XmCShadowType, XmRShadowType,
110 	sizeof(unsigned char), Offset(shadow_type),
111 	XmRImmediate, (XtPointer)XmSHADOW_OUT
112     },
113     {
114 	XmNshadowThickness, XmCShadowThickness, XmRHorizontalDimension,
115 	sizeof(Dimension), MGR_Offset(shadow_thickness),
116 	XmRImmediate, (XtPointer)0
117     },
118     {
119 	XmNmarginWidth, XmCMarginWidth, XmRHorizontalDimension,
120 	sizeof(Dimension), Offset(margin_width),
121 	XmRImmediate, (XtPointer)10
122     },
123     {
124 	XmNmarginHeight, XmCMarginHeight, XmRVerticalDimension,
125 	sizeof(Dimension), Offset(margin_height),
126 	XmRImmediate, (XtPointer)10
127     },
128     {
129 	XmNdefaultButton, XmCWidget, XmRWidget,
130 	sizeof(Widget), Offset(default_button),
131 	XmRImmediate, (XtPointer)NULL
132     },
133     {
134 	XmNcancelButton, XmCWidget, XmRWidget,
135 	sizeof(Widget), Offset(cancel_button),
136 	XmRImmediate, (XtPointer)NULL
137     },
138     {
139 	XmNfocusCallback, XmCCallback, XmRCallback,
140 	sizeof(XtCallbackList), Offset(focus_callback),
141 	XmRImmediate, (XtPointer)NULL
142     },
143     {
144 	XmNmapCallback, XmCCallback, XmRCallback,
145 	sizeof(XtCallbackList), Offset(map_callback),
146 	XmRImmediate, (XtPointer)NULL
147     },
148     {
149 	XmNunmapCallback, XmCCallback, XmRCallback,
150 	sizeof(XtCallbackList), Offset(unmap_callback),
151 	XmRImmediate, (XtPointer)NULL
152     },
153     {
154 	XmNbuttonFontList, XmCButtonFontList, XmRFontList,
155 	sizeof(XmFontList), Offset(button_font_list),
156 	XmRFontList, (XtPointer)NULL
157     },
158     {
159 	XmNlabelFontList, XmCLabelFontList, XmRFontList,
160 	sizeof(XmFontList), Offset(label_font_list),
161 	XmRFontList, (XtPointer)NULL
162     },
163     {
164 	XmNtextFontList, XmCTextFontList, XmRFontList,
165 	sizeof(XmFontList), Offset(text_font_list),
166 	XmRFontList, (XtPointer)NULL
167     },
168     {
169 	XmNtextTranslations, XmCTranslations, XmRTranslationTable,
170 	sizeof(XtTranslations), Offset(text_translations),
171 	XmRImmediate, (XtPointer)NULL
172     },
173     {
174 	XmNallowOverlap, XmCAllowOverlap, XmRBoolean,
175 	sizeof(Boolean), Offset(allow_overlap),
176 	XmRImmediate, (XtPointer)True
177     },
178     {
179 	XmNautoUnmanage, XmCAutoUnmanage, XmRBoolean,
180 	sizeof(Boolean), Offset(auto_unmanage),
181 	XmRImmediate, (XtPointer)True
182     },
183     {
184 	XmNdefaultPosition, XmCDefaultPosition, XmRBoolean,
185 	sizeof(Boolean), Offset(default_position),
186 	XmRImmediate, (XtPointer)True
187     },
188     {
189 	XmNresizePolicy, XmCResizePolicy, XmRResizePolicy,
190 	sizeof(unsigned char), Offset(resize_policy),
191 	XmRImmediate, (XtPointer)XmRESIZE_ANY
192     },
193     {
194 	XmNnoResize, XmCNoResize, XmRBoolean,
195 	sizeof(Boolean), Offset(no_resize),
196 	XmRImmediate, (XtPointer)False
197     },
198     {
199 	XmNdialogStyle, XmCDialogStyle, XmRDialogStyle,
200 	sizeof(unsigned char), Offset(dialog_style),
201 	XmRCallProc, (XtPointer)_XmBulletinBoardDialogStyleDefault
202     },
203     {
204 	XmNdialogTitle, XmCDialogTitle, XmRXmString,
205 	sizeof(XmString), Offset(dialog_title),
206 	XmRString, (XtPointer)NULL
207     },
208 };
209 
210 static XmSyntheticResource syn_resources[] =
211 {
212     {
213 	XmNdialogTitle,
214 	sizeof(XmString), Offset(dialog_title),
215 	_XmExportXmString, NULL
216     },
217     {
218 	XmNmarginWidth,
219 	sizeof(Dimension), Offset(margin_width),
220 	_XmFromHorizontalPixels, _XmToHorizontalPixels
221     },
222     {
223 	XmNmarginHeight,
224 	sizeof(Dimension), Offset(margin_height),
225 	_XmFromVerticalPixels, _XmToVerticalPixels
226     }
227 };
228 
229 static char _XmBulletinB_mapTranslations[] =
230 	"";
231 
232 static XtActionsRec actions[] =
233 {
234     /* {"Return", _XmReturn}, */
235     {"BulletinBoardReturn", (XtActionProc)_XmBulletinBoardReturn},
236     {"BulletinBoardCancel", (XtActionProc)_XmBulletinBoardCancel},
237 };
238 
239 static XtTranslations mapTrans;
240 static XtTranslations defTrans;
241 
242 #if 0
243 static XmBaseClassExtRec _XmBulletinBCoreClassExtRec = {
244     /* next_extension            */ NULL,
245     /* record_type               */ NULLQUARK,
246     /* version                   */ XmBaseClassExtVersion,
247     /* size                      */ sizeof(XmBaseClassExtRec),
248     /* initialize_prehook        */ NULL,
249     /* set_values_prehook        */ NULL,
250     /* initialize_posthook       */ NULL,
251     /* set_values_posthook       */ NULL,
252     /* secondary_object_class    */ NULL,
253     /* secondary_object_create   */ NULL,
254     /* get_secondary_resources   */ NULL,
255     /* fast_subclass             */ { 0 },
256     /* get_values_prehook        */ NULL,
257     /* get_values_posthook       */ NULL,
258     /* class_part_init_prehook   */ NULL,
259     /* class_part_init_posthook  */ NULL,
260     /* ext_resources             */ NULL,
261     /* compiled_ext_resources    */ NULL,
262     /* num_ext_resources         */ 0,
263     /* use_sub_resources         */ False,
264     /* widget_navigable          */ XmInheritWidgetNavigable,
265     /* focus_change              */ XmInheritFocusChange,
266     /* wrapper_data              */ NULL
267 };
268 
269 static CompositeClassExtensionRec bbCompositeExt =
270 {
271     /* next_extension */  NULL,
272     /* record_type    */  NULLQUARK,
273     /* version        */  XtCompositeExtensionVersion,
274     /* record_size    */  sizeof(CompositeClassExtensionRec),
275     /* accepts_objects */ True,
276 #if XtSpecificationRelease >= 6
277     /* allows_change_managed_set */ True
278 #endif
279 };
280 
281 static XmManagerClassExtRec _XmBulletinBMClassExtRec = {
282     /* next_extension            */ NULL,
283     /* record_type               */ NULLQUARK,
284     /* version                   */ XmManagerClassExtVersion,
285     /* record_size               */ sizeof(XmManagerClassExtRec),
286     /* traversal_children        */ NULL
287 };
288 #endif
289 
290 XmBulletinBoardClassRec xmBulletinBoardClassRec = {
291     /* Core class part */
292     {
293 	/* superclass            */ (WidgetClass) &xmManagerClassRec,
294         /* class_name            */ "XmBulletinBoard",
295 	/* widget_size           */ sizeof(XmBulletinBoardRec),
296 	/* class_initialize      */ class_initialize,
297 	/* class_part_initialize */ class_part_initialize,
298 	/* class_inited          */ False,
299 	/* initialize            */ initialize,
300 	/* initialize_hook       */ NULL,
301 	/* realize               */ XtInheritRealize /*realize*/,
302 	/* actions               */ actions,
303 	/* num_actions           */ XtNumber(actions),
304 	/* resources             */ resources,
305 	/* num_resources         */ XtNumber(resources),
306 	/* xrm_class             */ NULLQUARK,
307 	/* compress_motion       */ True,
308 	/* compress_exposure     */ XtExposeCompressMaximal,
309 	/* compress_enterleave   */ True,
310 	/* visible_interest      */ False,
311 	/* destroy               */ destroy,
312 	/* resize                */ resize,
313 	/* expose                */ expose,
314 	/* set_values            */ set_values,
315 	/* set_values_hook       */ NULL,
316 	/* set_values_almost     */ XtInheritSetValuesAlmost,
317 	/* get_values_hook       */ NULL,
318 	/* accept_focus          */ NULL,
319 	/* version               */ XtVersion,
320 	/* callback offsets      */ NULL,
321 	/* tm_table              */ _XmBulletinB_defaultTranslations,
322 	/* query_geometry        */ query_geometry,
323 	/* display_accelerator   */ NULL,
324 	/* extension             */ (XtPointer)NULL /*&_XmBulletinBCoreClassExtRec*/
325     },
326     /* Composite class part */
327     {
328 	/* geometry manager */ geometry_manager,
329         /* change_managed   */ change_managed,
330         /* insert_child     */ insert_child,
331         /* delete_child     */ delete_child,
332         /* extension        */ (XtPointer)NULL /*&bbCompositeExt,*/
333     },
334     /* Constraint class part */
335     {
336 	/* subresources      */ NULL,
337         /* subresource_count */ 0,
338         /* constraint_size   */ 0,
339         /* initialize        */ NULL /*constraint_initialize*/,
340         /* destroy           */ NULL,
341         /* set_values        */ NULL /*constraint_set_values*/,
342         /* extension         */ NULL,
343     },
344     /* XmManager class part */
345     {
346 	/* translations                 */ XtInheritTranslations,
347         /* syn_resources                */ syn_resources,
348         /* num_syn_resources            */ XtNumber(syn_resources),
349         /* syn_constraint_resources     */ NULL,
350         /* num_syn_constraint_resources */ 0,
351         /* parent_process               */ _XmBBParentProcess,
352 	/* extension                    */ (XtPointer)NULL /*&_XmBulletinBMClassExtRec*/
353     },
354     /* XmBulletinBoard class part */
355     {
356 	/* always_install_accelerators	*/ False,
357 	/* geo_matrix_create		*/ NULL,
358 	/* focus_moved_proc		*/ NULL,
359 	/* extension			*/ NULL,
360     },
361 };
362 
363 static XmSpecRenderTraitRec _XmBulletinBoardTraitRec = {
364 	/* version      */      0,
365 	/* cb           */      GetRenderTable
366 };
367 
368 WidgetClass xmBulletinBoardWidgetClass = (WidgetClass)&xmBulletinBoardClassRec;
369 
370 static void
class_initialize(void)371 class_initialize(void)
372 {
373 	/* Motif does not have this method */
374 #if 0
375 	_XmBulletinBCoreClassExtRec.record_type = XmQmotif;
376 #endif
377 
378 	mapTrans = XtParseTranslationTable(_XmBulletinB_mapTranslations);
379 	defTrans = XtParseTranslationTable(_XmBulletinB_defaultTranslations);
380 
381 	if (! XmeTraitSet((XtPointer)xmBulletinBoardWidgetClass, XmQTspecifyRenderTable,
382 			(XtPointer)&_XmBulletinBoardTraitRec)) {
383 		_XmWarning(NULL, "XmBulletinBoard ClassInitialize: XmeTraitSet failed\n");
384 	}
385 }
386 
387 static void
class_part_initialize(WidgetClass widget_class)388 class_part_initialize(WidgetClass widget_class)
389 {
390     XmBulletinBoardWidgetClass bbclass =
391     (XmBulletinBoardWidgetClass)widget_class;
392     XmBulletinBoardWidgetClass sclass =
393     (XmBulletinBoardWidgetClass)(widget_class->core_class.superclass);
394     CompositeClassExtension ext, *extptr;
395 
396     extptr = (CompositeClassExtension *)_XmGetClassExtensionPtr(
397 		    (XmGenericClassExt *)&(bbclass->composite_class.extension),
398 								   NULLQUARK);
399 
400     if (extptr == NULL || *extptr == NULL)
401     {
402 	ext = (CompositeClassExtension)XtNew(CompositeClassExtensionRec);
403 
404 	if (ext != NULL)
405 	{
406 	    ext->next_extension = bbclass->composite_class.extension;
407 	    ext->record_type = NULLQUARK;
408 	    ext->version = XtCompositeExtensionVersion;
409 	    ext->record_size = sizeof(CompositeClassExtensionRec);
410 	    ext->accepts_objects = True;
411 #if XtSpecificationRelease >= 6
412 	    ext->allows_change_managed_set = True;
413 #endif
414 	    bbclass->composite_class.extension = (XtPointer)ext;
415 	}
416     }
417     else if (!(*extptr)->accepts_objects)
418     {
419 	(*extptr)->accepts_objects = True;
420     }
421 
422     if (bbclass->bulletin_board_class.geo_matrix_create ==
423 	XmInheritGeoMatrixCreate && widget_class != xmBulletinBoardWidgetClass)
424     {
425 	bbclass->bulletin_board_class.geo_matrix_create =
426 	    sclass->bulletin_board_class.geo_matrix_create;
427     }
428 
429     if (bbclass->bulletin_board_class.focus_moved_proc ==
430 	XmInheritFocusMovedProc)
431     {
432 	if (sclass->bulletin_board_class.focus_moved_proc)
433 	{
434 	    bbclass->bulletin_board_class.focus_moved_proc =
435 		sclass->bulletin_board_class.focus_moved_proc;
436 	}
437 	else
438 	{
439 	    bbclass->bulletin_board_class.focus_moved_proc =
440 		_XmBulletinBoardFocusMoved;
441 	}
442     }
443 
444     _XmFastSubclassInit(widget_class, XmBULLETIN_BOARD_BIT);
445 }
446 
447 static void
initialize(Widget request,Widget new_w,ArgList args,Cardinal * num_args)448 initialize(Widget request, Widget new_w, ArgList args, Cardinal *num_args)
449 {
450     XmBulletinBoardWidget bb = (XmBulletinBoardWidget)new_w;
451     XmBulletinBoardWidgetClass bbclass;
452 
453     DEBUGOUT(_LtDebug(__FILE__, new_w, "BB Initialize LabelFontList %p ButtonFontList %p\n",
454 			    BB_LabelFontList(bb), BB_ButtonFontList(bb)));
455 
456         if (!BB_LabelFontList(bb)) {
457 		BB_LabelFontList(bb) = _XmGetDefaultFontList(new_w, XmLABEL_FONTLIST);
458         } else {
459 		BB_LabelFontList(bb) = XmFontListCopy(BB_LabelFontList(new_w));
460 	}
461 
462 	if (!BB_ButtonFontList(bb)) {
463 		BB_ButtonFontList(bb) = _XmGetDefaultFontList(new_w, XmBUTTON_FONTLIST);
464 	} else {
465 		BB_ButtonFontList(bb) = XmFontListCopy(BB_ButtonFontList(new_w));
466 	}
467 
468 	if (!BB_TextFontList(bb)) {
469 		BB_TextFontList(bb) = _XmGetDefaultFontList(new_w, XmTEXT_FONTLIST);
470 	} else {
471 		BB_TextFontList(bb) = XmFontListCopy(BB_TextFontList(new_w));
472 	}
473 
474     if (((XmBulletinBoardWidgetClass)XtClass(new_w))->bulletin_board_class.always_install_accelerators)
475     {
476 	XtAugmentTranslations(new_w, mapTrans);
477 	XtAugmentTranslations(new_w, defTrans);
478     }
479     /* rws 30 Aug 1998
480        We seem to loose a few hundred bytes every time we parse a translation
481        table, so like mapTrans lets parse it in class_initialize and use the
482        parsed version here.
483     XtAugmentTranslations(new_w,
484 		  XtParseTranslationTable(_XmBulletinB_defaultTranslations));
485 		  */
486 
487     if (XmIsDialogShell(XtParent(new_w)))
488     {
489 	DEBUGOUT(_LtDebug(__FILE__, new_w, "Init(%s)\n",
490 		_LtDebugDialogStyle2String(BB_DialogStyle(new_w))));
491 	switch (BB_DialogStyle(new_w))
492 	{
493 	case XmDIALOG_MODELESS:
494 	    XtVaSetValues(XtParent(new_w), XmNmwmInputMode,
495 			  MWM_INPUT_MODELESS, NULL);
496 	    break;
497 
498 	case XmDIALOG_PRIMARY_APPLICATION_MODAL:
499 	    XtVaSetValues(XtParent(new_w), XmNmwmInputMode,
500 			  MWM_INPUT_PRIMARY_APPLICATION_MODAL, NULL);
501 	    break;
502 
503 	case XmDIALOG_FULL_APPLICATION_MODAL:
504 	    XtVaSetValues(XtParent(new_w), XmNmwmInputMode,
505 			  MWM_INPUT_FULL_APPLICATION_MODAL, NULL);
506 	    break;
507 
508 	case XmDIALOG_SYSTEM_MODAL:
509 	    XtVaSetValues(XtParent(new_w), XmNmwmInputMode,
510 			  MWM_INPUT_SYSTEM_MODAL, NULL);
511 	    break;
512 	}
513 	/*
514 	 * --aldi: Better do the realize call of our parent -- which is a
515 	 * shell -- first here. Otherwise we have *real trouble* with
516 	 * the grab mechanism. This replaces the call to XtRealizeWidget()
517 	 * within the initialize_posthook() method of the BulletinBoard
518 	 * class. And it does get us rid off that %&!$ double installed
519 	 * grabs when using a dialog shell.
520 	 */
521 	XtRealizeWidget(XtParent(new_w));
522 
523 	/*
524 	 * Shouldn't this be in synthetic resource handlers?
525 	 *
526 	 * MLM: No.  The bottom line is that the resource converter can
527 	 * bypass the arglist passed to initialize; this means that it
528 	 * makes just as much sense to catch this here as it does in a
529 	 * Synth resource handler, and duplicating the work here.  This
530 	 * little jewel of knowledge came from Danny and I working out the
531 	 * rules for internal strings, as applicable for Labels.
532 	 */
533 	if (BB_DialogTitle(new_w))
534 	{
535 	    char *p;
536 
537 	    if ((p = _XmStringGetTextConcat(BB_DialogTitle(new_w))))
538 	    {
539 		XtVaSetValues(XtParent(new_w), XtNtitle, p, NULL);
540 		XtFree(p);
541 	    }
542 
543 	    BB_DialogTitle(new_w) = XmStringCopy(BB_DialogTitle(new_w));
544 	}
545     }
546 
547     if (XtIsSubclass(XtParent(new_w), xmDialogShellWidgetClass) ||
548 	XtIsSubclass(XtParent(new_w), vendorShellWidgetClass))
549     {
550 	if (MGR_ShadowThickness(new_w) == 0)
551 	{
552 	    MGR_ShadowThickness(new_w) = 1;
553 	}
554     }
555 
556     BB_DynamicDefaultButton(new_w) = NULL;
557     BB_DynamicCancelButton(new_w) = NULL;
558 
559     bbclass = (XmBulletinBoardWidgetClass)XtClass(new_w);
560     if (bbclass->bulletin_board_class.focus_moved_proc)
561     {
562 	Widget ve;
563 
564 	if ((ve = _LtFindVendorExt(new_w)) != NULL)
565 	{
566 	    _XtAddCallback(&VSEP_FocusMovedCallback(ve),
567 			   bbclass->bulletin_board_class.focus_moved_proc,
568                            (XtPointer)new_w);
569 	}
570     }
571 
572     /* initialize these to values that aren't possible */
573     BB_OldWidth(new_w) = -1;
574     BB_OldHeight(new_w) = -1;
575     BB_OldShadowThickness(new_w) = 0; /* better than uninitialized */
576 
577     BB_GeoCache(new_w) = NULL;
578     MGR_InitialFocus(new_w) = BB_DefaultButton(new_w);
579     BB_InSetValues(new_w) = False;
580 }
581 
582 static void
destroy(Widget w)583 destroy(Widget w)
584 {
585   Widget ve;
586 
587     DEBUGOUT(_LtDebug("RWS", w,"%s:destroy(%d)\n",
588     	__FILE__, __LINE__
589     	));
590 
591     if (BB_DialogTitle(w))
592         XmStringFree(BB_DialogTitle(w));
593     XmFontListFree(BB_LabelFontList(w));
594     XmFontListFree(BB_ButtonFontList(w));
595     XmFontListFree(BB_TextFontList(w));
596     if ((ve = _LtFindVendorExt(w)) != NULL)
597       {
598 	_XtRemoveAllCallbacks(&VSEP_FocusMovedCallback(ve));
599 	/* mitch
600 	XtRemoveAllCallbacks(ve,XmNfocusMovedCallback);
601 	*/
602       }
603 
604 
605 }
606 
607 static Boolean
set_values(Widget old,Widget request,Widget new_w,ArgList args,Cardinal * num_args)608 set_values(Widget old,
609 	   Widget request,
610 	   Widget new_w,
611 	   ArgList args,
612 	   Cardinal *num_args)
613 {
614     XmBulletinBoardWidget ow = (XmBulletinBoardWidget)old;
615     XmBulletinBoardWidget nw = (XmBulletinBoardWidget)new_w;
616     Boolean need_refresh = False;
617 
618     DEBUGOUT(_LtDebug(__FILE__, new_w,
619 		      "%s(%d):set_values - %i args\n"
620 		      "\t    old X %5i Y %5i W %5i H %5i\n"
621 		      "\trequest X %5i Y %5i W %5i H %5i\n"
622 		      "\t  new_w X %5i Y %5i W %5i H %5i\n",
623 		      __FILE__, __LINE__,
624 		      *num_args,
625 		      XtX(old), XtY(old),
626 		      XtWidth(old), XtHeight(old),
627 		      XtX(request), XtY(request),
628 		      XtWidth(request), XtHeight(request),
629 		      XtX(new_w), XtY(new_w),
630 		      XtWidth(new_w), XtHeight(new_w)));
631     DEBUGOUT(_LtDebugPrintArgList(__FILE__, new_w, args, *num_args, False));
632 
633     BB_InSetValues(new_w) = True;
634 
635     if (BB_DefaultButton(ow) != BB_DefaultButton(nw))
636     {
637 	Cardinal i;
638 
639 	/* the default button has changed, so set the old one's showAsDefault
640 	   to 0, and make the new one display as the default. */
641 
642 	for (i = 0; i < MGR_NumChildren(new_w); i++)
643 	{
644 	    _XmBulletinBoardSetDefaultShadow(MGR_Children(new_w)[i]);
645 	}
646 
647 	_XmBBUpdateDynDefaultButton(new_w);
648 
649 	MGR_InitialFocus(new_w) = BB_DefaultButton(nw);
650 	need_refresh = True;	/* do we need to ? */
651     }
652 
653     if (XmIsDialogShell(XtParent(new_w)))
654     {
655 	/*
656 	 * Shouldn't this be in synthetic resource handlers ?
657 	 * MLM 960524 not according to a dump of the synthetics.  Only an
658 	 * export proc is given, to copy the existing title.
659 	 */
660 	if (!XmStringCompare(BB_DialogTitle(old), BB_DialogTitle(new_w)))
661 	{
662 	    char *p;
663 
664 	    if ((p = _XmStringGetTextConcat(BB_DialogTitle(new_w))))
665 	    {
666 		XtVaSetValues(XtParent(new_w), XtNtitle, p, NULL);
667 		XtFree(p);
668 		BB_DialogTitle(new_w) = XmStringCopy(BB_DialogTitle(new_w));
669 	    }
670 
671             XmStringFree(BB_DialogTitle(old));
672         }
673         else if (BB_DialogTitle(old) != BB_DialogTitle(new_w))
674         {
675             BB_DialogTitle(new_w) = XmStringCopy(BB_DialogTitle(new_w));
676 	    XmStringFree(BB_DialogTitle(old));
677 	}
678 
679 #if 0
680 	/*
681 	 * If we're a dialog, refuse to be placed away from 0,0
682 	 */
683 	/* rws 23 Jan 1999
684 	   Na, let DialogShell handle the geometry request that Xt will make.
685 	 */
686 	if (XtX(new_w) != 0)
687 	{
688 	    XtX(new_w) = 0;
689 	    need_refresh = True;
690 	}
691 
692 	if (XtY(new_w) != 0)
693 	{
694 	    XtY(new_w) = 0;
695 	    need_refresh = True;
696 	}
697 #endif
698     }
699 
700     if (XmIsDialogShell(XtParent(new_w)))
701     {
702 	if (BB_DialogStyle(new_w) != BB_DialogStyle(old))
703 	{
704 	    DEBUGOUT(_LtDebug(__FILE__, new_w, "SetValues(%s)\n",
705 	    	_LtDebugDialogStyle2String(BB_DialogStyle(new_w))));
706 
707 	    switch (BB_DialogStyle(new_w))
708 	    {
709 	    case XmDIALOG_MODELESS:
710 		XtVaSetValues(XtParent(new_w), XmNmwmInputMode,
711 			      MWM_INPUT_MODELESS, NULL);
712 		break;
713 
714 	    case XmDIALOG_PRIMARY_APPLICATION_MODAL:
715 		XtVaSetValues(XtParent(new_w), XmNmwmInputMode,
716 			      MWM_INPUT_PRIMARY_APPLICATION_MODAL, NULL);
717 		break;
718 
719 	    case XmDIALOG_FULL_APPLICATION_MODAL:
720 		XtVaSetValues(XtParent(new_w), XmNmwmInputMode,
721 			      MWM_INPUT_FULL_APPLICATION_MODAL, NULL);
722 		break;
723 
724 	    case XmDIALOG_SYSTEM_MODAL:
725 		XtVaSetValues(XtParent(new_w), XmNmwmInputMode,
726 			      MWM_INPUT_SYSTEM_MODAL, NULL);
727 		break;
728 
729 	    }
730 	}
731     }
732 
733     if (BB_LabelFontList(new_w) != BB_LabelFontList(old))
734     {
735 	XmFontListFree(BB_LabelFontList(old));
736 	BB_LabelFontList(new_w) = XmFontListCopy(BB_LabelFontList(new_w));
737     }
738 
739     if (BB_ButtonFontList(new_w) != BB_ButtonFontList(old))
740     {
741 	XmFontListFree(BB_ButtonFontList(old));
742 	BB_ButtonFontList(new_w) = XmFontListCopy(BB_ButtonFontList(new_w));
743     }
744 
745     if (BB_TextFontList(new_w) != BB_TextFontList(old))
746     {
747 	XmFontListFree(BB_TextFontList(old));
748 	BB_TextFontList(new_w) = XmFontListCopy(BB_TextFontList(new_w));
749     }
750 
751     BB_InSetValues(new_w) = False;
752 
753     if (XtWidth(new_w) != XtWidth(old) || XtHeight(new_w) != XtHeight(old))
754     {
755 	need_refresh = True;
756     }
757 
758     if (need_refresh == True && XtClass(new_w) == xmBulletinBoardWidgetClass)
759     {
760 	_XmBulletinBoardSizeUpdate(new_w);
761 	return False;
762     }
763 
764     return need_refresh;
765 }
766 
767 static XtGeometryResult
query_geometry(Widget w,XtWidgetGeometry * proposed,XtWidgetGeometry * answer)768 query_geometry(Widget w, XtWidgetGeometry *proposed, XtWidgetGeometry *answer)
769 {
770     XmBulletinBoardWidgetClass bbc = (XmBulletinBoardWidgetClass)XtClass(w);
771     XtGeometryResult res;
772 
773     DEBUGOUT(_LtDebug(__FILE__, w, "%s:query_geometry(%d) - proposed %s\n",
774     		__FILE__, __LINE__,
775     		_LtDebugWidgetGeometry2String(proposed)));
776 
777     if (bbc->bulletin_board_class.geo_matrix_create)
778     {
779 	res = _XmHandleQueryGeometry(w, proposed, answer, BB_ResizePolicy(w),
780 				  bbc->bulletin_board_class.geo_matrix_create);
781 
782 	return res;
783     }
784 
785     res = _XmGMHandleQueryGeometry(w, proposed, answer,
786 				   BB_MarginWidth(w), BB_MarginHeight(w),
787 				   BB_ResizePolicy(w));
788 
789     DEBUGOUT(_LtDebug(__FILE__, w,
790 		      "BB wants %d %d\n", answer->width, answer->height));
791 
792     return res;
793 }
794 
795 static void
handle_resize(Widget w,XmGeoCreateProc mat_make)796 handle_resize(Widget w, XmGeoCreateProc mat_make)
797 {
798     Dimension wd, ht;
799     XmGeoMatrix geo;
800 
801     wd = XtWidth(w);
802     ht = XtHeight(w);
803 
804     geo = mat_make(w, NULL, NULL);
805 
806     _XmGeoMatrixGet(geo, XmGET_PREFERRED_SIZE);
807 
808     _XmGeoArrangeBoxes(geo, 0, 0, &wd, &ht);
809 
810     _XmGeoMatrixSet(geo);
811 
812     if (XtIsRealized(w))
813     {
814 	_XmClearShadowType(w, BB_OldWidth(w), BB_OldHeight(w),
815 			   BB_OldShadowThickness(w), 0);
816 
817 	_XmDrawShadows(XtDisplay(w), XtWindow(w),
818 		       MGR_TopShadowGC(w), MGR_BottomShadowGC(w),
819 		       0, 0, XtWidth(w), XtHeight(w),
820 		       MGR_ShadowThickness(w), BB_ShadowType(w));
821     }
822 
823     _XmGeoMatrixFree(geo);
824 
825     /*
826     BB_OldWidth(w) = XtWidth(w);
827     BB_OldHeight(w) = XtHeight(w);
828     BB_OldShadowThickness(w) = MGR_ShadowThickness(w);
829     */
830 }
831 
832 static void
resize(Widget w)833 resize(Widget w)
834 {
835     XmBulletinBoardClassRec *bb = (XmBulletinBoardClassRec *)XtClass(w);
836 
837     DEBUGOUT(_LtDebug(__FILE__, w, "resize\n"));
838 
839     if (bb->bulletin_board_class.geo_matrix_create)
840     {
841 	handle_resize(w, bb->bulletin_board_class.geo_matrix_create);
842 
843 	return;
844     }
845 
846     _XmGMEnforceMargin(w,
847 		       BB_MarginWidth(w), BB_MarginHeight(w),
848 		       False);
849 
850 #if 0
851     _XmClearShadowType(w, BB_OldWidth(w), BB_OldHeight(w),
852 		       BB_OldShadowThickness(w), 0);
853 
854     BB_OldShadowThickness(w) = 0;
855 #endif
856 
857 #if 0
858     /* rws 21 Jul 1998
859        _XmGMDoLayout will request a new size from the parent if it wants to.
860        This is bad in the resize method, we have to live with the size we
861        are given!  Since BulletinBoard, without a GeoMatrix proc, doesn't
862        layout much of anything, let's just skip this and see what happens.
863        This should not affect any of the standard dialogs since they all
864        use the GeoMatirx. ( test/Xm/pushbg/test8 )
865      */
866     if (XtIsRealized(w) || XtWidth(w) == 0 || XtHeight(w) == 0)
867     {
868 	_XmGMDoLayout(w, BB_MarginWidth(w), BB_MarginHeight(w),
869 		      BB_ResizePolicy(w), True);
870     }
871 #endif
872 
873 #if 0
874     if ((XtWidth(w) < BB_OldWidth(w) || XtHeight(w) < BB_OldHeight(w)) &&
875 	XtIsRealized(w))
876     {
877 	_XmDrawShadows(XtDisplay(w), XtWindow(w),
878 		       MGR_TopShadowGC(w), MGR_BottomShadowGC(w),
879 		       0, 0, XtWidth(w), XtHeight(w),
880 		       MGR_ShadowThickness(w), BB_ShadowType(w));
881     }
882 
883     BB_OldWidth(w) = XtWidth(w);
884     BB_OldHeight(w) = XtHeight(w);
885     BB_OldShadowThickness(w) = MGR_ShadowThickness(w);
886 #endif
887 }
888 
889 /*
890  * handle subclasses that use the GeoCache
891  */
892 static XtGeometryResult
handle_geometry_manager(Widget w,XtWidgetGeometry * desired,XtWidgetGeometry * allowed,XmGeoCreateProc mat_make)893 handle_geometry_manager(Widget w,
894 			XtWidgetGeometry *desired, XtWidgetGeometry *allowed,
895 			XmGeoCreateProc mat_make)
896 {
897     Widget bb = XtParent(w);
898     XtGeometryResult res;
899 
900     DEBUGOUT(_LtDebug2(__FILE__, bb, w,
901 		       "handle_geometry_manager\n\tdesired %s\n",
902 		       	_LtDebugWidgetGeometry2String(desired)));
903 
904     if (!(desired->request_mode & (CWWidth | CWHeight)))
905     {
906 	return XtGeometryYes;
907     }
908 
909     if (BB_OldShadowThickness(bb) != 0 ||
910 	BB_ResizePolicy(bb) != XmRESIZE_NONE)
911     {
912 	_XmClearShadowType(bb, BB_OldWidth(bb), BB_OldHeight(bb),
913 			   BB_OldShadowThickness(bb), 0);
914 	BB_OldShadowThickness(bb) = 0;
915     }
916 
917     res = _XmHandleGeometryManager(bb, w, desired, allowed,
918 				   BB_ResizePolicy(bb), &BB_GeoCache(bb),
919 				   mat_make);
920 
921     if (!BB_InSetValues(bb) ||
922 	XtWidth(bb) > BB_OldWidth(bb) || XtHeight(bb) > BB_OldHeight(bb))
923     {
924 	if (XtIsRealized(bb))
925 	{
926 	    _XmClearBorder(XtDisplay(bb), XtWindow(bb),
927 		       0,0,
928 			BB_OldWidth(bb), BB_OldHeight(bb),
929 			BB_OldShadowThickness(bb));
930 	    _XmDrawShadows(XtDisplay(bb), XtWindow(bb),
931 			   MGR_TopShadowGC(bb), MGR_BottomShadowGC(bb),
932 			   0, 0, XtWidth(bb), XtHeight(bb),
933 			   MGR_ShadowThickness(bb), BB_ShadowType(bb));
934 	}
935     }
936 
937     BB_OldWidth(bb) = XtWidth(bb);
938     BB_OldHeight(bb) = XtHeight(bb);
939     BB_OldShadowThickness(bb) = MGR_ShadowThickness(bb);
940 
941     return res;
942 }
943 
944 /*
945  * Geometry Manager is always called by a child of BB.
946  *      It asks to get a different geometry. We may allow this.
947  *      Also we may have to resize ourself because of this.
948  */
949 static XtGeometryResult
geometry_manager(Widget w,XtWidgetGeometry * desired,XtWidgetGeometry * allowed)950 geometry_manager(Widget w, XtWidgetGeometry *desired, XtWidgetGeometry *allowed)
951 {
952     Widget bb = XtParent(w);
953     XmBulletinBoardWidgetClass bbc = (XmBulletinBoardWidgetClass)XtClass(bb);
954 
955     DEBUGOUT(_LtDebug2(__FILE__, bb, w, "GeometryManager\n"));
956 
957     if (bbc->bulletin_board_class.geo_matrix_create)
958     {
959 	return handle_geometry_manager(w, desired, allowed,
960 				  bbc->bulletin_board_class.geo_matrix_create);
961     }
962 
963     return _XmGMHandleGeometryManager(bb, w, desired, allowed,
964 				      BB_MarginWidth(bb), BB_MarginHeight(bb),
965 				      BB_ResizePolicy(bb), BB_AllowOverlap(bb));
966 }
967 
968 static void
handle_change_managed(Widget w,XmGeoCreateProc mat_make)969 handle_change_managed(Widget w, XmGeoCreateProc mat_make)
970 {
971     Dimension wd, ht;
972     XmGeoMatrix geo;
973     XtWidgetGeometry request;
974 
975     if (!XtIsRealized(w))
976     {
977 	/* rws 5 Apr 1998
978 	   If we are not realized use the width/height. This will be
979 	   the user specified size, or 0x0 if not specified.
980 	 */
981 #if 0
982 	wd = ht = 0;
983 #else
984 	wd = XtWidth(w);
985 	ht = XtHeight(w);
986 #endif
987     }
988     else if (BB_ResizePolicy(w) != XmNONE)
989     {
990 	wd = ht = 0;
991     }
992     else
993     {
994 	wd = XtWidth(w);
995 	ht = XtHeight(w);
996     }
997 
998     geo = mat_make(w, NULL, NULL);
999 
1000     _XmGeoMatrixGet(geo, XmGET_PREFERRED_SIZE);
1001 
1002     _XmGeoArrangeBoxes(geo, 0, 0, &wd, &ht);
1003 
1004     if (BB_ResizePolicy(w) == XmRESIZE_GROW)
1005     {
1006 	/* check the return against the original.  If the procedure would
1007 	 * like the BB to shrink, call again */
1008 	if (wd < XtWidth(w) || ht < XtHeight(w))
1009 	{
1010 	    wd = XtWidth(w);
1011 	    ht = XtHeight(w);
1012 	    _XmGeoArrangeBoxes(geo, 0, 0, &wd, &ht);
1013 	}
1014     }
1015 
1016     if (wd == XtWidth(w) && ht == XtHeight(w))
1017     {
1018 	/* rws 16 Aug 1998
1019 	   Ok, so the BB hasn't changed size so we do not need to make the
1020 	   geo request but, the kids may not have been positioned yet, see
1021 	   messagebox/test14.  So, let's always do the set.
1022 	 */
1023 	_XmGeoMatrixSet(geo);
1024 	_XmGeoMatrixFree(geo);
1025 	_XmNavigChangeManaged(w);
1026 
1027 	return;
1028     }
1029 
1030     request.request_mode = (CWWidth | CWHeight);
1031     request.width = wd;
1032     request.height = ht;
1033     request.request_mode |= CWBorderWidth;
1034     request.border_width = XtBorderWidth(w);
1035 
1036     {
1037     XtGeometryResult res;
1038 
1039 	res = _XmMakeGeometryRequest(w, &request);
1040 	DEBUGOUT(_LtDebug(__FILE__, w, "handle_change_managed request %s %s\n",
1041 		_LtDebugWidgetGeometry2String(&request),
1042 		_LtDebugGeometryResult2String(res)));
1043     	if (res == XtGeometryNo)
1044     	{
1045 	    /* rws 16 Aug 1998
1046 	       If the parent says NO we must re-layout the kids, since they
1047 	       are laid out to their preferred places at this point.
1048 	       (messagebox/test13)
1049 	     */
1050 	    request.width = XtWidth(w);
1051 	    request.height = XtHeight(w);
1052     	}
1053     }
1054 
1055     if (request.width != wd || request.height != ht)
1056     {
1057 	_XmGeoArrangeBoxes(geo, 0, 0, &request.width, &request.height);
1058     }
1059 
1060     _XmGeoMatrixSet(geo);
1061 
1062     if (XtIsRealized(w))
1063     {
1064 	_XmClearShadowType(w, BB_OldWidth(w), BB_OldHeight(w),
1065 			   BB_OldShadowThickness(w), 0);
1066 
1067 	_XmDrawShadows(XtDisplay(w), XtWindow(w),
1068 		       MGR_TopShadowGC(w), MGR_BottomShadowGC(w),
1069 		       0, 0, XtWidth(w), XtHeight(w),
1070 		       MGR_ShadowThickness(w), BB_ShadowType(w));
1071     }
1072 
1073     _XmGeoMatrixFree(geo);
1074 
1075     BB_OldWidth(w) = XtWidth(w);
1076     BB_OldHeight(w) = XtHeight(w);
1077     BB_OldShadowThickness(w) = MGR_ShadowThickness(w);
1078 
1079     _XmNavigChangeManaged(w);
1080 }
1081 
1082 static void
change_managed(Widget w)1083 change_managed(Widget w)
1084 {
1085 	XmBulletinBoardClassRec *bb = (XmBulletinBoardClassRec *)XtClass(w);
1086 
1087 	/*
1088 	 * Try to get the MODAL behaviour rolling.
1089 	 */
1090 	DEBUGOUT(_LtDebug(__FILE__, w, "BB-ChangeManaged(%s)\n",
1091 		_LtDebugDialogStyle2String(BB_DialogStyle(w))));
1092 
1093 	switch (BB_DialogStyle(w))
1094 	{
1095 	case XmDIALOG_MODELESS:
1096 	    XtVaSetValues(XtParent(w), XmNmwmInputMode,
1097 			  MWM_INPUT_MODELESS, NULL);
1098 	    break;
1099 
1100 	case XmDIALOG_PRIMARY_APPLICATION_MODAL:
1101 	    XtVaSetValues(XtParent(w), XmNmwmInputMode,
1102 			  MWM_INPUT_PRIMARY_APPLICATION_MODAL, NULL);
1103 	    break;
1104 
1105 	case XmDIALOG_FULL_APPLICATION_MODAL:
1106 	    XtVaSetValues(XtParent(w), XmNmwmInputMode,
1107 			  MWM_INPUT_FULL_APPLICATION_MODAL, NULL);
1108 	    break;
1109 
1110 	case XmDIALOG_SYSTEM_MODAL:
1111 	    XtVaSetValues(XtParent(w), XmNmwmInputMode,
1112 			  MWM_INPUT_SYSTEM_MODAL, NULL);
1113 	    break;
1114 	}
1115 
1116 	if (bb->bulletin_board_class.geo_matrix_create) {
1117 		handle_change_managed(w, bb->bulletin_board_class.geo_matrix_create);
1118 		return;
1119 	}
1120 
1121 	_XmGMEnforceMargin(w, BB_MarginWidth(w), BB_MarginHeight(w), False);
1122 
1123 	_XmClearShadowType(w, BB_OldWidth(w), BB_OldHeight(w), BB_OldShadowThickness(w), 0);
1124 
1125 	BB_OldShadowThickness(w) = 0;
1126 
1127 	/* mainw/test13 */
1128 	if (/* XtIsRealized(w) || */ XtWidth(w) == 0 || XtHeight(w) == 0) {
1129 		_XmGMDoLayout(w, BB_MarginWidth(w), BB_MarginHeight(w),
1130 			BB_ResizePolicy(w), False);
1131 	}
1132 
1133 	if ((XtWidth(w) < BB_OldWidth(w) || XtHeight(w) < BB_OldHeight(w)) &&
1134 			XtIsRealized(w)) {
1135 		_XmDrawShadows(XtDisplay(w), XtWindow(w),
1136 			MGR_TopShadowGC(w), MGR_BottomShadowGC(w),
1137 			0, 0, XtWidth(w), XtHeight(w),
1138 			MGR_ShadowThickness(w), BB_ShadowType(w));
1139 	}
1140 
1141 	BB_OldWidth(w) = XtWidth(w);
1142 	BB_OldHeight(w) = XtHeight(w);
1143 	BB_OldShadowThickness(w) = MGR_ShadowThickness(w);
1144 
1145 	_XmNavigChangeManaged(w);
1146 }
1147 
1148 Widget
XmCreateBulletinBoard(Widget parent,char * name,Arg * arglist,Cardinal argcount)1149 XmCreateBulletinBoard(Widget parent, char *name,
1150 		      Arg *arglist, Cardinal argcount)
1151 {
1152     return XtCreateWidget(name,
1153 			  xmBulletinBoardWidgetClass,
1154 			  parent,
1155 			  arglist,
1156 			  argcount);
1157 }
1158 
1159 Widget
XmCreateBulletinBoardDialog(Widget parent,char * name,Arg * arglist,Cardinal argcount)1160 XmCreateBulletinBoardDialog(Widget parent, char *name,
1161 			    Arg *arglist, Cardinal argcount)
1162 {
1163     Widget d;
1164     char *s;
1165 
1166     s = _XmMakeDialogName(name);
1167 
1168     d = XtCreateWidget(s, xmDialogShellWidgetClass, parent, arglist, argcount);
1169     XtFree(s);
1170 
1171     return XtCreateWidget(name,
1172 			  xmBulletinBoardWidgetClass,
1173 			  d,
1174 			  arglist, argcount);
1175 }
1176 
1177 #if 0
1178 static void
1179 constraint_initialize(Widget request, Widget new_w, Arg *args, Cardinal *nargs)
1180 {
1181     DEBUGOUT(_LtDebug(__FILE__, new_w, "constraint_initialize\n"));
1182     DEBUGOUT(_LtDebug2(__FILE__, XtParent(new_w), new_w,
1183 		       "_XmBulletinBoardconstraint_initialize: %i args\n\t"
1184 		       "request X %5i Y %5i W %5i H %5i\n\t  new_w X %5i Y %5i"
1185 		       " W %5i H %5i\n\t   BB W %5i H %5i\n",
1186 		       *nargs,
1187 		       XtX(request), XtY(request),
1188 		       XtWidth(request), XtHeight(request),
1189 		       XtX(new_w), XtY(new_w),
1190 		       XtWidth(new_w), XtHeight(new_w),
1191 		       XtWidth(XtParent(new_w)), XtHeight(XtParent(new_w))));
1192 
1193     DEBUGOUT(_LtDebugPrintArgList(__FILE__, new_w, args, *nargs, False));
1194 
1195     if (XtWidth(request) != 0)
1196     {
1197 	XtWidth(new_w) = XtWidth(request);
1198     }
1199     if (XtHeight(request) != 0)
1200     {
1201 	XtHeight(new_w) = XtHeight(request);
1202     }
1203 }
1204 
1205 static Boolean
1206 constraint_set_values(Widget old, Widget request, Widget new_w,
1207 		      Arg *args, Cardinal *nargs)
1208 {
1209     DEBUGOUT(_LtDebug2(__FILE__, XtParent(new_w), new_w,
1210 		       "constraint_set_values\n"));
1211     DEBUGOUT(_LtDebug2(__FILE__, XtParent(new_w), new_w,
1212 		       "_XmBulletinBoardconstraint_set_values: %i args\n\t"
1213 		       "current X %5i Y %5i W %5i H %5i\n\trequest X %5i Y %5i"
1214 		       " W %5i H %5i\n\t  new_w X %5i Y %5i W %5i H %5i\n\t"
1215 		       "  BB W %5i H %5i\n",
1216 		       *nargs,
1217 		       XtX(old), XtY(old),
1218 		       XtWidth(old), XtHeight(old),
1219 		       XtX(request), XtY(request),
1220 		       XtWidth(request), XtHeight(request),
1221 		       XtX(new_w), XtY(new_w),
1222 		       XtWidth(new_w), XtHeight(new_w),
1223 		       XtWidth(XtParent(new_w)), XtHeight(XtParent(new_w))));
1224     DEBUGOUT(_LtDebugPrintArgList(__FILE__, new_w, args, *nargs, False));
1225 
1226     return False;
1227 }
1228 #endif
1229 
1230 #if 0
1231 static void
1232 handle_realize(Widget w, XmGeoCreateProc mat_make)
1233 {
1234     Dimension wd, ht;
1235     XmGeoMatrix geo;
1236     XtWidgetGeometry request;
1237 
1238     wd = XtWidth(w);
1239     ht = XtHeight(w);
1240 
1241     geo = mat_make(w, NULL, NULL);
1242 
1243     _XmGeoMatrixGet(geo, XmGET_PREFERRED_SIZE);
1244 
1245     _XmGeoArrangeBoxes(geo, 0, 0, &wd, &ht);
1246 
1247     if (BB_ResizePolicy(w) == XmRESIZE_GROW)
1248     {
1249 	/* check the return against the original.  If the procedure would
1250 	 * like the BB to shrink, call again */
1251 	if (wd < XtWidth(w) || ht < XtHeight(w))
1252 	{
1253 	    wd = XtWidth(w);
1254 	    ht = XtHeight(w);
1255 	    _XmGeoArrangeBoxes(geo, 0, 0, &wd, &ht);
1256 	}
1257     }
1258 
1259     if (wd == XtWidth(w) && ht == XtHeight(w))
1260     {
1261 	_XmGeoMatrixFree(geo);
1262 
1263 	return;
1264     }
1265 
1266     request.request_mode = (CWWidth | CWHeight);
1267     request.width = wd;
1268     request.height = ht;
1269     request.request_mode |= CWBorderWidth;
1270     request.border_width = XtBorderWidth(w);
1271 
1272     _XmMakeGeometryRequest(w, &request);
1273 
1274     if (request.width != wd || request.height != ht)
1275     {
1276 	_XmGeoArrangeBoxes(geo, 0, 0, &request.width, &request.height);
1277     }
1278 
1279     _XmGeoMatrixSet(geo);
1280 
1281     if (XtIsRealized(w))
1282     {
1283 
1284 	_XmClearShadowType(w, BB_OldWidth(w), BB_OldHeight(w),
1285 			   BB_OldShadowThickness(w), 0);
1286 
1287 	_XmDrawShadows(XtDisplay(w), XtWindow(w),
1288 		       MGR_TopShadowGC(w), MGR_BottomShadowGC(w),
1289 		       0, 0, XtWidth(w), XtHeight(w),
1290 		       MGR_ShadowThickness(w), BB_ShadowType(w));
1291     }
1292 
1293     _XmGeoMatrixFree(geo);
1294 
1295     BB_OldWidth(w) = XtWidth(w);
1296     BB_OldHeight(w) = XtHeight(w);
1297     BB_OldShadowThickness(w) = MGR_ShadowThickness(w);
1298 }
1299 #endif
1300 
1301 #if 0
1302 static void
1303 realize(Widget w,
1304 	XtValueMask *value_mask,
1305 	XSetWindowAttributes *attributes)
1306 {
1307     /* Motif inherits this method */
1308     XmBulletinBoardClassRec *bb = (XmBulletinBoardClassRec *)XtClass(w);
1309 
1310 #if 1
1311     /* bulletinboard/test11 */
1312     if (XtWidth(w) == 0) XtWidth(w) = 1;
1313     if (XtHeight(w) == 0) XtHeight(w) = 1;
1314 #endif
1315 
1316     DEBUGOUT(_LtDebug(__FILE__, w, "%s:realize(%d) - %dx%d\n",
1317     	__FILE__, __LINE__,
1318     	XtWidth(w), XtHeight(w)));
1319 
1320 #define superclass (&xmManagerClassRec)
1321     (*superclass->core_class.realize) (w, value_mask, attributes);
1322 #undef superclass
1323 
1324     if (bb->bulletin_board_class.geo_matrix_create)
1325     {
1326 	handle_realize(w, bb->bulletin_board_class.geo_matrix_create);
1327 
1328 	return;
1329     }
1330 
1331 #if 0
1332     /* rws 21 Oct 1998
1333        This should not be necessary. All this should get done in change_managed.
1334        (bulletinboard/test14)
1335      */
1336     _XmGMEnforceMargin(w,
1337 		       BB_MarginWidth(w), BB_MarginHeight(w),
1338 		       False);
1339 
1340     _XmClearShadowType(w, BB_OldWidth(w), BB_OldHeight(w),
1341 		       BB_OldShadowThickness(w), 0);
1342 
1343     BB_OldShadowThickness(w) = 0;
1344 
1345     _XmGMDoLayout(w, BB_MarginWidth(w), BB_MarginHeight(w),
1346 		  BB_ResizePolicy(w), False);
1347 
1348     if (XtWidth(w) < BB_OldWidth(w) || XtHeight(w) < BB_OldHeight(w))
1349     {
1350 	_XmDrawShadows(XtDisplay(w), XtWindow(w),
1351 		       MGR_TopShadowGC(w), MGR_BottomShadowGC(w),
1352 		       0, 0, XtWidth(w), XtHeight(w),
1353 		       MGR_ShadowThickness(w), BB_ShadowType(w));
1354     }
1355 
1356     BB_OldWidth(w) = XtWidth(w);
1357     BB_OldHeight(w) = XtHeight(w);
1358     BB_OldShadowThickness(w) = MGR_ShadowThickness(w);
1359 #endif
1360 }
1361 #endif
1362 
1363 static void
expose(Widget w,XEvent * event,Region region)1364 expose(Widget w, XEvent *event, Region region)
1365 {
1366     DEBUGOUT(_LtDebug(__FILE__, w, "expose\n"));
1367 
1368     if (BB_OldWidth(w) != XtWidth(w) ||
1369         BB_OldHeight(w) != XtHeight(w) ||
1370         BB_OldShadowThickness(w) != MGR_ShadowThickness(w))
1371     {
1372 	_XmClearBorder(XtDisplay(w), XtWindow(w),
1373 		       0,0,
1374 			BB_OldWidth(w), BB_OldHeight(w),
1375 			BB_OldShadowThickness(w));
1376 	BB_OldWidth(w) = XtWidth(w);
1377 	BB_OldHeight(w) = XtHeight(w);
1378 	BB_OldShadowThickness(w) = MGR_ShadowThickness(w);
1379     }
1380 
1381     _XmRedisplayGadgets(w, event, region);
1382 
1383     if (MGR_ShadowThickness(w))
1384     {
1385 	_XmDrawShadows(XtDisplay(w), XtWindow(w),
1386 		       MGR_TopShadowGC(w), MGR_BottomShadowGC(w),
1387 		       0, 0, XtWidth(w), XtHeight(w),
1388 		       MGR_ShadowThickness(w), BB_ShadowType(w));
1389     }
1390 }
1391 
1392 static void
_XmBbButton(Widget w,XtPointer client,XtPointer call)1393 _XmBbButton(Widget w, XtPointer client, XtPointer call)
1394 {
1395     XmBulletinBoardWidget bb = (XmBulletinBoardWidget)XtParent(w);
1396 
1397     DEBUGOUT(_LtDebug2(__FILE__, (Widget)bb, w, "XmBbButton\n"));
1398 
1399     /*
1400      * How do we make sure the APPLY or HELP buttons don't
1401      * trigger unmanaging ??
1402      *
1403      * Somebody already caught this.  See comments in SelectionBox.c (look
1404      * for auto_unmanage).
1405      */
1406     if (BB_AutoUnmanage(bb))
1407     {
1408 	Widget s = XtParent((Widget)bb);
1409 
1410 	if (XtIsSubclass(s, xmDialogShellWidgetClass))
1411 	{
1412 	    XtUnmanageChild((Widget)bb);
1413 	    DEBUGOUT(_LtDebug2(__FILE__, (Widget)bb, w, "AutoUnmanage\n"));
1414 
1415 #if 0
1416 	    /* rws 19 Sep 1998
1417 	       This is a job for Shell, not BB
1418 	     */
1419 	    /* XtNpopdownCallback */
1420 	    XtCallCallbackList(s, Shell_PopdownCallback(s), call);
1421 #endif
1422 	}
1423     }
1424 }
1425 
1426 /*
1427  * Keep track of button children
1428  */
1429 static void
insert_child(Widget w)1430 insert_child(Widget w)
1431 {
1432 #define	superclass	(&xmManagerClassRec)
1433     (*superclass->composite_class.insert_child) (w);
1434 #undef	superclass
1435 
1436     if (_XmIsFastSubclass(XtClass(w), XmPUSH_BUTTON_GADGET_BIT) ||
1437 	_XmIsFastSubclass(XtClass(w), XmPUSH_BUTTON_BIT))
1438     {
1439 	XtAddCallback(w, XmNactivateCallback, _XmBbButton, NULL);
1440 
1441 	if (BB_DefaultButton(XtParent(w)))
1442 	{
1443 	    _XmBulletinBoardSetDefaultShadow(w);
1444 	}
1445     }
1446 }
1447 
1448 static void
delete_child(Widget w)1449 delete_child(Widget w)
1450 {
1451     Widget bb = XtParent(w);
1452 
1453     DEBUGOUT(_LtDebug2(__FILE__, bb, w, "delete_child\n"));
1454 
1455 #define	superclass	(&xmManagerClassRec)
1456     (*superclass->composite_class.delete_child) (w);
1457 #undef superclass
1458 
1459     if (w == BB_CancelButton(bb))
1460     {
1461 	BB_CancelButton(bb) = NULL;
1462     }
1463     if (w == BB_DynamicCancelButton(bb))
1464     {
1465 	BB_DynamicCancelButton(bb) = NULL;
1466     }
1467     if (w == BB_DynamicDefaultButton(bb))
1468     {
1469 	BB_DynamicDefaultButton(bb) = NULL;
1470     }
1471     if (w == BB_DefaultButton(bb))
1472     {
1473 	BB_DefaultButton(bb) = NULL;
1474 	MGR_InitialFocus(bb) = NULL;
1475     }
1476 }
1477 
1478 static Boolean
_XmBBParentProcess(Widget widget,XmParentProcessData data)1479 _XmBBParentProcess(Widget widget, XmParentProcessData data)
1480 {
1481     DEBUGOUT(_LtDebug(__FILE__, widget, "_XmBBParentProcess\n"));
1482 
1483     if (data->input_action.process_type == XmINPUT_ACTION)
1484     {
1485 	if (data->input_action.action == XmPARENT_ACTIVATE)
1486 	{
1487 	    if (BB_DefaultButton(widget) || BB_DynamicDefaultButton(widget))
1488 	    {
1489 		_XmBulletinBoardReturn(widget,
1490 				   data->input_action.event,
1491 				   data->input_action.params,
1492 				   data->input_action.num_params);
1493 
1494 		return True;
1495 	    }
1496 	    else
1497 	    {
1498 	    Widget w = XtParent(widget);
1499 	    XmManagerWidgetClass mwc = (XmManagerWidgetClass)w->core.widget_class;
1500 
1501 		if (XmIsManager(w) && mwc->manager_class.parent_process)
1502 		{
1503 		    return((*mwc->manager_class.parent_process) (w, data));
1504 		}
1505 	    }
1506 	}
1507 	else if (data->input_action.action == XmPARENT_CANCEL)
1508 	{
1509 	    DEBUGOUT(_LtDebug(__FILE__, widget, "_XmBBParentProcess CANCEL\n"));
1510 	    if (BB_CancelButton(widget))
1511 	    {
1512 		DEBUGOUT(_LtDebug(__FILE__, widget, "_XmBBParentProcess CANCEL %s\n",XtName(BB_CancelButton(widget))));
1513 		_XmBulletinBoardCancel(widget,
1514 				       data->input_action.event,
1515 				       data->input_action.params,
1516 				       data->input_action.num_params);
1517 
1518 		return True;
1519 	    }
1520 	    else
1521 	    {
1522 	    Widget w = XtParent(widget);
1523 	    XmManagerWidgetClass mwc = (XmManagerWidgetClass)w->core.widget_class;
1524 
1525 		DEBUGOUT(_LtDebug(__FILE__, widget, "_XmBBParentProcess CANCEL no button\n"));
1526 		if (XmIsManager(w) && mwc->manager_class.parent_process)
1527 		{
1528 		    return((*mwc->manager_class.parent_process) (w, data));
1529 		}
1530 	    }
1531 	}
1532     }
1533 
1534     return False;
1535 }
1536 
1537 Widget
_XmBB_CreateButtonG(Widget bb,XmString l_string,char * name)1538 _XmBB_CreateButtonG(Widget bb, XmString l_string, char *name)
1539 {
1540     Widget button;
1541     Arg args[2];
1542     Cardinal n = 0;
1543 
1544     if (l_string && l_string != (XmString)XmUNSPECIFIED)
1545     {
1546 	XtSetArg(args[n], XmNlabelString, l_string); n++;
1547     }
1548 #ifdef USE_WIDGETS
1549     button = XmCreatePushButton(bb, name, args, n);
1550 #else
1551     button = XmCreatePushButtonGadget(bb, name, args, n);
1552 #endif
1553     _XmBulletinBoardSetDefaultShadow(button);
1554 
1555     return button;
1556 }
1557 
1558 Widget
_XmBB_CreateLabelG(Widget bb,XmString l_string,char * name)1559 _XmBB_CreateLabelG(Widget bb, XmString l_string, char *name)
1560 {
1561     Widget label;
1562     Arg args[2];
1563     Cardinal n = 0;
1564 
1565     if (l_string && l_string != (XmString)XmUNSPECIFIED)
1566     {
1567 	XtSetArg(args[n], XmNlabelString, l_string); n++;
1568     }
1569 
1570 #ifdef USE_WIDGETS
1571     label = XmCreateLabel(bb, name, args, n);
1572 #else
1573     label = XmCreateLabelGadget(bb, name, args, n);
1574 #endif
1575 
1576     return label;
1577 }
1578 
1579 void
_XmBulletinBoardSizeUpdate(Widget w)1580 _XmBulletinBoardSizeUpdate(Widget w)
1581 {
1582     XmBulletinBoardWidgetClass bbc = (XmBulletinBoardWidgetClass)XtClass(w);
1583 
1584     if (!XtIsRealized(w))
1585     {
1586 	return;
1587     }
1588 
1589     if (bbc->bulletin_board_class.geo_matrix_create == NULL)
1590     {
1591 	BB_OldWidth(w) = XtWidth(w);
1592 	BB_OldHeight(w) = XtHeight(w);
1593 
1594 	return;
1595     }
1596 
1597     if (!BB_OldShadowThickness(w) && BB_ResizePolicy(w) != XmRESIZE_NONE)
1598     {
1599 	_XmClearShadowType(w, BB_OldWidth(w), BB_OldHeight(w),
1600 			   BB_OldShadowThickness(w), 0);
1601 
1602 	BB_OldShadowThickness(w) = 0;
1603     }
1604 
1605     _XmHandleSizeUpdate(w, BB_ResizePolicy(w),
1606 			bbc->bulletin_board_class.geo_matrix_create);
1607 
1608     if ((XtWidth(w) < BB_OldWidth(w) || XtHeight(w) < BB_OldHeight(w)) &&
1609 	XtIsRealized(w))
1610     {
1611 	_XmDrawShadows(XtDisplay(w), XtWindow(w),
1612 		       MGR_TopShadowGC(w), MGR_BottomShadowGC(w),
1613 		       0, 0, XtWidth(w), XtHeight(w),
1614 		       MGR_ShadowThickness(w), BB_ShadowType(w));
1615     }
1616 
1617     BB_OldWidth(w) = XtWidth(w);
1618     BB_OldHeight(w) = XtHeight(w);
1619     BB_OldShadowThickness(w) = MGR_ShadowThickness(w);
1620 }
1621 
1622 void
_XmBulletinBoardFocusMoved(Widget wid,XtPointer client_data,XtPointer data)1623 _XmBulletinBoardFocusMoved(Widget wid, XtPointer client_data, XtPointer data)
1624 {
1625     XmFocusMovedCallback cbs = (XmFocusMovedCallback)data;
1626     Widget bb = (Widget)client_data;
1627     XmAnyCallbackStruct cb;
1628     Boolean to_bb = False, from_bb = False;
1629     Widget default_button = NULL;
1630     Widget par;
1631 
1632     DEBUGOUT(_LtDebug(__FILE__, wid, "%s:%d - %s %s %s\n",
1633     	__FILE__, __LINE__,
1634     	cbs->cont ? "True" : "False",
1635     	cbs->old_focus ? XtName(cbs->old_focus) : "NULL",
1636     	cbs->new_focus ? XtName(cbs->new_focus) : "NULL"));
1637 
1638     if (!cbs->cont)
1639     {
1640 	return;
1641     }
1642     for (par = cbs->new_focus; par != NULL && !XtIsShell(par);
1643 	 par = XtParent(par))
1644     {
1645 
1646 	if (bb == par)
1647 	{
1648 	    to_bb = True;
1649 	    break;
1650 	}
1651 	if (XmIsBulletinBoard(par))
1652 	{
1653 	    if (default_button == NULL)
1654 	    {
1655 		default_button = BB_DefaultButton(par);
1656 	    }
1657 	}
1658     }
1659     for (par = cbs->old_focus; par != NULL && !XtIsShell(par);
1660 	 par = XtParent(par))
1661     {
1662 	if (bb == par)
1663 	{
1664 	    from_bb = True;
1665 	    break;
1666 	}
1667     }
1668     if (to_bb)
1669     {
1670 	if (default_button == NULL)
1671 	{
1672 	    default_button = BB_DefaultButton(bb);
1673 	}
1674 	if (default_button == NULL)
1675 	{
1676 	    BB_DynamicDefaultButton(bb) = NULL;
1677 	}
1678 	else
1679 	{
1680 	    par = cbs->new_focus;
1681 	    if (XmIsPushButton(cbs->new_focus) ||
1682 		XmIsPushButtonGadget(cbs->new_focus))
1683 	    {
1684 		_XmBulletinBoardSetDynDefaultButton(bb, cbs->new_focus);
1685 	    }
1686 	    else if (cbs->focus_policy == XmEXPLICIT ||
1687 		     !XmIsManager(cbs->new_focus) ||
1688 		     cbs->old_focus == NULL ||
1689 		     (!XmIsPushButtonGadget(cbs->old_focus) &&
1690 		      !XmIsPushButton(cbs->old_focus)))
1691 	    {
1692 		if (XtIsManaged(default_button))
1693 		{
1694 		    _XmBulletinBoardSetDynDefaultButton(bb, default_button);
1695 		}
1696 	    }
1697 	}
1698 	if (!from_bb)
1699 	{
1700 	    cb.reason = XmCR_FOCUS;
1701 	    cb.event = cbs->event;
1702 	    XtCallCallbackList(bb, BB_FocusCallback(bb), data);
1703 	}
1704     }
1705     else
1706     {
1707 	if (from_bb && cbs->new_focus != NULL)
1708 	{
1709 	    _XmBulletinBoardSetDynDefaultButton(bb, NULL);
1710 	}
1711     }
1712 }
1713 
1714 void
_XmBulletinBoardUnmap(Widget w)1715 _XmBulletinBoardUnmap(Widget w)
1716 {
1717     XmAnyCallbackStruct cb;
1718 
1719     cb.event = NULL;
1720     cb.reason = XmCR_UNMAP;
1721 
1722     XtCallCallbackList(w, BB_UnmapCallback(w), (XtPointer)&cb);
1723 }
1724 
1725 void
_XmBulletinBoardMap(Widget w)1726 _XmBulletinBoardMap(Widget w)
1727 {
1728     XmAnyCallbackStruct cb;
1729 
1730     cb.event = NULL;
1731     cb.reason = XmCR_MAP;
1732     XtCallCallbackList(w, BB_MapCallback(w), (XtPointer)&cb);
1733 }
1734 
1735 static void
ArmAndActivate(Widget wid,XEvent * event,String * params,Cardinal * numParams)1736 ArmAndActivate(Widget wid, XEvent *event,
1737 		       String *params, Cardinal *numParams)
1738 {
1739     if (XmIsGadget(wid))
1740     {
1741 	if ((((XmGadgetClass)(XtClass(wid)))->gadget_class.arm_and_activate))
1742 	{
1743 	    (((XmGadgetClass)(XtClass(wid)))->gadget_class.arm_and_activate)
1744 		(wid,
1745 		    event,
1746 		    params,
1747 		    numParams);
1748 	}
1749     }
1750     else if (XmIsPrimitive(wid))
1751     {
1752 	if ((((XmPrimitiveWidgetClass)(XtClass(wid)))->primitive_class.arm_and_activate))
1753 	{
1754 	    (((XmPrimitiveWidgetClass)(XtClass(wid)))->primitive_class.arm_and_activate)
1755 		(wid,
1756 		    event,
1757 		    params,
1758 		    numParams);
1759 	}
1760     }
1761 }
1762 
1763 void
_XmBulletinBoardReturn(Widget wid,XEvent * event,String * params,Cardinal * numParams)1764 _XmBulletinBoardReturn(Widget wid, XEvent *event,
1765 		       String *params, Cardinal *numParams)
1766 {
1767     /* FIX ME -- this needs filling in */
1768     /*
1769        rws 12 Jul 1997
1770        This is now filled in but, is it correct??
1771        see man XmBulletinBoard under KActivate
1772      */
1773     XmPushButtonCallbackStruct cbs;
1774 
1775     cbs.reason = XmCR_OK;
1776     cbs.event = event;
1777 
1778     if (BB_DynamicDefaultButton(wid) &&
1779 	XtIsSensitive(BB_DynamicDefaultButton(wid)) &&
1780 	XtIsManaged(BB_DynamicDefaultButton(wid)) &&
1781 	XtIsRealized(BB_DynamicDefaultButton(wid)))
1782     {
1783 	ArmAndActivate(BB_DynamicDefaultButton(wid), event, params, numParams);
1784     }
1785     else if (BB_DefaultButton(wid) &&
1786 	XtIsSensitive(BB_DefaultButton(wid)) &&
1787 	XtIsManaged(BB_DefaultButton(wid)) &&
1788 	XtIsRealized(BB_DefaultButton(wid)))
1789     {
1790 	ArmAndActivate(BB_DefaultButton(wid), event, params, numParams);
1791     }
1792 }
1793 
1794 void
_XmBulletinBoardCancel(Widget wid,XEvent * event,String * params,Cardinal * numParams)1795 _XmBulletinBoardCancel(Widget wid, XEvent *event,
1796 		       String *params, Cardinal *numParams)
1797 {
1798     XmPushButtonCallbackStruct cbs;
1799 
1800     /* see man XmBulletinBoard under KCancel */
1801     cbs.reason = XmCR_ACTIVATE;
1802     cbs.event = event;
1803 
1804     if (BB_CancelButton(wid) && XtIsSensitive(BB_CancelButton(wid)) &&
1805 	XtIsManaged(BB_CancelButton(wid)) && XtIsRealized(BB_CancelButton(wid)))
1806     {
1807 	ArmAndActivate(BB_CancelButton(wid), event, params, numParams);
1808     }
1809     else if (BB_DynamicCancelButton(wid) &&
1810 	     XtIsSensitive(BB_DynamicCancelButton(wid)) &&
1811 	     XtIsManaged(BB_DynamicCancelButton(wid)) &&
1812 	     XtIsRealized(BB_DynamicCancelButton(wid)))
1813     {
1814 	ArmAndActivate(BB_DynamicCancelButton(wid), event, params, numParams);
1815     }
1816 }
1817 
1818 void
_XmBulletinBoardSetDefaultShadow(Widget button)1819 _XmBulletinBoardSetDefaultShadow(Widget button)
1820 {
1821     Dimension st, dbst;
1822     Arg args[2];
1823 
1824     if (_XmIsFastSubclass(XtClass(button), XmPUSH_BUTTON_GADGET_BIT) ||
1825 	_XmIsFastSubclass(XtClass(button), XmPUSH_BUTTON_BIT))
1826     {
1827 
1828 	XtSetArg(args[0], XmNdefaultButtonShadowThickness, &dbst);
1829 	XtSetArg(args[1], XmNshadowThickness, &st);
1830 	XtGetValues(button, args, 2);
1831 
1832 	if (st > 1)
1833 	{
1834 	    st >>= 1;
1835 	}
1836 
1837 	XtSetArg(args[0], XmNdefaultButtonShadowThickness, st);
1838 	XtSetValues(button, args, 1);
1839     }
1840 }
1841 
1842 void
_XmBulletinBoardSetDynDefaultButton(Widget wid,Widget newDefaultButton)1843 _XmBulletinBoardSetDynDefaultButton(Widget wid, Widget newDefaultButton)
1844 {
1845     Arg argl[2];
1846 
1847     DEBUGOUT(_LtDebug(__FILE__, wid, "%s:%d - %s\n",
1848     	__FILE__, __LINE__,
1849     	newDefaultButton ? XtName(newDefaultButton) : "NULL"));
1850 
1851     if (newDefaultButton && wid != XtParent(newDefaultButton))
1852     {
1853     	return;
1854     }
1855     if (BB_DynamicDefaultButton(wid) != NULL)
1856     {
1857 	if (!BB_DynamicDefaultButton(wid)->core.being_destroyed)
1858 	{
1859 	    XtSetArg(argl[0], XmNshowAsDefault, 0);
1860 	    XtSetValues(BB_DynamicDefaultButton(wid), argl, 1);
1861 	}
1862     }
1863 
1864     if (newDefaultButton == NULL)
1865     {
1866 	BB_DynamicDefaultButton(wid) = NULL;
1867 
1868 	return;
1869     }
1870 
1871     if (XmIsPushButtonGadget(newDefaultButton) ||
1872 	XmIsPushButton(newDefaultButton))
1873     {
1874 	BB_DynamicDefaultButton(wid) = newDefaultButton;
1875 
1876 	XtSetArg(argl[0], XmNshowAsDefault, 1);
1877 
1878 	XtSetValues(BB_DynamicDefaultButton(wid), argl, 1);
1879     }
1880 }
1881 
1882 void
_XmBBUpdateDynDefaultButton(Widget bb)1883 _XmBBUpdateDynDefaultButton(Widget bb)
1884 {
1885     DEBUGOUT(_LtDebug(__FILE__, bb, "%s:_XmBBUpdateDynDefault(%d) - %s(%smanaged) %s\n",
1886     	__FILE__, __LINE__,
1887     	BB_DynamicDefaultButton(bb) ? XtName(BB_DynamicDefaultButton(bb)) : "NULL",
1888     	BB_DynamicDefaultButton(bb) ? XtIsManaged(BB_DynamicDefaultButton(bb)) ? "" : "not " : "not ",
1889     	BB_DefaultButton(bb) ? XtName(BB_DefaultButton(bb)) : "NULL"));
1890 
1891     if (BB_DynamicDefaultButton(bb) &&
1892         XtIsManaged(BB_DynamicDefaultButton(bb)))
1893     {
1894 	_XmBulletinBoardSetDynDefaultButton(bb, BB_DynamicDefaultButton(bb));
1895     }
1896     else
1897     {
1898 	_XmBulletinBoardSetDynDefaultButton(bb, BB_DefaultButton(bb));
1899     }
1900 }
1901 
1902 static void
_XmBulletinBoardDialogStyleDefault(Widget w,int offset,XrmValue * val)1903 _XmBulletinBoardDialogStyleDefault(Widget w,
1904 				   int offset,
1905 				   XrmValue *val)
1906 {
1907     static unsigned char style;
1908 
1909     if (XmIsDialogShell(XtParent(w)))
1910     {
1911 	style = XmDIALOG_MODELESS;
1912     }
1913     else
1914     {
1915 	style = XmDIALOG_WORK_AREA;
1916     }
1917 
1918     val->addr = (XPointer)&style;
1919 }
1920 
GetRenderTable(Widget w,XtEnum renderTableType)1921 static XmRenderTable GetRenderTable(Widget w, XtEnum renderTableType)
1922 {
1923 	XmBulletinBoardWidget bb = (XmBulletinBoardWidget)w;
1924 
1925 	switch(renderTableType) {
1926 	case XmLABEL_RENDER_TABLE:
1927 			return bb->bulletin_board.label_font_list;
1928 	case XmBUTTON_RENDER_TABLE:
1929 			return bb->bulletin_board.button_font_list;
1930 	case XmTEXT_RENDER_TABLE:
1931 			return bb->bulletin_board.text_font_list;
1932 													    }
1933 	return NULL;
1934 }
1935