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 #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
14 #ifdef MSDOS /* from compiler */
15 #define SHORT_FILENAMES
18 #ifdef SHORT_FILENAMES
19 #include <X11/IntrinsP.h>
21 #include <X11/IntrinsicP.h>
23 #include <X11/StringDefs.h>
25 #ifdef PRESERVE_NO_SYSV
29 #undef PRESERVE_NO_SYSV
37 static XtResource resources[] = {
38 #define offset(field) XtOffset(WindowWidget, window.field)
39 /* {name, class, type, size, offset, default_type, default_addr}, */
40 { nhStr(XtNrows), nhStr(XtCRows), XtRDimension, sizeof(Dimension),
41 offset(rows), XtRImmediate, (XtPointer) 21 },
42 { nhStr(XtNcolumns), nhStr(XtCColumns), XtRDimension, sizeof(Dimension),
43 offset(columns), XtRImmediate, (XtPointer) 80 },
44 { nhStr(XtNforeground), XtCForeground, XtRPixel, sizeof(Pixel),
45 offset(foreground), XtRString, (XtPointer) XtDefaultForeground },
47 { nhStr(XtNblack), XtCColor, XtRPixel, sizeof(Pixel), offset(black),
48 XtRString, (XtPointer) "black" },
49 { nhStr(XtNred), XtCColor, XtRPixel, sizeof(Pixel), offset(red),
50 XtRString, (XtPointer) "red" },
51 { nhStr(XtNgreen), XtCColor, XtRPixel, sizeof(Pixel), offset(green),
52 XtRString, (XtPointer) "pale green" },
53 { nhStr(XtNbrown), XtCColor, XtRPixel, sizeof(Pixel), offset(brown),
54 XtRString, (XtPointer) "brown" },
55 { nhStr(XtNblue), XtCColor, XtRPixel, sizeof(Pixel), offset(blue),
56 XtRString, (XtPointer) "blue" },
57 { nhStr(XtNmagenta), XtCColor, XtRPixel, sizeof(Pixel), offset(magenta),
58 XtRString, (XtPointer) "magenta" },
59 { nhStr(XtNcyan), XtCColor, XtRPixel, sizeof(Pixel), offset(cyan),
60 XtRString, (XtPointer) "light cyan" },
61 { nhStr(XtNgray), XtCColor, XtRPixel, sizeof(Pixel), offset(gray),
62 XtRString, (XtPointer) "gray" },
63 { nhStr(XtNorange), XtCColor, XtRPixel, sizeof(Pixel), offset(orange),
64 XtRString, (XtPointer) "orange" },
65 { nhStr(XtNbright_green), XtCColor, XtRPixel, sizeof(Pixel),
66 offset(bright_green), XtRString, (XtPointer) "green" },
67 { nhStr(XtNyellow), XtCColor, XtRPixel, sizeof(Pixel), offset(yellow),
68 XtRString, (XtPointer) "yellow" },
69 { nhStr(XtNbright_blue), XtCColor, XtRPixel, sizeof(Pixel),
70 offset(bright_blue), XtRString, (XtPointer) "royal blue" },
71 { nhStr(XtNbright_magenta), XtCColor, XtRPixel, sizeof(Pixel),
72 offset(bright_magenta), XtRString, (XtPointer) "violet" },
73 { nhStr(XtNbright_cyan), XtCColor, XtRPixel, sizeof(Pixel),
74 offset(bright_cyan), XtRString, (XtPointer) "cyan" },
75 { nhStr(XtNwhite), XtCColor, XtRPixel, sizeof(Pixel), offset(white),
76 XtRString, (XtPointer) "white" },
78 { nhStr(XtNfont), XtCFont, XtRFontStruct, sizeof(XFontStruct *),
79 offset(font), XtRString, (XtPointer) XtDefaultFont },
80 { nhStr(XtNexposeCallback), XtCCallback, XtRCallback,
81 sizeof(XtCallbackList), offset(expose_callback), XtRCallback,
83 { nhStr(XtNcallback), XtCCallback, XtRCallback, sizeof(XtCallbackList),
84 offset(input_callback), XtRCallback, (char *) 0 },
85 { nhStr(XtNresizeCallback), XtCCallback, XtRCallback,
86 sizeof(XtCallbackList), offset(resize_callback), XtRCallback,
93 no_op(w, event, params, num_params)
94 Widget w; /* unused */
95 XEvent *event; /* unused */
96 String *params; /* unused */
97 Cardinal *num_params; /* unused */
107 static XtActionsRec actions[] = {
108 { nhStr("no-op"), no_op },
111 static char translations[] = "<BtnDown>: input() \
116 Redisplay(w, event, region)
119 Region region; /* unused */
123 /* This isn't correct - we need to call the callback with region. */
124 XtCallCallbacks(w, XtNexposeCallback, (caddr_t) event);
132 XtCallCallbacks(w, XtNresizeCallback, (caddr_t) 0);
135 WindowClassRec windowClassRec = {
137 /* superclass */ (WidgetClass) &widgetClassRec,
138 /* class_name */ nhStr("Window"),
139 /* widget_size */ sizeof(WindowRec),
140 /* class_initialize */ 0,
141 /* class_part_initialize */ 0,
142 /* class_inited */ FALSE,
144 /* initialize_hook */ 0,
145 /* realize */ XtInheritRealize,
146 /* actions */ actions,
147 /* num_actions */ XtNumber(actions),
148 /* resources */ resources,
149 /* num_resources */ XtNumber(resources),
150 /* xrm_class */ NULLQUARK,
151 /* compress_motion */ TRUE,
152 /* compress_exposure */ TRUE,
153 /* compress_enterleave */ TRUE,
154 /* visible_interest */ FALSE,
157 /* expose */ Redisplay,
159 /* set_values_hook */ 0,
160 /* set_values_almost */ XtInheritSetValuesAlmost,
161 /* get_values_hook */ 0,
162 /* accept_focus */ 0,
163 /* version */ XtVersion,
164 /* callback_private */ 0,
165 /* tm_table */ translations,
166 /* query_geometry */ XtInheritQueryGeometry,
167 /* display_accelerator */ XtInheritDisplayAccelerator,
169 { /* window fields */
173 WidgetClass windowWidgetClass = (WidgetClass) &windowClassRec;
179 return ((WindowWidget) w)->window.font->fid;
186 return ((WindowWidget) w)->window.font;