1 /* aNetHack 0.0.1 winval.c $ANH-Date: 1432512808 2015/05/25 00:13:28 $ $ANH-Branch: master $:$ANH-Revision: 1.9 $ */
2 /* Copyright (c) Dean Luick, 1992 */
3 /* aNetHack 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(parent
, name_value
)
37 const char *name_value
;
44 XtSetArg(args
[num_args
], XtNborderWidth
, 0);
46 XtSetArg(args
[num_args
], nhStr(XtNdefaultDistance
), 0);
48 form
= XtCreateManagedWidget(name_value
, formWidgetClass
, parent
, args
,
52 XtSetArg(args
[num_args
], XtNjustify
, XtJustifyRight
);
54 XtSetArg(args
[num_args
], XtNborderWidth
, 0);
56 XtSetArg(args
[num_args
], XtNlabel
, name_value
);
58 XtSetArg(args
[num_args
], XtNinternalHeight
, 0);
61 XtCreateManagedWidget(WNAME
, labelWidgetClass
, form
, args
, num_args
);
64 XtSetArg(args
[num_args
], XtNjustify
, XtJustifyRight
);
66 XtSetArg(args
[num_args
], XtNborderWidth
, 0);
68 XtSetArg(args
[num_args
], nhStr(XtNfromHoriz
), name
);
70 XtSetArg(args
[num_args
], XtNinternalHeight
, 0);
72 (void) XtCreateManagedWidget(WVALUE
, labelWidgetClass
, form
, args
,
78 set_name(w
, new_label
)
80 const char *new_label
;
85 name
= XtNameToWidget(w
, WNAME
);
86 XtSetArg(args
[0], XtNlabel
, new_label
);
87 XtSetValues(name
, args
, ONE
);
91 set_name_width(w
, new_width
)
98 name
= XtNameToWidget(w
, WNAME
);
99 XtSetArg(args
[0], XtNwidth
, new_width
);
100 XtSetValues(name
, args
, ONE
);
111 name
= XtNameToWidget(w
, WNAME
);
112 XtSetArg(args
[0], XtNwidth
, &width
);
113 XtGetValues(name
, args
, ONE
);
118 set_value(w
, new_value
)
120 const char *new_value
;
125 val
= XtNameToWidget(w
, WVALUE
);
126 XtSetArg(args
[0], XtNlabel
, new_value
);
127 XtSetValues(val
, args
, ONE
);
131 set_value_width(w
, new_width
)
138 val
= XtNameToWidget(w
, WVALUE
);
139 XtSetArg(args
[0], XtNwidth
, new_width
);
140 XtSetValues(val
, args
, ONE
);
151 val
= XtNameToWidget(w
, WVALUE
);
152 XtSetArg(args
[0], XtNwidth
, &width
);
153 XtGetValues(val
, args
, ONE
);
157 /* Swap foreground and background colors (this is the best I can do with */
158 /* a label widget, unless I can get some init hook in there). */
163 swap_fg_bg(XtNameToWidget(w
, WVALUE
));
166 /* Swap the foreground and background colors of the given widget */
174 XtSetArg(args
[0], XtNforeground
, &fg
);
175 XtSetArg(args
[1], XtNbackground
, &bg
);
176 XtGetValues(w
, args
, TWO
);
178 XtSetArg(args
[0], XtNforeground
, bg
);
179 XtSetArg(args
[1], XtNbackground
, fg
);
180 XtSetValues(w
, args
, TWO
);