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