OSDN Git Service

update year to 2020
[jnethack/source.git] / win / X11 / Window.c
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. */
4
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. */
9
10 /*
11  * Data structures and support routines for the Window widget.  This is a
12  * drawing canvas with 16 colors and one font.
13  */
14
15 #ifndef SYSV
16 #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
17 #endif
18
19 #ifdef MSDOS /* from compiler */
20 #define SHORT_FILENAMES
21 #endif
22
23 #ifdef SHORT_FILENAMES
24 #include <X11/IntrinsP.h>
25 #else
26 #include <X11/IntrinsicP.h>
27 #endif
28 #include <X11/StringDefs.h>
29
30 #ifdef PRESERVE_NO_SYSV
31 #ifdef SYSV
32 #undef SYSV
33 #endif
34 #undef PRESERVE_NO_SYSV
35 #endif
36
37 #include "xwindowp.h"
38
39 #include "config.h"
40 #include "lint.h"
41
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 },
51
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" },
82
83     { nhStr(XtNfont), XtCFont, XtRFontStruct, sizeof(XFontStruct *),
84       offset(font), XtRString, (XtPointer) XtDefaultFont },
85 #ifdef XI18N
86     { XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet *),
87         offset(fontset), XtRString, XtDefaultFontSet },
88 #endif
89     { nhStr(XtNexposeCallback), XtCCallback, XtRCallback,
90       sizeof(XtCallbackList), offset(expose_callback), XtRCallback,
91       (char *) 0 },
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,
96       (char *) 0 },
97 #undef offset
98 };
99
100 /* ARGSUSED */
101 static void
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 */
107 {
108     nhUse(w);
109     nhUse(event);
110     nhUse(params);
111     nhUse(num_params);
112
113     return;
114 }
115
116 static XtActionsRec actions[] = {
117     { nhStr("no-op"), no_op },
118 };
119
120 static char translations[] = "<BtnDown>:     input() \
121 ";
122
123 /* ARGSUSED */
124 static void
125 Redisplay(w, event, region)
126 Widget w;
127 XEvent *event;
128 Region region; /* unused */
129 {
130     nhUse(region);
131
132     /* This isn't correct - we need to call the callback with region. */
133     XtCallCallbacks(w, XtNexposeCallback, (XtPointer)event);
134 }
135
136 /* ARGSUSED */
137 static void
138 Resize(w)
139 Widget w;
140 {
141     XtCallCallbacks(w, XtNresizeCallback, (XtPointer) 0);
142 }
143
144 WindowClassRec windowClassRec = {
145     { /* core fields */
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,
152       /* initialize             */ 0,
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,
164       /* destroy                        */ 0,
165       /* resize                 */ Resize,
166       /* expose                 */ Redisplay,
167       /* set_values             */ 0,
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,
177       /* extension              */ 0 },
178     { /* window fields */
179       /* empty                  */ 0 }
180 };
181
182 WidgetClass windowWidgetClass = (WidgetClass) &windowClassRec;
183
184 Font
185 WindowFont(w)
186 Widget w;
187 {
188     return ((WindowWidget) w)->window.font->fid;
189 }
190
191 XFontStruct *
192 WindowFontStruct(w)
193 Widget w;
194 {
195     return ((WindowWidget) w)->window.font;
196 }
197
198 #ifdef XI18N
199 XFontSet
200 WindowFontSet(w)
201 Widget w;
202 {
203     return ((WindowWidget) w)->window.fontset;
204 }
205 #endif