more quieting of Qt6 build warnings
[NetHack.git] / win / X11 / winval.c
blobc333a5483c2e90c1d365366babfe88009efbf0ad
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. */
5 /*
6 * Routines that define a name-value label widget pair that fit inside a
7 * form widget.
8 */
9 #include <stdio.h>
11 #ifndef SYSV
12 #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
13 #endif
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
22 #ifdef SYSV
23 #undef SYSV
24 #endif
25 #undef PRESERVE_NO_SYSV
26 #endif
28 #include "hack.h" /* #define for const for non __STDC__ compilers */
29 #include "winX.h"
31 #define WNAME "name"
32 #define WVALUE "value"
34 Widget
35 create_value(Widget parent, const char *name_value)
37 Widget form, name;
38 Arg args[8];
39 Cardinal num_args;
41 num_args = 0;
42 XtSetArg(args[num_args], XtNborderWidth, 0);
43 num_args++;
44 XtSetArg(args[num_args], nhStr(XtNdefaultDistance), 0);
45 num_args++;
46 form = XtCreateManagedWidget(name_value, formWidgetClass, parent, args,
47 num_args);
49 num_args = 0;
50 XtSetArg(args[num_args], XtNjustify, XtJustifyRight);
51 num_args++;
52 XtSetArg(args[num_args], XtNborderWidth, 0);
53 num_args++;
54 XtSetArg(args[num_args], XtNlabel, name_value);
55 num_args++;
56 XtSetArg(args[num_args], XtNinternalHeight, 0);
57 num_args++;
58 name =
59 XtCreateManagedWidget(WNAME, labelWidgetClass, form, args, num_args);
61 num_args = 0;
62 XtSetArg(args[num_args], XtNjustify, XtJustifyRight);
63 num_args++;
64 XtSetArg(args[num_args], XtNborderWidth, 0);
65 num_args++;
66 XtSetArg(args[num_args], nhStr(XtNfromHoriz), name);
67 num_args++;
68 XtSetArg(args[num_args], XtNinternalHeight, 0);
69 num_args++;
70 (void) XtCreateManagedWidget(WVALUE, labelWidgetClass, form, args,
71 num_args);
72 return form;
75 void
76 set_name(Widget w, const char *new_label)
78 Arg args[1];
79 Widget name;
81 name = XtNameToWidget(w, WNAME);
82 XtSetArg(args[0], XtNlabel, new_label);
83 XtSetValues(name, args, ONE);
86 void
87 set_name_width(Widget w, int new_width)
89 Arg args[1];
90 Widget name;
92 name = XtNameToWidget(w, WNAME);
93 XtSetArg(args[0], XtNwidth, new_width);
94 XtSetValues(name, args, ONE);
97 int
98 get_name_width(Widget w)
100 Arg args[1];
101 Dimension width;
102 Widget name;
104 name = XtNameToWidget(w, WNAME);
105 XtSetArg(args[0], XtNwidth, &width);
106 XtGetValues(name, args, ONE);
107 return (int) width;
110 Widget
111 get_value_widget(Widget w)
113 return XtNameToWidget(w, WVALUE);
116 void
117 set_value(Widget w, const char *new_value)
119 Arg args[1];
120 Widget val;
122 val = get_value_widget(w);
123 XtSetArg(args[0], XtNlabel, new_value);
124 XtSetValues(val, args, ONE);
127 void
128 set_value_width(Widget w, int new_width)
130 Arg args[1];
131 Widget val;
133 val = get_value_widget(w);
134 XtSetArg(args[0], XtNwidth, new_width);
135 XtSetValues(val, args, ONE);
139 get_value_width(Widget w)
141 Arg args[1];
142 Widget val;
143 Dimension width;
145 val = get_value_widget(w);
146 XtSetArg(args[0], XtNwidth, &width);
147 XtGetValues(val, args, ONE);
148 return (int) width;
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). */
153 void
154 hilight_value(Widget w)
156 swap_fg_bg(get_value_widget(w));
159 /* Swap the foreground and background colors of the given widget */
160 void
161 swap_fg_bg(Widget w)
163 Arg args[2];
164 Pixel fg, bg;
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);