1 /* SCCS Id: @(#)winval.c 3.4 1992/3/7 */
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 */
32 #define WVALUE "value"
36 create_value(parent, name_value)
38 const char *name_value;
45 XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
46 XtSetArg(args[num_args], XtNdefaultDistance, 0); num_args++;
47 form = XtCreateManagedWidget(name_value,
49 parent, args, num_args);
52 XtSetArg(args[num_args], XtNjustify, XtJustifyRight); num_args++;
53 XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
54 XtSetArg(args[num_args], XtNlabel, name_value); num_args++;
55 XtSetArg(args[num_args], XtNinternalHeight, 0); num_args++;
56 name = XtCreateManagedWidget(WNAME,
58 form, args, num_args);
61 XtSetArg(args[num_args], XtNjustify, XtJustifyRight); num_args++;
62 XtSetArg(args[num_args], XtNborderWidth, 0); num_args++;
63 XtSetArg(args[num_args], XtNfromHoriz, name); num_args++;
64 XtSetArg(args[num_args], XtNinternalHeight, 0); num_args++;
65 (void) XtCreateManagedWidget(WVALUE,
67 form, args, num_args);
72 set_name(w, new_label)
79 name = XtNameToWidget(w, WNAME);
80 XtSetArg(args[0], XtNlabel, new_label);
81 XtSetValues(name, args, ONE);
85 set_name_width(w, new_width)
92 name = XtNameToWidget(w, WNAME);
93 XtSetArg(args[0], XtNwidth, new_width);
94 XtSetValues(name, args, ONE);
105 name = XtNameToWidget(w, WNAME);
106 XtSetArg(args[0], XtNwidth, &width);
107 XtGetValues(name, args, ONE);
113 set_value(w, new_value)
115 const char *new_value;
120 val = XtNameToWidget(w, WVALUE);
121 XtSetArg(args[0], XtNlabel, new_value);
122 XtSetValues(val, args, ONE);
126 set_value_width(w, new_width)
133 val = XtNameToWidget(w, WVALUE);
134 XtSetArg(args[0], XtNwidth, new_width);
135 XtSetValues(val, args, ONE);
146 val = XtNameToWidget(w, WVALUE);
147 XtSetArg(args[0], XtNwidth, &width);
148 XtGetValues(val, args, ONE);
152 /* Swap foreground and background colors (this is the best I can do with */
153 /* a label widget, unless I can get some init hook in there). */
158 swap_fg_bg(XtNameToWidget(w, WVALUE));
161 /* Swap the foreground and background colors of the given widget */
169 XtSetArg(args[0], XtNforeground, &fg);
170 XtSetArg(args[1], XtNbackground, &bg);
171 XtGetValues(w, args, TWO);
173 XtSetArg(args[0], XtNforeground, bg);
174 XtSetArg(args[1], XtNbackground, fg);
175 XtSetValues(w, args, TWO);