Dialog.c revision 775e7de9
17a84e134Smrg/* $Xorg: Dialog.c,v 1.4 2001/02/09 02:03:43 xorgcvs Exp $ */
27a84e134Smrg
37a84e134Smrg/***********************************************************
47a84e134Smrg
57a84e134SmrgCopyright 1987, 1988, 1994, 1998  The Open Group
67a84e134Smrg
77a84e134SmrgPermission to use, copy, modify, distribute, and sell this software and its
87a84e134Smrgdocumentation for any purpose is hereby granted without fee, provided that
97a84e134Smrgthe above copyright notice appear in all copies and that both that
107a84e134Smrgcopyright notice and this permission notice appear in supporting
117a84e134Smrgdocumentation.
127a84e134Smrg
137a84e134SmrgThe above copyright notice and this permission notice shall be included in
147a84e134Smrgall copies or substantial portions of the Software.
157a84e134Smrg
167a84e134SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
177a84e134SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187a84e134SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
197a84e134SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
207a84e134SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
217a84e134SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
227a84e134Smrg
237a84e134SmrgExcept as contained in this notice, the name of The Open Group shall not be
247a84e134Smrgused in advertising or otherwise to promote the sale, use or other dealings
257a84e134Smrgin this Software without prior written authorization from The Open Group.
267a84e134Smrg
277a84e134Smrg
287a84e134SmrgCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
297a84e134Smrg
307a84e134Smrg                        All Rights Reserved
317a84e134Smrg
327a84e134SmrgPermission to use, copy, modify, and distribute this software and its
337a84e134Smrgdocumentation for any purpose and without fee is hereby granted,
347a84e134Smrgprovided that the above copyright notice appear in all copies and that
357a84e134Smrgboth that copyright notice and this permission notice appear in
367a84e134Smrgsupporting documentation, and that the name of Digital not be
377a84e134Smrgused in advertising or publicity pertaining to distribution of the
387a84e134Smrgsoftware without specific, written prior permission.
397a84e134Smrg
407a84e134SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
417a84e134SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
427a84e134SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
437a84e134SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
447a84e134SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
457a84e134SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
467a84e134SmrgSOFTWARE.
477a84e134Smrg
487a84e134Smrg******************************************************************/
497a84e134Smrg/* $XFree86: xc/lib/Xaw/Dialog.c,v 1.7 2001/01/17 19:42:26 dawes Exp $ */
507a84e134Smrg
517a84e134Smrg#ifdef HAVE_CONFIG_H
527a84e134Smrg#include <config.h>
537a84e134Smrg#endif
547a84e134Smrg#include <X11/IntrinsicP.h>
557a84e134Smrg#include <X11/StringDefs.h>
567a84e134Smrg#include <X11/Xos.h>
577a84e134Smrg#include <X11/Xmu/Misc.h>
587a84e134Smrg#include <X11/Xaw/AsciiText.h>
597a84e134Smrg#include <X11/Xaw/Cardinals.h>
607a84e134Smrg#include <X11/Xaw/Command.h>
617a84e134Smrg#include <X11/Xaw/Label.h>
627a84e134Smrg#include <X11/Xaw/DialogP.h>
637a84e134Smrg#include <X11/Xaw/XawInit.h>
647a84e134Smrg#include "Private.h"
657a84e134Smrg
667a84e134Smrg/*
677a84e134Smrg * After we have set the string in the value widget we set the
687a84e134Smrg * string to a magic value.  So that when a SetValues request is made
697a84e134Smrg * on the dialog value we will notice it, and reset the string
707a84e134Smrg */
717a84e134Smrg#define MAGIC_VALUE	((char *)3)
727a84e134Smrg
737a84e134Smrg#define streq(a,b)	(strcmp((a), (b)) == 0)
747a84e134Smrg
757a84e134Smrg/*
767a84e134Smrg * Class Methods
777a84e134Smrg */
787a84e134Smrgstatic void XawDialogConstraintInitialize(Widget, Widget,
797a84e134Smrg					  ArgList, Cardinal*);
807a84e134Smrgstatic void XawDialogGetValuesHook(Widget, ArgList, Cardinal*);
817a84e134Smrgstatic void XawDialogInitialize(Widget, Widget, ArgList, Cardinal*);
827a84e134Smrgstatic Boolean XawDialogSetValues(Widget, Widget, Widget,
837a84e134Smrg				  ArgList, Cardinal*);
847a84e134Smrg
857a84e134Smrg/*
867a84e134Smrg * Prototypes
877a84e134Smrg */
887a84e134Smrgstatic void CreateDialogValueWidget(Widget);
897a84e134Smrg
907a84e134Smrg/*
917a84e134Smrg * Initialization
927a84e134Smrg */
937a84e134Smrgstatic XtResource resources[] = {
947a84e134Smrg  {
957a84e134Smrg    XtNlabel,
967a84e134Smrg    XtCLabel,
977a84e134Smrg    XtRString,
987a84e134Smrg    sizeof(String),
997a84e134Smrg    XtOffsetOf(DialogRec, dialog.label),
1007a84e134Smrg    XtRString,
1017a84e134Smrg    NULL
1027a84e134Smrg  },
1037a84e134Smrg  {
1047a84e134Smrg    XtNvalue,
1057a84e134Smrg    XtCValue,
1067a84e134Smrg    XtRString,
1077a84e134Smrg    sizeof(String),
1087a84e134Smrg    XtOffsetOf(DialogRec, dialog.value),
1097a84e134Smrg    XtRString,
1107a84e134Smrg    NULL
1117a84e134Smrg  },
1127a84e134Smrg  {
1137a84e134Smrg    XtNicon,
1147a84e134Smrg    XtCIcon,
1157a84e134Smrg    XtRBitmap,
1167a84e134Smrg    sizeof(Pixmap),
1177a84e134Smrg    XtOffsetOf(DialogRec, dialog.icon),
1187a84e134Smrg    XtRImmediate,
119775e7de9Smrg    NULL
1207a84e134Smrg  },
1217a84e134Smrg};
1227a84e134Smrg
1237a84e134SmrgDialogClassRec dialogClassRec = {
1247a84e134Smrg  /* core */
1257a84e134Smrg  {
1267a84e134Smrg    (WidgetClass)&formClassRec,		/* superclass */
1277a84e134Smrg    "Dialog",				/* class_name */
1287a84e134Smrg    sizeof(DialogRec),			/* widget_size */
1297a84e134Smrg    XawInitializeWidgetSet,		/* class_initialize */
1307a84e134Smrg    NULL,				/* class_part init */
1317a84e134Smrg    False,				/* class_inited */
1327a84e134Smrg    XawDialogInitialize,		/* initialize */
1337a84e134Smrg    NULL,				/* initialize_hook */
1347a84e134Smrg    XtInheritRealize,			/* realize */
1357a84e134Smrg    NULL,				/* actions */
1367a84e134Smrg    0,					/* num_actions */
1377a84e134Smrg    resources,				/* resources */
1387a84e134Smrg    XtNumber(resources),		/* num_resources */
1397a84e134Smrg    NULLQUARK,				/* xrm_class */
1407a84e134Smrg    True,				/* compress_motion */
1417a84e134Smrg    True,				/* compress_exposure */
1427a84e134Smrg    True,				/* compress_enterleave */
1437a84e134Smrg    False,				/* visible_interest */
1447a84e134Smrg    NULL,				/* destroy */
1457a84e134Smrg    XtInheritResize,			/* resize */
1467a84e134Smrg    XtInheritExpose,			/* expose */
1477a84e134Smrg    XawDialogSetValues,			/* set_values */
1487a84e134Smrg    NULL,				/* set_values_hook */
1497a84e134Smrg    XtInheritSetValuesAlmost,		/* set_values_almost */
1507a84e134Smrg    XawDialogGetValuesHook,		/* get_values_hook */
1517a84e134Smrg    NULL,				/* accept_focus */
1527a84e134Smrg    XtVersion,				/* version */
1537a84e134Smrg    NULL,				/* callback_private */
1547a84e134Smrg    NULL,				/* tm_table */
1557a84e134Smrg    XtInheritQueryGeometry,		/* query_geometry */
1567a84e134Smrg    XtInheritDisplayAccelerator,	/* display_accelerator */
1577a84e134Smrg    NULL,				/* extension */
1587a84e134Smrg  },
1597a84e134Smrg  /* composite */
1607a84e134Smrg  {
1617a84e134Smrg    XtInheritGeometryManager,		/* geometry_manager */
1627a84e134Smrg    XtInheritChangeManaged,		/* change_managed */
1637a84e134Smrg    XtInheritInsertChild,		/* insert_child */
1647a84e134Smrg    XtInheritDeleteChild,		/* delete_child */
1657a84e134Smrg    NULL,				/* extension */
1667a84e134Smrg  },
1677a84e134Smrg  /* constraint */
1687a84e134Smrg  {
1697a84e134Smrg    NULL,				/* subresourses */
1707a84e134Smrg    0,					/* subresource_count */
1717a84e134Smrg    sizeof(DialogConstraintsRec),	/* constraint_size */
1727a84e134Smrg    XawDialogConstraintInitialize,	/* initialize */
1737a84e134Smrg    NULL,				/* destroy */
1747a84e134Smrg    NULL,				/* set_values */
1757a84e134Smrg    NULL,				/* extension */
1767a84e134Smrg  },
1777a84e134Smrg  /* form */
1787a84e134Smrg  {
1797a84e134Smrg    XtInheritLayout,			/* layout */
1807a84e134Smrg  },
1817a84e134Smrg  /* dialog */
1827a84e134Smrg  {
1837a84e134Smrg    NULL,				/* extension */
1847a84e134Smrg  }
1857a84e134Smrg};
1867a84e134Smrg
1877a84e134SmrgWidgetClass dialogWidgetClass = (WidgetClass)&dialogClassRec;
1887a84e134Smrg
1897a84e134Smrg/*
1907a84e134Smrg * Implementation
1917a84e134Smrg */
1927a84e134Smrg/*ARGSUSED*/
1937a84e134Smrgstatic void
1947a84e134SmrgXawDialogInitialize(Widget request, Widget cnew,
1957a84e134Smrg		    ArgList args, Cardinal *num_args)
1967a84e134Smrg{
1977a84e134Smrg    DialogWidget dw = (DialogWidget)cnew;
1987a84e134Smrg    Arg arglist[9];
1997a84e134Smrg    Cardinal arg_cnt = 0;
2007a84e134Smrg
2017a84e134Smrg    XtSetArg(arglist[arg_cnt], XtNborderWidth, 0);		    arg_cnt++;
2027a84e134Smrg    XtSetArg(arglist[arg_cnt], XtNleft, XtChainLeft);		    arg_cnt++;
2037a84e134Smrg
2047a84e134Smrg    if (dw->dialog.icon != (Pixmap)0) {
2057a84e134Smrg	XtSetArg(arglist[arg_cnt], XtNbitmap, dw->dialog.icon);     arg_cnt++;
2067a84e134Smrg	XtSetArg(arglist[arg_cnt], XtNright, XtChainLeft);	    arg_cnt++;
2077a84e134Smrg	dw->dialog.iconW = XtCreateManagedWidget("icon", labelWidgetClass,
2087a84e134Smrg						 cnew, arglist, arg_cnt);
2097a84e134Smrg	arg_cnt = 2;
2107a84e134Smrg	XtSetArg(arglist[arg_cnt], XtNfromHoriz, dw->dialog.iconW); arg_cnt++;
2117a84e134Smrg    }
2127a84e134Smrg    else
2137a84e134Smrg	dw->dialog.iconW = NULL;
2147a84e134Smrg
2157a84e134Smrg    XtSetArg(arglist[arg_cnt], XtNlabel, dw->dialog.label);	    arg_cnt++;
2167a84e134Smrg    XtSetArg(arglist[arg_cnt], XtNright, XtChainRight);		    arg_cnt++;
2177a84e134Smrg
2187a84e134Smrg    dw->dialog.labelW = XtCreateManagedWidget("label", labelWidgetClass,
2197a84e134Smrg					      cnew, arglist, arg_cnt);
2207a84e134Smrg
2217a84e134Smrg    if (dw->dialog.iconW != NULL &&
2227a84e134Smrg        XtHeight(dw->dialog.labelW) < XtHeight(dw->dialog.iconW)) {
2237a84e134Smrg	XtSetArg(arglist[0], XtNheight, XtHeight(dw->dialog.iconW));
2247a84e134Smrg	XtSetValues(dw->dialog.labelW, arglist, 1);
2257a84e134Smrg    }
2267a84e134Smrg    if (dw->dialog.value != NULL)
2277a84e134Smrg	CreateDialogValueWidget((Widget)dw);
2287a84e134Smrg    else
2297a84e134Smrg        dw->dialog.valueW = NULL;
2307a84e134Smrg}
2317a84e134Smrg
2327a84e134Smrg/*ARGSUSED*/
2337a84e134Smrgstatic void
2347a84e134SmrgXawDialogConstraintInitialize(Widget request, Widget cnew,
2357a84e134Smrg			      ArgList args, Cardinal *num_args)
2367a84e134Smrg{
2377a84e134Smrg    DialogWidget dw = (DialogWidget)cnew->core.parent;
2387a84e134Smrg    DialogConstraints constraint = (DialogConstraints)cnew->core.constraints;
2397a84e134Smrg
2407a84e134Smrg    if (!XtIsSubclass(cnew, commandWidgetClass)) /* if not a button */
2417a84e134Smrg	return;					 /* then just use defaults */
2427a84e134Smrg
2437a84e134Smrg    constraint->form.left = constraint->form.right = XtChainLeft;
2447a84e134Smrg    if (dw->dialog.valueW == NULL)
2457a84e134Smrg	constraint->form.vert_base = dw->dialog.labelW;
2467a84e134Smrg    else
2477a84e134Smrg	constraint->form.vert_base = dw->dialog.valueW;
2487a84e134Smrg
2497a84e134Smrg    if (dw->composite.num_children > 1) {
2507a84e134Smrg	WidgetList children = dw->composite.children;
2517a84e134Smrg	Widget *childP;
2527a84e134Smrg
2537a84e134Smrg        for (childP = children + dw->composite.num_children - 1;
2547a84e134Smrg	   childP >= children; childP-- ) {
2557a84e134Smrg	    if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW)
2567a84e134Smrg		break;
2577a84e134Smrg	    if (XtIsManaged(*childP) &&
2587a84e134Smrg	        XtIsSubclass(*childP, commandWidgetClass)) {
2597a84e134Smrg		constraint->form.horiz_base = *childP;
2607a84e134Smrg		break;
2617a84e134Smrg	    }
2627a84e134Smrg	}
2637a84e134Smrg    }
2647a84e134Smrg}
2657a84e134Smrg
2667a84e134Smrg#define ICON 0
2677a84e134Smrg#define LABEL 1
2687a84e134Smrg#define NUM_CHECKS 2
2697a84e134Smrg/*ARGSUSED*/
2707a84e134Smrgstatic Boolean
2717a84e134SmrgXawDialogSetValues(Widget current, Widget request, Widget cnew,
2727a84e134Smrg		   ArgList in_args, Cardinal *in_num_args)
2737a84e134Smrg{
2747a84e134Smrg    DialogWidget w = (DialogWidget)cnew;
2757a84e134Smrg    DialogWidget old = (DialogWidget)current;
2767a84e134Smrg    Arg args[5];
2777a84e134Smrg    Cardinal num_args;
2787a84e134Smrg    unsigned int i;
2797a84e134Smrg    Bool checks[NUM_CHECKS];
2807a84e134Smrg
2817a84e134Smrg    for (i = 0; i < NUM_CHECKS; i++)
2827a84e134Smrg	checks[i] = False;
2837a84e134Smrg
2847a84e134Smrg    for (i = 0; i < *in_num_args; i++) {
2857a84e134Smrg	if (streq(XtNicon, in_args[i].name))
2867a84e134Smrg	    checks[ICON] = True;
2877a84e134Smrg	else if (streq(XtNlabel, in_args[i].name))
2887a84e134Smrg	    checks[LABEL] = True;
2897a84e134Smrg    }
2907a84e134Smrg
2917a84e134Smrg    if (checks[ICON]) {
2927a84e134Smrg	if (w->dialog.icon != 0) {
2937a84e134Smrg	    XtSetArg(args[0], XtNbitmap, w->dialog.icon);
2947a84e134Smrg	    if (old->dialog.iconW != NULL)
2957a84e134Smrg		XtSetValues(old->dialog.iconW, args, 1);
2967a84e134Smrg	    else {
2977a84e134Smrg		XtSetArg(args[1], XtNborderWidth, 0);
2987a84e134Smrg		XtSetArg(args[2], XtNleft, XtChainLeft);
2997a84e134Smrg		XtSetArg(args[3], XtNright, XtChainLeft);
3007a84e134Smrg		w->dialog.iconW = XtCreateWidget("icon", labelWidgetClass,
3017a84e134Smrg						 cnew, args, 4);
3027a84e134Smrg		((DialogConstraints)w->dialog.labelW->core.constraints)->
3037a84e134Smrg		    form.horiz_base = w->dialog.iconW;
3047a84e134Smrg		XtManageChild(w->dialog.iconW);
3057a84e134Smrg	    }
3067a84e134Smrg	}
3077a84e134Smrg	else if (old->dialog.icon != 0) {
3087a84e134Smrg	    ((DialogConstraints)w->dialog.labelW->core.constraints)->
3097a84e134Smrg		form.horiz_base = NULL;
3107a84e134Smrg	    XtDestroyWidget(old->dialog.iconW);
3117a84e134Smrg	    w->dialog.iconW = NULL;
3127a84e134Smrg	}
3137a84e134Smrg    }
3147a84e134Smrg
3157a84e134Smrg    if (checks[LABEL]) {
3167a84e134Smrg	num_args = 0;
3177a84e134Smrg	XtSetArg(args[num_args], XtNlabel, w->dialog.label);	num_args++;
3187a84e134Smrg	if (w->dialog.iconW != NULL &&
3197a84e134Smrg	    XtHeight(w->dialog.labelW) <= XtHeight(w->dialog.iconW)) {
3207a84e134Smrg	    XtSetArg(args[num_args], XtNheight, XtHeight(w->dialog.iconW));
3217a84e134Smrg	    num_args++;
3227a84e134Smrg	}
3237a84e134Smrg	XtSetValues(w->dialog.labelW, args, num_args);
3247a84e134Smrg    }
3257a84e134Smrg
3267a84e134Smrg    if (w->dialog.value != old->dialog.value) {
3277a84e134Smrg	if (w->dialog.value == NULL)	/* only get here if it
3287a84e134Smrg					   wasn't NULL before */
3297a84e134Smrg	    XtDestroyWidget(old->dialog.valueW);
3307a84e134Smrg	else if (old->dialog.value == NULL) {	/* create a new value widget */
3317a84e134Smrg	    XtWidth(w) = XtWidth(old);
3327a84e134Smrg	    XtHeight(w) = XtHeight(old);
3337a84e134Smrg	    CreateDialogValueWidget(cnew);
3347a84e134Smrg	}
3357a84e134Smrg	else {				/* Widget ok, just change string */
3367a84e134Smrg	    Arg nargs[1];
3377a84e134Smrg
3387a84e134Smrg	    XtSetArg(nargs[0], XtNstring, w->dialog.value);
3397a84e134Smrg	    XtSetValues(w->dialog.valueW, nargs, 1);
3407a84e134Smrg	    w->dialog.value = MAGIC_VALUE;
3417a84e134Smrg	}
3427a84e134Smrg    }
3437a84e134Smrg
3447a84e134Smrg    return (False);
3457a84e134Smrg}
3467a84e134Smrg
3477a84e134Smrg/*
3487a84e134Smrg * Function:
3497a84e134Smrg *	XawDialogGetValuesHook
3507a84e134Smrg *
3517a84e134Smrg * Parameters:
3527a84e134Smrg *	w	 - Dialog Widget
3537a84e134Smrg *	args	 - argument list
3547a84e134Smrg *	num_args - number of args
3557a84e134Smrg *
3567a84e134Smrg * Description:
3577a84e134Smrg *	This is a get values hook routine that gets the values in the dialog.
3587a84e134Smrg */
3597a84e134Smrgstatic void
3607a84e134SmrgXawDialogGetValuesHook(Widget w, ArgList args, Cardinal *num_args)
3617a84e134Smrg{
3627a84e134Smrg    Arg a[1];
3637a84e134Smrg    String s;
3647a84e134Smrg    DialogWidget src = (DialogWidget)w;
3657a84e134Smrg    unsigned int i;
3667a84e134Smrg
3677a84e134Smrg    for (i = 0; i < *num_args; i++)
3687a84e134Smrg	if (streq(args[i].name, XtNvalue)) {
3697a84e134Smrg	    XtSetArg(a[0], XtNstring, &s);
3707a84e134Smrg	    XtGetValues(src->dialog.valueW, a, 1);
3717a84e134Smrg	    *((char **)args[i].value) = s;
3727a84e134Smrg	}
3737a84e134Smrg	else if (streq(args[i].name, XtNlabel)) {
3747a84e134Smrg	    XtSetArg(a[0], XtNlabel, &s);
3757a84e134Smrg	    XtGetValues(src->dialog.labelW, a, 1);
3767a84e134Smrg	    *((char **)args[i].value) = s;
3777a84e134Smrg	}
3787a84e134Smrg}
3797a84e134Smrg
3807a84e134Smrg/*
3817a84e134Smrg * Function:
3827a84e134Smrg *	CreateDialogValueWidget
3837a84e134Smrg *
3847a84e134Smrg * Parameters:
3857a84e134Smrg *	w - dialog widget
3867a84e134Smrg *
3877a84e134Smrg * Description:
3887a84e134Smrg *	Creates the dialog widgets value widget.
3897a84e134Smrg *
3907a84e134Smrg * Note
3917a84e134Smrg *	Must be called only when w->dialog.value is non-nil
3927a84e134Smrg */
3937a84e134Smrgstatic void
3947a84e134SmrgCreateDialogValueWidget(Widget w)
3957a84e134Smrg{
3967a84e134Smrg    DialogWidget dw = (DialogWidget)w;
3977a84e134Smrg    Arg arglist[10];
3987a84e134Smrg    Cardinal num_args = 0;
3997a84e134Smrg
4007a84e134Smrg    XtSetArg(arglist[num_args], XtNstring, dw->dialog.value);     num_args++;
4017a84e134Smrg    XtSetArg(arglist[num_args], XtNresizable, True);              num_args++;
4027a84e134Smrg    XtSetArg(arglist[num_args], XtNeditType, XawtextEdit);        num_args++;
4037a84e134Smrg    XtSetArg(arglist[num_args], XtNfromVert, dw->dialog.labelW);  num_args++;
4047a84e134Smrg    XtSetArg(arglist[num_args], XtNleft, XtChainLeft);            num_args++;
4057a84e134Smrg    XtSetArg(arglist[num_args], XtNright, XtChainRight);          num_args++;
4067a84e134Smrg
4077a84e134Smrg    dw->dialog.valueW = XtCreateWidget("value", asciiTextWidgetClass,
4087a84e134Smrg				       w, arglist, num_args);
4097a84e134Smrg
4107a84e134Smrg    /* if the value widget is being added after buttons,
4117a84e134Smrg     * then the buttons need new layout constraints
4127a84e134Smrg     */
4137a84e134Smrg    if (dw->composite.num_children > 1) {
4147a84e134Smrg	WidgetList children = dw->composite.children;
4157a84e134Smrg	Widget *childP;
4167a84e134Smrg
4177a84e134Smrg        for (childP = children + dw->composite.num_children - 1;
4187a84e134Smrg	     childP >= children; childP-- ) {
4197a84e134Smrg	    if (*childP == dw->dialog.labelW || *childP == dw->dialog.valueW)
4207a84e134Smrg		continue;
4217a84e134Smrg
4227a84e134Smrg	    if (XtIsManaged(*childP) &&
4237a84e134Smrg	        XtIsSubclass(*childP, commandWidgetClass)) {
4247a84e134Smrg		((DialogConstraints)(*childP)->core.constraints)->
4257a84e134Smrg		    form.vert_base = dw->dialog.valueW;
4267a84e134Smrg	    }
4277a84e134Smrg	}
4287a84e134Smrg    }
4297a84e134Smrg    XtManageChild(dw->dialog.valueW);
4307a84e134Smrg
4317a84e134Smrg    /*
4327a84e134Smrg     * Value widget gets the keyboard focus
4337a84e134Smrg     */
4347a84e134Smrg    XtSetKeyboardFocus(w, dw->dialog.valueW);
4357a84e134Smrg    dw->dialog.value = MAGIC_VALUE;
4367a84e134Smrg}
4377a84e134Smrg
4387a84e134Smrgvoid
4397a84e134SmrgXawDialogAddButton(Widget dialog, _Xconst char* name, XtCallbackProc function,
4407a84e134Smrg		   XtPointer param)
4417a84e134Smrg{
4427a84e134Smrg    /*
4437a84e134Smrg     * Correct Constraints are all set in ConstraintInitialize()
4447a84e134Smrg     */
4457a84e134Smrg    Widget button;
4467a84e134Smrg
4477a84e134Smrg    button = XtCreateManagedWidget(name, commandWidgetClass, dialog, NULL, 0);
4487a84e134Smrg
4497a84e134Smrg    if (function != NULL)	/* don't add NULL callback func */
4507a84e134Smrg	XtAddCallback(button, XtNcallback, function, param);
4517a84e134Smrg}
4527a84e134Smrg
4537a84e134Smrgchar *
4547a84e134SmrgXawDialogGetValueString(Widget w)
4557a84e134Smrg{
4567a84e134Smrg    Arg args[1];
4577a84e134Smrg    char *value;
4587a84e134Smrg
4597a84e134Smrg    XtSetArg(args[0], XtNstring, &value);
4607a84e134Smrg    XtGetValues(((DialogWidget)w)->dialog.valueW, args, 1);
4617a84e134Smrg
4627a84e134Smrg    return(value);
4637a84e134Smrg}
464