annotate x11window.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1 /* $Id: x11window.c,v 1.1.1.1 1997/12/06 05:41:31 darius Exp $ */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4 /* x11window.c
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5 *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 * Kevin P. Smith 6/11/89
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7 * Much modified by Jerry Frain and Joe Young
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #ifdef __STDC__
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12 #include <stdlib.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14 #include <X11/Xlib.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15 #include <X11/Xutil.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 #ifdef RFCURSORS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17 #include <X11/Xmu/CurUtil.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19 #include <X11/cursorfont.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20 #include <assert.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21 #include <string.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 #include "Wlib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23 #include "defs.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24 #include "struct.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 #include "proto.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28 #define INVALID_POSITION -10000 /* gotta be a big negative */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 /* XFIX speedup */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 #define MAXCACHE 128
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32 /* changes too good to risk leaving out, by Richard Caley (rjc@cstr.ed.ac.uk)*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33 #define RJC
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34 #define FOURPLANEFIX
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37 #define NORMAL_FONT "-*-fixed-medium-r-*-*-10-*-*-*-*-*-*-*"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 #define BOLD_FONT "-*-fixed-medium-r-*-*-10-*-*-*-*-*-*-*"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39 #define ITALIC_FONT "-*-fixed-medium-r-*-*-10-*-*-*-*-*-*-*"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 #define NORMAL_FONT "6x10"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43 #define BOLD_FONT "6x10"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44 #define BOLD_FONT2 "-*-clean-bold-r-normal--10-100-75-75-c-60-*"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45 #define ITALIC_FONT "6x10"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 #define ITALIC_FONT2 "-*-clean-bold-r-normal--10-100-75-75-c-60-*"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47 #define BIG_FONT "-adobe-helvetica-bold-r-normal--34-*-*-*-*-*-*-*"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48 #define IND_FONT "-*-clean-bold-r-normal--10-100-75-75-c-60-*"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49 /*#define BOLD_FONT2 "-schumacher-clean-bold-r-normal--10-100-75-75-c-60-iso8859-1"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50 #define ITALIC_FONT2 "-misc-fixed-medium-i-normal--10-100-75-75-c-60-iso8859-1"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51 #define BIG_FONT "-adobe-helvetica-bold-r-normal--34-*-*-*-*-*-*-*"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54 static char *_nfonts[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55 NORMAL_FONT,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 "-*-clean-medium-r-normal--10-100-75-75-c-60-*",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 "fixed",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 NULL,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60 static char *_bfonts[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61 BOLD_FONT,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62 "-*-clean-bold-r-normal--10-100-75-75-c-60-*",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 "fixed",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 NULL,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66 static char *_ifonts[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 ITALIC_FONT,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 "-*-clean-bold-r-normal--10-100-75-75-c-60-*",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 "fixed",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70 NULL,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 static char *_bgfonts[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73 BIG_FONT,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74 "-*-lucidatypewriter-*-*-*-*-40-*-*-*-*-*-*-*",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 "fixed",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76 NULL,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 #define FONTS 4
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80 #define BITGC 4
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 #define WHITE 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83 #define BLACK 1
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 #define RED 2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 #define GREEN 3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 #define YELLOW 4
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 #define CYAN 5
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88 #define GREY 6
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 static int zero = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91 static int one = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92 static int two = 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93 static int three = 3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
94
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
95 int controlkey = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
96 #define BillsScrewyAltMask (Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
97 int altkey = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
98 int W_FastClear = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
99 #ifdef CONTINUOUS_MOUSE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
100 int buttonDown = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
101 #endif /* CONTINUOUS_MOUSE */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
102 Display *W_Display;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
103 Window W_Root;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
104 Colormap W_Colormap;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
105 int W_Screen;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
106 #ifdef FOURPLANEFIX
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
107 Visual *W_Visual;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
108 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
109 W_Font W_BigFont = (W_Font) & zero, W_RegularFont = (W_Font) & one;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
110 W_Font W_HighlightFont = (W_Font) & two, W_UnderlineFont = (W_Font) & three;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
111 W_Color W_White = WHITE, W_Black = BLACK, W_Red = RED, W_Green = GREEN;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
112 W_Color W_Yellow = YELLOW, W_Cyan = CYAN, W_Grey = GREY;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
113 int W_Textwidth, W_Textheight;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
114 char *getdefault();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
115 char *strdup();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
116
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
117 int W_in_message = 0; /* jfy -- for Jerry's warp message hack */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
118
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
119 #ifdef RJC
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
120 extern W_Window baseWin;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
121 static XClassHint class_hint = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
122 "netrek", "Netrek",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
123 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
124
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
125 static XWMHints wm_hint = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
126 InputHint | StateHint,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
127 True,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
128 WithdrawnState,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
129 None,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
130 None,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
131 0, 0,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
132 None,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
133 None,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
134 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
135
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
136 static XSizeHints wm_size_hint;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
137 #endif /* RJC */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
138
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
139 static W_Event W_myevent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
140 static int W_isEvent = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
141
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
142 struct fontInfo {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
143 XFontStruct *fontstruct;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
144 int baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
145 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
146
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
147 struct colors {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
148 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
149 GC contexts[FONTS + 1];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
150 Pixmap pixmap;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
151 long pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
152 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
153
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
154 struct icon {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
155 Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
156 Pixmap bitmap;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
157 int width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
158 Pixmap pixmap;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
159 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
160
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
161 #define WIN_GRAPH 1
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
162 #define WIN_TEXT 2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
163 #define WIN_MENU 3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
164 #define WIN_SCROLL 4
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
165
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
166 struct window {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
167 Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
168 int type;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
169 char *data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
170 int mapped;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
171 int width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
172 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
173 Cursor cursor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
174 #ifdef SHORT_PACKETS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
175 int insensitive;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
176 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
177 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
178 W_Callback handle_keydown;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
179 W_Callback handle_keyup;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
180 W_Callback handle_button;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
181 W_Callback handle_expose;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
182 #endif /* 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
183 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
184
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
185 struct stringList {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
186 char *string;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
187 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
188 struct stringList *next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
189 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
190
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
191 struct menuItem {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
192 char *string;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
193 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
194 W_Font font;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
195 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
196
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
197 struct colors colortable[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
198 {"white"},
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
199 {"black"},
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
200 {"red"},
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
201 {"green"},
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
202 {"yellow"},
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
203 {"cyan"},
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
204 {"light grey"}
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
205 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
206
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
207 struct windowlist {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
208 struct window *window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
209 struct windowlist *next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
210 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
211
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
212 #define HASHSIZE 29
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
213 #define hash(x) (((int) (x)) % HASHSIZE)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
214
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
215 struct windowlist *hashtable[HASHSIZE];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
216 struct fontInfo fonts[FONTS];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
217
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
218 struct window *newWindow();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
219 #ifndef NeXT
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
220 #ifndef __STDC__
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
221 char *malloc();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
222 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
223 #endif /* NeXT */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
224 short *x11tox10bits();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
225
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
226 struct window myroot;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
227
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
228 #define NCOLORS (sizeof(colortable)/sizeof(colortable[0]))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
229 #define W_Void2Window(win) ((win) ? (struct window *) (win) : &myroot)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
230 #define W_Window2Void(window) ((W_Window) (window))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
231 #define W_Void2Icon(bit) ((struct icon *) (bit))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
232 #define W_Icon2Void(bit) ((W_Icon) (bit))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
233 #define fontNum(font) (*((int *) font))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
234 #define TILESIDE 16
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
235
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
236 #define WIN_EDGE 5 /* border on l/r edges of text windows */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
237 #define MENU_PAD 4 /* border on t/b edges of text windows */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
238 #define MENU_BAR 2 /* width of menu bar */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
239
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
240 static unsigned char gray[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
241 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
242 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
243 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
244 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
245 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
246
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
247 static unsigned char striped[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
248 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
249 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
250 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
251 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
252 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
253
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
254 static unsigned char solid[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
255 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
256 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
257 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
258 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
259 };
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
260
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
261 /* Prototypes */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
262 /*static int _myerror P((Display *d , XErrorEvent *e ));*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
263 static void GetFonts P((void));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
264 static XFontStruct *find_font P((char *oldf, char **fonts));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
265 static void GetColors P((void));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
266 static void FlushClearAreaCache P((Window win));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
267 static int W_SpNextEvent P((W_Event * wevent));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
268 static void FlushLineCache P((Window win, int color));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
269 static void FlushPointCache P((Window win, int color));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
270 static struct window *findWindow P((Window window));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
271 static void addToHash P((struct window * win));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
272 static void AddToScrolling P((struct window * win, W_Color color, char *str, int len));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
273 static void redrawScrolling P((struct window * win));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
274 static void resizeScrolling P((struct window * win, int width, int height));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
275 static void redrawMenu P((struct window * win));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
276 static void redrawMenuItem P((struct window * win, int n));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
277 static void changeMenuItem P((struct window * win, int n, W_Color color, char *str, int len, W_Font font));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
278 /*static void W_SetTransientForHint P((W_Window w , W_Window pw ));*/
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
279 static void checkGeometry P((char *name, int *x, int *y, int *width, int *height));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
280 static void checkParent P((char *name, W_Window * parent));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
281 static void checkCursor P((char *name, char *cursname, Cursor * cursor));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
282 static void findMouse P((int *x, int *y));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
283 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
284 static void W_Flush P((void));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
285 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
286 static void deleteWindow P((struct window * window));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
287
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
288 /* X debugging */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
289 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
290 static int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
291 _myerror(d, e)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
292 Display *d;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
293 XErrorEvent *e;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
294 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
295 abort();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
296 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
297 #endif /* 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
298
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
299 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
300 W_Initialize(str)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
301 char *str;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
302 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
303 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
304
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
305 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
306 printf("Initializing...\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
307 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
308 for (i = 0; i < HASHSIZE; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
309 hashtable[i] = NULL;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
310 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
311 if ((W_Display = XOpenDisplay(str)) == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
312 fprintf(stderr, "Cannot open display \"%s\"\n", str ? str : "(null)");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
313 EXIT(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
314 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
315 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
316 /* tmp */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
317 XSynchronize(W_Display, True);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
318 XSetErrorHandler(_myerror);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
319 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
320
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
321 W_Root = DefaultRootWindow(W_Display);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
322 #ifdef FOURPLANEFIX
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
323 W_Visual = DefaultVisual(W_Display, DefaultScreen(W_Display));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
324 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
325 W_Screen = DefaultScreen(W_Display);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
326 W_Colormap = DefaultColormap(W_Display, W_Screen);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
327 myroot.window = W_Root;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
328 myroot.type = WIN_GRAPH;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
329 GetFonts();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
330 GetColors();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
331 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
332
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
333 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
334 GetFonts()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
335 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
336 Font regular, italic, bold, big;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
337 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
338 XGCValues values;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
339 XFontStruct *fontinfo;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
340 char *fontname;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
341
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
342 fontname = getdefault("font");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
343 if (fontname == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
344 fontname = NORMAL_FONT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
345 fontinfo = XLoadQueryFont(W_Display, fontname);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
346 if (fontinfo == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
347 fontinfo = find_font(fontname, _nfonts);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
348 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
349 if (fontinfo == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
350 printf("netrek: Can't find any fonts!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
351 EXIT(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
352 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
353 regular = fontinfo->fid;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
354 W_Textwidth = fontinfo->max_bounds.width;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
355 W_Textheight = fontinfo->max_bounds.descent + fontinfo->max_bounds.ascent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
356 fonts[1].baseline = fontinfo->max_bounds.ascent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
357 fonts[1].fontstruct = fontinfo;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
358
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
359 fontname = getdefault("boldfont");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
360 if (fontname == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
361 if (DisplayCells(W_Display, W_Screen) <= 4)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
362 fontname = BOLD_FONT2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
363 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
364 fontname = BOLD_FONT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
365 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
366 fontinfo = XLoadQueryFont(W_Display, fontname);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
367 if (fontinfo == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
368 fontinfo = find_font(fontname, _bfonts);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
369 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
370 if (fontinfo == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
371 bold = regular;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
372 fonts[2].baseline = fonts[1].baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
373 fonts[2].fontstruct = fonts[1].fontstruct;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
374 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
375 bold = fontinfo->fid;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
376 fonts[2].baseline = fontinfo->max_bounds.ascent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
377 fonts[2].fontstruct = fontinfo;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
378 if (fontinfo->max_bounds.width > W_Textwidth)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
379 W_Textwidth = fontinfo->max_bounds.width;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
380 if (fontinfo->max_bounds.descent + fontinfo->max_bounds.ascent > W_Textheight)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
381 W_Textheight = fontinfo->max_bounds.descent + fontinfo->max_bounds.ascent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
382 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
383
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
384 fontname = getdefault("italicfont");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
385 if (fontname == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
386 if (DisplayCells(W_Display, W_Screen) <= 4)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
387 fontname = ITALIC_FONT2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
388 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
389 fontname = ITALIC_FONT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
390 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
391 fontinfo = XLoadQueryFont(W_Display, fontname);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
392 if (fontinfo == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
393 fontinfo = find_font(fontname, _ifonts);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
394 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
395 if (fontinfo == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
396 italic = regular;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
397 fonts[3].baseline = fonts[1].baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
398 fonts[3].fontstruct = fonts[1].fontstruct;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
399 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
400 italic = fontinfo->fid;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
401 fonts[3].baseline = fontinfo->max_bounds.ascent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
402 fonts[3].fontstruct = fontinfo;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
403 if (fontinfo->max_bounds.width > W_Textwidth)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
404 W_Textwidth = fontinfo->max_bounds.width;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
405 if (fontinfo->max_bounds.descent + fontinfo->max_bounds.ascent > W_Textheight)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
406 W_Textheight = fontinfo->max_bounds.descent + fontinfo->max_bounds.ascent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
407 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
408
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
409 fontname = getdefault("bigfont");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
410 if (fontname == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
411 fontname = BIG_FONT;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
412 fontinfo = XLoadQueryFont(W_Display, fontname);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
413 if (fontinfo == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
414 fontinfo = find_font(fontname, _bgfonts);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
415 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
416 if (fontinfo == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
417 big = regular;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
418 fonts[0].baseline = fonts[1].baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
419 fonts[0].fontstruct = fonts[1].fontstruct;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
420 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
421 big = fontinfo->fid;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
422 fonts[0].baseline = fontinfo->max_bounds.ascent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
423 fonts[0].fontstruct = fontinfo;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
424 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
425 for (i = 0; i < NCOLORS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
426 values.font = big;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
427 colortable[i].contexts[0] = XCreateGC(W_Display, W_Root, GCFont, &values);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
428 XSetGraphicsExposures(W_Display, colortable[i].contexts[0], False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
429 values.font = regular;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
430 colortable[i].contexts[1] = XCreateGC(W_Display, W_Root, GCFont, &values);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
431 XSetGraphicsExposures(W_Display, colortable[i].contexts[1], False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
432 values.font = bold;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
433 colortable[i].contexts[2] = XCreateGC(W_Display, W_Root, GCFont, &values);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
434 XSetGraphicsExposures(W_Display, colortable[i].contexts[2], False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
435 values.font = italic;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
436 colortable[i].contexts[3] = XCreateGC(W_Display, W_Root, GCFont, &values);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
437 XSetGraphicsExposures(W_Display, colortable[i].contexts[3], False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
438 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
439 static char dl[] = {1, 4};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
440 XSetLineAttributes(W_Display, colortable[i].contexts[3],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
441 0, LineOnOffDash, CapButt, JoinMiter);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
442 XSetDashes(W_Display, colortable[i].contexts[3], 0, dl, 2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
443 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
444 values.function = GXor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
445 colortable[i].contexts[BITGC] = XCreateGC(W_Display, W_Root, GCFunction, &values);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
446 XSetGraphicsExposures(W_Display, colortable[i].contexts[BITGC], False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
447 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
448 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
449
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
450 static XFontStruct *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
451 find_font(oldf, fonts)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
452 char *oldf, **fonts;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
453 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
454 XFontStruct *fi;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
455 char **f;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
456 fprintf(stderr, "netrek: Can't find font %s. Trying others...\n",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
457 oldf);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
458 for (f = fonts; *f; f++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
459 if (strcmp(*f, oldf) != 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
460 if ((fi = XLoadQueryFont(W_Display, *f)))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
461 return fi;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
462 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
463 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
464 printf("Error - can't find any font!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
465 return NULL;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
466 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
467
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
468 #ifdef FOURPLANEFIX
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
469 static unsigned short extrared[8] = {0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xb0, 0xc0};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
470 static unsigned short extragreen[8] = {0x40, 0x60, 0x80, 0xa0, 0xb0, 0xc0, 0x00, 0x20};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
471 static unsigned short extrablue[8] = {0x80, 0xa0, 0xb0, 0xc0, 0x00, 0x20, 0x40, 0x60};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
472 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
473
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
474 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
475 W_Mono()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
476 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
477 return forceMono;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
478 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
479
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
480 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
481 GetColors()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
482 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
483 int i, j;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
484 XColor foo;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
485 int white, black;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
486 unsigned long pixel;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
487 unsigned long planes[3];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
488 char defaultstring[100];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
489 char *defaults;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
490 #ifdef FOURPLANEFIX
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
491 unsigned long extracolors[8];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
492 XColor colordef;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
493 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
494 extern int forceMono;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
495 forceMono = booleanDefault("forcemono", forceMono);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
496
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
497 if ((DisplayCells(W_Display, W_Screen) <= 4) || forceMono) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
498 forceMono = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
499 white = WhitePixel(W_Display, W_Screen);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
500 black = BlackPixel(W_Display, W_Screen);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
501 for (i = 0; i < NCOLORS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
502 if (i != W_Black) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
503 colortable[i].pixelValue = white;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
504 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
505 colortable[i].pixelValue = black;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
506 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
507 if (i == W_Red) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
508 colortable[i].pixmap = XCreatePixmapFromBitmapData
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
509 (W_Display,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
510 W_Root, (char *) striped, TILESIDE, TILESIDE,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
511 white, black,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
512 DefaultDepth(W_Display, W_Screen));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
513 } else if (i == W_Yellow) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
514 colortable[i].pixmap = XCreatePixmapFromBitmapData
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
515 (W_Display,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
516 W_Root, (char *) gray, TILESIDE, TILESIDE,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
517 white, black,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
518 DefaultDepth(W_Display, W_Screen));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
519 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
520 colortable[i].pixmap = XCreatePixmapFromBitmapData
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
521 (W_Display,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
522 W_Root, (char *) solid, TILESIDE, TILESIDE,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
523 colortable[i].pixelValue,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
524 colortable[i].pixelValue,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
525 DefaultDepth(W_Display, W_Screen));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
526 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
527
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
528 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
529 We assume white is 0 or 1, and black is 0 or 1. We adjust
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
530 graphics function based upon who is who.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
531 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
532 if (white == 0) { /* Black is 1 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
533 XSetFunction(W_Display, colortable[i].contexts[BITGC], GXand);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
534 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
535 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
536 } else if (DefaultVisual(W_Display, W_Screen)->class == TrueColor) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
537 /* Stuff added by sheldon@iastate.edu 5/28/93
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
538 * This is supposed to detect a TrueColor display, and then do a lookup of
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
539 * the colors in default colormap, instead of creating new colormap
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
540 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
541 for (i = 0; i < NCOLORS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
542 sprintf(defaultstring, "color.%s", colortable[i].name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
543
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
544 defaults = getdefault(defaultstring);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
545 if (defaults == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
546 defaults = colortable[i].name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
547 XParseColor(W_Display, W_Colormap, defaults, &foo);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
548 XAllocColor(W_Display, W_Colormap, &foo);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
549 colortable[i].pixelValue = foo.pixel;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
550 colortable[i].pixmap = XCreatePixmapFromBitmapData(W_Display,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
551 W_Root, (char *) solid, TILESIDE, TILESIDE, foo.pixel, foo.pixel,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
552 DefaultDepth(W_Display, W_Screen));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
553 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
554 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
555 #ifdef FOURPLANEFIX
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
556 if (!XAllocColorCells(W_Display, W_Colormap, False, planes, 3,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
557 &pixel, 1)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
558 /* couldn't allocate 3 planes, make a new colormap */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
559 W_Colormap = XCreateColormap(W_Display, W_Root, W_Visual, AllocNone);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
560 if (!XAllocColorCells(W_Display, W_Colormap, False, planes, 3,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
561 &pixel, 1)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
562 fprintf(stderr, "Cannot create new colormap\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
563 EXIT(1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
564 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
565 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
566 and fill it with at least 8 more colors so when mouse is
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
567 inside netrek windows, use might be able to see his other
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
568 windows
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
569 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
570 if (XAllocColorCells(W_Display, W_Colormap, False, NULL, 0,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
571 extracolors, 8)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
572 colordef.flags = DoRed | DoGreen | DoBlue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
573 for (i = 0; i < 8; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
574 colordef.pixel = extracolors[i];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
575 colordef.red = extrared[i] << 8;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
576 colordef.green = extragreen[i] << 8;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
577 colordef.blue = extrablue[i] << 8;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
578 XStoreColor(W_Display, W_Colormap, &colordef);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
579 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
580 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
581 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
582 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
583 XAllocColorCells(W_Display, W_Colormap, False, planes, 3, &pixel, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
584 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
585 for (i = 0; i < NCOLORS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
586 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
587 strcpy(defaultstring, "color.%s", colortable[i].name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
588 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
589 sprintf(defaultstring, "color.%s", colortable[i].name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
590
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
591 defaults = getdefault(defaultstring);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
592 if (defaults == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
593 defaults = colortable[i].name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
594 XParseColor(W_Display, W_Colormap, defaults, &foo);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
595 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
596 Black must be the color with all the planes off. That is the
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
597 only restriction I concerned myself with in the following case
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
598 statement.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
599 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
600 switch (i) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
601 case WHITE:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
602 foo.pixel = pixel | planes[0] | planes[1] | planes[2];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
603 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
604 case BLACK:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
605 foo.pixel = pixel;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
606 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
607 case RED:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
608 foo.pixel = pixel | planes[0];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
609 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
610 case CYAN:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
611 foo.pixel = pixel | planes[1];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
612 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
613 case YELLOW:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
614 foo.pixel = pixel | planes[2];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
615 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
616 case GREY:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
617 foo.pixel = pixel | planes[0] | planes[1];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
618 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
619 case GREEN:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
620 foo.pixel = pixel | planes[1] | planes[2];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
621 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
622 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
623 XStoreColor(W_Display, W_Colormap, &foo);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
624 colortable[i].pixelValue = foo.pixel;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
625 colortable[i].pixmap = XCreatePixmapFromBitmapData(W_Display,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
626 W_Root, (char *) solid, TILESIDE, TILESIDE, foo.pixel, foo.pixel,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
627 DefaultDepth(W_Display, W_Screen));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
628 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
629 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
630 for (i = 0; i < NCOLORS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
631 for (j = 0; j < FONTS + 1; j++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
632 XSetForeground(W_Display, colortable[i].contexts[j],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
633 colortable[i].pixelValue);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
634 XSetBackground(W_Display, colortable[i].contexts[j],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
635 colortable[W_Black].pixelValue);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
636 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
637 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
638 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
639
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
640 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
641 W_RenameWindow(window, str)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
642 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
643 char *str;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
644 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
645 XStoreName(W_Display, ((struct window *) window)->window, str);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
646 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
647
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
648 static W_Window
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
649 w_MakeWindow(name, x, y, width, height, parent,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
650 cursname, border, color, wsort)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
651 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
652 int x, y, width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
653 W_Window parent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
654 char *cursname;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
655 int border;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
656 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
657 int wsort; /* WIN_? */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
658 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
659 int gx, gy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
660 struct window *newwin;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
661 Window wparent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
662 Cursor cursor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
663 XSetWindowAttributes attrs;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
664 int pwidth, pheight; /* pixel width and height */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
665
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
666
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
667 checkGeometry(name, &gx, &gy, &width, &height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
668 if (gx != INVALID_POSITION)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
669 x = gx;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
670 if (gy != INVALID_POSITION)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
671 y = gy;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
672
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
673 checkParent(name, &parent);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
674 wparent = W_Void2Window(parent)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
675
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
676 checkCursor(name, cursname, &cursor);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
677 attrs.cursor = cursor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
678
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
679 attrs.border_pixel = colortable[color].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
680 attrs.background_pixel = colortable[W_Black].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
681
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
682 if (wsort == WIN_TEXT || wsort == WIN_SCROLL || wsort == WIN_MENU) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
683 pwidth = width * W_Textwidth + WIN_EDGE * 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
684 if (wsort == WIN_MENU)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
685 pheight = height * (W_Textheight + MENU_PAD * 2 + MENU_BAR) - MENU_BAR;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
686 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
687 pheight = height * W_Textheight + MENU_PAD * 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
688 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
689 pwidth = width;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
690 pheight = height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
691 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
692
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
693 switch (wsort) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
694 case WIN_TEXT:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
695 case WIN_MENU:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
696 attrs.event_mask = KeyPressMask | ButtonPressMask | ExposureMask | ButtonReleaseMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
697 attrs.do_not_propagate_mask = ExposureMask | KeyPressMask | ButtonPressMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
698 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
699 case WIN_GRAPH:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
700 attrs.event_mask = KeyPressMask | ButtonPressMask | ExposureMask | LeaveWindowMask | ButtonReleaseMask | ButtonMotionMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
701 attrs.do_not_propagate_mask = ExposureMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
702 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
703 case WIN_SCROLL:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
704 attrs.event_mask = ResizeRedirectMask | ExposureMask | KeyPressMask | ButtonReleaseMask | ButtonPressMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
705 attrs.do_not_propagate_mask = ResizeRedirectMask | ExposureMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
706 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
707 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
708 fprintf(stderr, "x11window.c: w_MakeWindow: unknown wsort %d\n", wsort);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
709 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
710
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
711 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
712 if (attrs.event_mask & KeyPressMask)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
713 attrs.event_mask |= KeyReleaseMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
714 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
715
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
716 if (strcmp(name, "netrek_icon") == 0) /* icon should not select for
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
717 input */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
718 attrs.event_mask = ExposureMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
719 if (strcmp(name, "wait_icon") == 0) /* same here [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
720 attrs.event_mask = ExposureMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
721
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
722 if (strcmp(name, "info") == 0) /* make info window passthru [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
723 attrs.event_mask = ExposureMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
724
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
725 newwin = newWindow
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
726 (XCreateWindow(W_Display, wparent, x, y, pwidth, pheight, border,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
727 CopyFromParent, InputOutput, CopyFromParent,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
728 CWBackPixel | CWBorderPixel | CWEventMask |
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
729 (cursor ? CWCursor : 0),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
730 &attrs),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
731 wsort);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
732
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
733 newwin->cursor = cursor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
734
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
735 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
736 char *s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
737
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
738 if (0 == strcmp(name, "wait"))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
739 s = serverName;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
740 else if (0 == strcmp(name, "Motd"))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
741 s = "Motd - [f] forward, [b] back, [tab] sysdefs, [space] unmap";
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
742 else if (0 == strcmp(name, "netrek")) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
743 if (!title) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
744 char buf[80];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
745 sprintf(buf, "Netrek @ %s", serverName);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
746 s = buf;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
747 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
748 /* but title on command line will override */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
749 /* from -h arg */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
750 s = title;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
751 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
752 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
753 s = name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
754
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
755 XStoreName(W_Display, newwin->window, s);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
756 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
757
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
758 wm_size_hint.width = wm_size_hint.min_width =
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
759 wm_size_hint.max_width = wm_size_hint.base_width = pwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
760 wm_size_hint.min_height = wm_size_hint.height =
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
761 wm_size_hint.max_height = wm_size_hint.base_height = pheight;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
762 wm_size_hint.flags = USSize | PMinSize | PMaxSize | PBaseSize;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
763 if (gx > INVALID_POSITION || gy > INVALID_POSITION) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
764 wm_size_hint.flags |= USPosition;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
765 wm_size_hint.x = x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
766 wm_size_hint.y = y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
767 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
768 XSetWMNormalHints(W_Display, newwin->window, &wm_size_hint);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
769
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
770 class_hint.res_name = name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
771 class_hint.res_class = "Netrek";
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
772 XSetClassHint(W_Display, newwin->window, &class_hint);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
773
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
774 XSetWMHints(W_Display, newwin->window, &wm_hint);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
775
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
776 if (((wparent == W_Root &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
777 baseWin != NULL &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
778 strcmp(name, "wait") != 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
779 || wsort == WIN_MENU) &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
780 strcmp(name, "MetaServer List") != 0 &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
781 strcmp(name, "Motd") != 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
782 XSetTransientForHint(W_Display, newwin->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
783 W_Void2Window(baseWin)->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
784 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
785 newwin->name = strdup(name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
786 newwin->width = width;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
787 newwin->height = height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
788 if (wsort == WIN_MENU) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
789 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
790 struct menuItem *items;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
791 items = (struct menuItem *) malloc(height * sizeof(struct menuItem));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
792 for (i = 0; i < height; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
793 items[i].string = NULL;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
794 items[i].color = W_White;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
795 items[i].font = W_RegularFont;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
796 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
797 newwin->data = (char *) items;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
798 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
799 newwin->data = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
800 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
801
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
802 if (wparent != W_Root)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
803 if (checkMapped(name))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
804 W_MapWindow(W_Window2Void(newwin));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
805
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
806 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
807 printf("New graphics window %d, child of %d\n", newwin, parent);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
808 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
809
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
810 #ifdef FOURPLANEFIX
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
811 XSetWindowColormap(W_Display, newwin->window, W_Colormap);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
812 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
813
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
814 return (W_Window2Void(newwin));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
815 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
816
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
817
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
818
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
819
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
820 W_Window
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
821 W_MakeWindow(name, x, y, width, height, parent, cursname, border, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
822 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
823 int x, y, width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
824 W_Window parent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
825 char *cursname;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
826 int border;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
827 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
828 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
829 return w_MakeWindow(name, x, y, width, height, parent,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
830 cursname, border, color, WIN_GRAPH);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
831 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
832
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
833 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
834 W_ChangeBorder(window, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
835 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
836 int color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
837 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
838 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
839 printf("Changing border of %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
840 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
841
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
842 /* fix inexplicable color bug */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
843 if (DisplayCells(W_Display, W_Screen) <= 2)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
844 XSetWindowBorderPixmap(W_Display, W_Void2Window(window)->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
845 colortable[color].pixmap);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
846 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
847 XSetWindowBorder(W_Display, W_Void2Window(window)->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
848 colortable[color].pixelValue);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
849 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
850
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
851 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
852 W_MapWindow(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
853 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
854 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
855 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
856
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
857 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
858 printf("Mapping %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
859 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
860 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
861 if (win->mapped)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
862 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
863 win->mapped = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
864 XMapRaised(W_Display, win->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
865 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
866
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
867 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
868 W_UnmapWindow(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
869 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
870 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
871 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
872
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
873 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
874 printf("UnMapping %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
875 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
876 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
877 if (win->mapped == 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
878 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
879 win->mapped = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
880 XUnmapWindow(W_Display, win->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
881 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
882
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
883 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
884 W_IsMapped(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
885 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
886 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
887 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
888
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
889 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
890 if (win == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
891 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
892 return (win->mapped);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
893 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
894
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
895 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
896 W_FillArea(window, x, y, width, height, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
897 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
898 int x, y, width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
899 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
900 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
901 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
902
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
903 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
904 printf("Clearing (%d %d) x (%d %d) with %d on %d\n", x, y, width, height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
905 color, window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
906 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
907 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
908 switch (win->type) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
909 case WIN_GRAPH:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
910 XFillRectangle(W_Display, win->window, colortable[color].contexts[0],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
911 x, y, width, height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
912 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
913 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
914 XFillRectangle(W_Display, win->window, colortable[color].contexts[0],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
915 WIN_EDGE + x * W_Textwidth, MENU_PAD + y * W_Textheight,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
916 width * W_Textwidth, height * W_Textheight);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
917 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
918 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
919
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
920 /* XFIX */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
921
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
922 static XRectangle _rcache[MAXCACHE];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
923 static int _rcache_index;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
924
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
925 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
926 FlushClearAreaCache(win)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
927 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
928 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
929 XFillRectangles(W_Display, win, colortable[backColor].contexts[0],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
930 _rcache, _rcache_index);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
931 _rcache_index = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
932 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
933
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
934 /* local window only */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
935 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
936 W_CacheClearArea(window, x, y, width, height)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
937 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
938 int x, y, width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
939 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
940 Window win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
941 register XRectangle *r;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
942
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
943 if (_rcache_index == MAXCACHE)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
944 FlushClearAreaCache(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
945
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
946 r = &_rcache[_rcache_index++];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
947 r->x = (short) x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
948 r->y = (short) y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
949 r->width = (unsigned short) width;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
950 r->height = (unsigned short) height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
951 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
952
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
953 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
954 W_FlushClearAreaCache(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
955 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
956 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
957 Window win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
958
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
959 if (_rcache_index)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
960 FlushClearAreaCache(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
961 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
962
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
963 /* XFIX: clears now instead of filling. */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
964 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
965 W_ClearArea(window, x, y, width, height)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
966 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
967 int x, y, width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
968 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
969 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
970
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
971 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
972 printf("Clearing (%d %d) x (%d %d) with %d on %d\n", x, y, width, height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
973 color, window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
974 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
975 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
976 switch (win->type) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
977 case WIN_GRAPH:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
978 /* XFIX: changed */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
979 XClearArea(W_Display, win->window, x, y, width, height, False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
980 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
981 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
982 /* XFIX: changed */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
983 XClearArea(W_Display, win->window, WIN_EDGE + x * W_Textwidth,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
984 MENU_PAD + y * W_Textheight, width * W_Textwidth, height * W_Textheight, False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
985 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
986 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
987 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
988
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
989 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
990 W_ClearWindow(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
991 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
992 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
993 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
994 printf("Clearing %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
995 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
996 XClearWindow(W_Display, W_Void2Window(window)->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
997 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
998
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
999 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1000 W_GetEvent(wevent)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1001 W_Event *wevent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1002 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1003 /* blocks until an event is received [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1004 XEvent event;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1005
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1006 if (W_isEvent) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1007 *wevent = W_myevent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1008 W_isEvent = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1009 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1010 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1011 XNextEvent(W_Display, &event);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1012 XPutBackEvent(W_Display, &event);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1013 W_SpNextEvent(wevent);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1014 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1015
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1016 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1017 W_EventsPending()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1018 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1019 if (W_isEvent)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1020 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1021 while (XPending(W_Display) || buttonDown) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1022 if (W_SpNextEvent(&W_myevent)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1023 W_isEvent = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1024 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1025 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1026 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1027 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1028 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1029
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1030 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1031 W_NextEvent(wevent)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1032 W_Event *wevent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1033 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1034 if (W_isEvent) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1035 *wevent = W_myevent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1036 W_isEvent = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1037 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1038 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1039 while (W_SpNextEvent(wevent) == 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1040 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1041
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1042 static int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1043 W_SpNextEvent(wevent)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1044 W_Event *wevent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1045 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1046 XEvent event;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1047 XKeyEvent *key;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1048 XButtonEvent *button;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1049 XExposeEvent *expose;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1050 XResizeRequestEvent *resize;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1051 char ch;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1052 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1053 #ifdef CONTINUOUS_MOUSE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1054 static W_Event buttonEvent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1055 static int delay, cupd = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1056 #endif /* CONTINUOUS_MOUSE */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1057
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1058 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1059 printf("Getting an event...\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1060 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1061 key = (XKeyEvent *) & event;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1062 button = (XButtonEvent *) & event;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1063 expose = (XExposeEvent *) & event;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1064 resize = (XResizeRequestEvent *) & event;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1065 for (;;) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1066 if (XPending(W_Display))
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1067 XNextEvent(W_Display, &event);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1068 #ifdef CONTINUOUS_MOUSE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1069 else if (buttonDown) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1070 if (continuousMouse && allowContinuousMouse) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1071 if (cupd != udcounter) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1072 cupd = udcounter;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1073 if (delay == 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1074 bcopy(&buttonEvent, wevent, sizeof(W_Event));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1075 delay = clickDelay;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1076 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1077 delay--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1078 wevent->type = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1079 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1080 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1081 wevent->type = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1082 exitInputLoop = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1083 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1084 wevent->type = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1085 buttonDown = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1086 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1087 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1088 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1089 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1090 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1091 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1092 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1093 printf("read an event %d\n", event.type);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1094 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1095 win = findWindow(key->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1096 if (win == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1097 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1098 if ((event.type == KeyPress || event.type == ButtonPress) &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1099 win->type == WIN_MENU) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1100 if (key->y % (W_Textheight + MENU_PAD * 2 + MENU_BAR) >=
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1101 W_Textheight + MENU_PAD * 2)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1102 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1103 key->y = key->y / (W_Textheight + MENU_PAD * 2 + MENU_BAR);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1104 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1105 switch ((int) event.type) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1106 case LeaveNotify: /* for message window -- jfy */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1107 if (win == (struct window *) messagew) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1108 W_in_message = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1109 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1110 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1111 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1112 case KeyPress:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1113 if (key->state & ControlMask) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1114 controlkey = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1115 key->state &= ~ControlMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1116 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1117 controlkey = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1118 if (key->state & BillsScrewyAltMask) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1119 altkey = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1120 key->state &= ~BillsScrewyAltMask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1121 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1122 altkey = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1123 if (XLookupString(key, &ch, 1, NULL, NULL) > 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1124 wevent->type = W_EV_KEY;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1125 wevent->Window = W_Window2Void(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1126 wevent->x = key->x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1127 wevent->y = key->y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1128 if (controlkey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1129 wevent->key = (int) ch + 128;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1130 else if (altkey)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1131 wevent->key = (int) ch + 256;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1132 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1133 wevent->key = ch;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1134 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1135 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1136 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1137 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1138 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1139 case KeyRelease:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1140 if (XLookupString(key, &ch, 1, NULL, NULL) > 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1141 wevent->type = W_EV_KEY_OFF;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1142 wevent->Window = W_Window2Void(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1143 wevent->x = key->x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1144 wevent->y = key->y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1145 wevent->key = ch;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1146 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1147 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1148 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1149 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1150 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1151 case ButtonPress:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1152 wevent->type = W_EV_BUTTON;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1153 wevent->Window = W_Window2Void(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1154 wevent->x = button->x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1155 wevent->y = button->y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1156 switch (button->button & 0xf) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1157 case Button3:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1158 wevent->key = W_RBUTTON;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1159 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1160 case Button1:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1161 wevent->key = W_LBUTTON;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1162 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1163 case Button2:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1164 wevent->key = W_MBUTTON;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1165 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1166 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1167 if (key->state & ControlMask)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1168 wevent->key += 6;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1169 if (key->state & ShiftMask)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1170 wevent->key += 3;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1171 if (key->state & BillsScrewyAltMask)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1172 wevent->key += 12; /* alt */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1173 #ifdef CONTINUOUS_MOUSE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1174 if (continuousMouse && allowContinuousMouse &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1175 (wevent->Window == w || wevent->Window == mapw) &&
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1176 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1177 buttonRepeatMask allows only certain buttons to repeat
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1178 [BDyess]
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1179 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1180 (1 << (wevent->key) & buttonRepeatMask)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1181 buttonDown = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1182 exitInputLoop = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1183 delay = clickDelay;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1184 bcopy(wevent, &buttonEvent, sizeof(W_Event));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1185 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1186 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1187 case ButtonRelease:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1188 /* bcopy(&buttonEvent,wevent,sizeof(W_Event)); */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1189 wevent->type = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1190 buttonDown = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1191 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1192 case MotionNotify:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1193 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1194 the !buttonDown ensures that if you press a button and then
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1195 press another, release just the second, and then move the
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1196 mouse that nothing happens.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1197 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1198 if (!(continuousMouse && allowContinuousMouse) || !buttonDown) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1199 wevent->type = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1200 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1201 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1202 wevent->type = W_EV_BUTTON;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1203 wevent->Window = W_Window2Void(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1204 wevent->x = button->x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1205 wevent->y = button->y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1206 wevent->key = buttonEvent.key;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1207 bcopy(wevent, &buttonEvent, sizeof(W_Event));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1208 if (cupd == udcounter)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1209 wevent->type = -1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1210 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1211 cupd = udcounter;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1212
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1213 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1214 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1215 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1216 #endif /* CONTINUOUS_MOUSE */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1217 case Expose:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1218 if (expose->count != 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1219 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1220 if (win->type == WIN_SCROLL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1221 redrawScrolling(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1222 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1223 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1224 if (win->type == WIN_MENU) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1225 redrawMenu(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1226 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1227 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1228 wevent->type = W_EV_EXPOSE;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1229 wevent->Window = W_Window2Void(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1230 return (1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1231 case ResizeRequest:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1232 resizeScrolling(win, resize->width, resize->height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1233 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1234 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1235 return (0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1236 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1237 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1238 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1239 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1240
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1241 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1242 W_MakeLine(window, x0, y0, x1, y1, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1243 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1244 int x0, y0, x1, y1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1245 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1246 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1247 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1248
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1249 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1250 printf("Line on %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1251 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1252 win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1253 XDrawLine(W_Display, win, colortable[color].contexts[0], x0, y0, x1, y1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1254 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1255
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1256 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1257 W_DrawPoint(window, x, y, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1258 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1259 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1260 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1261 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1262 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1263
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1264 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1265 printf("Point on %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1266 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1267 win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1268 XDrawPoint(W_Display, win, colortable[color].contexts[0], x, y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1269 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1270
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1271 /* XFIX */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1272
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1273 static XSegment _lcache[NCOLORS][MAXCACHE];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1274 static int _lcache_index[NCOLORS];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1275
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1276 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1277 FlushLineCache(win, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1278 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1279 int color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1280 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1281 XDrawSegments(W_Display, win, colortable[color].contexts[0],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1282 _lcache[color], _lcache_index[color]);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1283 _lcache_index[color] = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1284 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1285
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1286 /* for local window only */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1287 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1288 W_CacheLine(window, x0, y0, x1, y1, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1289 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1290 int x0, y0, x1, y1, color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1291 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1292 Window win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1293 register XSegment *s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1294
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1295 if (_lcache_index[color] == MAXCACHE)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1296 FlushLineCache(win, color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1297
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1298 s = &_lcache[color][_lcache_index[color]++];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1299 s->x1 = (short) x0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1300 s->y1 = (short) y0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1301 s->x2 = (short) x1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1302 s->y2 = (short) y1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1303 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1304
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1305 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1306 W_FlushLineCaches(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1307 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1308 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1309 Window win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1310 register i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1311 for (i = 0; i < NCOLORS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1312 if (_lcache_index[i])
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1313 FlushLineCache(win, i);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1314 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1315 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1316
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1317 static XPoint _pcache[NCOLORS][MAXCACHE];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1318 static int _pcache_index[NCOLORS];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1319
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1320 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1321 FlushPointCache(win, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1322 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1323 int color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1324 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1325 XDrawPoints(W_Display, win, colortable[color].contexts[0],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1326 _pcache[color], _pcache_index[color], CoordModeOrigin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1327 _pcache_index[color] = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1328 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1329
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1330 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1331 W_CachePoint(window, x, y, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1332 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1333 int x, y, color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1334 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1335 Window win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1336 register XPoint *p;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1337
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1338 if (_pcache_index[color] == MAXCACHE)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1339 FlushPointCache(win, color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1340
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1341 p = &_pcache[color][_pcache_index[color]++];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1342 p->x = (short) x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1343 p->y = (short) y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1344 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1345
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1346 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1347 W_FlushPointCaches(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1348 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1349 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1350 Window win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1351 register i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1352 for (i = 0; i < NCOLORS; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1353 if (_pcache_index[i])
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1354 FlushPointCache(win, i);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1355 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1356 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1357
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1358 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1359 W_MakeTractLine(window, x0, y0, x1, y1, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1360 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1361 int x0, y0, x1, y1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1362 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1363 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1364 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1365
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1366 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1367 printf("Line on %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1368 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1369 win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1370 XDrawLine(W_Display, win, colortable[color].contexts[3], x0, y0, x1, y1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1371 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1372
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1373 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1374 W_DrawSectorHighlight(window, x, y, w, h, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1375 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1376 int x, y, w, h;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1377 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1378 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1379 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1380 #ifdef YUCK
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1381 XRectangle r[2];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1382
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1383 r[0].x = (short) x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1384 r[0].y = (short) y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1385 r[0].width = (unsigned short) w;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1386 r[0].height = (unsigned short) h;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1387 r[1].x = (short) x + 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1388 r[1].y = (short) y + 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1389 r[1].width = (unsigned short) w - 4;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1390 r[1].height = (unsigned short) h - 4;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1391
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1392 win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1393 XDrawRectangles(W_Display, win, colortable[color].contexts[3],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1394 r, 2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1395 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1396 XRectangle r[1];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1397
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1398 r[0].x = (short) x + 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1399 r[0].y = (short) y + 2;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1400 r[0].width = (unsigned short) w - 4;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1401 r[0].height = (unsigned short) h - 4;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1402
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1403 win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1404 XDrawRectangles(W_Display, win, colortable[color].contexts[3],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1405 r, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1406 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1407 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1408
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1409 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1410 W_WriteTriangle(window, x, y, s, t, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1411 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1412 int x, y, s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1413 int t;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1414 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1415 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1416 struct window *win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1417 XPoint points[3];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1418
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1419 if (t == 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1420 points[0].x = x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1421 points[0].y = y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1422 points[1].x = x + s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1423 points[1].y = y - s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1424 points[2].x = x - s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1425 points[2].y = y - s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1426 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1427 points[0].x = x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1428 points[0].y = y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1429 points[1].x = x + s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1430 points[1].y = y + s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1431 points[2].x = x - s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1432 points[2].y = y + s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1433 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1434
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1435
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1436 XFillPolygon(W_Display, win->window, colortable[color].contexts[0],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1437 points, 3, Convex, CoordModeOrigin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1438 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1439
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1440 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1441 W_WriteText(window, x, y, color, str, len, font)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1442 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1443 int x, y, len;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1444 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1445 W_Font font;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1446 char *str;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1447 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1448 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1449 int addr;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1450
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1451 if (!font)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1452 font = W_RegularFont;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1453 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1454 printf("Text for %d @ (%d, %d) in %d: [%s]\n", window, x, y, color, str);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1455 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1456 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1457 switch (win->type) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1458 case WIN_GRAPH:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1459 addr = fonts[fontNum(font)].baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1460 XDrawImageString(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1461 colortable[color].contexts[fontNum(font)], x, y + addr, str, len);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1462 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1463 case WIN_SCROLL:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1464 if (y<0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1465 XCopyArea(W_Display, win->window, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1466
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1467 colortable[W_White].contexts[0], WIN_EDGE, MENU_PAD,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1468 win->width * W_Textwidth, (win->height - 1) * W_Textheight,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1469 WIN_EDGE, MENU_PAD+W_Textheight);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1470 XClearArea(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1471 WIN_EDGE, MENU_PAD,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1472 W_Textwidth * win->width, W_Textheight, False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1473 XDrawImageString(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1474 colortable[color].contexts[1],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1475 WIN_EDGE, MENU_PAD + fonts[1].baseline,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1476 str, len);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1477 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1478 XCopyArea(W_Display, win->window, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1479 colortable[W_White].contexts[0], WIN_EDGE, MENU_PAD + W_Textheight,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1480 win->width * W_Textwidth, (win->height - 1) * W_Textheight,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1481 WIN_EDGE, MENU_PAD);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1482 XClearArea(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1483 WIN_EDGE, MENU_PAD + W_Textheight * (win->height - 1),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1484 W_Textwidth * win->width, W_Textheight, False);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1485 XDrawImageString(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1486 colortable[color].contexts[1],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1487 WIN_EDGE, MENU_PAD + W_Textheight * (win->height - 1) + fonts[1].baseline,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1488 str, len);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1489 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1490 AddToScrolling(win, color, str, len);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1491 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1492 case WIN_MENU:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1493 changeMenuItem(win, y, color, str, len, font);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1494 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1495 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1496 addr = fonts[fontNum(font)].baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1497 XDrawImageString(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1498 colortable[color].contexts[fontNum(font)],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1499 x * W_Textwidth + WIN_EDGE, MENU_PAD + y * W_Textheight + addr,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1500 str, len);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1501 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1502 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1503 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1504
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1505 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1506 W_MaskText(window, x, y, color, str, len, font)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1507 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1508 int x, y, len;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1509 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1510 W_Font font;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1511 char *str;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1512 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1513 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1514 int addr;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1515
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1516 addr = fonts[fontNum(font)].baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1517 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1518 printf("TextMask for %d @ (%d, %d) in %d: [%s]\n", window, x, y, color, str);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1519 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1520 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1521 XDrawString(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1522 colortable[color].contexts[fontNum(font)], x, y + addr, str, len);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1523 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1524
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1525 W_Icon
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1526 W_StoreBitmap(width, height, data, window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1527 int width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1528 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1529 char *data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1530 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1531 struct icon *newicon;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1532 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1533
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1534 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1535 printf("Storing bitmap for %d (%d x %d)\n", window, width, height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1536 fflush(stdout);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1537 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1538 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1539 newicon = (struct icon *) malloc(sizeof(struct icon));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1540 newicon->width = width;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1541 newicon->height = height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1542 newicon->bitmap = XCreateBitmapFromData(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1543 data, width, height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1544 newicon->window = win->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1545 newicon->pixmap = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1546 return (W_Icon2Void(newicon));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1547 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1548
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1549 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1550 W_FreeBitmap(bit)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1551 W_Icon bit;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1552 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1553 struct icon *icon;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1554 icon = W_Void2Icon(bit);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1555 XFreePixmap(W_Display, icon->bitmap);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1556 free(icon);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1557 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1558
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1559 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1560 W_WriteBitmap(x, y, bit, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1561 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1562 W_Icon bit;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1563 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1564 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1565 struct icon *icon;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1566
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1567 icon = W_Void2Icon(bit);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1568 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1569 printf("Writing bitmap to %d\n", icon->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1570 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1571
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1572 XCopyPlane(W_Display, icon->bitmap, icon->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1573 colortable[color].contexts[BITGC], 0, 0, icon->width, icon->height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1574 x, y, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1575
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1576 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1577
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1578 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1579 W_WriteWinBitmap(win, x, y, bit, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1580 W_Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1581 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1582 W_Icon bit;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1583 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1584 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1585 struct icon *icon;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1586 Window original;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1587
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1588 icon = W_Void2Icon(bit);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1589 original = icon->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1590 icon->window = W_Void2Window(win)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1591 W_WriteBitmap(x, y, bit, color);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1592 icon->window = original;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1593 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1594 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1595
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1596 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1597 W_TileWindow(window, bit)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1598 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1599 W_Icon bit;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1600 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1601 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1602 struct icon *icon;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1603
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1604 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1605 printf("Tiling window %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1606 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1607 icon = W_Void2Icon(bit);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1608 win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1609
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1610 if (icon->pixmap == 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1611 icon->pixmap = XCreatePixmap(W_Display, W_Root,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1612 icon->width, icon->height, DefaultDepth(W_Display, W_Screen));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1613 XCopyPlane(W_Display, icon->bitmap, icon->pixmap,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1614 colortable[W_White].contexts[0], 0, 0, icon->width, icon->height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1615 0, 0, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1616 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1617 XSetWindowBackgroundPixmap(W_Display, win, icon->pixmap);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1618 XClearWindow(W_Display, win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1619
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1620 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1621 if (icon->pixmap==0) { icon->pixmap=XMakePixmap(icon->bitmap,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1622 colortable[W_White].pixelValue, colortable[W_Black].pixelValue); }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1623 XChangeBackground(win, icon->pixmap); XClear(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1624 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1625 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1626
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1627 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1628 W_UnTileWindow(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1629 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1630 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1631 Window win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1632
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1633 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1634 printf("Untiling window %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1635 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1636 win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1637
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1638 XSetWindowBackground(W_Display, win, colortable[W_Black].pixelValue);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1639 XClearWindow(W_Display, win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1640 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1641
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1642 W_Window
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1643 W_MakeTextWindow(name, x, y, width, height, parent, cursname, border)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1644 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1645 int x, y, width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1646 W_Window parent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1647 char *cursname;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1648 int border;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1649 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1650 return w_MakeWindow(name, x, y, width, height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1651 parent, cursname, border, W_White, WIN_TEXT);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1652 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1653
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1654 struct window *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1655 newWindow(window, type)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1656 Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1657 int type;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1658 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1659 struct window *newwin;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1660
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1661 newwin = (struct window *) malloc(sizeof(struct window));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1662 newwin->window = window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1663 newwin->type = type;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1664 newwin->mapped = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1665 newwin->insensitive = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1666 addToHash(newwin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1667 return (newwin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1668 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1669
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1670
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1671 static struct window *
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1672 findWindow(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1673 Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1674 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1675 struct windowlist *entry;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1676
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1677 entry = hashtable[hash(window)];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1678 while (entry != NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1679 if (entry->window->window == window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1680 return (entry->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1681 entry = entry->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1682 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1683 return (NULL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1684 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1685
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1686 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1687 addToHash(win)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1688 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1689 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1690 struct windowlist **new;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1691
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1692 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1693 printf("Adding to %d\n", hash(win->window));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1694 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1695 new = &hashtable[hash(win->window)];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1696 while (*new != NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1697 new = &((*new)->next);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1698 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1699 *new = (struct windowlist *) malloc(sizeof(struct windowlist));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1700 (*new)->next = NULL;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1701 (*new)->window = win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1702 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1703
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1704 W_Window
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1705 W_MakeScrollingWindow(name, x, y, width, height, parent, cursname, border)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1706 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1707 int x, y, width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1708 W_Window parent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1709 char *cursname;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1710 int border;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1711 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1712 return w_MakeWindow(name, x, y, width, height, parent, cursname,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1713 border, W_White, WIN_SCROLL);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1714 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1715
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1716 /* Add a string to the string list of the scrolling window.
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1717 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1718 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1719 AddToScrolling(win, color, str, len)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1720 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1721 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1722 char *str;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1723 int len;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1724 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1725 struct stringList **strings;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1726 char *newstring;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1727 int count;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1728
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1729 strings = (struct stringList **) & (win->data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1730 count = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1731 while ((*strings) != NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1732 count++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1733 strings = &((*strings)->next);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1734 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1735 (*strings) = (struct stringList *) malloc(sizeof(struct stringList));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1736 (*strings)->next = NULL;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1737 (*strings)->color = color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1738 newstring = (char *) malloc(len + 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1739 strncpy(newstring, str, len);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1740 newstring[len] = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1741 (*strings)->string = newstring;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1742 if (count >= 100) { /* Arbitrary large size. */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1743 struct stringList *temp;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1744
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1745 temp = (struct stringList *) win->data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1746 free(temp->string);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1747 temp = temp->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1748 free((char *) win->data);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1749 win->data = (char *) temp;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1750 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1751 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1752
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1753 #ifdef SHORT_PACKETS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1754 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1755 W_SetSensitive(w, v)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1756 W_Window w;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1757 int v;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1758 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1759 struct window *win = W_Void2Window(w);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1760
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1761 win->insensitive = !v;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1762
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1763 if (win->type == WIN_SCROLL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1764 redrawScrolling(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1765 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1766 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1767
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1768 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1769 redrawScrolling(win)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1770 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1771 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1772 int count;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1773 struct stringList *list;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1774 int y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1775
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1776 XClearWindow(W_Display, win->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1777 count = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1778 list = (struct stringList *) win->data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1779 while (list != NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1780 list = list->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1781 count++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1782 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1783 list = (struct stringList *) win->data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1784 while (count > win->height) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1785 list = list->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1786 count--;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1787 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1788 y = (win->height - count) * W_Textheight + fonts[1].baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1789 if (count == 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1790 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1791 while (list != NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1792 XDrawImageString(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1793 colortable[list->color].contexts[1],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1794 WIN_EDGE, MENU_PAD + y, list->string, strlen(list->string));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1795 list = list->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1796 y = y + W_Textheight;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1797 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1798 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1799
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1800 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1801 resizeScrolling(win, width, height)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1802 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1803 int width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1804 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1805 win->height = (height - MENU_PAD * 2) / W_Textheight;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1806 win->width = (width - WIN_EDGE * 2) / W_Textwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1807 XResizeWindow(W_Display, win->window, win->width * W_Textwidth + WIN_EDGE * 2,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1808 win->height * W_Textheight + MENU_PAD * 2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1809 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1810
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1811 W_Window
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1812 W_MakeMenu(name, x, y, width, height, parent, border)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1813 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1814 int x, y, width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1815 W_Window parent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1816 int border;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1817 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1818 return w_MakeWindow(name, x, y, width, height, parent,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1819 "left_ptr", border, W_White, WIN_MENU);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1820 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1821
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1822 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1823 redrawMenu(win)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1824 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1825 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1826 int count;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1827
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1828 for (count = 1; count < win->height; count++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1829 XFillRectangle(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1830 colortable[W_Grey].contexts[0],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1831 0, count * (W_Textheight + MENU_PAD * 2) + (count - 1) * MENU_BAR,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1832 win->width * W_Textwidth + WIN_EDGE * 2, MENU_BAR);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1833 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1834 for (count = 0; count < win->height; count++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1835 redrawMenuItem(win, count);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1836 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1837 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1838
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1839 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1840 redrawMenuItem(win, n)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1841 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1842 int n;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1843 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1844 struct menuItem *items;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1845 int addr;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1846
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1847 items = (struct menuItem *) win->data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1848
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1849 XFillRectangle(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1850 colortable[W_Black].contexts[0],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1851 WIN_EDGE, n * (W_Textheight + MENU_PAD * 2 + MENU_BAR) + MENU_PAD,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1852 win->width * W_Textwidth, W_Textheight);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1853 if (items[n].string) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1854 addr = fonts[fontNum(items[n].font)].baseline;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1855 XDrawImageString(W_Display, win->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1856 colortable[items[n].color].contexts[fontNum(items[n].font)],
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1857 WIN_EDGE,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1858 n * (W_Textheight + MENU_PAD * 2 + MENU_BAR) + MENU_PAD + addr,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1859 items[n].string, strlen(items[n].string));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1860 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1861 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1862
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1863 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1864 changeMenuItem(win, n, color, str, len, font)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1865 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1866 int n;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1867 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1868 char *str;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1869 int len;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1870 W_Font font;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1871 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1872 struct menuItem *items;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1873 char *news;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1874
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1875 items = (struct menuItem *) win->data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1876 if (items[n].string) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1877 free(items[n].string);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1878 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1879 news = malloc(len + 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1880 strncpy(news, str, len);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1881 news[len] = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1882 items[n].string = news;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1883 items[n].color = color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1884 items[n].font = font;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1885 redrawMenuItem(win, n);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1886 XFlush(W_Display);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1887 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1888
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1889 static Cursor
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1890 make_cursor(bits, mask, width, height, xhot, yhot)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1891 char *bits, *mask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1892 int width, height, xhot, yhot;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1893 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1894 Pixmap cursbits;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1895 Pixmap cursmask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1896 XColor whiteCol, blackCol;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1897 Cursor curs;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1898
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1899 whiteCol.pixel = colortable[W_White].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1900 XQueryColor(W_Display, W_Colormap, &whiteCol);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1901 blackCol.pixel = colortable[W_Black].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1902 XQueryColor(W_Display, W_Colormap, &blackCol);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1903
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1904 cursbits = XCreateBitmapFromData(W_Display, DefaultRootWindow(W_Display),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1905 bits, width, height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1906 cursmask = XCreateBitmapFromData(W_Display, DefaultRootWindow(W_Display),
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1907 mask, width, height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1908
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1909 curs = XCreatePixmapCursor(W_Display, cursbits, cursmask,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1910 &whiteCol, &blackCol, xhot, yhot);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1911
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1912 XFreePixmap(W_Display, cursbits);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1913 XFreePixmap(W_Display, cursmask);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1914 return curs;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1915 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1916
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1917 #ifdef TCURSORS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1918 #if 1
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1919
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1920 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1921 W_DefineTCrossCursor(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1922 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1923 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1924 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1925 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1926
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1927 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1928 W_DefineTextCursor(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1929 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1930 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1931 static Cursor new = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1932 struct window *win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1933 XColor f, b;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1934
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1935 if (!new) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1936 f.pixel = colortable[W_Yellow].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1937 b.pixel = colortable[W_Black].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1938
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1939 XQueryColor(W_Display, W_Colormap, &f);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1940 XQueryColor(W_Display, W_Colormap, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1941
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1942 new = XCreateFontCursor(W_Display, XC_xterm);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1943
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1944 XRecolorCursor(W_Display, new, &f, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1945 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1946 XDefineCursor(W_Display, win->window, new);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1947
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1948 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1949 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1950
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1951 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1952 W_RevertCursor(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1953 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1954 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1955 struct window *win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1956
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1957 XDefineCursor(W_Display, win->window, win->cursor);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1958
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1959 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1960 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1961
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1962 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1963 W_DefineCursor(window, width, height, bits, mask, xhot, yhot)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1964 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1965 int width, height, xhot, yhot;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1966 char *bits, *mask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1967 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1968 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1969 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1970
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1971 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1972
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1973 #ifdef YUCK
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1974 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1975 W_DefineTCrossCursor(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1976 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1977 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1978 static
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1979 Cursor new;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1980 struct window *win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1981 static
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1982 XColor f, b;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1983
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1984 if (new) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1985 XDefineCursor(W_Display, win->window, new);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1986 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1987 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1988 f.pixel = colortable[W_White].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1989 b.pixel = colortable[W_Black].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1990
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1991 XQueryColor(W_Display, W_Colormap, &f);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1992 XQueryColor(W_Display, W_Colormap, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1993
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1994 new = XCreateFontCursor(W_Display, XC_tcross);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1995 XRecolorCursor(W_Display, new, &f, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1996 XDefineCursor(W_Display, win->window, new);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1997 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1998
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1999 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2000 W_DefineTCrossCursor(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2001 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2002 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2003 W_DefineCursor(window, cross_width, cross_height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2004 cross_bits, crossmask_bits, cross_x_hot, cross_y_hot);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2005 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2006
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2007 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2008
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2009 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2010 W_DefineTextCursor(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2011 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2012 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2013 static
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2014 Cursor new;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2015 struct window *win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2016 XColor f, b;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2017
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2018 if (new) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2019 XDefineCursor(W_Display, win->window, new);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2020 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2021 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2022 f.pixel = colortable[W_Yellow].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2023 b.pixel = colortable[W_Black].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2024
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2025 XQueryColor(W_Display, W_Colormap, &f);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2026 XQueryColor(W_Display, W_Colormap, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2027
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2028 new = XCreateFontCursor(W_Display, XC_xterm);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2029 XRecolorCursor(W_Display, new, &f, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2030 XDefineCursor(W_Display, win->window, new);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2031 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2032
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2033 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2034 W_DefineCursor(window, width, height, bits, mask, xhot, yhot)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2035 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2036 int width, height, xhot, yhot;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2037 char *bits, *mask;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2038 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2039 static char *oldbits = NULL;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2040 static Cursor curs;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2041 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2042
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2043 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2044 printf("Defining cursor for %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2045 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2046 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2047 if (!oldbits || oldbits != bits) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2048 oldbits = bits;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2049 curs = make_cursor(bits, mask, width, height, xhot, yhot);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2050 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2051 XDefineCursor(W_Display, win->window, curs);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2052 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2053 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2054 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2055
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2056 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2057 W_Beep()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2058 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2059 XBell(W_Display, 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2060 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2061
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2062 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2063 W_WindowWidth(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2064 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2065 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2066 return (W_Void2Window(window)->width);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2067 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2068
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2069 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2070 W_WindowHeight(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2071 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2072 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2073 return (W_Void2Window(window)->height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2074 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2075
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2076 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2077 W_Socket()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2078 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2079 return (ConnectionNumber(W_Display));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2080 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2081
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2082 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2083 W_DestroyWindow(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2084 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2085 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2086 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2087
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2088 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2089 printf("Destroying %d\n", window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2090 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2091 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2092 deleteWindow(win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2093 XDestroyWindow(W_Display, win->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2094 free((char *) win);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2095 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2096
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2097 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2098 deleteWindow(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2099 struct window *window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2100 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2101 struct windowlist **rm;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2102 struct windowlist *temp;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2103
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2104 rm = &hashtable[hash(window->window)];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2105 while (*rm != NULL && (*rm)->window != window) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2106 rm = &((*rm)->next);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2107 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2108 if (*rm == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2109 printf("Attempt to delete non-existent window!\n");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2110 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2111 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2112 temp = *rm;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2113 *rm = temp->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2114 free((char *) temp);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2115 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2116
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2117 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2118 W_SetIconWindow(main, icon)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2119 W_Window main;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2120 W_Window icon;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2121 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2122 XWMHints hints;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2123
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2124 XSetIconName(W_Display, W_Void2Window(icon)->window, W_Void2Window(main)->name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2125
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2126 hints.flags = IconWindowHint;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2127 hints.icon_window = W_Void2Window(icon)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2128 XSetWMHints(W_Display, W_Void2Window(main)->window, &hints);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2129 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2130
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2131 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2132 checkGeometry(name, x, y, width, height)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2133 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2134 int *x, *y, *width, *height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2135 /* fixed so that it handles negative positions 12/21/93 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2136 /* note that this is NOT standard X syntax, but it was requested */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2137 /* and it's how BRM-Hadley works. [BDyess] */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2138 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2139 char *adefault;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2140 char buf[100];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2141 char *s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2142
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2143 #ifdef RJC
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2144 *x = *y = INVALID_POSITION;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2145 #endif /* RJC */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2146
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2147 sprintf(buf, "%s.geometry", name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2148 adefault = getdefault(buf);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2149 if (adefault == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2150 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2151 /* geometry should be of the form 502x885+1+1, 502x885, or +1+1 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2152 s = adefault;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2153 if (*s != '+' && *s != '-') {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2154 while (*s != 'x' && *s != 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2155 s++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2156 *width = atoi(adefault);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2157 if (*s == 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2158 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2159 s++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2160 adefault = s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2161 while (*s != '+' && *s != '-' && *s != 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2162 s++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2163 *height = atoi(adefault);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2164 if (*s == 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2165 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2166 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2167 adefault = s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2168 s++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2169 if (*s == '-')
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2170 s++; /* for the case where they have wxh+-x+y */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2171 while (*s != '+' && *s != '-' && *s != 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2172 s++;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2173 *x = atoi(adefault + 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2174 if (*adefault == '-')
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2175 *x = -*x;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2176 if (*s == 0)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2177 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2178 *y = atoi(s + 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2179 if (*s == '-')
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2180 *y = -*y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2181 /* printf("width: %d, height: %d, x: %d, y: %d\n",*width, *height,*x,*y); */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2182 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2183 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2184
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2185 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2186 checkParent(name, parent)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2187 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2188 W_Window *parent;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2189 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2190 char *adefault;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2191 char buf[100];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2192 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2193 struct windowlist *windows;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2194
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2195 sprintf(buf, "%s.parent", name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2196 adefault = getdefault(buf);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2197 if (adefault == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2198 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2199 /* parent must be name of other window or "root" */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2200 if (strcmpi(adefault, "root") == 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2201 *parent = W_Window2Void(&myroot);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2202 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2203 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2204 for (i = 0; i < HASHSIZE; i++) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2205 windows = hashtable[i];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2206 while (windows != NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2207 if (strcmpi(adefault, windows->window->name) == 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2208 *parent = W_Window2Void(windows->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2209 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2210 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2211 windows = windows->next;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2212 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2213 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2214 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2215
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2216 #ifdef YUCK
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2217 #define cross_width 15
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2218 #define cross_height 15
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2219 #define cross_x_hot 7
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2220 #define cross_y_hot 7
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2221 static unsigned char cross_bits[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2222 0x00, 0x00, 0xc0, 0x01, 0xa0, 0x02, 0x00, 0x00, 0x80, 0x00, 0x04, 0x10, 0x82, 0x20, 0x56,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2223 0x35, 0x82, 0x20, 0x04, 0x10, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x02, 0xc0, 0x01, 0x00, 0x00};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2224 static unsigned char crossmask_bits[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2225 0xe0, 0x03, 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xce, 0x39, 0xcf, 0x79, 0xff, 0x7f, 0xff,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2226 0x7f, 0xff, 0x7f, 0xcf, 0x79, 0xce, 0x39, 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xe0, 0x03};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2227 #else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2228 #define cross_width 16
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2229 #define cross_height 16
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2230 #define cross_x_hot 7
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2231 #define cross_y_hot 7
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2232 static unsigned char cross_bits[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2233 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xc0, 0x01, 0x80, 0x00,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2234 0x10, 0x04, 0x3f, 0x7e, 0x10, 0x04, 0x80, 0x00, 0xc0, 0x01, 0x80, 0x00,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2235 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2236 static unsigned char crossmask_bits[] = {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2237 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xd0, 0x05,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2238 0xbf, 0x7e, 0x7f, 0x7f, 0xbf, 0x7e, 0xd0, 0x05, 0xe0, 0x03, 0xc0, 0x01,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2239 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2240 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2241
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2242 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2243 checkCursor(name, cursname, cursor)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2244 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2245 char *cursname;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2246 Cursor *cursor;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2247 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2248 char buf[100];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2249 unsigned cnum;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2250 char *adefault;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2251
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2252 *cursor = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2253
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2254 sprintf(buf, "%s.cursor", name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2255 adefault = getdefault(buf);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2256 if (adefault == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2257 adefault = cursname;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2258 if (adefault == NULL)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2259 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2260
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2261 #ifdef RFCURSORS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2262 cnum = XmuCursorNameToIndex(adefault);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2263 if (cnum != -1) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2264 XColor f, b;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2265 *cursor = XCreateFontCursor(W_Display, cnum);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2266 if (cnum == XC_xterm) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2267
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2268 f.pixel = colortable[W_Yellow].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2269 b.pixel = colortable[W_Black].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2270
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2271 XQueryColor(W_Display, W_Colormap, &f);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2272 XQueryColor(W_Display, W_Colormap, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2273
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2274 XRecolorCursor(W_Display, *cursor, &f, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2275 } else if (cnum == XC_pirate) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2276 f.pixel = colortable[W_Red].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2277 b.pixel = colortable[W_Black].pixelValue;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2278
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2279 XQueryColor(W_Display, W_Colormap, &f);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2280 XQueryColor(W_Display, W_Colormap, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2281
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2282 XRecolorCursor(W_Display, *cursor, &f, &b);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2283 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2284 } else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2285 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2286 if (0 == strcmp("bomb here", adefault)) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2287 static Cursor bomb_here = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2288 if (bomb_here == 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2289 bomb_here = make_cursor(cross_bits, crossmask_bits,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2290 cross_width, cross_height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2291 cross_x_hot, cross_y_hot);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2292 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2293 *cursor = bomb_here;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2294 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2295 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2296
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2297 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2298 checkMapped(name)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2299 char *name;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2300 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2301 char buf[100];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2302
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2303 sprintf(buf, "%s.mapped", name);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2304 return (booleanDefault(buf, 0));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2305 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2306
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2307 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2308 W_WarpPointer(window, x, y)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2309 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2310 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2311 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2312 static int warped_from_x = 0, warped_from_y = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2313
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2314 if (window == NULL) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2315 if (W_in_message) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2316 XWarpPointer(W_Display, None, W_Root, 0, 0, 0, 0, warped_from_x, warped_from_y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2317 W_in_message = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2318 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2319 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2320 findMouse(&warped_from_x, &warped_from_y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2321 XWarpPointer(W_Display, None, W_Void2Window(window)->window, 0, 0, 0, 0, 0, 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2322 W_in_message = 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2323 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2324 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2325
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2326 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2327 findMouse(x, y)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2328 int *x, *y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2329 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2330 Window theRoot, theChild;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2331 int wX, wY, rootX, rootY, status;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2332 unsigned int wButtons;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2333
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2334 status = XQueryPointer(W_Display, W_Root, &theRoot, &theChild, &rootX, &rootY, &wX, &wY, &wButtons);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2335 if (status == True) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2336 *x = wX;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2337 *y = wY;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2338 } else {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2339 *x = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2340 *y = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2341 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2342 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2343
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2344 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2345 findMouseInWin(x, y, w)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2346 int *x, *y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2347 W_Window w;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2348 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2349 Window theRoot, theChild;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2350 int wX, wY, rootX, rootY, status;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2351 unsigned int wButtons;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2352 struct window *win = W_Void2Window(w);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2353 Window thisWin = win->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2354
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2355 status = XQueryPointer(W_Display, thisWin, &theRoot, &theChild,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2356 &rootX, &rootY, &wX, &wY, &wButtons);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2357 if (status == True) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2358 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2359 if it's in the window we specified then the values returned should
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2360 be within the with and height of the window
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2361 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2362 if (wX <= win->width && wY <= win->height) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2363 *x = wX;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2364 *y = wY;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2365 return 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2366 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2367 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2368 *x = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2369 *y = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2370 return 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2371 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2372
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2373 #ifdef AUTOKEY
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2374 static void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2375 W_Flush()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2376 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2377 XFlush(W_Display);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2378 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2379
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2380 W_AutoRepeatOff()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2381 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2382 XAutoRepeatOff(W_Display);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2383 W_Flush();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2384 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2385
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2386 W_AutoRepeatOn()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2387 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2388 XAutoRepeatOn(W_Display);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2389 W_Flush();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2390 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2391 #endif /* AUTOKEY */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2392
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2393 /* find the width of a font */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2394 int
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2395 W_StringWidth(string, font)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2396 char string[];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2397 W_Font font;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2398 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2399 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2400
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2401 y = strlen(string);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2402 x = XTextWidth(fonts[fontNum(font)].fontstruct, string, y);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2403 return (x); /* just a guess ?? old never returned! WHS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2404 4/6/93 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2405 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2406
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2407 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2408 W_TranslatePoints(w, x, y)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2409 int *x, *y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2410 W_Window w;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2411 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2412 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2413 win = W_Void2Window(w);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2414
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2415 if (win->type == WIN_TEXT) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2416 *y = (*y - MENU_PAD) / W_Textheight;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2417 *x = (*x - MENU_PAD) / W_Textwidth;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2418 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2419 return;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2420 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2421
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2422 #if 0
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2423 #define MAKE_WINDOW_GETTER(name, part) \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2424 W_Callback name(w) \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2425 W_Window w; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2426 { \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2427 return W_Void2Window(w)->part; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2428 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2429
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2430 #define MAKE_WINDOW_SETTER(name, port) \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2431 W_Callback name(w, c) \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2432 W_Window w; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2433 W_Callback c; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2434 { \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2435 W_Void2Window(w)->port = c; \
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2436 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2437
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2438 MAKE_WINDOW_GETTER(W_GetWindowKeyDownHandler, handle_keydown);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2439 MAKE_WINDOW_SETTER(W_SetWindowKeyDownHandler, handle_keydown);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2440
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2441 MAKE_WINDOW_GETTER(W_GetWindowKeyUpHandler, handle_keyup);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2442 MAKE_WINDOW_SETTER(W_SetWindowKeyUpHandler, handle_keyup);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2443
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2444 MAKE_WINDOW_GETTER(W_GetWindowButtonHandler, handle_button);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2445 MAKE_WINDOW_SETTER(W_SetWindowButtonHandler, handle_button);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2446
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2447 MAKE_WINDOW_GETTER(W_GetWindowExposeHandler, handle_expose);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2448 MAKE_WINDOW_SETTER(W_SetWindowExposeHandler, handle_expose);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2449 #endif /* 0 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2450
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2451 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2452 W_ResizeWindow(window, neww, newh) /* TSH 2/93 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2453 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2454 int neww, newh;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2455 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2456 Window win = W_Void2Window(window)->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2457
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2458 XResizeWindow(W_Display, win, (unsigned int) neww, (unsigned int) newh);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2459 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2460
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2461 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2462 W_ResizeMenu(window, neww, newh)/* TSH 2/93 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2463 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2464 int neww, newh;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2465 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2466 W_ResizeWindow(window, neww * W_Textwidth + WIN_EDGE * 2,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2467 newh * (W_Textheight + MENU_PAD * 2) + (newh - 1) * MENU_BAR);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2468 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2469
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2470 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2471 W_ResizeText(window, neww, newh)/* TSH 2/93 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2472 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2473 int neww, newh;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2474 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2475 W_ResizeWindow(window, neww * W_Textwidth + WIN_EDGE * 2,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2476 newh * W_Textheight + MENU_PAD * 2);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2477 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2478
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2479 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2480 W_Deiconify(window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2481 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2482 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2483 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2484 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2485 /* according to ICCCM 4.1.4, this is how you deiconify a window. */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2486 XMapWindow(W_Display, win->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2487 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2488
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2489 W_Icon
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2490 W_MakeShieldBitmap(width, height, window)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2491 int width, height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2492 W_Window window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2493 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2494 static GC pen = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2495 struct window *win;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2496 struct icon *newicon;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2497
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2498 win = W_Void2Window(window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2499
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2500 newicon = (struct icon *) malloc(sizeof(struct icon));
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2501 newicon->width = width;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2502 newicon->height = height;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2503 newicon->bitmap = XCreatePixmap(W_Display, win->window, width, height, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2504 newicon->window = win->window;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2505 newicon->pixmap = 0;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2506
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2507 pen = XCreateGC(W_Display, newicon->bitmap, 0L, 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2508 XSetForeground(W_Display, pen, 0L);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2509 XFillRectangle(W_Display, newicon->bitmap, pen, 0, 0, width, height);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2510 XSetForeground(W_Display, pen, 1L);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2511 XDrawArc(W_Display, newicon->bitmap, pen, 0, 0, width - 1, height - 1, 0, 360 * 64);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2512 XFreeGC(W_Display, pen);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2513
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2514 return W_Icon2Void(newicon);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2515 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2516
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2517 #ifdef BEEPLITE
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2518 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2519 W_OverlayBitmap(x, y, bit, color)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2520 int x, y;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2521 W_Icon bit;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2522 W_Color color;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2523 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2524 struct icon *icon = W_Void2Icon(bit);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2525 #ifdef DEBUG
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2526 printf("Overlaying bitmap to %d\n", icon->window);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2527 #endif
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2528 XCopyPlane(W_Display, icon->bitmap, icon->window,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2529 colortable[color].contexts[0], 0, 0, icon->width, icon->height,
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2530 x, y, 1);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2531 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2532 #endif