1 /* NetHack 3.6 Window.c $NHDT-Date: 1432512808 2015/05/25 00:13:28 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
2 /* Copyright (c) Dean Luick, 1992 */
3 /* NetHack may be freely redistributed. See license for details. */
5 /* JNetHack Copyright */
6 /* (c) Issei Numata 1994-1999 */
7 /* For 3.4-, Copyright (c) SHIRAKATA Kentaro, 2002-2020 */
8 /* JNetHack may be freely redistributed. See license for details. */
11 * Data structures and support routines for the Window widget. This is a
12 * drawing canvas with 16 colors and one font.
16 #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
19 #ifdef MSDOS /* from compiler */
20 #define SHORT_FILENAMES
23 #ifdef SHORT_FILENAMES
24 #include <X11/IntrinsP.h>
26 #include <X11/IntrinsicP.h>
28 #include <X11/StringDefs.h>
30 #ifdef PRESERVE_NO_SYSV
34 #undef PRESERVE_NO_SYSV
42 static XtResource resources[] = {
43 #define offset(field) XtOffset(WindowWidget, window.field)
44 /* {name, class, type, size, offset, default_type, default_addr}, */
45 { nhStr(XtNrows), nhStr(XtCRows), XtRDimension, sizeof(Dimension),
46 offset(rows), XtRImmediate, (XtPointer) 21 },
47 { nhStr(XtNcolumns), nhStr(XtCColumns), XtRDimension, sizeof(Dimension),
48 offset(columns), XtRImmediate, (XtPointer) 80 },
49 { nhStr(XtNforeground), XtCForeground, XtRPixel, sizeof(Pixel),
50 offset(foreground), XtRString, (XtPointer) XtDefaultForeground },
52 { nhStr(XtNblack), XtCColor, XtRPixel, sizeof(Pixel), offset(black),
53 XtRString, (XtPointer) "black" },
54 { nhStr(XtNred), XtCColor, XtRPixel, sizeof(Pixel), offset(red),
55 XtRString, (XtPointer) "red" },
56 { nhStr(XtNgreen), XtCColor, XtRPixel, sizeof(Pixel), offset(green),
57 XtRString, (XtPointer) "pale green" },
58 { nhStr(XtNbrown), XtCColor, XtRPixel, sizeof(Pixel), offset(brown),
59 XtRString, (XtPointer) "brown" },
60 { nhStr(XtNblue), XtCColor, XtRPixel, sizeof(Pixel), offset(blue),
61 XtRString, (XtPointer) "blue" },
62 { nhStr(XtNmagenta), XtCColor, XtRPixel, sizeof(Pixel), offset(magenta),
63 XtRString, (XtPointer) "magenta" },
64 { nhStr(XtNcyan), XtCColor, XtRPixel, sizeof(Pixel), offset(cyan),
65 XtRString, (XtPointer) "light cyan" },
66 { nhStr(XtNgray), XtCColor, XtRPixel, sizeof(Pixel), offset(gray),
67 XtRString, (XtPointer) "gray" },
68 { nhStr(XtNorange), XtCColor, XtRPixel, sizeof(Pixel), offset(orange),
69 XtRString, (XtPointer) "orange" },
70 { nhStr(XtNbright_green), XtCColor, XtRPixel, sizeof(Pixel),
71 offset(bright_green), XtRString, (XtPointer) "green" },
72 { nhStr(XtNyellow), XtCColor, XtRPixel, sizeof(Pixel), offset(yellow),
73 XtRString, (XtPointer) "yellow" },
74 { nhStr(XtNbright_blue), XtCColor, XtRPixel, sizeof(Pixel),
75 offset(bright_blue), XtRString, (XtPointer) "royal blue" },
76 { nhStr(XtNbright_magenta), XtCColor, XtRPixel, sizeof(Pixel),
77 offset(bright_magenta), XtRString, (XtPointer) "violet" },
78 { nhStr(XtNbright_cyan), XtCColor, XtRPixel, sizeof(Pixel),
79 offset(bright_cyan), XtRString, (XtPointer) "cyan" },
80 { nhStr(XtNwhite), XtCColor, XtRPixel, sizeof(Pixel), offset(white),
81 XtRString, (XtPointer) "white" },
83 { nhStr(XtNfont), XtCFont, XtRFontStruct, sizeof(XFontStruct *),
84 offset(font), XtRString, (XtPointer) XtDefaultFont },
86 { XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet *),
87 offset(fontset), XtRString, XtDefaultFontSet },
89 { nhStr(XtNexposeCallback), XtCCallback, XtRCallback,
90 sizeof(XtCallbackList), offset(expose_callback), XtRCallback,
92 { nhStr(XtNcallback), XtCCallback, XtRCallback, sizeof(XtCallbackList),
93 offset(input_callback), XtRCallback, (char *) 0 },
94 { nhStr(XtNresizeCallback), XtCCallback, XtRCallback,
95 sizeof(XtCallbackList), offset(resize_callback), XtRCallback,
102 no_op(w, event, params, num_params)
103 Widget w; /* unused */
104 XEvent *event; /* unused */
105 String *params; /* unused */
106 Cardinal *num_params; /* unused */
116 static XtActionsRec actions[] = {
117 { nhStr("no-op"), no_op },
120 static char translations[] = "<BtnDown>: input() \
125 Redisplay(w, event, region)
128 Region region; /* unused */
132 /* This isn't correct - we need to call the callback with region. */
133 XtCallCallbacks(w, XtNexposeCallback, (XtPointer)event);
141 XtCallCallbacks(w, XtNresizeCallback, (XtPointer) 0);
144 WindowClassRec windowClassRec = {
146 /* superclass */ (WidgetClass) &widgetClassRec,
147 /* class_name */ nhStr("Window"),
148 /* widget_size */ sizeof(WindowRec),
149 /* class_initialize */ 0,
150 /* class_part_initialize */ 0,
151 /* class_inited */ FALSE,
153 /* initialize_hook */ 0,
154 /* realize */ XtInheritRealize,
155 /* actions */ actions,
156 /* num_actions */ XtNumber(actions),
157 /* resources */ resources,
158 /* num_resources */ XtNumber(resources),
159 /* xrm_class */ NULLQUARK,
160 /* compress_motion */ TRUE,
161 /* compress_exposure */ TRUE,
162 /* compress_enterleave */ TRUE,
163 /* visible_interest */ FALSE,
166 /* expose */ Redisplay,
168 /* set_values_hook */ 0,
169 /* set_values_almost */ XtInheritSetValuesAlmost,
170 /* get_values_hook */ 0,
171 /* accept_focus */ 0,
172 /* version */ XtVersion,
173 /* callback_private */ 0,
174 /* tm_table */ translations,
175 /* query_geometry */ XtInheritQueryGeometry,
176 /* display_accelerator */ XtInheritDisplayAccelerator,
178 { /* window fields */
182 WidgetClass windowWidgetClass = (WidgetClass) &windowClassRec;
188 return ((WindowWidget) w)->window.font->fid;
195 return ((WindowWidget) w)->window.font;
203 return ((WindowWidget) w)->window.fontset;