1 /* NetHack 3.6 winval.c $NHDT-Date: 1432512808 2015/05/25 00:13:28 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
2 /* Copyright (c) Dean Luick, 1992 */
3 /* NetHack may be freely redistributed. See license for details. */
6 * Routines that define a name-value label widget pair that fit inside a
12 #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
15 #include <X11/Intrinsic.h>
16 #include <X11/StringDefs.h>
17 #include <X11/Xaw/Label.h>
18 #include <X11/Xaw/Form.h>
19 #include <X11/Xaw/Cardinals.h>
21 #ifdef PRESERVE_NO_SYSV
25 #undef PRESERVE_NO_SYSV
28 #include "hack.h" /* #define for const for non __STDC__ compilers */
31 #include <X11/Xaw/Xawi18n.h>
36 #define WVALUE "value"
39 create_value(parent, name_value)
41 const char *name_value;
48 XtSetArg(args[num_args], XtNborderWidth, 0);
50 XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0);
52 form = XtCreateManagedWidget(name_value, formWidgetClass, parent, args,
56 XtSetArg(args[num_args], XtNjustify, XtJustifyRight);
58 XtSetArg(args[num_args], XtNborderWidth, 0);
60 XtSetArg(args[num_args], XtNlabel, name_value);
63 #if defined(X11R6) && defined(XI18N)
64 XtSetArg(args[num_args], XtNinternational, True);
67 XtSetArg(args[num_args], XtNinternalHeight, 0);
70 XtCreateManagedWidget(WNAME, labelWidgetClass, form, args, num_args);
73 XtSetArg(args[num_args], XtNjustify, XtJustifyRight);
75 XtSetArg(args[num_args], XtNborderWidth, 0);
77 XtSetArg(args[num_args], nhStr(XtNfromHoriz), name);
80 #if defined(X11R6) && defined(XI18N)
81 XtSetArg(args[num_args], XtNinternational, True);
84 XtSetArg(args[num_args], XtNinternalHeight, 0);
86 (void) XtCreateManagedWidget(WVALUE, labelWidgetClass, form, args,
92 set_name(w, new_label)
94 const char *new_label;
99 name = XtNameToWidget(w, WNAME);
100 XtSetArg(args[0], XtNlabel, new_label);
101 XtSetValues(name, args, ONE);
105 set_name_width(w, new_width)
112 name = XtNameToWidget(w, WNAME);
113 XtSetArg(args[0], XtNwidth, new_width);
114 XtSetValues(name, args, ONE);
125 name = XtNameToWidget(w, WNAME);
126 XtSetArg(args[0], XtNwidth, &width);
127 XtGetValues(name, args, ONE);
132 set_value(w, new_value)
134 const char *new_value;
139 val = XtNameToWidget(w, WVALUE);
140 XtSetArg(args[0], XtNlabel, new_value);
141 XtSetValues(val, args, ONE);
145 set_value_width(w, new_width)
152 val = XtNameToWidget(w, WVALUE);
153 XtSetArg(args[0], XtNwidth, new_width);
154 XtSetValues(val, args, ONE);
165 val = XtNameToWidget(w, WVALUE);
166 XtSetArg(args[0], XtNwidth, &width);
167 XtGetValues(val, args, ONE);
171 /* Swap foreground and background colors (this is the best I can do with */
172 /* a label widget, unless I can get some init hook in there). */
177 swap_fg_bg(XtNameToWidget(w, WVALUE));
180 /* Swap the foreground and background colors of the given widget */
188 XtSetArg(args[0], XtNforeground, &fg);
189 XtSetArg(args[1], XtNbackground, &bg);
190 XtGetValues(w, args, TWO);
192 XtSetArg(args[0], XtNforeground, bg);
193 XtSetArg(args[1], XtNbackground, fg);
194 XtSetValues(w, args, TWO);