more quieting of Qt6 build warnings
[NetHack.git] / win / X11 / Window.c
blob82cb5a1c6271f920e602a9e29c36fc558b3bf934
1 /* NetHack 3.7 Window.c $NHDT-Date: 1596498371 2020/08/03 23:46:11 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.12 $ */
2 /* Copyright (c) Dean Luick, 1992 */
3 /* NetHack may be freely redistributed. See license for details. */
5 /*
6 * Data structures and support routines for the Window widget. This is a
7 * drawing canvas with 16 colors and one font.
8 */
10 #ifndef SYSV
11 #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
12 #endif
14 #ifdef MSDOS /* from compiler */
15 #define SHORT_FILENAMES
16 #endif
18 #ifdef SHORT_FILENAMES
19 #include <X11/IntrinsP.h>
20 #else
21 #include <X11/IntrinsicP.h>
22 #endif
23 #include <X11/StringDefs.h>
25 #ifdef PRESERVE_NO_SYSV
26 #ifdef SYSV
27 #undef SYSV
28 #endif
29 #undef PRESERVE_NO_SYSV
30 #endif
32 #include "xwindowp.h"
34 #include "config.h" /* #define for const for non __STDC__ compilers */
35 #include "lint.h" /* for nethack's nhStr() macro */
36 #include "winX.h" /* to make sure prototypes match corresponding functions */
38 static XtResource resources[] = {
39 #define offset(field) XtOffset(WindowWidget, window.field)
40 /* {name, class, type, size, offset, default_type, default_addr}, */
41 { nhStr(XtNrows), nhStr(XtCRows), XtRDimension, sizeof(Dimension),
42 offset(rows), XtRImmediate, (XtPointer) 21 },
43 { nhStr(XtNcolumns), nhStr(XtCColumns), XtRDimension, sizeof(Dimension),
44 offset(columns), XtRImmediate, (XtPointer) 80 },
45 { nhStr(XtNforeground), XtCForeground, XtRPixel, sizeof(Pixel),
46 offset(foreground), XtRString, (XtPointer) XtDefaultForeground },
48 { nhStr(XtNblack), XtCColor, XtRPixel, sizeof(Pixel), offset(black),
49 XtRString, (XtPointer) "black" },
50 { nhStr(XtNred), XtCColor, XtRPixel, sizeof(Pixel), offset(red),
51 XtRString, (XtPointer) "red" },
52 { nhStr(XtNgreen), XtCColor, XtRPixel, sizeof(Pixel), offset(green),
53 XtRString, (XtPointer) "pale green" },
54 { nhStr(XtNbrown), XtCColor, XtRPixel, sizeof(Pixel), offset(brown),
55 XtRString, (XtPointer) "brown" },
56 { nhStr(XtNblue), XtCColor, XtRPixel, sizeof(Pixel), offset(blue),
57 XtRString, (XtPointer) "blue" },
58 { nhStr(XtNmagenta), XtCColor, XtRPixel, sizeof(Pixel), offset(magenta),
59 XtRString, (XtPointer) "magenta" },
60 { nhStr(XtNcyan), XtCColor, XtRPixel, sizeof(Pixel), offset(cyan),
61 XtRString, (XtPointer) "light cyan" },
62 { nhStr(XtNgray), XtCColor, XtRPixel, sizeof(Pixel), offset(gray),
63 XtRString, (XtPointer) "gray" },
64 { nhStr(XtNorange), XtCColor, XtRPixel, sizeof(Pixel), offset(orange),
65 XtRString, (XtPointer) "orange" },
66 { nhStr(XtNbright_green), XtCColor, XtRPixel, sizeof(Pixel),
67 offset(bright_green), XtRString, (XtPointer) "green" },
68 { nhStr(XtNyellow), XtCColor, XtRPixel, sizeof(Pixel), offset(yellow),
69 XtRString, (XtPointer) "yellow" },
70 { nhStr(XtNbright_blue), XtCColor, XtRPixel, sizeof(Pixel),
71 offset(bright_blue), XtRString, (XtPointer) "royal blue" },
72 { nhStr(XtNbright_magenta), XtCColor, XtRPixel, sizeof(Pixel),
73 offset(bright_magenta), XtRString, (XtPointer) "violet" },
74 { nhStr(XtNbright_cyan), XtCColor, XtRPixel, sizeof(Pixel),
75 offset(bright_cyan), XtRString, (XtPointer) "cyan" },
76 { nhStr(XtNwhite), XtCColor, XtRPixel, sizeof(Pixel), offset(white),
77 XtRString, (XtPointer) "white" },
79 { nhStr(XtNfont), XtCFont, XtRFontStruct, sizeof(XFontStruct *),
80 offset(font), XtRString, (XtPointer) XtDefaultFont },
81 { nhStr(XtNexposeCallback), XtCCallback, XtRCallback,
82 sizeof(XtCallbackList), offset(expose_callback), XtRCallback,
83 (char *) 0 },
84 { nhStr(XtNcallback), XtCCallback, XtRCallback, sizeof(XtCallbackList),
85 offset(input_callback), XtRCallback, (char *) 0 },
86 { nhStr(XtNresizeCallback), XtCCallback, XtRCallback,
87 sizeof(XtCallbackList), offset(resize_callback), XtRCallback,
88 (char *) 0 },
89 #undef offset
92 /* ARGSUSED */
93 static void
94 no_op(Widget w, /* unused */
95 XEvent *event, /* unused */
96 String *params, /* unused */
97 Cardinal *num_params) /* unused */
99 nhUse(w);
100 nhUse(event);
101 nhUse(params);
102 nhUse(num_params);
104 return;
107 static XtActionsRec actions[] = {
108 { nhStr("no-op"), no_op },
111 static char translations[] = "<BtnDown>: input() \
114 /* ARGSUSED */
115 static void
116 Redisplay(Widget w, XEvent *event, Region region /* unused */)
118 nhUse(region);
120 /* This isn't correct - we need to call the callback with region. */
121 XtCallCallbacks(w, XtNexposeCallback, (XtPointer)event);
124 /* ARGSUSED */
125 static void
126 Resize(Widget w)
128 XtCallCallbacks(w, XtNresizeCallback, (XtPointer) 0);
131 WindowClassRec windowClassRec = {
132 { /* core fields */
133 /* superclass */ (WidgetClass) &widgetClassRec,
134 /* class_name */ nhStr("Window"),
135 /* widget_size */ sizeof(WindowRec),
136 /* class_initialize */ 0,
137 /* class_part_initialize */ 0,
138 /* class_inited */ FALSE,
139 /* initialize */ 0,
140 /* initialize_hook */ 0,
141 /* realize */ XtInheritRealize,
142 /* actions */ actions,
143 /* num_actions */ XtNumber(actions),
144 /* resources */ resources,
145 /* num_resources */ XtNumber(resources),
146 /* xrm_class */ NULLQUARK,
147 /* compress_motion */ TRUE,
148 /* compress_exposure */ TRUE,
149 /* compress_enterleave */ TRUE,
150 /* visible_interest */ FALSE,
151 /* destroy */ 0,
152 /* resize */ Resize,
153 /* expose */ Redisplay,
154 /* set_values */ 0,
155 /* set_values_hook */ 0,
156 /* set_values_almost */ XtInheritSetValuesAlmost,
157 /* get_values_hook */ 0,
158 /* accept_focus */ 0,
159 /* version */ XtVersion,
160 /* callback_private */ 0,
161 /* tm_table */ translations,
162 /* query_geometry */ XtInheritQueryGeometry,
163 /* display_accelerator */ XtInheritDisplayAccelerator,
164 /* extension */ 0 },
165 { /* window fields */
166 /* empty */ 0 }
169 WidgetClass windowWidgetClass = (WidgetClass) &windowClassRec;
171 Font
172 WindowFont(Widget w)
174 return ((WindowWidget) w)->window.font->fid;
177 XFontStruct *
178 WindowFontStruct(Widget w)
180 return ((WindowWidget) w)->window.font;