OSDN Git Service

version++
[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 /*
6  * Data structures and support routines for the Window widget.  This is a
7  * drawing canvas with 16 colors and one font.
8  */
9
10 /*
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. 
15 */
16
17 #ifndef SYSV
18 #define PRESERVE_NO_SYSV /* X11 include files may define SYSV */
19 #endif
20
21 #ifdef MSDOS /* from compiler */
22 #define SHORT_FILENAMES
23 #endif
24
25 #ifdef SHORT_FILENAMES
26 #include <X11/IntrinsP.h>
27 #else
28 #include <X11/IntrinsicP.h>
29 #endif
30 #include <X11/StringDefs.h>
31
32 #ifdef PRESERVE_NO_SYSV
33 #ifdef SYSV
34 #undef SYSV
35 #endif
36 #undef PRESERVE_NO_SYSV
37 #endif
38
39 #include "xwindowp.h"
40
41 #include "config.h"
42 #include "lint.h"
43
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 },
53
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" },
84
85     { nhStr(XtNfont), XtCFont, XtRFontStruct, sizeof(XFontStruct *),
86       offset(font), XtRString, (XtPointer) XtDefaultFont },
87 #ifdef XI18N
88     { XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet *),
89         offset(fontset), XtRString, XtDefaultFontSet },
90 #endif
91     { nhStr(XtNexposeCallback), XtCCallback, XtRCallback,
92       sizeof(XtCallbackList), offset(expose_callback), XtRCallback,
93       (char *) 0 },
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,
98       (char *) 0 },
99 #undef offset
100 };
101
102 /* ARGSUSED */
103 static void
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 */
109 {
110     nhUse(w);
111     nhUse(event);
112     nhUse(params);
113     nhUse(num_params);
114
115     return;
116 }
117
118 static XtActionsRec actions[] = {
119     { nhStr("no-op"), no_op },
120 };
121
122 static char translations[] = "<BtnDown>:     input() \
123 ";
124
125 /* ARGSUSED */
126 static void
127 Redisplay(w, event, region)
128 Widget w;
129 XEvent *event;
130 Region region; /* unused */
131 {
132     nhUse(region);
133
134     /* This isn't correct - we need to call the callback with region. */
135 #if 0 /*JP*/
136     XtCallCallbacks(w, XtNexposeCallback, (caddr_t) event);
137 #else
138     XtCallCallbacks(w, XtNexposeCallback, (XtPointer) event);
139 #endif
140 }
141
142 /* ARGSUSED */
143 static void
144 Resize(w)
145 Widget w;
146 {
147 #if 0 /*JP*/
148     XtCallCallbacks(w, XtNresizeCallback, (caddr_t) 0);
149 #else
150     XtCallCallbacks(w, XtNresizeCallback, (XtPointer) 0);
151 #endif
152 }
153
154 WindowClassRec windowClassRec = {
155     { /* core fields */
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,
162       /* initialize             */ 0,
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,
174       /* destroy                        */ 0,
175       /* resize                 */ Resize,
176       /* expose                 */ Redisplay,
177       /* set_values             */ 0,
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,
187       /* extension              */ 0 },
188     { /* window fields */
189       /* empty                  */ 0 }
190 };
191
192 WidgetClass windowWidgetClass = (WidgetClass) &windowClassRec;
193
194 Font
195 WindowFont(w)
196 Widget w;
197 {
198     return ((WindowWidget) w)->window.font->fid;
199 }
200
201 XFontStruct *
202 WindowFontStruct(w)
203 Widget w;
204 {
205     return ((WindowWidget) w)->window.font;
206 }
207
208 #ifdef XI18N
209 XFontSet
210 WindowFontSet(w)
211 Widget w;
212 {
213     return ((WindowWidget) w)->window.fontset;
214 }
215 #endif