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. */
6 * Data structures and support routines for the Window widget. This is a
7 * drawing canvas with 16 colors and one font.
11 ** Japanese version Copyright (C) Issei Numata, 1994-1999
12 ** changing point is marked `JP' (94/6/7) or XI18N (96/7/19)
13 ** For 3.4.0, Copyright (c) Kentaro Shirakata, 2002
14 ** JNetHack may be freely redistributed. See license for details.
18 #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
21 #ifdef MSDOS /* from compiler */
22 #define SHORT_FILENAMES
25 #ifdef SHORT_FILENAMES
26 #include <X11/IntrinsP.h>
28 #include <X11/IntrinsicP.h>
30 #include <X11/StringDefs.h>
32 #ifdef PRESERVE_NO_SYSV
36 #undef PRESERVE_NO_SYSV
44 static XtResource resources[] = {
45 #define offset(field) XtOffset(WindowWidget, window.field)
46 /* {name, class, type, size, offset, default_type, default_addr}, */
47 { nhStr(XtNrows), nhStr(XtCRows), XtRDimension, sizeof(Dimension),
48 offset(rows), XtRImmediate, (XtPointer) 21 },
49 { nhStr(XtNcolumns), nhStr(XtCColumns), XtRDimension, sizeof(Dimension),
50 offset(columns), XtRImmediate, (XtPointer) 80 },
51 { nhStr(XtNforeground), XtCForeground, XtRPixel, sizeof(Pixel),
52 offset(foreground), XtRString, (XtPointer) XtDefaultForeground },
54 { nhStr(XtNblack), XtCColor, XtRPixel, sizeof(Pixel), offset(black),
55 XtRString, (XtPointer) "black" },
56 { nhStr(XtNred), XtCColor, XtRPixel, sizeof(Pixel), offset(red),
57 XtRString, (XtPointer) "red" },
58 { nhStr(XtNgreen), XtCColor, XtRPixel, sizeof(Pixel), offset(green),
59 XtRString, (XtPointer) "pale green" },
60 { nhStr(XtNbrown), XtCColor, XtRPixel, sizeof(Pixel), offset(brown),
61 XtRString, (XtPointer) "brown" },
62 { nhStr(XtNblue), XtCColor, XtRPixel, sizeof(Pixel), offset(blue),
63 XtRString, (XtPointer) "blue" },
64 { nhStr(XtNmagenta), XtCColor, XtRPixel, sizeof(Pixel), offset(magenta),
65 XtRString, (XtPointer) "magenta" },
66 { nhStr(XtNcyan), XtCColor, XtRPixel, sizeof(Pixel), offset(cyan),
67 XtRString, (XtPointer) "light cyan" },
68 { nhStr(XtNgray), XtCColor, XtRPixel, sizeof(Pixel), offset(gray),
69 XtRString, (XtPointer) "gray" },
70 { nhStr(XtNorange), XtCColor, XtRPixel, sizeof(Pixel), offset(orange),
71 XtRString, (XtPointer) "orange" },
72 { nhStr(XtNbright_green), XtCColor, XtRPixel, sizeof(Pixel),
73 offset(bright_green), XtRString, (XtPointer) "green" },
74 { nhStr(XtNyellow), XtCColor, XtRPixel, sizeof(Pixel), offset(yellow),
75 XtRString, (XtPointer) "yellow" },
76 { nhStr(XtNbright_blue), XtCColor, XtRPixel, sizeof(Pixel),
77 offset(bright_blue), XtRString, (XtPointer) "royal blue" },
78 { nhStr(XtNbright_magenta), XtCColor, XtRPixel, sizeof(Pixel),
79 offset(bright_magenta), XtRString, (XtPointer) "violet" },
80 { nhStr(XtNbright_cyan), XtCColor, XtRPixel, sizeof(Pixel),
81 offset(bright_cyan), XtRString, (XtPointer) "cyan" },
82 { nhStr(XtNwhite), XtCColor, XtRPixel, sizeof(Pixel), offset(white),
83 XtRString, (XtPointer) "white" },
85 { nhStr(XtNfont), XtCFont, XtRFontStruct, sizeof(XFontStruct *),
86 offset(font), XtRString, (XtPointer) XtDefaultFont },
88 { XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet *),
89 offset(fontset), XtRString, XtDefaultFontSet },
91 { nhStr(XtNexposeCallback), XtCCallback, XtRCallback,
92 sizeof(XtCallbackList), offset(expose_callback), XtRCallback,
94 { nhStr(XtNcallback), XtCCallback, XtRCallback, sizeof(XtCallbackList),
95 offset(input_callback), XtRCallback, (char *) 0 },
96 { nhStr(XtNresizeCallback), XtCCallback, XtRCallback,
97 sizeof(XtCallbackList), offset(resize_callback), XtRCallback,
104 no_op(w, event, params, num_params)
105 Widget w; /* unused */
106 XEvent *event; /* unused */
107 String *params; /* unused */
108 Cardinal *num_params; /* unused */
118 static XtActionsRec actions[] = {
119 { nhStr("no-op"), no_op },
122 static char translations[] = "<BtnDown>: input() \
127 Redisplay(w, event, region)
130 Region region; /* unused */
134 /* This isn't correct - we need to call the callback with region. */
136 XtCallCallbacks(w, XtNexposeCallback, (caddr_t) event);
138 XtCallCallbacks(w, XtNexposeCallback, (XtPointer) event);
148 XtCallCallbacks(w, XtNresizeCallback, (caddr_t) 0);
150 XtCallCallbacks(w, XtNresizeCallback, (XtPointer) 0);
154 WindowClassRec windowClassRec = {
156 /* superclass */ (WidgetClass) &widgetClassRec,
157 /* class_name */ nhStr("Window"),
158 /* widget_size */ sizeof(WindowRec),
159 /* class_initialize */ 0,
160 /* class_part_initialize */ 0,
161 /* class_inited */ FALSE,
163 /* initialize_hook */ 0,
164 /* realize */ XtInheritRealize,
165 /* actions */ actions,
166 /* num_actions */ XtNumber(actions),
167 /* resources */ resources,
168 /* num_resources */ XtNumber(resources),
169 /* xrm_class */ NULLQUARK,
170 /* compress_motion */ TRUE,
171 /* compress_exposure */ TRUE,
172 /* compress_enterleave */ TRUE,
173 /* visible_interest */ FALSE,
176 /* expose */ Redisplay,
178 /* set_values_hook */ 0,
179 /* set_values_almost */ XtInheritSetValuesAlmost,
180 /* get_values_hook */ 0,
181 /* accept_focus */ 0,
182 /* version */ XtVersion,
183 /* callback_private */ 0,
184 /* tm_table */ translations,
185 /* query_geometry */ XtInheritQueryGeometry,
186 /* display_accelerator */ XtInheritDisplayAccelerator,
188 { /* window fields */
192 WidgetClass windowWidgetClass = (WidgetClass) &windowClassRec;
198 return ((WindowWidget) w)->window.font->fid;
205 return ((WindowWidget) w)->window.font;
213 return ((WindowWidget) w)->window.fontset;