1 /* NetHack 3.7 winval.c $NHDT-Date: 1611697183 2021/01/26 21:39:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.11 $ */
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"
35 create_value(Widget parent
, const char *name_value
)
42 XtSetArg(args
[num_args
], XtNborderWidth
, 0);
44 XtSetArg(args
[num_args
], nhStr(XtNdefaultDistance
), 0);
46 form
= XtCreateManagedWidget(name_value
, formWidgetClass
, parent
, args
,
50 XtSetArg(args
[num_args
], XtNjustify
, XtJustifyRight
);
52 XtSetArg(args
[num_args
], XtNborderWidth
, 0);
54 XtSetArg(args
[num_args
], XtNlabel
, name_value
);
56 XtSetArg(args
[num_args
], XtNinternalHeight
, 0);
59 XtCreateManagedWidget(WNAME
, labelWidgetClass
, form
, args
, num_args
);
62 XtSetArg(args
[num_args
], XtNjustify
, XtJustifyRight
);
64 XtSetArg(args
[num_args
], XtNborderWidth
, 0);
66 XtSetArg(args
[num_args
], nhStr(XtNfromHoriz
), name
);
68 XtSetArg(args
[num_args
], XtNinternalHeight
, 0);
70 (void) XtCreateManagedWidget(WVALUE
, labelWidgetClass
, form
, args
,
76 set_name(Widget w
, const char *new_label
)
81 name
= XtNameToWidget(w
, WNAME
);
82 XtSetArg(args
[0], XtNlabel
, new_label
);
83 XtSetValues(name
, args
, ONE
);
87 set_name_width(Widget w
, int new_width
)
92 name
= XtNameToWidget(w
, WNAME
);
93 XtSetArg(args
[0], XtNwidth
, new_width
);
94 XtSetValues(name
, args
, ONE
);
98 get_name_width(Widget w
)
104 name
= XtNameToWidget(w
, WNAME
);
105 XtSetArg(args
[0], XtNwidth
, &width
);
106 XtGetValues(name
, args
, ONE
);
111 get_value_widget(Widget w
)
113 return XtNameToWidget(w
, WVALUE
);
117 set_value(Widget w
, const char *new_value
)
122 val
= get_value_widget(w
);
123 XtSetArg(args
[0], XtNlabel
, new_value
);
124 XtSetValues(val
, args
, ONE
);
128 set_value_width(Widget w
, int new_width
)
133 val
= get_value_widget(w
);
134 XtSetArg(args
[0], XtNwidth
, new_width
);
135 XtSetValues(val
, args
, ONE
);
139 get_value_width(Widget w
)
145 val
= get_value_widget(w
);
146 XtSetArg(args
[0], XtNwidth
, &width
);
147 XtGetValues(val
, args
, ONE
);
151 /* Swap foreground and background colors (this is the best I can do with */
152 /* a label widget, unless I can get some init hook in there). */
154 hilight_value(Widget w
)
156 swap_fg_bg(get_value_widget(w
));
159 /* Swap the foreground and background colors of the given widget */
166 XtSetArg(args
[0], XtNforeground
, &fg
);
167 XtSetArg(args
[1], XtNbackground
, &bg
);
168 XtGetValues(w
, args
, TWO
);
170 XtSetArg(args
[0], XtNforeground
, bg
);
171 XtSetArg(args
[1], XtNbackground
, fg
);
172 XtSetValues(w
, args
, TWO
);