Mercurial > hg > xemacs-beta
comparison src/glyphs-msw.c @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | de805c49cfc1 |
children | e804706bfb8c |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
1 /* mswindows-specific glyph objects. | 1 /* mswindows-specific glyph objects. |
2 Copyright (C) 1998, 1999, 2000 Andy Piper. | 2 Copyright (C) 1998 Andy Piper. |
3 | 3 |
4 This file is part of XEmacs. | 4 This file is part of XEmacs. |
5 | 5 |
6 XEmacs is free software; you can redistribute it and/or modify it | 6 XEmacs is free software; you can redistribute it and/or modify it |
7 under the terms of the GNU General Public License as published by the | 7 under the terms of the GNU General Public License as published by the |
8 Free Software Foundation; either version 2, or (at your option) any | 8 Free Software Foundation; either version 2, or (at your option) any |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 Boston, MA 02111-1307, USA. */ | 19 Boston, MA 02111-1307, USA. */ |
20 | 20 |
21 /* Synched up with: Not in FSF. */ | 21 /* Synched up with: Not in FSF. */ |
22 | 22 |
23 /* written by Andy Piper <andy@xemacs.org> plagiarising bits from | 23 /* written by Andy Piper <andy@xemacs.org> plagerising bits from |
24 glyphs-x.c */ | 24 glyphs-x.c */ |
25 | 25 |
26 #include <config.h> | 26 #include <config.h> |
27 #include "lisp.h" | 27 #include "lisp.h" |
28 #include "lstream.h" | 28 #include "lstream.h" |
51 #include <setjmp.h> | 51 #include <setjmp.h> |
52 #endif | 52 #endif |
53 | 53 |
54 #define WIDGET_GLYPH_SLOT 0 | 54 #define WIDGET_GLYPH_SLOT 0 |
55 | 55 |
56 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing); | |
57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string); | |
58 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string); | |
59 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit); | |
60 #ifdef HAVE_JPEG | |
61 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg); | |
62 #endif | |
63 #ifdef HAVE_TIFF | |
64 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff); | |
65 #endif | |
66 #ifdef HAVE_PNG | |
67 DECLARE_IMAGE_INSTANTIATOR_FORMAT (png); | |
68 #endif | |
69 #ifdef HAVE_GIF | |
70 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif); | |
71 #endif | |
72 #ifdef HAVE_XPM | 56 #ifdef HAVE_XPM |
73 DEFINE_DEVICE_IIFORMAT (mswindows, xpm); | 57 DEFINE_DEVICE_IIFORMAT (mswindows, xpm); |
74 DEFINE_DEVICE_IIFORMAT (msprinter, xpm); | |
75 #endif | 58 #endif |
76 DEFINE_DEVICE_IIFORMAT (mswindows, xbm); | 59 DEFINE_DEVICE_IIFORMAT (mswindows, xbm); |
77 DEFINE_DEVICE_IIFORMAT (msprinter, xbm); | |
78 #ifdef HAVE_XFACE | 60 #ifdef HAVE_XFACE |
79 DEFINE_DEVICE_IIFORMAT (mswindows, xface); | 61 DEFINE_DEVICE_IIFORMAT (mswindows, xface); |
80 DEFINE_DEVICE_IIFORMAT (msprinter, xface); | |
81 #endif | 62 #endif |
82 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout); | |
83 DEFINE_DEVICE_IIFORMAT (mswindows, native_layout); | |
84 DEFINE_DEVICE_IIFORMAT (mswindows, button); | 63 DEFINE_DEVICE_IIFORMAT (mswindows, button); |
85 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field); | 64 DEFINE_DEVICE_IIFORMAT (mswindows, edit); |
65 #if 0 | |
66 DEFINE_DEVICE_IIFORMAT (mswindows, group); | |
67 #endif | |
86 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow); | 68 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow); |
87 DEFINE_DEVICE_IIFORMAT (mswindows, widget); | 69 DEFINE_DEVICE_IIFORMAT (mswindows, widget); |
88 DEFINE_DEVICE_IIFORMAT (mswindows, label); | 70 DEFINE_DEVICE_IIFORMAT (mswindows, label); |
89 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar); | 71 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar); |
90 DEFINE_DEVICE_IIFORMAT (mswindows, combo_box); | 72 DEFINE_DEVICE_IIFORMAT (mswindows, combo); |
91 DEFINE_DEVICE_IIFORMAT (mswindows, progress_gauge); | 73 DEFINE_DEVICE_IIFORMAT (mswindows, progress); |
92 DEFINE_DEVICE_IIFORMAT (mswindows, tree_view); | |
93 DEFINE_DEVICE_IIFORMAT (mswindows, tab_control); | |
94 | 74 |
95 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp); | 75 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp); |
96 Lisp_Object Qbmp; | 76 Lisp_Object Qbmp; |
97 Lisp_Object Vmswindows_bitmap_file_path; | 77 Lisp_Object Vmswindows_bitmap_file_path; |
98 static COLORREF transparent_color = RGB (1,1,1); | 78 static COLORREF transparent_color = RGB (1,1,1); |
100 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource); | 80 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource); |
101 Lisp_Object Q_resource_type, Q_resource_id; | 81 Lisp_Object Q_resource_type, Q_resource_id; |
102 Lisp_Object Qmswindows_resource; | 82 Lisp_Object Qmswindows_resource; |
103 | 83 |
104 static void | 84 static void |
105 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, | 85 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii, |
106 int slices, | 86 enum image_instance_type type); |
107 enum image_instance_type type); | 87 static void |
108 static void | 88 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image, |
109 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, | 89 struct frame* f); |
110 HDC hcdc); | 90 |
111 | 91 COLORREF mswindows_string_to_color (CONST char *name); |
112 /* | |
113 * Given device D, retrieve compatible device context. D can be either | |
114 * mswindows or an msprinter device. | |
115 */ | |
116 inline static HDC | |
117 get_device_compdc (struct device *d) | |
118 { | |
119 if (DEVICE_MSWINDOWS_P (d)) | |
120 return DEVICE_MSWINDOWS_HCDC (d); | |
121 else | |
122 return DEVICE_MSPRINTER_HCDC (d); | |
123 } | |
124 | |
125 /* | |
126 * Initialize image instance pixel sizes in II. For a display bitmap, | |
127 * these will be same as real bitmap sizes. For a printer bitmap, | |
128 * these will be scaled up so that the bitmap is proportionally enlarged | |
129 * when output to printer. Redisplay code takes care of scaling, to | |
130 * conserve memory we do not really scale bitmaps. Set the watermark | |
131 * only here. | |
132 * #### Add support for unscalable bitmaps. | |
133 */ | |
134 static void init_image_instance_geometry (Lisp_Image_Instance *ii) | |
135 { | |
136 struct device *d = DOMAIN_XDEVICE (ii->domain); | |
137 | |
138 if (/* #### Scaleable && */ DEVICE_MSPRINTER_P (d)) | |
139 { | |
140 HDC printer_dc = DEVICE_MSPRINTER_HCDC (d); | |
141 HDC display_dc = CreateCompatibleDC (NULL); | |
142 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = | |
143 MulDiv (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), | |
144 GetDeviceCaps (printer_dc, LOGPIXELSX), | |
145 GetDeviceCaps (display_dc, LOGPIXELSX)); | |
146 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = | |
147 MulDiv (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), | |
148 GetDeviceCaps (printer_dc, LOGPIXELSY), | |
149 GetDeviceCaps (display_dc, LOGPIXELSY)); | |
150 } | |
151 else | |
152 { | |
153 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = | |
154 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii); | |
155 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = | |
156 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii); | |
157 } | |
158 } | |
159 | 92 |
160 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) | 93 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) |
161 | 94 |
162 /************************************************************************/ | 95 /************************************************************************/ |
163 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ | 96 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ |
174 RGBQUAD* colortbl; | 107 RGBQUAD* colortbl; |
175 int ncolors; | 108 int ncolors; |
176 BITMAPINFO* bmp_info; | 109 BITMAPINFO* bmp_info; |
177 unsigned char *ip, *dp; | 110 unsigned char *ip, *dp; |
178 | 111 |
179 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0) | 112 if (DEVICE_MSWINDOWS_BITSPIXEL (d) > 0) |
180 { | 113 { |
181 int bpline = BPLINE(width * 3); | 114 int bpline = BPLINE(width * 3); |
182 /* FIXME: we can do this because 24bpp implies no color table, once | 115 /* FIXME: we can do this because 24bpp implies no color table, once |
183 * we start palettizing this is no longer true. The X versions of | 116 * we start palettizing this is no longer true. The X versions of |
184 * this function quantises to 256 colors or bit masks down to a | 117 * this function quantises to 256 colors or bit masks down to a |
185 * long. Windows can actually handle rgb triples in the raw so I | 118 * long. Windows can actually handle rgb triples in the raw so I |
186 * don't see much point trying to optimize down to the best | 119 * don't see much point trying to optimize down to the best |
187 * structure - unless it has memory / color allocation implications | 120 * structure - unless it has memory / color allocation implications |
188 * .... */ | 121 * .... */ |
189 bmp_info=xnew_and_zero (BITMAPINFO); | 122 bmp_info=xnew_and_zero (BITMAPINFO); |
190 | 123 |
191 if (!bmp_info) | 124 if (!bmp_info) |
192 { | 125 { |
193 return NULL; | 126 return NULL; |
194 } | 127 } |
195 | 128 |
196 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */ | 129 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */ |
197 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */ | 130 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */ |
198 bmp_info->bmiHeader.biSizeImage=width*height*3; | 131 bmp_info->bmiHeader.biSizeImage=width*height*3; |
199 | 132 |
200 /* bitmap data needs to be in blue, green, red triples - in that | 133 /* bitmap data needs to be in blue, green, red triples - in that |
201 order, eimage is in RGB format so we need to convert */ | 134 order, eimage is in RGB format so we need to convert */ |
202 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height); | 135 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height); |
203 *bit_count = bpline * height; | 136 *bit_count = bpline * height; |
229 qtable = build_EImage_quantable(pic, width, height, 256); | 162 qtable = build_EImage_quantable(pic, width, height, 256); |
230 if (qtable == NULL) return NULL; | 163 if (qtable == NULL) return NULL; |
231 | 164 |
232 /* use our quantize table to allocate the colors */ | 165 /* use our quantize table to allocate the colors */ |
233 ncolors = qtable->num_active_colors; | 166 ncolors = qtable->num_active_colors; |
234 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) + | 167 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) + |
235 sizeof(RGBQUAD) * ncolors); | 168 sizeof(RGBQUAD) * ncolors); |
236 if (!bmp_info) | 169 if (!bmp_info) |
237 { | 170 { |
238 xfree (qtable); | 171 xfree (qtable); |
239 return NULL; | 172 return NULL; |
240 } | 173 } |
241 | 174 |
242 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER)); | 175 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER)); |
243 | 176 |
244 bmp_info->bmiHeader.biBitCount=8; | 177 bmp_info->bmiHeader.biBitCount=8; |
245 bmp_info->bmiHeader.biCompression=BI_RGB; | 178 bmp_info->bmiHeader.biCompression=BI_RGB; |
246 bmp_info->bmiHeader.biSizeImage=bpline*height; | 179 bmp_info->bmiHeader.biSizeImage=bpline*height; |
247 bmp_info->bmiHeader.biClrUsed=ncolors; | 180 bmp_info->bmiHeader.biClrUsed=ncolors; |
248 bmp_info->bmiHeader.biClrImportant=ncolors; | 181 bmp_info->bmiHeader.biClrImportant=ncolors; |
249 | 182 |
250 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height); | 183 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height); |
251 *bit_count = bpline * height; | 184 *bit_count = bpline * height; |
252 | 185 |
253 if (!*bmp_data) | 186 if (!*bmp_data) |
254 { | 187 { |
255 xfree (qtable); | 188 xfree (qtable); |
256 xfree (bmp_info); | 189 xfree (bmp_info); |
257 return NULL; | 190 return NULL; |
258 } | 191 } |
259 | 192 |
260 /* build up an RGBQUAD colortable */ | 193 /* build up an RGBQUAD colortable */ |
261 for (i = 0; i < qtable->num_active_colors; i++) | 194 for (i = 0; i < qtable->num_active_colors; i++) { |
262 { | 195 colortbl[i].rgbRed = (BYTE) qtable->rm[i]; |
263 colortbl[i].rgbRed = (BYTE) qtable->rm[i]; | 196 colortbl[i].rgbGreen = (BYTE) qtable->gm[i]; |
264 colortbl[i].rgbGreen = (BYTE) qtable->gm[i]; | 197 colortbl[i].rgbBlue = (BYTE) qtable->bm[i]; |
265 colortbl[i].rgbBlue = (BYTE) qtable->bm[i]; | 198 colortbl[i].rgbReserved = 0; |
266 colortbl[i].rgbReserved = 0; | 199 } |
267 } | |
268 | 200 |
269 /* now build up the data. picture has to be upside-down and | 201 /* now build up the data. picture has to be upside-down and |
270 back-to-front for msw bitmaps */ | 202 back-to-front for msw bitmaps */ |
271 ip = pic; | 203 ip = pic; |
272 for (i = height-1; i >= 0; i--) | 204 for (i = height-1; i >= 0; i--) { |
273 { | 205 dp = (*bmp_data) + (i * bpline); |
274 dp = (*bmp_data) + (i * bpline); | 206 for (j = 0; j < width; j++) { |
275 for (j = 0; j < width; j++) | 207 rd = *ip++; |
276 { | 208 gr = *ip++; |
277 rd = *ip++; | 209 bl = *ip++; |
278 gr = *ip++; | 210 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl); |
279 bl = *ip++; | |
280 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl); | |
281 } | |
282 } | 211 } |
212 } | |
283 xfree (qtable); | 213 xfree (qtable); |
284 } | 214 } |
285 /* fix up the standard stuff */ | 215 /* fix up the standard stuff */ |
286 bmp_info->bmiHeader.biWidth=width; | 216 bmp_info->bmiHeader.biWidth=width; |
287 bmp_info->bmiHeader.biHeight=height; | 217 bmp_info->bmiHeader.biHeight=height; |
288 bmp_info->bmiHeader.biPlanes=1; | 218 bmp_info->bmiHeader.biPlanes=1; |
289 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | 219 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); |
290 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */ | 220 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */ |
291 bmp_info->bmiHeader.biYPelsPerMeter=0; | 221 bmp_info->bmiHeader.biYPelsPerMeter=0; |
292 | 222 |
293 return bmp_info; | 223 return bmp_info; |
294 } | 224 } |
295 | 225 |
296 /* Given a pixmap filename, look through all of the "standard" places | 226 /* Given a pixmap filename, look through all of the "standard" places |
310 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) || | 240 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) || |
311 (XSTRING_BYTE (name, 1) == '.' && | 241 (XSTRING_BYTE (name, 1) == '.' && |
312 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2))))))) | 242 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2))))))) |
313 { | 243 { |
314 if (!NILP (Ffile_readable_p (name))) | 244 if (!NILP (Ffile_readable_p (name))) |
315 return Fexpand_file_name (name, Qnil); | 245 return name; |
316 else | 246 else |
317 return Qnil; | 247 return Qnil; |
318 } | 248 } |
319 | 249 |
320 if (locate_file (Vmswindows_bitmap_file_path, name, Qnil, &found, R_OK) < 0) | 250 if (locate_file (Vmswindows_bitmap_file_path, name, Qnil, &found, R_OK) < 0) |
324 | 254 |
325 GCPRO1 (temp); | 255 GCPRO1 (temp); |
326 locate_file (temp, name, Qnil, &found, R_OK); | 256 locate_file (temp, name, Qnil, &found, R_OK); |
327 UNGCPRO; | 257 UNGCPRO; |
328 } | 258 } |
329 | 259 |
330 return found; | 260 return found; |
331 } | 261 } |
332 | 262 |
333 | 263 |
334 /* Initialize an image instance from a bitmap | 264 /* Initialize an image instance from a bitmap |
337 | 267 |
338 If this fails, signal an error. INSTANTIATOR is only used | 268 If this fails, signal an error. INSTANTIATOR is only used |
339 in the error message. */ | 269 in the error message. */ |
340 | 270 |
341 static void | 271 static void |
342 init_image_instance_from_dibitmap (Lisp_Image_Instance *ii, | 272 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii, |
343 BITMAPINFO *bmp_info, | 273 BITMAPINFO *bmp_info, |
344 int dest_mask, | 274 int dest_mask, |
345 void *bmp_data, | 275 void *bmp_data, |
346 int bmp_bits, | 276 int bmp_bits, |
347 int slices, | 277 Lisp_Object instantiator, |
348 Lisp_Object instantiator, | |
349 int x_hot, int y_hot, | 278 int x_hot, int y_hot, |
350 int create_mask) | 279 int create_mask) |
351 { | 280 { |
352 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); | 281 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
282 struct device *d = XDEVICE (device); | |
283 struct frame *f; | |
353 void* bmp_buf=0; | 284 void* bmp_buf=0; |
354 enum image_instance_type type; | 285 int type; |
355 HBITMAP bitmap; | 286 HBITMAP bitmap; |
356 HDC hdc; | 287 HDC hdc; |
357 | 288 |
289 if (!DEVICE_MSWINDOWS_P (d)) | |
290 signal_simple_error ("Not an mswindows device", device); | |
291 | |
292 if (NILP (DEVICE_SELECTED_FRAME (d))) | |
293 signal_simple_error ("No selected frame on mswindows device", device); | |
294 | |
295 f = XFRAME (DEVICE_SELECTED_FRAME (d)); | |
296 | |
358 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) | 297 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) |
359 type = IMAGE_COLOR_PIXMAP; | 298 type = IMAGE_COLOR_PIXMAP; |
360 else if (dest_mask & IMAGE_POINTER_MASK) | 299 else if (dest_mask & IMAGE_POINTER_MASK) |
361 type = IMAGE_POINTER; | 300 type = IMAGE_POINTER; |
362 else | 301 else |
363 incompatible_image_types (instantiator, dest_mask, | 302 incompatible_image_types (instantiator, dest_mask, |
364 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); | 303 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); |
365 | 304 hdc = FRAME_MSWINDOWS_CDC (f); |
366 hdc = get_device_compdc (d); | 305 |
367 bitmap = CreateDIBSection (hdc, | 306 bitmap=CreateDIBSection (hdc, |
368 bmp_info, | 307 bmp_info, |
369 DIB_RGB_COLORS, | 308 DIB_RGB_COLORS, |
370 &bmp_buf, | 309 &bmp_buf, |
371 0, 0); | 310 0,0); |
372 | 311 |
373 if (!bitmap || !bmp_buf) | 312 if (!bitmap || !bmp_buf) |
374 signal_simple_error ("Unable to create bitmap", instantiator); | 313 signal_simple_error ("Unable to create bitmap", instantiator); |
375 | 314 |
376 /* copy in the actual bitmap */ | 315 /* copy in the actual bitmap */ |
377 memcpy (bmp_buf, bmp_data, bmp_bits); | 316 memcpy (bmp_buf, bmp_data, bmp_bits); |
378 | 317 |
379 mswindows_initialize_dibitmap_image_instance (ii, slices, type); | 318 mswindows_initialize_dibitmap_image_instance (ii, type); |
380 | 319 |
381 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = | 320 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = |
382 find_keyword_in_vector (instantiator, Q_file); | 321 find_keyword_in_vector (instantiator, Q_file); |
383 | 322 |
384 /* Fixup a set of bitmaps. */ | |
385 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; | 323 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; |
386 | |
387 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; | 324 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; |
388 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = | 325 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth; |
389 bmp_info->bmiHeader.biWidth; | 326 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight; |
390 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = | 327 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; |
391 bmp_info->bmiHeader.biHeight; | |
392 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; | |
393 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot); | 328 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot); |
394 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot); | 329 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot); |
395 init_image_instance_geometry (ii); | |
396 | 330 |
397 if (create_mask) | 331 if (create_mask) |
398 { | 332 { |
399 mswindows_initialize_image_instance_mask (ii, hdc); | 333 mswindows_initialize_image_instance_mask (ii, f); |
400 } | 334 } |
401 | 335 |
402 if (type == IMAGE_POINTER) | 336 if (type == IMAGE_POINTER) |
403 { | 337 { |
404 mswindows_initialize_image_instance_icon(ii, TRUE); | 338 mswindows_initialize_image_instance_icon(ii, TRUE); |
405 } | 339 } |
406 } | 340 } |
407 | 341 |
408 static void | 342 static void |
409 image_instance_add_dibitmap (Lisp_Image_Instance *ii, | 343 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii, |
410 BITMAPINFO *bmp_info, | |
411 void *bmp_data, | |
412 int bmp_bits, | |
413 int slice, | |
414 Lisp_Object instantiator) | |
415 { | |
416 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii)); | |
417 void* bmp_buf=0; | |
418 | |
419 HBITMAP bitmap = CreateDIBSection (get_device_compdc (d), | |
420 bmp_info, | |
421 DIB_RGB_COLORS, | |
422 &bmp_buf, | |
423 0,0); | |
424 | |
425 if (!bitmap || !bmp_buf) | |
426 signal_simple_error ("Unable to create bitmap", instantiator); | |
427 | |
428 /* copy in the actual bitmap */ | |
429 memcpy (bmp_buf, bmp_data, bmp_bits); | |
430 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap; | |
431 } | |
432 | |
433 static void | |
434 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii, | |
435 int width, int height, | 344 int width, int height, |
436 int slices, | 345 unsigned char *eimage, |
437 unsigned char *eimage, | |
438 int dest_mask, | 346 int dest_mask, |
439 Lisp_Object instantiator, | 347 Lisp_Object instantiator, |
440 Lisp_Object domain) | 348 Lisp_Object domain) |
441 { | 349 { |
442 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 350 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
443 BITMAPINFO* bmp_info; | 351 BITMAPINFO* bmp_info; |
444 unsigned char* bmp_data; | 352 unsigned char* bmp_data; |
445 int bmp_bits; | 353 int bmp_bits; |
446 COLORREF bkcolor; | 354 COLORREF bkcolor; |
447 int slice; | 355 |
448 | 356 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) |
449 CHECK_MSGDI_DEVICE (device); | 357 signal_simple_error ("Not an mswindows device", device); |
450 | 358 |
451 /* this is a hack but MaskBlt and TransparentBlt are not supported | 359 /* this is a hack but MaskBlt and TransparentBlt are not supported |
452 on most windows variants */ | 360 on most windows variants */ |
453 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR | 361 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR |
454 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); | 362 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); |
455 | 363 |
456 for (slice = 0; slice < slices; slice++) | 364 /* build a bitmap from the eimage */ |
457 { | 365 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage, |
458 /* build a bitmap from the eimage */ | 366 &bmp_bits, &bmp_data))) |
459 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, | 367 { |
460 eimage + (width * height * 3 * slice), | 368 signal_simple_error ("EImage to DIBitmap conversion failed", |
461 &bmp_bits, &bmp_data))) | 369 instantiator); |
462 { | 370 } |
463 signal_simple_error ("EImage to DIBitmap conversion failed", | 371 |
464 instantiator); | 372 /* Now create the pixmap and set up the image instance */ |
465 } | 373 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, |
466 | 374 bmp_data, bmp_bits, instantiator, |
467 /* Now create the pixmap and set up the image instance */ | 375 0, 0, 0); |
468 if (slice == 0) | 376 |
469 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, | 377 xfree (bmp_info); |
470 bmp_data, bmp_bits, slices, instantiator, | 378 xfree (bmp_data); |
471 0, 0, 0); | 379 } |
472 else | 380 |
473 image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice, | 381 static void set_mono_pixel ( unsigned char* bits, |
474 instantiator); | 382 int bpline, int height, |
475 | 383 int x, int y, int white ) |
476 xfree (bmp_info); | 384 { |
477 xfree (bmp_data); | 385 int index; |
478 } | 386 unsigned char bitnum; |
479 } | |
480 | |
481 inline static void | |
482 set_mono_pixel (unsigned char* bits, | |
483 int bpline, int height, | |
484 int x, int y, int white) | |
485 { | |
486 int i; | |
487 unsigned char bitnum; | |
488 /* Find the byte on which this scanline begins */ | 387 /* Find the byte on which this scanline begins */ |
489 i = (height - y - 1) * bpline; | 388 index = (height - y - 1) * bpline; |
490 /* Find the byte containing this pixel */ | 389 /* Find the byte containing this pixel */ |
491 i += (x >> 3); | 390 index += (x >> 3); |
492 /* Which bit is it? */ | 391 /* Which bit is it? */ |
493 bitnum = (unsigned char) (7 - (x & 7)); | 392 bitnum = (unsigned char)( 7 - (x % 8) ); |
494 if (white) /* Turn it on */ | 393 if( white ) /* Turn it on */ |
495 bits[i] |= (1 << bitnum); | 394 bits[index] |= (1<<bitnum); |
496 else /* Turn it off */ | 395 else /* Turn it off */ |
497 bits[i] &= ~(1 << bitnum); | 396 bits[index] &= ~(1<<bitnum); |
498 } | 397 } |
499 | 398 |
500 static void | 399 static void |
501 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, | 400 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image, |
502 HDC hcdc) | 401 struct frame* f) |
503 { | 402 { |
504 HBITMAP mask; | 403 HBITMAP mask; |
505 HGDIOBJ old = NULL; | 404 HGDIOBJ old = NULL; |
506 unsigned char *dibits, *and_bits; | 405 HDC hcdc = FRAME_MSWINDOWS_CDC (f); |
507 BITMAPINFO *bmp_info = | 406 unsigned char* dibits; |
508 (BITMAPINFO*) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD)); | 407 BITMAPINFO* bmp_info = |
408 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); | |
509 int i, j; | 409 int i, j; |
510 int height = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (image); | 410 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image); |
511 | 411 |
512 int maskbpline = BPLINE ((IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) + 7) / 8); | 412 void* and_bits; |
513 int bpline = BPLINE (IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image) * 3); | 413 int maskbpline = BPLINE (((IMAGE_INSTANCE_PIXMAP_WIDTH (image)+7)/8)); |
414 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3); | |
514 | 415 |
515 if (!bmp_info) | 416 if (!bmp_info) |
516 return; | 417 return; |
517 | 418 |
518 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); | 419 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image); |
519 bmp_info->bmiHeader.biHeight = height; | 420 bmp_info->bmiHeader.biHeight = height; |
520 bmp_info->bmiHeader.biPlanes = 1; | 421 bmp_info->bmiHeader.biPlanes=1; |
521 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | 422 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); |
522 bmp_info->bmiHeader.biBitCount = 1; | 423 bmp_info->bmiHeader.biBitCount=1; |
523 bmp_info->bmiHeader.biCompression = BI_RGB; | 424 bmp_info->bmiHeader.biCompression=BI_RGB; |
524 bmp_info->bmiHeader.biClrUsed = 2; | 425 bmp_info->bmiHeader.biClrUsed = 2; |
525 bmp_info->bmiHeader.biClrImportant = 2; | 426 bmp_info->bmiHeader.biClrImportant = 2; |
526 bmp_info->bmiHeader.biSizeImage = height * maskbpline; | 427 bmp_info->bmiHeader.biSizeImage = height * maskbpline; |
527 bmp_info->bmiColors[0].rgbRed = 0; | 428 bmp_info->bmiColors[0].rgbRed = 0; |
528 bmp_info->bmiColors[0].rgbGreen = 0; | 429 bmp_info->bmiColors[0].rgbGreen = 0; |
529 bmp_info->bmiColors[0].rgbBlue = 0; | 430 bmp_info->bmiColors[0].rgbBlue = 0; |
530 bmp_info->bmiColors[0].rgbReserved = 0; | 431 bmp_info->bmiColors[0].rgbReserved = 0; |
531 bmp_info->bmiColors[1].rgbRed = 255; | 432 bmp_info->bmiColors[1].rgbRed = 255; |
532 bmp_info->bmiColors[1].rgbGreen = 255; | 433 bmp_info->bmiColors[1].rgbGreen = 255; |
533 bmp_info->bmiColors[1].rgbBlue = 255; | 434 bmp_info->bmiColors[1].rgbBlue = 255; |
534 bmp_info->bmiColors[0].rgbReserved = 0; | 435 bmp_info->bmiColors[0].rgbReserved = 0; |
535 | 436 |
536 if (!(mask = CreateDIBSection (hcdc, | 437 if (!(mask = CreateDIBSection (hcdc, |
537 bmp_info, | 438 bmp_info, |
538 DIB_RGB_COLORS, | 439 DIB_RGB_COLORS, |
539 (void**)&and_bits, | 440 &and_bits, |
540 0,0))) | 441 0,0))) |
541 { | 442 { |
542 xfree (bmp_info); | 443 xfree (bmp_info); |
543 return; | 444 return; |
544 } | 445 } |
545 | 446 |
546 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image)); | 447 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image)); |
547 /* build up an in-memory set of bits to mess with */ | 448 /* build up an in-memory set of bits to mess with */ |
548 xzero (*bmp_info); | 449 xzero (*bmp_info); |
549 | 450 |
550 bmp_info->bmiHeader.biWidth = IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); | 451 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image); |
551 bmp_info->bmiHeader.biHeight = -height; | 452 bmp_info->bmiHeader.biHeight = -height; |
552 bmp_info->bmiHeader.biPlanes = 1; | 453 bmp_info->bmiHeader.biPlanes=1; |
553 bmp_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | 454 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); |
554 bmp_info->bmiHeader.biBitCount = 24; | 455 bmp_info->bmiHeader.biBitCount=24; |
555 bmp_info->bmiHeader.biCompression = BI_RGB; | 456 bmp_info->bmiHeader.biCompression=BI_RGB; |
556 bmp_info->bmiHeader.biClrUsed = 0; | 457 bmp_info->bmiHeader.biClrUsed = 0; |
557 bmp_info->bmiHeader.biClrImportant = 0; | 458 bmp_info->bmiHeader.biClrImportant = 0; |
558 bmp_info->bmiHeader.biSizeImage = height * bpline; | 459 bmp_info->bmiHeader.biSizeImage = height * bpline; |
559 | 460 |
560 dibits = (unsigned char*) xmalloc_and_zero (bpline * height); | 461 dibits = xmalloc_and_zero (bpline * height); |
561 if (GetDIBits (hcdc, | 462 if (GetDIBits (hcdc, |
562 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), | 463 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image), |
563 0, | 464 0, |
564 height, | 465 height, |
565 dibits, | 466 dibits, |
570 return; | 471 return; |
571 } | 472 } |
572 | 473 |
573 /* now set the colored bits in the mask and transparent ones to | 474 /* now set the colored bits in the mask and transparent ones to |
574 black in the original */ | 475 black in the original */ |
575 for (i = 0; i < IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (image); i++) | 476 for(i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++) |
576 { | 477 { |
577 for (j=0; j<height; j++) | 478 for(j=0; j<height; j++) |
578 { | 479 { |
579 unsigned char* idx = &dibits[j * bpline + i * 3]; | 480 unsigned char* idx = &dibits[j * bpline + i * 3]; |
580 | 481 |
581 if (RGB (idx[2], idx[1], idx[0]) == transparent_color) | 482 if( RGB (idx[2], idx[1], idx[0]) == transparent_color ) |
582 { | 483 { |
583 idx[0] = idx[1] = idx[2] = 0; | 484 idx[0] = idx[1] = idx[2] = 0; |
584 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE); | 485 set_mono_pixel( and_bits, maskbpline, height, i, j, TRUE ); |
585 } | 486 } |
586 else | 487 else |
587 { | 488 { |
588 set_mono_pixel (and_bits, maskbpline, height, i, j, FALSE); | 489 set_mono_pixel( and_bits, maskbpline, height, i, j, FALSE ); |
589 } | 490 } |
590 } | 491 } |
591 } | 492 } |
592 | 493 |
593 SetDIBits (hcdc, | 494 SetDIBits (hcdc, |
598 bmp_info, | 499 bmp_info, |
599 DIB_RGB_COLORS); | 500 DIB_RGB_COLORS); |
600 | 501 |
601 xfree (bmp_info); | 502 xfree (bmp_info); |
602 xfree (dibits); | 503 xfree (dibits); |
603 | 504 |
604 SelectObject(hcdc, old); | 505 SelectObject(hcdc, old); |
605 | 506 |
606 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; | 507 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; |
607 } | 508 } |
608 | 509 |
609 void | 510 void |
610 mswindows_initialize_image_instance_icon (Lisp_Image_Instance* image, | 511 mswindows_initialize_image_instance_icon (struct Lisp_Image_Instance* image, |
611 int cursor) | 512 int cursor) |
612 { | 513 { |
613 ICONINFO x_icon; | 514 ICONINFO x_icon; |
614 | 515 |
615 /* we rely on windows to do any resizing necessary */ | 516 /* we rely on windows to do any resizing necessary */ |
616 x_icon.fIcon=cursor ? FALSE : TRUE; | 517 x_icon.fIcon=cursor ? FALSE : TRUE; |
617 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image)); | 518 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image)); |
618 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image)); | 519 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image)); |
619 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image); | 520 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image); |
620 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image); | 521 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image); |
621 | 522 |
622 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= | 523 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= |
623 CreateIconIndirect (&x_icon); | 524 CreateIconIndirect (&x_icon); |
624 } | 525 } |
625 | 526 |
626 static HBITMAP | 527 HBITMAP |
627 create_resized_bitmap (HBITMAP curbmp, struct frame *f, | 528 mswindows_create_resized_bitmap (struct Lisp_Image_Instance* ii, |
628 int curx, int cury, | 529 struct frame* f, |
629 int newx, int newy) | 530 int newx, int newy) |
630 { | 531 { |
631 HBITMAP newbmp; | 532 HBITMAP newbmp; |
632 HGDIOBJ old1, old2; | 533 HGDIOBJ old1, old2; |
633 | 534 HDC hcdc = FRAME_MSWINDOWS_CDC (f); |
634 HDC hcdc = get_device_compdc (XDEVICE (FRAME_DEVICE (f))); | 535 HDC hdcDst = CreateCompatibleDC (hcdc); |
635 HDC hdcDst = CreateCompatibleDC (hcdc); | 536 |
636 | 537 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)); |
637 old1 = SelectObject (hcdc, curbmp); | 538 |
638 | |
639 newbmp = CreateCompatibleBitmap (hcdc, newx, newy); | 539 newbmp = CreateCompatibleBitmap (hcdc, newx, newy); |
640 | 540 |
641 old2 = SelectObject (hdcDst, newbmp); | 541 old2 = SelectObject (hdcDst, newbmp); |
642 | 542 |
643 if (!StretchBlt (hdcDst, 0, 0, newx, newy, | 543 if (!StretchBlt (hdcDst, 0, 0, newx, newy, |
644 hcdc, 0, 0, | 544 hcdc, 0, 0, |
645 curx, | 545 IMAGE_INSTANCE_PIXMAP_WIDTH (ii), |
646 cury, | 546 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii), |
647 SRCCOPY)) | 547 SRCCOPY)) |
648 { | 548 { |
649 DeleteObject (newbmp); | 549 DeleteObject (newbmp); |
650 DeleteDC (hdcDst); | 550 DeleteDC (hdcDst); |
651 return 0; | 551 return 0; |
657 | 557 |
658 return newbmp; | 558 return newbmp; |
659 } | 559 } |
660 | 560 |
661 HBITMAP | 561 HBITMAP |
662 mswindows_create_resized_bitmap (Lisp_Image_Instance* ii, | 562 mswindows_create_resized_mask (struct Lisp_Image_Instance* ii, |
663 struct frame* f, | |
664 int newx, int newy) | |
665 { | |
666 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii), | |
667 f, | |
668 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), | |
669 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), | |
670 newx, newy); | |
671 } | |
672 | |
673 HBITMAP | |
674 mswindows_create_resized_mask (Lisp_Image_Instance* ii, | |
675 struct frame* f, | 563 struct frame* f, |
676 int newx, int newy) | 564 int newx, int newy) |
677 { | 565 { |
678 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii) == NULL) | 566 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) |
679 return NULL; | 567 { |
680 | 568 HBITMAP newmask; |
681 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_MASK (ii), | 569 HGDIOBJ old1, old2; |
682 f, | 570 HDC hcdc = FRAME_MSWINDOWS_CDC (f); |
683 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii), | 571 HDC hdcDst = CreateCompatibleDC (hcdc); |
684 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii), | 572 |
685 newx, newy); | 573 old1 = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_MASK (ii)); |
686 } | 574 newmask = CreateCompatibleBitmap(hcdc, newx, newy); |
687 | 575 old2 = SelectObject (hdcDst, newmask); |
688 #if 0 /* Currently unused */ | 576 |
689 /* #### Warining: This function is not correct anymore with | 577 if (!StretchBlt(hdcDst, 0, 0, newx, newy, |
690 resizable printer bitmaps. If you uncomment it, clean it. --kkm */ | 578 hcdc, 0, 0, |
579 IMAGE_INSTANCE_PIXMAP_WIDTH (ii), | |
580 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii), | |
581 SRCCOPY)) | |
582 { | |
583 DeleteObject (newmask); | |
584 DeleteDC (hdcDst); | |
585 return NULL; | |
586 } | |
587 | |
588 SelectObject (hdcDst, old2); | |
589 SelectObject (hcdc, old1); | |
590 | |
591 DeleteDC (hdcDst); | |
592 | |
593 return newmask; | |
594 } | |
595 | |
596 return NULL; | |
597 } | |
598 | |
691 int | 599 int |
692 mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii, | 600 mswindows_resize_dibitmap_instance (struct Lisp_Image_Instance* ii, |
693 struct frame* f, | 601 struct frame* f, |
694 int newx, int newy) | 602 int newx, int newy) |
695 { | 603 { |
696 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy); | 604 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy); |
697 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy); | 605 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy); |
698 | 606 |
699 if (!newbmp) | 607 if (!newbmp) |
700 return FALSE; | 608 return FALSE; |
701 | 609 |
702 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)) | 610 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)) |
703 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)); | 611 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii)); |
704 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) | 612 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) |
705 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)); | 613 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)); |
706 | 614 |
709 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx; | 617 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx; |
710 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy; | 618 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy; |
711 | 619 |
712 return TRUE; | 620 return TRUE; |
713 } | 621 } |
714 #endif | |
715 | 622 |
716 /********************************************************************** | 623 /********************************************************************** |
717 * XPM * | 624 * XPM * |
718 **********************************************************************/ | 625 **********************************************************************/ |
719 | 626 |
773 colortbl = xnew_array_and_zero (struct color_symbol, i); | 680 colortbl = xnew_array_and_zero (struct color_symbol, i); |
774 | 681 |
775 for (j=0; j<i; j++) | 682 for (j=0; j<i; j++) |
776 { | 683 { |
777 Lisp_Object cons = XCAR (results); | 684 Lisp_Object cons = XCAR (results); |
778 colortbl[j].color = | 685 colortbl[j].color = |
779 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons))); | 686 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons))); |
780 | 687 |
781 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (cons), | 688 GET_C_STRING_OS_DATA_ALLOCA (XCAR (cons), colortbl[j].name); |
782 C_STRING_ALLOCA, colortbl[j].name, | |
783 Qnative); | |
784 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */ | 689 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */ |
785 free_cons (XCONS (cons)); | 690 free_cons (XCONS (cons)); |
786 cons = results; | 691 cons = results; |
787 results = XCDR (results); | 692 results = XCDR (results); |
788 free_cons (XCONS (cons)); | 693 free_cons (XCONS (cons)); |
789 } | 694 } |
790 return colortbl; | 695 return colortbl; |
791 } | 696 } |
792 | 697 |
793 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer, | 698 static int xpm_to_eimage (Lisp_Object image, CONST Extbyte *buffer, |
794 unsigned char** data, | 699 unsigned char** data, |
795 int* width, int* height, | 700 int* width, int* height, |
796 int* x_hot, int* y_hot, | 701 int* x_hot, int* y_hot, |
797 int* transp, | 702 int* transp, |
798 struct color_symbol* color_symbols, | 703 struct color_symbol* color_symbols, |
802 XpmInfo xpminfo; | 707 XpmInfo xpminfo; |
803 int result, i, j, transp_idx, maskbpline; | 708 int result, i, j, transp_idx, maskbpline; |
804 unsigned char* dptr; | 709 unsigned char* dptr; |
805 unsigned int* sptr; | 710 unsigned int* sptr; |
806 COLORREF color; /* the american spelling virus hits again .. */ | 711 COLORREF color; /* the american spelling virus hits again .. */ |
807 COLORREF* colortbl; | 712 COLORREF* colortbl; |
808 | 713 |
809 xzero (xpmimage); | 714 xzero (xpmimage); |
810 xzero (xpminfo); | 715 xzero (xpminfo); |
811 xpminfo.valuemask=XpmHotspot; | 716 xpminfo.valuemask=XpmHotspot; |
812 *transp=FALSE; | 717 *transp=FALSE; |
828 "out of memory", image); | 733 "out of memory", image); |
829 } | 734 } |
830 default: | 735 default: |
831 { | 736 { |
832 signal_double_file_error_2 ("Parsing pixmap data", | 737 signal_double_file_error_2 ("Parsing pixmap data", |
833 "unknown error", | 738 "unknown error code", |
834 make_int (result), image); | 739 make_int (result), image); |
835 } | 740 } |
836 } | 741 } |
837 | 742 |
838 *width = xpmimage.width; | 743 *width = xpmimage.width; |
839 *height = xpmimage.height; | 744 *height = xpmimage.height; |
840 maskbpline = BPLINE ((~7UL & (unsigned long)(*width + 7)) / 8); | 745 maskbpline = BPLINE (((~7UL & (unsigned long)(*width + 7)) / 8)); |
841 | 746 |
842 *data = xnew_array_and_zero (unsigned char, *width * *height * 3); | 747 *data = xnew_array_and_zero (unsigned char, *width * *height * 3); |
843 | 748 |
844 if (!*data) | 749 if (!*data) |
845 { | 750 { |
846 XpmFreeXpmImage (&xpmimage); | 751 XpmFreeXpmImage (&xpmimage); |
867 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor") | 772 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor") |
868 || | 773 || |
869 !strcasecmp (xpmimage.colorTable[i].symbolic,"None")) | 774 !strcasecmp (xpmimage.colorTable[i].symbolic,"None")) |
870 { | 775 { |
871 *transp=TRUE; | 776 *transp=TRUE; |
872 colortbl[i]=transparent_color; | 777 colortbl[i]=transparent_color; |
873 transp_idx=i; | 778 transp_idx=i; |
874 goto label_found_color; | 779 goto label_found_color; |
875 } | 780 } |
876 else if (color_symbols) | 781 else if (color_symbols) |
877 { | 782 { |
892 } | 797 } |
893 /* pick up transparencies */ | 798 /* pick up transparencies */ |
894 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None")) | 799 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None")) |
895 { | 800 { |
896 *transp=TRUE; | 801 *transp=TRUE; |
897 colortbl[i]=transparent_color; | 802 colortbl[i]=transparent_color; |
898 transp_idx=i; | 803 transp_idx=i; |
899 goto label_found_color; | 804 goto label_found_color; |
900 } | 805 } |
901 /* finally pick up a normal color spec */ | 806 /* finally pick up a normal color spec */ |
902 if (xpmimage.colorTable[i].c_color) | 807 if (xpmimage.colorTable[i].c_color) |
903 { | 808 { |
904 colortbl[i]= | 809 colortbl[i]= |
905 mswindows_string_to_color (xpmimage.colorTable[i].c_color); | 810 mswindows_string_to_color (xpmimage.colorTable[i].c_color); |
906 goto label_found_color; | 811 goto label_found_color; |
907 } | 812 } |
908 | 813 |
909 label_no_color: | 814 label_no_color: |
910 xfree (*data); | 815 xfree (*data); |
911 xfree (colortbl); | 816 xfree (colortbl); |
912 XpmFreeXpmImage (&xpmimage); | 817 XpmFreeXpmImage (&xpmimage); |
913 XpmFreeXpmInfo (&xpminfo); | 818 XpmFreeXpmInfo (&xpminfo); |
914 return 0; | 819 return 0; |
915 | 820 |
916 label_found_color:; | 821 label_found_color:; |
917 } | 822 } |
918 | 823 |
919 /* convert the image */ | 824 /* convert the image */ |
920 sptr=xpmimage.data; | 825 sptr=xpmimage.data; |
942 mswindows_xpm_instantiate (Lisp_Object image_instance, | 847 mswindows_xpm_instantiate (Lisp_Object image_instance, |
943 Lisp_Object instantiator, | 848 Lisp_Object instantiator, |
944 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 849 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
945 int dest_mask, Lisp_Object domain) | 850 int dest_mask, Lisp_Object domain) |
946 { | 851 { |
947 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 852 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
948 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 853 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
949 const Extbyte *bytes; | 854 CONST Extbyte *bytes; |
950 Extcount len; | 855 Extcount len; |
951 unsigned char *eimage; | 856 unsigned char *eimage; |
952 int width, height, x_hot, y_hot; | 857 int width, height, x_hot, y_hot; |
953 BITMAPINFO* bmp_info; | 858 BITMAPINFO* bmp_info; |
954 unsigned char* bmp_data; | 859 unsigned char* bmp_data; |
955 int bmp_bits; | 860 int bmp_bits; |
956 int nsymbols=0, transp; | 861 int nsymbols=0, transp; |
957 struct color_symbol* color_symbols=NULL; | 862 struct color_symbol* color_symbols=NULL; |
958 | 863 |
959 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 864 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
960 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, | 865 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, |
961 Q_color_symbols); | 866 Q_color_symbols); |
962 | 867 |
963 CHECK_MSGDI_DEVICE (device); | 868 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) |
869 signal_simple_error ("Not an mswindows device", device); | |
964 | 870 |
965 assert (!NILP (data)); | 871 assert (!NILP (data)); |
966 | 872 |
967 TO_EXTERNAL_FORMAT (LISP_STRING, data, | 873 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len); |
968 ALLOCA, (bytes, len), | |
969 Qbinary); | |
970 | 874 |
971 /* in case we have color symbols */ | 875 /* in case we have color symbols */ |
972 color_symbols = extract_xpm_color_names (device, domain, | 876 color_symbols = extract_xpm_color_names (device, domain, |
973 color_symbol_alist, &nsymbols); | 877 color_symbol_alist, &nsymbols); |
974 | 878 |
975 /* convert to an eimage to make processing easier */ | 879 /* convert to an eimage to make processing easier */ |
976 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height, | 880 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height, |
977 &x_hot, &y_hot, &transp, color_symbols, nsymbols)) | 881 &x_hot, &y_hot, &transp, color_symbols, nsymbols)) |
978 { | 882 { |
979 signal_simple_error ("XPM to EImage conversion failed", | 883 signal_simple_error ("XPM to EImage conversion failed", |
980 image_instance); | 884 image_instance); |
981 } | 885 } |
982 | 886 |
983 if (color_symbols) | 887 if (color_symbols) |
984 { | 888 { |
985 while (nsymbols--) | 889 while (nsymbols--) |
986 { | 890 { |
987 xfree (color_symbols[nsymbols].name); | 891 xfree (color_symbols[nsymbols].name); |
988 } | 892 } |
989 xfree(color_symbols); | 893 xfree(color_symbols); |
990 } | 894 } |
991 | 895 |
992 /* build a bitmap from the eimage */ | 896 /* build a bitmap from the eimage */ |
993 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage, | 897 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage, |
994 &bmp_bits, &bmp_data))) | 898 &bmp_bits, &bmp_data))) |
995 { | 899 { |
996 signal_simple_error ("XPM to EImage conversion failed", | 900 signal_simple_error ("XPM to EImage conversion failed", |
998 } | 902 } |
999 xfree (eimage); | 903 xfree (eimage); |
1000 | 904 |
1001 /* Now create the pixmap and set up the image instance */ | 905 /* Now create the pixmap and set up the image instance */ |
1002 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, | 906 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, |
1003 bmp_data, bmp_bits, 1, instantiator, | 907 bmp_data, bmp_bits, instantiator, |
1004 x_hot, y_hot, transp); | 908 x_hot, y_hot, transp); |
1005 | 909 |
1006 xfree (bmp_info); | 910 xfree (bmp_info); |
1007 xfree (bmp_data); | 911 xfree (bmp_data); |
1008 } | 912 } |
1033 static void | 937 static void |
1034 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 938 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1035 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 939 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1036 int dest_mask, Lisp_Object domain) | 940 int dest_mask, Lisp_Object domain) |
1037 { | 941 { |
1038 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 942 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1039 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 943 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1040 const Extbyte *bytes; | 944 CONST Extbyte *bytes; |
1041 Extcount len; | 945 Extcount len; |
1042 BITMAPFILEHEADER* bmp_file_header; | 946 BITMAPFILEHEADER* bmp_file_header; |
1043 BITMAPINFO* bmp_info; | 947 BITMAPINFO* bmp_info; |
1044 void* bmp_data; | 948 void* bmp_data; |
1045 int bmp_bits; | 949 int bmp_bits; |
1046 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 950 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1047 | 951 |
1048 CHECK_MSGDI_DEVICE (device); | 952 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) |
953 signal_simple_error ("Not an mswindows device", device); | |
1049 | 954 |
1050 assert (!NILP (data)); | 955 assert (!NILP (data)); |
1051 | 956 |
1052 TO_EXTERNAL_FORMAT (LISP_STRING, data, | 957 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len); |
1053 ALLOCA, (bytes, len), | 958 |
1054 Qbinary); | |
1055 | |
1056 /* Then slurp the image into memory, decoding along the way. | 959 /* Then slurp the image into memory, decoding along the way. |
1057 The result is the image in a simple one-byte-per-pixel | 960 The result is the image in a simple one-byte-per-pixel |
1058 format. */ | 961 format. */ |
1059 | 962 |
1060 bmp_file_header=(BITMAPFILEHEADER*)bytes; | 963 bmp_file_header=(BITMAPFILEHEADER*)bytes; |
1061 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER)); | 964 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER)); |
1062 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits; | 965 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits; |
1063 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits; | 966 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits; |
1064 | 967 |
1065 /* Now create the pixmap and set up the image instance */ | 968 /* Now create the pixmap and set up the image instance */ |
1066 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, | 969 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, |
1067 bmp_data, bmp_bits, 1, instantiator, | 970 bmp_data, bmp_bits, instantiator, |
1068 0, 0, 0); | 971 0, 0, 0); |
1069 } | 972 } |
1070 | 973 |
1071 | 974 |
1072 /********************************************************************** | 975 /********************************************************************** |
1074 **********************************************************************/ | 977 **********************************************************************/ |
1075 | 978 |
1076 static void | 979 static void |
1077 mswindows_resource_validate (Lisp_Object instantiator) | 980 mswindows_resource_validate (Lisp_Object instantiator) |
1078 { | 981 { |
1079 if ((NILP (find_keyword_in_vector (instantiator, Q_file)) | 982 if ((NILP (find_keyword_in_vector (instantiator, Q_file)) |
1080 && | 983 && |
1081 NILP (find_keyword_in_vector (instantiator, Q_resource_id))) | 984 NILP (find_keyword_in_vector (instantiator, Q_resource_id))) |
1082 || | 985 || |
1083 NILP (find_keyword_in_vector (instantiator, Q_resource_type))) | 986 NILP (find_keyword_in_vector (instantiator, Q_resource_type))) |
1084 signal_simple_error ("Must supply :file, :resource-id and :resource-type", | 987 signal_simple_error ("Must supply :file, :resource-id and :resource-type", |
1085 instantiator); | 988 instantiator); |
1086 } | 989 } |
1093 struct gcpro gcpro1, gcpro2; | 996 struct gcpro gcpro1, gcpro2; |
1094 Lisp_Object alist = Qnil; | 997 Lisp_Object alist = Qnil; |
1095 | 998 |
1096 GCPRO2 (file, alist); | 999 GCPRO2 (file, alist); |
1097 | 1000 |
1098 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data, | 1001 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data, |
1099 console_type); | 1002 console_type); |
1100 | 1003 |
1101 if (CONSP (file)) /* failure locating filename */ | 1004 if (CONSP (file)) /* failure locating filename */ |
1102 signal_double_file_error ("Opening pixmap file", | 1005 signal_double_file_error ("Opening pixmap file", |
1103 "no such file or directory", | 1006 "no such file or directory", |
1124 mswindows_resource_possible_dest_types (void) | 1027 mswindows_resource_possible_dest_types (void) |
1125 { | 1028 { |
1126 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK; | 1029 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK; |
1127 } | 1030 } |
1128 | 1031 |
1129 typedef struct | 1032 typedef struct |
1130 { | 1033 { |
1131 char *name; | 1034 char *name; |
1132 int resource_id; | 1035 int resource_id; |
1133 } resource_t; | 1036 } resource_t; |
1134 | 1037 |
1138 #define OIC_HAND 32513 | 1041 #define OIC_HAND 32513 |
1139 #define OIC_QUES 32514 | 1042 #define OIC_QUES 32514 |
1140 #define OIC_BANG 32515 | 1043 #define OIC_BANG 32515 |
1141 #define OIC_NOTE 32516 | 1044 #define OIC_NOTE 32516 |
1142 #define OIC_WINLOGO 32517 | 1045 #define OIC_WINLOGO 32517 |
1143 #if defined (CYGWIN) && CYGWIN_VERSION_DLL_MAJOR < 21 | |
1144 #define LR_SHARED 0x8000 | 1046 #define LR_SHARED 0x8000 |
1145 #endif | 1047 #endif |
1146 #endif | 1048 |
1147 | 1049 static CONST resource_t bitmap_table[] = |
1148 static const resource_t bitmap_table[] = | |
1149 { | 1050 { |
1150 /* bitmaps */ | 1051 /* bitmaps */ |
1151 { "close", OBM_CLOSE }, | 1052 { "close", OBM_CLOSE }, |
1152 { "uparrow", OBM_UPARROW }, | 1053 { "uparrow", OBM_UPARROW }, |
1153 { "dnarrow", OBM_DNARROW }, | 1054 { "dnarrow", OBM_DNARROW }, |
1175 { "checkboxes", OBM_CHECKBOXES }, | 1076 { "checkboxes", OBM_CHECKBOXES }, |
1176 { "btncorners" , OBM_BTNCORNERS }, | 1077 { "btncorners" , OBM_BTNCORNERS }, |
1177 {0} | 1078 {0} |
1178 }; | 1079 }; |
1179 | 1080 |
1180 static const resource_t cursor_table[] = | 1081 static CONST resource_t cursor_table[] = |
1181 { | 1082 { |
1182 /* cursors */ | 1083 /* cursors */ |
1183 { "normal", OCR_NORMAL }, | 1084 { "normal", OCR_NORMAL }, |
1184 { "ibeam", OCR_IBEAM }, | 1085 { "ibeam", OCR_IBEAM }, |
1185 { "wait", OCR_WAIT }, | 1086 { "wait", OCR_WAIT }, |
1194 /* { "icour", OCR_ICOCUR }, */ | 1095 /* { "icour", OCR_ICOCUR }, */ |
1195 { "no", OCR_NO }, | 1096 { "no", OCR_NO }, |
1196 { 0 } | 1097 { 0 } |
1197 }; | 1098 }; |
1198 | 1099 |
1199 static const resource_t icon_table[] = | 1100 static CONST resource_t icon_table[] = |
1200 { | 1101 { |
1201 /* icons */ | 1102 /* icons */ |
1202 { "sample", OIC_SAMPLE }, | 1103 { "sample", OIC_SAMPLE }, |
1203 { "hand", OIC_HAND }, | 1104 { "hand", OIC_HAND }, |
1204 { "ques", OIC_QUES }, | 1105 { "ques", OIC_QUES }, |
1208 {0} | 1109 {0} |
1209 }; | 1110 }; |
1210 | 1111 |
1211 static int resource_name_to_resource (Lisp_Object name, int type) | 1112 static int resource_name_to_resource (Lisp_Object name, int type) |
1212 { | 1113 { |
1213 const resource_t* res = (type == IMAGE_CURSOR ? cursor_table | 1114 CONST resource_t* res = (type == IMAGE_CURSOR ? cursor_table |
1214 : type == IMAGE_ICON ? icon_table | 1115 : type == IMAGE_ICON ? icon_table |
1215 : bitmap_table); | 1116 : bitmap_table); |
1216 | 1117 |
1217 if (INTP (name)) | 1118 if (INTP (name)) |
1218 { | 1119 { |
1219 return XINT (name); | 1120 return XINT (name); |
1220 } | 1121 } |
1221 else if (!STRINGP (name)) | 1122 else if (!STRINGP (name)) |
1222 { | 1123 { |
1223 signal_simple_error ("invalid resource identifier", name); | 1124 signal_simple_error ("invalid resource identifier", name); |
1224 } | 1125 } |
1225 | 1126 |
1226 do { | 1127 do { |
1227 Extbyte* nm=0; | 1128 Extbyte* nm=0; |
1228 TO_EXTERNAL_FORMAT (LISP_STRING, name, | 1129 GET_C_STRING_OS_DATA_ALLOCA (name, nm); |
1229 C_STRING_ALLOCA, nm, | |
1230 Qnative); | |
1231 if (!strcasecmp ((char*)res->name, nm)) | 1130 if (!strcasecmp ((char*)res->name, nm)) |
1232 return res->resource_id; | 1131 return res->resource_id; |
1233 } while ((++res)->name); | 1132 } while ((++res)->name); |
1234 return 0; | 1133 return 0; |
1235 } | 1134 } |
1250 static void | 1149 static void |
1251 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1150 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1252 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1151 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1253 int dest_mask, Lisp_Object domain) | 1152 int dest_mask, Lisp_Object domain) |
1254 { | 1153 { |
1255 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1154 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1256 unsigned int type = 0; | 1155 unsigned int type = 0; |
1257 HANDLE himage = NULL; | 1156 HANDLE himage = NULL; |
1258 LPCTSTR resid=0; | 1157 LPCTSTR resid=0; |
1259 HINSTANCE hinst = NULL; | 1158 HINSTANCE hinst = NULL; |
1260 ICONINFO iconinfo; | 1159 ICONINFO iconinfo; |
1261 enum image_instance_type iitype; | 1160 int iitype=0; |
1262 char* fname=0; | 1161 char* fname=0; |
1263 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1162 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1264 | 1163 |
1265 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); | 1164 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file); |
1266 Lisp_Object resource_type = find_keyword_in_vector (instantiator, | 1165 Lisp_Object resource_type = find_keyword_in_vector (instantiator, |
1267 Q_resource_type); | 1166 Q_resource_type); |
1268 Lisp_Object resource_id = find_keyword_in_vector (instantiator, | 1167 Lisp_Object resource_id = find_keyword_in_vector (instantiator, |
1269 Q_resource_id); | 1168 Q_resource_id); |
1270 | 1169 |
1271 xzero (iconinfo); | 1170 xzero (iconinfo); |
1272 | 1171 |
1273 CHECK_MSGDI_DEVICE (device); | 1172 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) |
1173 signal_simple_error ("Not an mswindows device", device); | |
1274 | 1174 |
1275 type = resource_symbol_to_type (resource_type); | 1175 type = resource_symbol_to_type (resource_type); |
1276 | 1176 |
1277 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR) | 1177 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR) |
1278 iitype = IMAGE_POINTER; | 1178 iitype = IMAGE_POINTER; |
1279 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) | 1179 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK) |
1280 iitype = IMAGE_COLOR_PIXMAP; | 1180 iitype = IMAGE_COLOR_PIXMAP; |
1281 else | 1181 else |
1282 incompatible_image_types (instantiator, dest_mask, | 1182 incompatible_image_types (instantiator, dest_mask, |
1283 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); | 1183 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); |
1284 | 1184 |
1285 /* mess with the keyword info we were provided with */ | 1185 /* mess with the keyword info we were provided with */ |
1286 if (!NILP (file)) | 1186 if (!NILP (file)) |
1287 { | 1187 { |
1288 Extbyte* f=0; | 1188 Extbyte* f=0; |
1289 TO_EXTERNAL_FORMAT (LISP_STRING, file, | 1189 GET_C_STRING_FILENAME_DATA_ALLOCA (file, f); |
1290 C_STRING_ALLOCA, f, | 1190 #ifdef __CYGWIN32__ |
1291 Qfile_name); | |
1292 #ifdef CYGWIN | |
1293 CYGWIN_WIN32_PATH (f, fname); | 1191 CYGWIN_WIN32_PATH (f, fname); |
1294 #else | 1192 #else |
1295 fname = f; | 1193 fname = f; |
1296 #endif | 1194 #endif |
1297 | 1195 |
1298 if (NILP (resource_id)) | 1196 if (NILP (resource_id)) |
1299 resid = (LPCTSTR)fname; | 1197 resid = (LPCTSTR)fname; |
1300 else | 1198 else |
1301 { | 1199 { |
1302 hinst = LoadLibraryEx (fname, NULL, | 1200 hinst = LoadLibraryEx (fname, NULL, |
1303 LOAD_LIBRARY_AS_DATAFILE); | 1201 LOAD_LIBRARY_AS_DATAFILE); |
1304 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, | 1202 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, |
1305 type)); | 1203 type)); |
1306 | 1204 |
1307 if (!resid) | 1205 if (!resid) |
1308 TO_EXTERNAL_FORMAT (LISP_STRING, resource_id, | 1206 GET_C_STRING_OS_DATA_ALLOCA (resource_id, resid); |
1309 C_STRING_ALLOCA, resid, | |
1310 Qnative); | |
1311 } | 1207 } |
1312 } | 1208 } |
1313 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, | 1209 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, |
1314 type)))) | 1210 type)))) |
1315 signal_simple_error ("Invalid resource identifier", resource_id); | 1211 signal_simple_error ("Invalid resource identifier", resource_id); |
1316 | 1212 |
1317 /* load the image */ | 1213 /* load the image */ |
1318 if (!(himage = LoadImage (hinst, resid, type, 0, 0, | 1214 if (!(himage = LoadImage (hinst, resid, type, 0, 0, |
1319 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | | 1215 LR_CREATEDIBSECTION | LR_DEFAULTSIZE | |
1320 LR_SHARED | | 1216 LR_SHARED | |
1321 (!NILP (file) ? LR_LOADFROMFILE : 0)))) | 1217 (!NILP (file) ? LR_LOADFROMFILE : 0)))) |
1322 { | 1218 { |
1323 signal_simple_error ("Cannot load image", instantiator); | 1219 signal_simple_error ("Cannot load image", instantiator); |
1324 } | 1220 } |
1325 | 1221 |
1326 if (hinst) | 1222 if (hinst) |
1327 FreeLibrary (hinst); | 1223 FreeLibrary (hinst); |
1328 | 1224 |
1329 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype); | 1225 mswindows_initialize_dibitmap_image_instance (ii, iitype); |
1330 | 1226 |
1331 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file; | 1227 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file; |
1332 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = | 1228 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = |
1333 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON); | 1229 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON); |
1334 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = | 1230 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = |
1335 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON); | 1231 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON); |
1336 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; | 1232 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; |
1337 init_image_instance_geometry (ii); | |
1338 | 1233 |
1339 /* hey, we've got an icon type thing so we can reverse engineer the | 1234 /* hey, we've got an icon type thing so we can reverse engineer the |
1340 bitmap and mask */ | 1235 bitmap and mask */ |
1341 if (type != IMAGE_BITMAP) | 1236 if (type != IMAGE_BITMAP) |
1342 { | 1237 { |
1343 GetIconInfo ((HICON)himage, &iconinfo); | 1238 GetIconInfo (himage, &iconinfo); |
1344 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor; | 1239 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor; |
1345 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask; | 1240 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask; |
1346 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot); | 1241 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot); |
1347 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot); | 1242 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot); |
1348 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = (HICON) himage; | 1243 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = himage; |
1349 } | 1244 } |
1350 else | 1245 else |
1351 { | 1246 { |
1352 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL; | 1247 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL; |
1353 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = (HBITMAP) himage; | 1248 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = himage; |
1354 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; | 1249 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; |
1355 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); | 1250 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); |
1356 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); | 1251 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); |
1357 } | 1252 } |
1358 } | 1253 } |
1372 && | 1267 && |
1373 !resource_name_to_resource (data, IMAGE_ICON) | 1268 !resource_name_to_resource (data, IMAGE_ICON) |
1374 && | 1269 && |
1375 !resource_name_to_resource (data, IMAGE_BITMAP)) | 1270 !resource_name_to_resource (data, IMAGE_BITMAP)) |
1376 signal_simple_error ("invalid resource identifier", data); | 1271 signal_simple_error ("invalid resource identifier", data); |
1272 } | |
1273 | |
1274 void | |
1275 check_valid_string_or_int (Lisp_Object data) | |
1276 { | |
1277 if (!INTP (data)) | |
1278 CHECK_STRING (data); | |
1279 else | |
1280 CHECK_INT (data); | |
1377 } | 1281 } |
1378 | 1282 |
1379 /********************************************************************** | 1283 /********************************************************************** |
1380 * XBM * | 1284 * XBM * |
1381 **********************************************************************/ | 1285 **********************************************************************/ |
1418 * XmuReadBitmapData read data from FILE descriptor | 1322 * XmuReadBitmapData read data from FILE descriptor |
1419 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files | 1323 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files |
1420 * and return data | 1324 * and return data |
1421 * | 1325 * |
1422 * Note that this file and ../X/XRdBitF.c look very similar.... Keep them | 1326 * Note that this file and ../X/XRdBitF.c look very similar.... Keep them |
1423 * that way (but don't use common source code so that people can have one | 1327 * that way (but don't use common source code so that people can have one |
1424 * without the other). | 1328 * without the other). |
1425 */ | 1329 */ |
1426 | 1330 |
1427 | 1331 |
1428 /* | 1332 /* |
1442 | 1346 |
1443 /* | 1347 /* |
1444 * Table index for the hex values. Initialized once, first time. | 1348 * Table index for the hex values. Initialized once, first time. |
1445 * Used for translation value or delimiter significance lookup. | 1349 * Used for translation value or delimiter significance lookup. |
1446 */ | 1350 */ |
1447 static void | 1351 static void initHexTable() |
1448 initHexTable (void) | |
1449 { | 1352 { |
1450 /* | 1353 /* |
1451 * We build the table at run time for several reasons: | 1354 * We build the table at run time for several reasons: |
1452 * | 1355 * |
1453 * 1. portable to non-ASCII machines. | 1356 * 1. portable to non-ASCII machines. |
1469 | 1372 |
1470 /* delimiters of significance are flagged w/ negative value */ | 1373 /* delimiters of significance are flagged w/ negative value */ |
1471 hexTable[' '] = -1; hexTable[','] = -1; | 1374 hexTable[' '] = -1; hexTable[','] = -1; |
1472 hexTable['}'] = -1; hexTable['\n'] = -1; | 1375 hexTable['}'] = -1; hexTable['\n'] = -1; |
1473 hexTable['\t'] = -1; | 1376 hexTable['\t'] = -1; |
1474 | 1377 |
1475 initialized = TRUE; | 1378 initialized = TRUE; |
1476 } | 1379 } |
1477 | 1380 |
1478 /* | 1381 /* |
1479 * read next hex value in the input stream, return -1 if EOF | 1382 * read next hex value in the input stream, return -1 if EOF |
1480 */ | 1383 */ |
1481 static int | 1384 static int NextInt ( FILE *fstream ) |
1482 NextInt (FILE *fstream) | |
1483 { | 1385 { |
1484 int ch; | 1386 int ch; |
1485 int value = 0; | 1387 int value = 0; |
1486 int gotone = 0; | 1388 int gotone = 0; |
1487 int done = 0; | 1389 int done = 0; |
1488 | 1390 |
1489 /* loop, accumulate hex value until find delimiter */ | 1391 /* loop, accumulate hex value until find delimiter */ |
1490 /* skip any initial delimiters found in read stream */ | 1392 /* skip any initial delimiters found in read stream */ |
1491 | 1393 |
1492 while (!done) { | 1394 while (!done) { |
1493 ch = getc(fstream); | 1395 ch = getc(fstream); |
1512 * The data returned by the following routine is always in left-most byte | 1414 * The data returned by the following routine is always in left-most byte |
1513 * first and left-most bit first. If it doesn't return BitmapSuccess then | 1415 * first and left-most bit first. If it doesn't return BitmapSuccess then |
1514 * its arguments won't have been touched. This routine should look as much | 1416 * its arguments won't have been touched. This routine should look as much |
1515 * like the Xlib routine XReadBitmapfile as possible. | 1417 * like the Xlib routine XReadBitmapfile as possible. |
1516 */ | 1418 */ |
1517 int read_bitmap_data (FILE* fstream, unsigned int *width, | 1419 int read_bitmap_data (fstream, width, height, datap, x_hot, y_hot) |
1518 unsigned int *height, unsigned char **datap, | 1420 FILE *fstream; /* handle on file */ |
1519 int *x_hot, int *y_hot) | 1421 unsigned int *width, *height; /* RETURNED */ |
1422 unsigned char **datap; /* RETURNED */ | |
1423 int *x_hot, *y_hot; /* RETURNED */ | |
1520 { | 1424 { |
1521 unsigned char *data = NULL; /* working variable */ | 1425 unsigned char *data = NULL; /* working variable */ |
1522 char line[MAX_SIZE]; /* input line from file */ | 1426 char line[MAX_SIZE]; /* input line from file */ |
1523 int size; /* number of bytes of data */ | 1427 int size; /* number of bytes of data */ |
1524 char name_and_type[MAX_SIZE]; /* an input line */ | 1428 char name_and_type[MAX_SIZE]; /* an input line */ |
1562 if (!strcmp("y_hot", type)) | 1466 if (!strcmp("y_hot", type)) |
1563 hy = value; | 1467 hy = value; |
1564 } | 1468 } |
1565 continue; | 1469 continue; |
1566 } | 1470 } |
1567 | 1471 |
1568 if (sscanf(line, "static short %s = {", name_and_type) == 1) | 1472 if (sscanf(line, "static short %s = {", name_and_type) == 1) |
1569 version10p = 1; | 1473 version10p = 1; |
1570 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) | 1474 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) |
1571 version10p = 0; | 1475 version10p = 0; |
1572 else if (sscanf(line, "static char %s = {", name_and_type) == 1) | 1476 else if (sscanf(line, "static char %s = {", name_and_type) == 1) |
1579 else | 1483 else |
1580 type++; | 1484 type++; |
1581 | 1485 |
1582 if (strcmp("bits[]", type)) | 1486 if (strcmp("bits[]", type)) |
1583 continue; | 1487 continue; |
1584 | 1488 |
1585 if (!ww || !hh) | 1489 if (!ww || !hh) |
1586 RETURN (BitmapFileInvalid); | 1490 RETURN (BitmapFileInvalid); |
1587 | 1491 |
1588 if ((ww % 16) && ((ww % 16) < 9) && version10p) | 1492 if ((ww % 16) && ((ww % 16) < 9) && version10p) |
1589 padding = 1; | 1493 padding = 1; |
1592 | 1496 |
1593 bytes_per_line = (ww+7)/8 + padding; | 1497 bytes_per_line = (ww+7)/8 + padding; |
1594 | 1498 |
1595 size = bytes_per_line * hh; | 1499 size = bytes_per_line * hh; |
1596 data = (unsigned char *) Xmalloc ((unsigned int) size); | 1500 data = (unsigned char *) Xmalloc ((unsigned int) size); |
1597 if (!data) | 1501 if (!data) |
1598 RETURN (BitmapNoMemory); | 1502 RETURN (BitmapNoMemory); |
1599 | 1503 |
1600 if (version10p) { | 1504 if (version10p) { |
1601 unsigned char *ptr; | 1505 unsigned char *ptr; |
1602 int bytes; | 1506 int bytes; |
1611 } else { | 1515 } else { |
1612 unsigned char *ptr; | 1516 unsigned char *ptr; |
1613 int bytes; | 1517 int bytes; |
1614 | 1518 |
1615 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) { | 1519 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) { |
1616 if ((value = NextInt(fstream)) < 0) | 1520 if ((value = NextInt(fstream)) < 0) |
1617 RETURN (BitmapFileInvalid); | 1521 RETURN (BitmapFileInvalid); |
1618 *ptr=value; | 1522 *ptr=value; |
1619 } | 1523 } |
1620 } | 1524 } |
1621 break; | 1525 break; |
1634 | 1538 |
1635 RETURN (BitmapSuccess); | 1539 RETURN (BitmapSuccess); |
1636 } | 1540 } |
1637 | 1541 |
1638 | 1542 |
1639 int read_bitmap_data_from_file (const char *filename, unsigned int *width, | 1543 int read_bitmap_data_from_file (CONST char *filename, unsigned int *width, |
1640 unsigned int *height, unsigned char **datap, | 1544 unsigned int *height, unsigned char **datap, |
1641 int *x_hot, int *y_hot) | 1545 int *x_hot, int *y_hot) |
1642 { | 1546 { |
1643 FILE *fstream; | 1547 FILE *fstream; |
1644 int status; | 1548 int status; |
1663 from left to right, little-endian within a byte. 0 = white, 1 = | 1567 from left to right, little-endian within a byte. 0 = white, 1 = |
1664 black. It must be converted to the following format: Widths are | 1568 black. It must be converted to the following format: Widths are |
1665 padded to a multiple of 16. Scan lines are stored in increasing | 1569 padded to a multiple of 16. Scan lines are stored in increasing |
1666 byte order from left to right, big-endian within a byte. 0 = | 1570 byte order from left to right, big-endian within a byte. 0 = |
1667 black, 1 = white. */ | 1571 black, 1 = white. */ |
1668 static HBITMAP | 1572 HBITMAP |
1669 xbm_create_bitmap_from_data (HDC hdc, char *data, | 1573 xbm_create_bitmap_from_data (HDC hdc, char *data, |
1670 unsigned int width, unsigned int height, | 1574 unsigned int width, unsigned int height, |
1671 int mask, COLORREF fg, COLORREF bg) | 1575 int mask, COLORREF fg, COLORREF bg) |
1672 { | 1576 { |
1673 int old_width = (width + 7)/8; | 1577 int old_width = (width + 7)/8; |
1674 int new_width = BPLINE (2*((width + 15)/16)); | 1578 int new_width = BPLINE (2*((width + 15)/16)); |
1675 unsigned char *offset; | 1579 unsigned char *offset; |
1676 void *bmp_buf = 0; | 1580 void *bmp_buf = 0; |
1677 unsigned char *new_data, *new_offset; | 1581 unsigned char *new_data, *new_offset; |
1678 int i, j; | 1582 int i, j; |
1679 BITMAPINFO *bmp_info = | 1583 BITMAPINFO* bmp_info = |
1680 (BITMAPINFO*) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); | 1584 xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD)); |
1681 HBITMAP bitmap; | 1585 HBITMAP bitmap; |
1682 | 1586 |
1683 if (!bmp_info) | 1587 if (!bmp_info) |
1684 return NULL; | 1588 return NULL; |
1685 | 1589 |
1686 new_data = (unsigned char *) xmalloc_and_zero (height * new_width); | 1590 new_data = (unsigned char *) xmalloc_and_zero (height * new_width); |
1687 | 1591 |
1688 if (!new_data) | 1592 if (!new_data) |
1689 { | 1593 { |
1690 xfree (bmp_info); | 1594 xfree (bmp_info); |
1691 return NULL; | 1595 return NULL; |
1692 } | 1596 } |
1693 | 1597 |
1694 for (i=0; i<height; i++) | 1598 for (i=0; i<height; i++) |
1695 { | 1599 { |
1696 offset = data + i*old_width; | 1600 offset = data + i*old_width; |
1697 new_offset = new_data + i*new_width; | 1601 new_offset = new_data + i*new_width; |
1698 | 1602 |
1716 | 1620 |
1717 bmp_info->bmiHeader.biWidth=width; | 1621 bmp_info->bmiHeader.biWidth=width; |
1718 bmp_info->bmiHeader.biHeight=-(LONG)height; | 1622 bmp_info->bmiHeader.biHeight=-(LONG)height; |
1719 bmp_info->bmiHeader.biPlanes=1; | 1623 bmp_info->bmiHeader.biPlanes=1; |
1720 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); | 1624 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER); |
1721 bmp_info->bmiHeader.biBitCount=1; | 1625 bmp_info->bmiHeader.biBitCount=1; |
1722 bmp_info->bmiHeader.biCompression=BI_RGB; | 1626 bmp_info->bmiHeader.biCompression=BI_RGB; |
1723 bmp_info->bmiHeader.biClrUsed = 2; | 1627 bmp_info->bmiHeader.biClrUsed = 2; |
1724 bmp_info->bmiHeader.biClrImportant = 2; | 1628 bmp_info->bmiHeader.biClrImportant = 2; |
1725 bmp_info->bmiHeader.biSizeImage = height * new_width; | 1629 bmp_info->bmiHeader.biSizeImage = height * new_width; |
1726 bmp_info->bmiColors[0].rgbRed = GetRValue (fg); | 1630 bmp_info->bmiColors[0].rgbRed = GetRValue (fg); |
1727 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg); | 1631 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg); |
1728 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg); | 1632 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg); |
1729 bmp_info->bmiColors[0].rgbReserved = 0; | 1633 bmp_info->bmiColors[0].rgbReserved = 0; |
1730 bmp_info->bmiColors[1].rgbRed = GetRValue (bg); | 1634 bmp_info->bmiColors[1].rgbRed = GetRValue (bg); |
1731 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg); | 1635 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg); |
1732 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg); | 1636 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg); |
1733 bmp_info->bmiColors[1].rgbReserved = 0; | 1637 bmp_info->bmiColors[1].rgbReserved = 0; |
1734 | 1638 |
1735 bitmap = CreateDIBSection (hdc, | 1639 bitmap = CreateDIBSection (hdc, |
1736 bmp_info, | 1640 bmp_info, |
1737 DIB_RGB_COLORS, | 1641 DIB_RGB_COLORS, |
1738 &bmp_buf, | 1642 &bmp_buf, |
1739 0,0); | 1643 0,0); |
1740 | 1644 |
1741 xfree (bmp_info); | 1645 xfree (bmp_info); |
1742 | 1646 |
1743 if (!bitmap || !bmp_buf) | 1647 if (!bitmap || !bmp_buf) |
1744 { | 1648 { |
1745 xfree (new_data); | 1649 xfree (new_data); |
1746 return NULL; | 1650 return NULL; |
1747 } | 1651 } |
1748 | 1652 |
1749 /* copy in the actual bitmap */ | 1653 /* copy in the actual bitmap */ |
1750 memcpy (bmp_buf, new_data, height * new_width); | 1654 memcpy (bmp_buf, new_data, height * new_width); |
1751 xfree (new_data); | 1655 xfree (new_data); |
1752 | 1656 |
1753 return bitmap; | 1657 return bitmap; |
1755 | 1659 |
1756 /* Given inline data for a mono pixmap, initialize the given | 1660 /* Given inline data for a mono pixmap, initialize the given |
1757 image instance accordingly. */ | 1661 image instance accordingly. */ |
1758 | 1662 |
1759 static void | 1663 static void |
1760 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii, | 1664 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii, |
1761 int width, int height, | 1665 int width, int height, |
1762 /* Note that data is in ext-format! */ | 1666 /* Note that data is in ext-format! */ |
1763 const char *bits, | 1667 CONST char *bits, |
1764 Lisp_Object instantiator, | 1668 Lisp_Object instantiator, |
1765 Lisp_Object pointer_fg, | 1669 Lisp_Object pointer_fg, |
1766 Lisp_Object pointer_bg, | 1670 Lisp_Object pointer_bg, |
1767 int dest_mask, | 1671 int dest_mask, |
1768 HBITMAP mask, | 1672 HBITMAP mask, |
1769 Lisp_Object mask_filename) | 1673 Lisp_Object mask_filename) |
1770 { | 1674 { |
1771 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1675 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1676 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME (XDEVICE (device))); | |
1772 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground); | 1677 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground); |
1773 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background); | 1678 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background); |
1774 enum image_instance_type type; | 1679 enum image_instance_type type; |
1775 COLORREF black = PALETTERGB (0,0,0); | 1680 COLORREF black = PALETTERGB (0,0,0); |
1776 COLORREF white = PALETTERGB (255,255,255); | 1681 COLORREF white = PALETTERGB (255,255,255); |
1777 HDC hdc; | 1682 |
1778 | 1683 HDC hdc = FRAME_MSWINDOWS_CDC (f); |
1779 CHECK_MSGDI_DEVICE (device); | 1684 |
1780 | 1685 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) |
1781 hdc = get_device_compdc (XDEVICE (device)); | 1686 signal_simple_error ("Not an MS-Windows device", device); |
1782 | 1687 |
1783 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) && | 1688 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) && |
1784 (dest_mask & IMAGE_COLOR_PIXMAP_MASK)) | 1689 (dest_mask & IMAGE_COLOR_PIXMAP_MASK)) |
1785 { | 1690 { |
1786 if (!NILP (foreground) || !NILP (background)) | 1691 if (!NILP (foreground) || !NILP (background)) |
1797 else | 1702 else |
1798 incompatible_image_types (instantiator, dest_mask, | 1703 incompatible_image_types (instantiator, dest_mask, |
1799 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK | 1704 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK |
1800 | IMAGE_POINTER_MASK); | 1705 | IMAGE_POINTER_MASK); |
1801 | 1706 |
1802 mswindows_initialize_dibitmap_image_instance (ii, 1, type); | 1707 mswindows_initialize_dibitmap_image_instance (ii, type); |
1803 | 1708 |
1804 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = | 1709 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = |
1805 find_keyword_in_vector (instantiator, Q_file); | 1710 find_keyword_in_vector (instantiator, Q_file); |
1806 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_WIDTH (ii) = width; | 1711 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width; |
1807 IMAGE_INSTANCE_MSWINDOWS_BITMAP_REAL_HEIGHT (ii) = height; | 1712 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height; |
1808 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; | 1713 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; |
1809 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); | 1714 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0); |
1810 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); | 1715 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0); |
1811 init_image_instance_geometry (ii); | |
1812 | |
1813 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask : | 1716 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask : |
1814 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, | 1717 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, |
1815 TRUE, black, white); | 1718 TRUE, black, white); |
1816 | 1719 |
1817 switch (type) | 1720 switch (type) |
1818 { | 1721 { |
1819 case IMAGE_MONO_PIXMAP: | 1722 case IMAGE_MONO_PIXMAP: |
1820 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = | 1723 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = |
1821 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, | 1724 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, |
1822 FALSE, black, black); | 1725 FALSE, black, black); |
1823 break; | 1726 break; |
1824 | 1727 |
1825 case IMAGE_COLOR_PIXMAP: | 1728 case IMAGE_COLOR_PIXMAP: |
1826 { | 1729 { |
1844 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background)); | 1747 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background)); |
1845 | 1748 |
1846 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; | 1749 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; |
1847 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; | 1750 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; |
1848 | 1751 |
1849 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = | 1752 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = |
1850 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, | 1753 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, |
1851 FALSE, fg, black); | 1754 FALSE, fg, black); |
1852 } | 1755 } |
1853 break; | 1756 break; |
1854 | 1757 |
1855 case IMAGE_POINTER: | 1758 case IMAGE_POINTER: |
1860 if (NILP (foreground)) | 1763 if (NILP (foreground)) |
1861 foreground = pointer_fg; | 1764 foreground = pointer_fg; |
1862 if (NILP (background)) | 1765 if (NILP (background)) |
1863 background = pointer_bg; | 1766 background = pointer_bg; |
1864 | 1767 |
1865 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = | 1768 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = |
1866 find_keyword_in_vector (instantiator, Q_hotspot_x); | 1769 find_keyword_in_vector (instantiator, Q_hotspot_x); |
1867 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = | 1770 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = |
1868 find_keyword_in_vector (instantiator, Q_hotspot_y); | 1771 find_keyword_in_vector (instantiator, Q_hotspot_y); |
1869 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; | 1772 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground; |
1870 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; | 1773 IMAGE_INSTANCE_PIXMAP_BG (ii) = background; |
1871 if (COLOR_INSTANCEP (foreground)) | 1774 if (COLOR_INSTANCEP (foreground)) |
1872 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground)); | 1775 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground)); |
1873 if (COLOR_INSTANCEP (background)) | 1776 if (COLOR_INSTANCEP (background)) |
1874 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background)); | 1777 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background)); |
1875 | 1778 |
1876 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = | 1779 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = |
1877 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, | 1780 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height, |
1878 TRUE, fg, black); | 1781 TRUE, fg, black); |
1879 mswindows_initialize_image_instance_icon (ii, TRUE); | 1782 mswindows_initialize_image_instance_icon (ii, TRUE); |
1880 } | 1783 } |
1881 break; | 1784 break; |
1882 | 1785 |
1888 static void | 1791 static void |
1889 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, | 1792 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator, |
1890 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1793 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1891 int dest_mask, int width, int height, | 1794 int dest_mask, int width, int height, |
1892 /* Note that data is in ext-format! */ | 1795 /* Note that data is in ext-format! */ |
1893 const char *bits) | 1796 CONST char *bits) |
1894 { | 1797 { |
1895 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); | 1798 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); |
1896 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); | 1799 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); |
1897 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1800 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1898 HDC hdc = get_device_compdc (XDEVICE (IMAGE_INSTANCE_DEVICE (ii))); | 1801 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME |
1802 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii)))); | |
1803 HDC hdc = FRAME_MSWINDOWS_CDC (f); | |
1899 HBITMAP mask = 0; | 1804 HBITMAP mask = 0; |
1805 CONST char *gcc_may_you_rot_in_hell; | |
1900 | 1806 |
1901 if (!NILP (mask_data)) | 1807 if (!NILP (mask_data)) |
1902 { | 1808 { |
1903 const char *ext_data; | 1809 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (mask_data))), |
1904 | 1810 gcc_may_you_rot_in_hell); |
1905 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))), | 1811 mask = |
1906 C_STRING_ALLOCA, ext_data, | 1812 xbm_create_bitmap_from_data ( hdc, |
1907 Qbinary); | 1813 (unsigned char *) |
1908 mask = xbm_create_bitmap_from_data (hdc, | 1814 gcc_may_you_rot_in_hell, |
1909 (unsigned char *) ext_data, | 1815 XINT (XCAR (mask_data)), |
1910 XINT (XCAR (mask_data)), | 1816 XINT (XCAR (XCDR (mask_data))), FALSE, |
1911 XINT (XCAR (XCDR (mask_data))), | 1817 PALETTERGB (0,0,0), |
1912 FALSE, | 1818 PALETTERGB (255,255,255)); |
1913 PALETTERGB (0,0,0), | |
1914 PALETTERGB (255,255,255)); | |
1915 } | 1819 } |
1916 | 1820 |
1917 init_image_instance_from_xbm_inline (ii, width, height, bits, | 1821 init_image_instance_from_xbm_inline (ii, width, height, bits, |
1918 instantiator, pointer_fg, pointer_bg, | 1822 instantiator, pointer_fg, pointer_bg, |
1919 dest_mask, mask, mask_file); | 1823 dest_mask, mask, mask_file); |
1920 } | 1824 } |
1921 | 1825 |
1922 /* Instantiate method for XBM's. */ | 1826 /* Instantiate method for XBM's. */ |
1923 | 1827 |
1924 static void | 1828 static void |
1925 mswindows_xbm_instantiate (Lisp_Object image_instance, | 1829 mswindows_xbm_instantiate (Lisp_Object image_instance, |
1926 Lisp_Object instantiator, | 1830 Lisp_Object instantiator, |
1927 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1831 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1928 int dest_mask, Lisp_Object domain) | 1832 int dest_mask, Lisp_Object domain) |
1929 { | 1833 { |
1930 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1834 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1931 const char *ext_data; | 1835 CONST char *gcc_go_home; |
1932 | 1836 |
1933 assert (!NILP (data)); | 1837 assert (!NILP (data)); |
1934 | 1838 |
1935 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))), | 1839 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (data))), |
1936 C_STRING_ALLOCA, ext_data, | 1840 gcc_go_home); |
1937 Qbinary); | |
1938 | 1841 |
1939 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, | 1842 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, |
1940 pointer_bg, dest_mask, XINT (XCAR (data)), | 1843 pointer_bg, dest_mask, XINT (XCAR (data)), |
1941 XINT (XCAR (XCDR (data))), ext_data); | 1844 XINT (XCAR (XCDR (data))), gcc_go_home); |
1942 } | 1845 } |
1943 | 1846 |
1944 #ifdef HAVE_XFACE | 1847 #ifdef HAVE_XFACE |
1945 /********************************************************************** | 1848 /********************************************************************** |
1946 * X-Face * | 1849 * X-Face * |
1971 int dest_mask, Lisp_Object domain) | 1874 int dest_mask, Lisp_Object domain) |
1972 { | 1875 { |
1973 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1876 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1974 int i, stattis; | 1877 int i, stattis; |
1975 char *p, *bits, *bp; | 1878 char *p, *bits, *bp; |
1976 const char * volatile emsg = 0; | 1879 CONST char * volatile emsg = 0; |
1977 const char * volatile dstring; | 1880 CONST char * volatile dstring; |
1978 | 1881 |
1979 assert (!NILP (data)); | 1882 assert (!NILP (data)); |
1980 | 1883 |
1981 TO_EXTERNAL_FORMAT (LISP_STRING, data, | 1884 GET_C_STRING_BINARY_DATA_ALLOCA (data, dstring); |
1982 C_STRING_ALLOCA, dstring, | |
1983 Qbinary); | |
1984 | 1885 |
1985 if ((p = strchr (dstring, ':'))) | 1886 if ((p = strchr (dstring, ':'))) |
1986 { | 1887 { |
1987 dstring = p + 1; | 1888 dstring = p + 1; |
1988 } | 1889 } |
2034 /************************************************************************/ | 1935 /************************************************************************/ |
2035 /* image instance methods */ | 1936 /* image instance methods */ |
2036 /************************************************************************/ | 1937 /************************************************************************/ |
2037 | 1938 |
2038 static void | 1939 static void |
2039 mswindows_print_image_instance (Lisp_Image_Instance *p, | 1940 mswindows_print_image_instance (struct Lisp_Image_Instance *p, |
2040 Lisp_Object printcharfun, | 1941 Lisp_Object printcharfun, |
2041 int escapeflag) | 1942 int escapeflag) |
2042 { | 1943 { |
2043 char buf[100]; | 1944 char buf[100]; |
2044 | 1945 |
2045 switch (IMAGE_INSTANCE_TYPE (p)) | 1946 switch (IMAGE_INSTANCE_TYPE (p)) |
2046 { | 1947 { |
2047 case IMAGE_MONO_PIXMAP: | 1948 case IMAGE_MONO_PIXMAP: |
2048 case IMAGE_COLOR_PIXMAP: | 1949 case IMAGE_COLOR_PIXMAP: |
2049 case IMAGE_POINTER: | 1950 case IMAGE_POINTER: |
2050 sprintf (buf, " (0x%lx", | 1951 sprintf (buf, " (0x%lx", |
2051 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); | 1952 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); |
2052 write_c_string (buf, printcharfun); | 1953 write_c_string (buf, printcharfun); |
2053 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) | 1954 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) |
2054 { | 1955 { |
2055 sprintf (buf, "/0x%lx", | 1956 sprintf (buf, "/0x%lx", |
2056 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p)); | 1957 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p)); |
2057 write_c_string (buf, printcharfun); | 1958 write_c_string (buf, printcharfun); |
2058 } | 1959 } |
2059 write_c_string (")", printcharfun); | 1960 write_c_string (")", printcharfun); |
2060 break; | 1961 break; |
2062 default: | 1963 default: |
2063 break; | 1964 break; |
2064 } | 1965 } |
2065 } | 1966 } |
2066 | 1967 |
2067 #ifdef DEBUG_WIDGETS | 1968 static void |
2068 extern int debug_widget_instances; | 1969 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p) |
2069 #endif | 1970 { |
2070 | 1971 if (DEVICE_LIVE_P (XDEVICE (p->device))) |
2071 static void | 1972 { |
2072 mswindows_finalize_image_instance (Lisp_Image_Instance *p) | 1973 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET |
2073 { | 1974 || |
2074 if (!p->data) | 1975 IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW) |
2075 return; | |
2076 | |
2077 if (DEVICE_LIVE_P (XDEVICE (IMAGE_INSTANCE_DEVICE (p)))) | |
2078 { | |
2079 if (image_instance_type_to_mask (IMAGE_INSTANCE_TYPE (p)) | |
2080 & (IMAGE_WIDGET_MASK | IMAGE_SUBWINDOW_MASK)) | |
2081 { | 1976 { |
2082 #ifdef DEBUG_WIDGETS | |
2083 debug_widget_instances--; | |
2084 stderr_out ("widget destroyed, %d left\n", debug_widget_instances); | |
2085 #endif | |
2086 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) | 1977 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) |
2087 { | 1978 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)); |
2088 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)); | 1979 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0; |
2089 DestroyWindow (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p)); | |
2090 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0; | |
2091 } | |
2092 } | 1980 } |
2093 else if (p->data) | 1981 else if (p->data) |
2094 { | 1982 { |
2095 int i; | 1983 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)) |
2096 if (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p)) | 1984 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); |
2097 disable_glyph_animated_timeout (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p)); | 1985 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0; |
2098 | |
2099 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p)) | |
2100 { | |
2101 for (i = 0; i < IMAGE_INSTANCE_PIXMAP_MAXSLICE (p); i++) | |
2102 { | |
2103 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i)) | |
2104 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i)); | |
2105 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i) = 0; | |
2106 } | |
2107 xfree (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p)); | |
2108 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p) = 0; | |
2109 } | |
2110 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) | 1986 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) |
2111 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p)); | 1987 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p)); |
2112 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0; | 1988 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0; |
2113 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p)) | 1989 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p)) |
2114 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p)); | 1990 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p)); |
2125 | 2001 |
2126 /************************************************************************/ | 2002 /************************************************************************/ |
2127 /* subwindow and widget support */ | 2003 /* subwindow and widget support */ |
2128 /************************************************************************/ | 2004 /************************************************************************/ |
2129 | 2005 |
2130 static HFONT | |
2131 mswindows_widget_hfont (Lisp_Image_Instance *p, | |
2132 Lisp_Object domain) | |
2133 { | |
2134 Lisp_Object face = IMAGE_INSTANCE_WIDGET_FACE (p); | |
2135 int under = FACE_UNDERLINE_P (face, domain); | |
2136 int strike = FACE_STRIKETHRU_P (face, domain); | |
2137 Lisp_Object font = query_string_font (IMAGE_INSTANCE_WIDGET_TEXT (p), | |
2138 face, domain); | |
2139 | |
2140 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike); | |
2141 } | |
2142 | |
2143 static HDWP | |
2144 begin_defer_window_pos (struct frame *f) | |
2145 { | |
2146 if (FRAME_MSWINDOWS_DATA (f)->hdwp == 0) | |
2147 FRAME_MSWINDOWS_DATA (f)->hdwp = BeginDeferWindowPos (10); | |
2148 return FRAME_MSWINDOWS_DATA (f)->hdwp; | |
2149 } | |
2150 | |
2151 /* unmap the image if it is a widget. This is used by redisplay via | 2006 /* unmap the image if it is a widget. This is used by redisplay via |
2152 redisplay_unmap_subwindows */ | 2007 redisplay_unmap_subwindows */ |
2153 static void | 2008 static void |
2154 mswindows_unmap_subwindow (Lisp_Image_Instance *p) | 2009 mswindows_unmap_subwindow (struct Lisp_Image_Instance *p) |
2155 { | 2010 { |
2156 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) | 2011 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) |
2157 { | 2012 { |
2158 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p)); | 2013 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2159 HDWP hdwp = begin_defer_window_pos (f); | 2014 NULL, |
2160 HDWP new_hdwp; | 2015 0, 0, 0, 0, |
2161 new_hdwp = DeferWindowPos (hdwp, IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | 2016 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE |
2162 NULL, | 2017 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); |
2163 0, 0, 0, 0, | |
2164 SWP_HIDEWINDOW | SWP_NOACTIVATE | | |
2165 SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | |
2166 /* Setting this flag causes the call to | |
2167 DeferWindowPos to fail with | |
2168 "Invalid parameter". I don't understand | |
2169 why we bother to try and set this | |
2170 anyway. -- ben */ | |
2171 /* | SWP_NOSENDCHANGING */ | |
2172 ); | |
2173 if (!new_hdwp) | |
2174 mswindows_output_last_error ("unmapping"); | |
2175 else | |
2176 hdwp = new_hdwp; | |
2177 FRAME_MSWINDOWS_DATA (f)->hdwp = hdwp; | |
2178 if (GetFocus() == WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)) | |
2179 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p))); | |
2180 } | 2018 } |
2181 } | 2019 } |
2182 | 2020 |
2183 /* map the subwindow. This is used by redisplay via | 2021 /* map the subwindow. This is used by redisplay via |
2184 redisplay_output_subwindow */ | 2022 redisplay_output_subwindow */ |
2185 static void | 2023 static void |
2186 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y, | 2024 mswindows_map_subwindow (struct Lisp_Image_Instance *p, int x, int y) |
2187 struct display_glyph_area* dga) | 2025 { |
2188 { | 2026 /* ShowWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), SW_SHOW);*/ |
2189 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p)); | 2027 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2190 HDWP hdwp = begin_defer_window_pos (f); | 2028 NULL, |
2191 HDWP new_hdwp; | 2029 x, y, 0, 0, |
2192 /* move the window before mapping it ... */ | 2030 SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOSIZE |
2193 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | |
2194 NULL, | |
2195 x, y, dga->width, dga->height, | |
2196 SWP_NOZORDER | |
2197 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); | 2031 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); |
2198 /* ... adjust the child ... */ | |
2199 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | |
2200 NULL, | |
2201 -dga->xoffset, -dga->yoffset, 0, 0, | |
2202 SWP_NOZORDER | SWP_NOSIZE | |
2203 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); | |
2204 /* ... now map it - we are not allowed to move it at the same time. */ | |
2205 new_hdwp = DeferWindowPos (hdwp, IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | |
2206 NULL, | |
2207 0, 0, 0, 0, | |
2208 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE | |
2209 | SWP_SHOWWINDOW | |
2210 /* | SWP_NOCOPYBITS */ | |
2211 /* Setting this flag causes the call to | |
2212 DeferWindowPos to fail with | |
2213 "Invalid parameter". I don't understand | |
2214 why we bother to try and set this | |
2215 anyway. -- ben */ | |
2216 /* | SWP_NOSENDCHANGING */ | |
2217 | SWP_NOACTIVATE); | |
2218 if (!new_hdwp) | |
2219 mswindows_output_last_error ("mapping"); | |
2220 else | |
2221 hdwp = new_hdwp; | |
2222 FRAME_MSWINDOWS_DATA (f)->hdwp = hdwp; | |
2223 } | |
2224 | |
2225 /* resize the subwindow instance */ | |
2226 static void | |
2227 mswindows_resize_subwindow (Lisp_Image_Instance* ii, int w, int h) | |
2228 { | |
2229 /* Set the size of the control .... */ | |
2230 if (!SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
2231 NULL, | |
2232 0, 0, w, h, | |
2233 SWP_NOZORDER | SWP_NOMOVE | |
2234 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING)) | |
2235 mswindows_output_last_error ("resizing"); | |
2236 } | |
2237 | |
2238 /* Simply resize the window here. */ | |
2239 static void | |
2240 mswindows_update_subwindow (Lisp_Image_Instance *p) | |
2241 { | |
2242 mswindows_resize_subwindow (p, | |
2243 IMAGE_INSTANCE_WIDTH (p), | |
2244 IMAGE_INSTANCE_HEIGHT (p)); | |
2245 } | 2032 } |
2246 | 2033 |
2247 /* when you click on a widget you may activate another widget this | 2034 /* when you click on a widget you may activate another widget this |
2248 needs to be checked and all appropriate widgets updated */ | 2035 needs to be checked and all appropriate widgets updated */ |
2249 static void | 2036 static void |
2250 mswindows_update_widget (Lisp_Image_Instance *p) | 2037 mswindows_update_subwindow (struct Lisp_Image_Instance *p) |
2251 { | 2038 { |
2252 /* Possibly update the face font and colors. */ | 2039 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) |
2253 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (p)) | 2040 { |
2254 && (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p) | 2041 /* buttons checked or otherwise */ |
2255 || XFRAME (IMAGE_INSTANCE_FRAME (p))->faces_changed | 2042 if ( EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qbutton)) |
2256 || IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))) | 2043 { |
2257 { | 2044 if (gui_item_selected_p (&IMAGE_INSTANCE_WIDGET_ITEM (p))) |
2258 /* set the widget font from the widget face */ | 2045 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2259 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | 2046 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); |
2260 WM_SETFONT, | 2047 else |
2261 (WPARAM) mswindows_widget_hfont | 2048 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2262 (p, IMAGE_INSTANCE_FRAME (p)), | 2049 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); |
2263 MAKELPARAM (TRUE, 0)); | 2050 } |
2264 } | |
2265 /* Possibly update the dimensions. */ | |
2266 if (IMAGE_INSTANCE_SIZE_CHANGED (p)) | |
2267 { | |
2268 mswindows_resize_subwindow (p, | |
2269 IMAGE_INSTANCE_WIDTH (p), | |
2270 IMAGE_INSTANCE_HEIGHT (p)); | |
2271 } | |
2272 /* Possibly update the text in the widget. */ | |
2273 if (IMAGE_INSTANCE_TEXT_CHANGED (p) | |
2274 && !NILP (IMAGE_INSTANCE_WIDGET_TEXT (p))) | |
2275 { | |
2276 Extbyte* lparam=0; | |
2277 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (p), | |
2278 C_STRING_ALLOCA, lparam, | |
2279 Qnative); | |
2280 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | |
2281 WM_SETTEXT, 0, (LPARAM)lparam); | |
2282 } | 2051 } |
2283 } | 2052 } |
2284 | 2053 |
2285 /* register widgets into our hastable so that we can cope with the | 2054 /* register widgets into our hastable so that we can cope with the |
2286 callbacks. The hashtable is weak so deregistration is handled | 2055 callbacks. The hashtable is weak so deregistration is handled |
2287 automatically */ | 2056 automatically */ |
2288 static int | 2057 static int |
2289 mswindows_register_gui_item (Lisp_Object image_instance, | 2058 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain) |
2290 Lisp_Object gui, Lisp_Object domain) | 2059 { |
2291 { | 2060 Lisp_Object frame = FW_FRAME (domain); |
2292 Lisp_Object frame = DOMAIN_FRAME (domain); | |
2293 struct frame* f = XFRAME (frame); | 2061 struct frame* f = XFRAME (frame); |
2294 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), | 2062 int id = gui_item_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f), |
2295 gui, | 2063 &XIMAGE_INSTANCE_WIDGET_ITEM (instance), |
2296 WIDGET_GLYPH_SLOT); | 2064 WIDGET_GLYPH_SLOT); |
2297 Fputhash (make_int (id), image_instance, | 2065 Fputhash (make_int (id), |
2298 FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f)); | 2066 XIMAGE_INSTANCE_WIDGET_CALLBACK (instance), |
2299 Fputhash (make_int (id), XGUI_ITEM (gui)->callback, | 2067 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f)); |
2300 FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f)); | |
2301 Fputhash (make_int (id), XGUI_ITEM (gui)->callback_ex, | |
2302 FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f)); | |
2303 return id; | 2068 return id; |
2304 } | |
2305 | |
2306 static int | |
2307 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain) | |
2308 { | |
2309 return mswindows_register_gui_item (instance, | |
2310 XIMAGE_INSTANCE_WIDGET_ITEM (instance), | |
2311 domain); | |
2312 } | 2069 } |
2313 | 2070 |
2314 static void | 2071 static void |
2315 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2072 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2316 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2073 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2317 int dest_mask, Lisp_Object domain) | 2074 int dest_mask, Lisp_Object domain) |
2318 { | 2075 { |
2319 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2076 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2320 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 2077 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
2321 Lisp_Object frame = DOMAIN_FRAME (domain); | 2078 struct device* d = XDEVICE (device); |
2079 Lisp_Object frame = FW_FRAME (domain); | |
2322 HWND wnd; | 2080 HWND wnd; |
2323 | 2081 |
2324 CHECK_MSWINDOWS_DEVICE (device); | 2082 if (!DEVICE_MSWINDOWS_P (d)) |
2083 signal_simple_error ("Not an mswindows device", device); | |
2325 | 2084 |
2326 /* have to set the type this late in case there is no device | 2085 /* have to set the type this late in case there is no device |
2327 instantiation for a widget */ | 2086 instantiation for a widget */ |
2328 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; | 2087 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; |
2329 /* Allocate space for the clip window */ | 2088 |
2330 ii->data = xnew_and_zero (struct mswindows_subwindow_data); | 2089 wnd = CreateWindow( "STATIC", |
2331 | |
2332 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) | |
2333 = CreateWindowEx( | |
2334 0, /* EX flags */ | |
2335 XEMACS_CONTROL_CLASS, | |
2336 0, /* text */ | |
2337 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, | |
2338 0, /* starting x position */ | |
2339 0, /* starting y position */ | |
2340 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | |
2341 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | |
2342 /* parent window */ | |
2343 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | |
2344 NULL, /* No menu */ | |
2345 NULL, /* must be null for this class */ | |
2346 NULL)) == NULL) | |
2347 signal_simple_error ("window creation failed with code", | |
2348 make_int (GetLastError())); | |
2349 | |
2350 wnd = CreateWindow( "STATIC", | |
2351 "", | 2090 "", |
2352 WS_CHILD, | 2091 WS_CHILD, |
2353 0, /* starting x position */ | 2092 0, /* starting x position */ |
2354 0, /* starting y position */ | 2093 0, /* starting y position */ |
2355 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | 2094 IMAGE_INSTANCE_WIDGET_WIDTH (ii), |
2356 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | 2095 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), |
2357 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii), | 2096 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), /* parent window */ |
2358 0, | 2097 0, |
2359 (HINSTANCE) | 2098 (HINSTANCE) |
2360 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | 2099 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), |
2361 GWL_HINSTANCE), | 2100 GWL_HINSTANCE), |
2362 NULL); | 2101 NULL); |
2363 | 2102 |
2364 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); | 2103 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); |
2365 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; | 2104 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
2366 } | 2105 } |
2367 | 2106 |
2368 static int | 2107 static int |
2369 mswindows_image_instance_equal (Lisp_Image_Instance *p1, | 2108 mswindows_image_instance_equal (struct Lisp_Image_Instance *p1, |
2370 Lisp_Image_Instance *p2, int depth) | 2109 struct Lisp_Image_Instance *p2, int depth) |
2371 { | 2110 { |
2372 switch (IMAGE_INSTANCE_TYPE (p1)) | 2111 switch (IMAGE_INSTANCE_TYPE (p1)) |
2373 { | 2112 { |
2374 case IMAGE_MONO_PIXMAP: | 2113 case IMAGE_MONO_PIXMAP: |
2375 case IMAGE_COLOR_PIXMAP: | 2114 case IMAGE_COLOR_PIXMAP: |
2376 case IMAGE_POINTER: | 2115 case IMAGE_POINTER: |
2377 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1) | 2116 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1) |
2378 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2)) | 2117 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2)) |
2379 return 0; | 2118 return 0; |
2380 break; | 2119 break; |
2381 | 2120 |
2382 default: | 2121 default: |
2383 break; | 2122 break; |
2384 } | 2123 } |
2385 | 2124 |
2386 return 1; | 2125 return 1; |
2387 } | 2126 } |
2388 | 2127 |
2389 static unsigned long | 2128 static unsigned long |
2390 mswindows_image_instance_hash (Lisp_Image_Instance *p, int depth) | 2129 mswindows_image_instance_hash (struct Lisp_Image_Instance *p, int depth) |
2391 { | 2130 { |
2392 switch (IMAGE_INSTANCE_TYPE (p)) | 2131 switch (IMAGE_INSTANCE_TYPE (p)) |
2393 { | 2132 { |
2394 case IMAGE_MONO_PIXMAP: | 2133 case IMAGE_MONO_PIXMAP: |
2395 case IMAGE_COLOR_PIXMAP: | 2134 case IMAGE_COLOR_PIXMAP: |
2396 case IMAGE_POINTER: | 2135 case IMAGE_POINTER: |
2397 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p); | 2136 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p); |
2398 | 2137 |
2399 default: | 2138 default: |
2400 return 0; | 2139 return 0; |
2401 } | 2140 } |
2402 } | 2141 } |
2403 | 2142 |
2406 method. It is assumed that the device slot within the image | 2145 method. It is assumed that the device slot within the image |
2407 instance is already set -- this is the case when instantiate | 2146 instance is already set -- this is the case when instantiate |
2408 methods are called. */ | 2147 methods are called. */ |
2409 | 2148 |
2410 static void | 2149 static void |
2411 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, | 2150 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii, |
2412 int slices, | |
2413 enum image_instance_type type) | 2151 enum image_instance_type type) |
2414 { | 2152 { |
2415 ii->data = xnew_and_zero (struct mswindows_image_instance_data); | 2153 ii->data = xnew_and_zero (struct mswindows_image_instance_data); |
2416 IMAGE_INSTANCE_TYPE (ii) = type; | 2154 IMAGE_INSTANCE_TYPE (ii) = type; |
2417 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil; | 2155 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil; |
2418 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil; | 2156 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil; |
2419 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil; | 2157 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil; |
2420 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil; | 2158 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil; |
2421 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil; | 2159 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil; |
2422 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil; | 2160 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil; |
2423 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices; | |
2424 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (ii) = | |
2425 xnew_array_and_zero (HBITMAP, slices); | |
2426 } | 2161 } |
2427 | 2162 |
2428 | 2163 |
2429 #ifdef HAVE_WIDGETS | |
2430 | |
2431 /************************************************************************/ | 2164 /************************************************************************/ |
2432 /* widgets */ | 2165 /* widgets */ |
2433 /************************************************************************/ | 2166 /************************************************************************/ |
2167 | |
2434 static void | 2168 static void |
2435 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2169 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2436 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2170 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2437 int dest_mask, Lisp_Object domain, | 2171 int dest_mask, Lisp_Object domain, |
2438 const char* class, int flags, int exflags) | 2172 CONST char* class, int flags, int exflags) |
2439 { | 2173 { |
2440 /* this function can call lisp */ | 2174 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2441 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2175 #if 0 |
2176 struct Lisp_Image_Instance *groupii = 0; | |
2177 Lisp_Object group = find_keyword_in_vector (instantiator, Q_group); | |
2178 #endif | |
2442 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; | 2179 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; |
2443 Lisp_Object frame = DOMAIN_FRAME (domain); | 2180 struct device* d = XDEVICE (device); |
2181 Lisp_Object frame = FW_FRAME (domain); | |
2444 Extbyte* nm=0; | 2182 Extbyte* nm=0; |
2445 HWND wnd; | 2183 HWND wnd; |
2446 int id = 0xffff; | 2184 int id = 0xffff; |
2447 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2185 struct gui_item* pgui = &IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2448 Lisp_Gui_Item* pgui = XGUI_ITEM (gui); | 2186 |
2449 | 2187 if (!DEVICE_MSWINDOWS_P (d)) |
2450 CHECK_MSWINDOWS_DEVICE (device); | 2188 signal_simple_error ("Not an mswindows device", device); |
2451 | 2189 #if 0 |
2452 if (!gui_item_active_p (gui)) | 2190 /* if the user specified another glyph as a group pick up the |
2191 instance in our domain. */ | |
2192 if (!NILP (group)) | |
2193 { | |
2194 if (SYMBOLP (group)) | |
2195 group = XSYMBOL (group)->value; | |
2196 group = glyph_image_instance (group, domain, ERROR_ME, 1); | |
2197 groupii = XIMAGE_INSTANCE (group); | |
2198 } | |
2199 #endif | |
2200 if (!gui_item_active_p (pgui)) | |
2453 flags |= WS_DISABLED; | 2201 flags |= WS_DISABLED; |
2454 | 2202 |
2455 style = pgui->style; | 2203 style = pgui->style; |
2456 | 2204 |
2457 if (!NILP (pgui->callback) || !NILP (pgui->callback_ex)) | 2205 if (!NILP (pgui->callback)) |
2458 { | 2206 { |
2459 id = mswindows_register_widget_instance (image_instance, domain); | 2207 id = mswindows_register_widget_instance (image_instance, domain); |
2460 } | 2208 } |
2461 | 2209 /* have to set the type this late in case there is no device |
2210 instantiation for a widget */ | |
2211 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET; | |
2462 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) | 2212 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) |
2463 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (ii), | 2213 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm); |
2464 C_STRING_ALLOCA, nm, | 2214 |
2465 Qnative); | 2215 wnd = CreateWindowEx( |
2466 | 2216 exflags /* | WS_EX_NOPARENTNOTIFY*/, |
2467 /* allocate space for the clip window and then allocate the clip window */ | 2217 class, |
2468 ii->data = xnew_and_zero (struct mswindows_subwindow_data); | 2218 nm, |
2469 | 2219 flags | WS_CHILD, |
2470 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) | 2220 0, /* starting x position */ |
2471 = CreateWindowEx( | 2221 0, /* starting y position */ |
2472 WS_EX_CONTROLPARENT, /* EX flags */ | 2222 IMAGE_INSTANCE_WIDGET_WIDTH (ii), |
2473 XEMACS_CONTROL_CLASS, | 2223 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), |
2474 0, /* text */ | 2224 /* parent window */ |
2475 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, | 2225 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), |
2476 0, /* starting x position */ | 2226 (HMENU)id, /* No menu */ |
2477 0, /* starting y position */ | 2227 (HINSTANCE) |
2478 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | 2228 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), |
2479 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | 2229 GWL_HINSTANCE), |
2480 /* parent window */ | 2230 NULL); |
2481 DOMAIN_MSWINDOWS_HANDLE (domain), | |
2482 (HMENU)id, /* No menu */ | |
2483 NULL, /* must be null for this class */ | |
2484 NULL)) == NULL) | |
2485 signal_simple_error ("window creation failed with code", | |
2486 make_int (GetLastError())); | |
2487 | |
2488 if ((wnd = CreateWindowEx( | |
2489 exflags /* | WS_EX_NOPARENTNOTIFY*/, | |
2490 class, | |
2491 nm, | |
2492 flags | WS_CHILD | WS_VISIBLE, | |
2493 0, /* starting x position */ | |
2494 0, /* starting y position */ | |
2495 IMAGE_INSTANCE_WIDGET_WIDTH (ii), | |
2496 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), | |
2497 /* parent window */ | |
2498 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii), | |
2499 (HMENU)id, /* No menu */ | |
2500 (HINSTANCE) | |
2501 GetWindowLong | |
2502 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | |
2503 GWL_HINSTANCE), | |
2504 NULL)) == NULL) | |
2505 signal_simple_error ("window creation failed with code", | |
2506 make_int (GetLastError())); | |
2507 | 2231 |
2508 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; | 2232 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
2509 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); | 2233 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); |
2510 /* set the widget font from the widget face */ | 2234 /* set the widget font from the widget face */ |
2511 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) | 2235 SendMessage (wnd, WM_SETFONT, |
2512 SendMessage (wnd, WM_SETFONT, | 2236 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT |
2513 (WPARAM) mswindows_widget_hfont (ii, domain), | 2237 (XFONT_INSTANCE (widget_face_font_info |
2514 MAKELPARAM (TRUE, 0)); | 2238 (domain, |
2515 } | 2239 IMAGE_INSTANCE_WIDGET_FACE (ii), |
2516 | 2240 0, 0))), |
2517 /* Instantiate a native layout widget. */ | 2241 MAKELPARAM (TRUE, 0)); |
2518 static void | |
2519 mswindows_native_layout_instantiate (Lisp_Object image_instance, | |
2520 Lisp_Object instantiator, | |
2521 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | |
2522 int dest_mask, Lisp_Object domain) | |
2523 { | |
2524 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2525 | |
2526 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
2527 pointer_bg, dest_mask, domain, "STATIC", | |
2528 /* Approximation to styles available with | |
2529 an XEmacs layout. */ | |
2530 EQ (IMAGE_INSTANCE_LAYOUT_BORDER (ii), | |
2531 Qetched_in) || | |
2532 EQ (IMAGE_INSTANCE_LAYOUT_BORDER (ii), | |
2533 Qetched_out) || | |
2534 GLYPHP (IMAGE_INSTANCE_LAYOUT_BORDER (ii)) | |
2535 ? SS_ETCHEDFRAME : SS_SUNKEN, | |
2536 0); | |
2537 } | 2242 } |
2538 | 2243 |
2539 /* Instantiate a button widget. Unfortunately instantiated widgets are | 2244 /* Instantiate a button widget. Unfortunately instantiated widgets are |
2540 particular to a frame since they need to have a parent. It's not | 2245 particular to a frame since they need to have a parent. It's not |
2541 like images where you just select the image into the context you | 2246 like images where you just select the image into the context you |
2542 want to display it in and BitBlt it. So image instances can have a | 2247 want to display it in and BitBlt it. So images instances can have a |
2543 many-to-one relationship with things you see, whereas widgets can | 2248 many-to-one relationship with things you see, whereas widgets can |
2544 only be one-to-one (i.e. per frame) */ | 2249 only be one-to-one (i.e. per frame) */ |
2545 static void | 2250 static void |
2546 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2251 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2547 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2252 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2548 int dest_mask, Lisp_Object domain) | 2253 int dest_mask, Lisp_Object domain) |
2549 { | 2254 { |
2550 /* This function can call lisp */ | 2255 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2551 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2552 HWND wnd; | 2256 HWND wnd; |
2553 int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback | 2257 int flags = BS_NOTIFY; |
2554 only. Since we seem to want nothing beyond BN_CLICK, | |
2555 the style is perhaps not necessary -- kkm */ | |
2556 Lisp_Object style; | 2258 Lisp_Object style; |
2557 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2259 struct gui_item* pgui = &IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2558 Lisp_Gui_Item* pgui = XGUI_ITEM (gui); | |
2559 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); | 2260 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); |
2261 | |
2262 if (!gui_item_active_p (pgui)) | |
2263 flags |= WS_DISABLED; | |
2560 | 2264 |
2561 if (!NILP (glyph)) | 2265 if (!NILP (glyph)) |
2562 { | 2266 { |
2563 if (!IMAGE_INSTANCEP (glyph)) | 2267 if (!IMAGE_INSTANCEP (glyph)) |
2564 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1); | 2268 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1); |
2565 | 2269 |
2566 if (IMAGE_INSTANCEP (glyph)) | 2270 if (IMAGE_INSTANCEP (glyph)) |
2567 flags |= XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | 2271 flags |= XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? |
2568 BS_BITMAP : BS_ICON; | 2272 BS_BITMAP : BS_ICON; |
2569 } | 2273 } |
2570 | 2274 |
2571 style = pgui->style; | 2275 style = pgui->style; |
2572 | 2276 |
2573 /* #### consider using the default face for radio and toggle | |
2574 buttons. */ | |
2575 if (EQ (style, Qradio)) | 2277 if (EQ (style, Qradio)) |
2576 { | 2278 { |
2577 flags |= BS_RADIOBUTTON; | 2279 flags |= BS_RADIOBUTTON; |
2578 } | 2280 } |
2579 else if (EQ (style, Qtoggle)) | 2281 else if (EQ (style, Qtoggle)) |
2580 { | 2282 { |
2581 flags |= BS_AUTOCHECKBOX; | 2283 flags |= BS_AUTOCHECKBOX; |
2582 } | 2284 } |
2583 else | 2285 else |
2584 { | 2286 flags |= BS_DEFPUSHBUTTON; |
2585 flags |= BS_DEFPUSHBUTTON; | |
2586 } | |
2587 | 2287 |
2588 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2288 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2589 pointer_bg, dest_mask, domain, "BUTTON", | 2289 pointer_bg, dest_mask, domain, "BUTTON", flags, |
2590 flags, 0); | 2290 WS_EX_CONTROLPARENT); |
2591 | 2291 |
2592 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2292 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2593 /* set the checked state */ | 2293 /* set the checked state */ |
2594 if (gui_item_selected_p (gui)) | 2294 if (gui_item_selected_p (pgui)) |
2595 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | 2295 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); |
2596 else | 2296 else |
2597 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); | 2297 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); |
2598 /* add the image if one was given */ | 2298 /* add the image if one was given */ |
2599 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph) | 2299 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)) |
2600 && | 2300 { |
2601 IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph))) | 2301 SendMessage (wnd, BM_SETIMAGE, |
2602 { | 2302 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? |
2603 SendMessage (wnd, BM_SETIMAGE, | |
2604 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | |
2605 IMAGE_BITMAP : IMAGE_ICON), | 2303 IMAGE_BITMAP : IMAGE_ICON), |
2606 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | 2304 (LPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? |
2607 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : | 2305 XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : |
2608 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); | 2306 XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); |
2609 } | 2307 } |
2610 } | |
2611 | |
2612 /* Update the state of a button. */ | |
2613 static void | |
2614 mswindows_button_update (Lisp_Object image_instance) | |
2615 { | |
2616 /* This function can GC if IN_REDISPLAY is false. */ | |
2617 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2618 | |
2619 /* buttons checked or otherwise */ | |
2620 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii))) | |
2621 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
2622 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | |
2623 else | |
2624 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
2625 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); | |
2626 } | 2308 } |
2627 | 2309 |
2628 /* instantiate an edit control */ | 2310 /* instantiate an edit control */ |
2629 static void | 2311 static void |
2630 mswindows_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2312 mswindows_edit_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2631 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2313 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2632 int dest_mask, Lisp_Object domain) | 2314 int dest_mask, Lisp_Object domain) |
2633 { | 2315 { |
2634 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2316 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2635 pointer_bg, dest_mask, domain, "EDIT", | 2317 pointer_bg, dest_mask, domain, "EDIT", |
2636 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP | 2318 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP |
2637 | WS_BORDER, WS_EX_CLIENTEDGE); | 2319 | WS_BORDER, |
2638 } | 2320 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT); |
2639 | 2321 } |
2640 /* instantiate a progress gauge */ | 2322 |
2641 static void | 2323 /* instantiate an edit control */ |
2642 mswindows_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2324 static void |
2325 mswindows_progress_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | |
2643 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2326 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2644 int dest_mask, Lisp_Object domain) | 2327 int dest_mask, Lisp_Object domain) |
2645 { | 2328 { |
2646 HWND wnd; | 2329 HWND wnd; |
2647 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2330 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2648 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2331 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2649 pointer_bg, dest_mask, domain, PROGRESS_CLASS, | 2332 pointer_bg, dest_mask, domain, PROGRESS_CLASS, |
2650 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE); | 2333 WS_TABSTOP | WS_BORDER | PBS_SMOOTH, |
2334 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT); | |
2651 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2335 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2652 /* set the colors */ | 2336 /* set the colors */ |
2653 #ifdef PBS_SETBKCOLOR | 2337 #ifdef PBS_SETBKCOLOR |
2654 SendMessage (wnd, PBS_SETBKCOLOR, 0, | 2338 SendMessage (wnd, PBS_SETBKCOLOR, 0, |
2655 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR | 2339 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR |
2656 (XCOLOR_INSTANCE | 2340 (XCOLOR_INSTANCE |
2657 (FACE_BACKGROUND | 2341 (FACE_BACKGROUND |
2658 (XIMAGE_INSTANCE_WIDGET_FACE (ii), | 2342 (XIMAGE_INSTANCE_WIDGET_FACE (ii), |
2659 XIMAGE_INSTANCE_FRAME (ii)))))); | 2343 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii)))))); |
2660 #endif | 2344 #endif |
2661 #ifdef PBS_SETBARCOLOR | 2345 #ifdef PBS_SETBARCOLOR |
2662 SendMessage (wnd, PBS_SETBARCOLOR, 0, | 2346 SendMessage (wnd, PBS_SETBARCOLOR, 0, |
2663 (L:PARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR | 2347 (L:PARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR |
2664 (XCOLOR_INSTANCE | 2348 (XCOLOR_INSTANCE |
2665 (FACE_FOREGROUND | 2349 (FACE_FOREGROUND |
2666 (XIMAGE_INSTANCE_WIDGET_FACE (ii), | 2350 (XIMAGE_INSTANCE_WIDGET_FACE (ii), |
2667 XIMAGE_INSTANCE_FRAME (ii)))))); | 2351 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii)))))); |
2668 #endif | 2352 #endif |
2669 } | |
2670 | |
2671 /* instantiate a tree view widget */ | |
2672 static HTREEITEM add_tree_item (Lisp_Object image_instance, | |
2673 HWND wnd, HTREEITEM parent, Lisp_Object item, | |
2674 int children, Lisp_Object domain) | |
2675 { | |
2676 TV_INSERTSTRUCT tvitem; | |
2677 HTREEITEM ret; | |
2678 | |
2679 tvitem.hParent = parent; | |
2680 tvitem.hInsertAfter = TVI_LAST; | |
2681 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN; | |
2682 tvitem.item.cChildren = children; | |
2683 | |
2684 if (GUI_ITEMP (item)) | |
2685 { | |
2686 tvitem.item.lParam = mswindows_register_gui_item (image_instance, | |
2687 item, domain); | |
2688 tvitem.item.mask |= TVIF_PARAM; | |
2689 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, | |
2690 C_STRING_ALLOCA, tvitem.item.pszText, | |
2691 Qnative); | |
2692 } | |
2693 else | |
2694 TO_EXTERNAL_FORMAT (LISP_STRING, item, | |
2695 C_STRING_ALLOCA, tvitem.item.pszText, | |
2696 Qnative); | |
2697 | |
2698 tvitem.item.cchTextMax = strlen (tvitem.item.pszText); | |
2699 | |
2700 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM, | |
2701 0, (LPARAM)&tvitem)) == 0) | |
2702 signal_simple_error ("error adding tree view entry", item); | |
2703 | |
2704 return ret; | |
2705 } | |
2706 | |
2707 static void add_tree_item_list (Lisp_Object image_instance, | |
2708 HWND wnd, HTREEITEM parent, Lisp_Object list, | |
2709 Lisp_Object domain) | |
2710 { | |
2711 Lisp_Object rest; | |
2712 | |
2713 /* get the first item */ | |
2714 parent = add_tree_item (image_instance, wnd, parent, XCAR (list), TRUE, domain); | |
2715 /* recursively add items to the tree view */ | |
2716 LIST_LOOP (rest, XCDR (list)) | |
2717 { | |
2718 if (LISTP (XCAR (rest))) | |
2719 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain); | |
2720 else | |
2721 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain); | |
2722 } | |
2723 } | |
2724 | |
2725 static void | |
2726 mswindows_tree_view_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | |
2727 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | |
2728 int dest_mask, Lisp_Object domain) | |
2729 { | |
2730 Lisp_Object rest; | |
2731 HWND wnd; | |
2732 HTREEITEM parent; | |
2733 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2734 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
2735 pointer_bg, dest_mask, domain, WC_TREEVIEW, | |
2736 WS_TABSTOP | WS_BORDER | PBS_SMOOTH | |
2737 | TVS_HASLINES | TVS_HASBUTTONS, | |
2738 WS_EX_CLIENTEDGE); | |
2739 | |
2740 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | |
2741 | |
2742 /* define a root */ | |
2743 parent = add_tree_item (image_instance, wnd, NULL, | |
2744 XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)), | |
2745 TRUE, domain); | |
2746 | |
2747 /* recursively add items to the tree view */ | |
2748 /* add items to the tab */ | |
2749 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) | |
2750 { | |
2751 if (LISTP (XCAR (rest))) | |
2752 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain); | |
2753 else | |
2754 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain); | |
2755 } | |
2756 } | |
2757 | |
2758 /* instantiate a tab control */ | |
2759 static TC_ITEM* add_tab_item (Lisp_Object image_instance, | |
2760 HWND wnd, Lisp_Object item, | |
2761 Lisp_Object domain, int i) | |
2762 { | |
2763 TC_ITEM tvitem, *ret; | |
2764 | |
2765 tvitem.mask = TCIF_TEXT; | |
2766 | |
2767 if (GUI_ITEMP (item)) | |
2768 { | |
2769 tvitem.lParam = mswindows_register_gui_item (image_instance, | |
2770 item, domain); | |
2771 tvitem.mask |= TCIF_PARAM; | |
2772 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, | |
2773 C_STRING_ALLOCA, tvitem.pszText, | |
2774 Qnative); | |
2775 } | |
2776 else | |
2777 { | |
2778 CHECK_STRING (item); | |
2779 TO_EXTERNAL_FORMAT (LISP_STRING, item, | |
2780 C_STRING_ALLOCA, tvitem.pszText, | |
2781 Qnative); | |
2782 } | |
2783 | |
2784 tvitem.cchTextMax = strlen (tvitem.pszText); | |
2785 | |
2786 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM, | |
2787 i, (LPARAM)&tvitem)) < 0) | |
2788 signal_simple_error ("error adding tab entry", item); | |
2789 | |
2790 return ret; | |
2791 } | |
2792 | |
2793 static void | |
2794 mswindows_tab_control_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | |
2795 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | |
2796 int dest_mask, Lisp_Object domain) | |
2797 { | |
2798 /* This function can call lisp */ | |
2799 Lisp_Object rest; | |
2800 HWND wnd; | |
2801 int i = 0, selected = 0; | |
2802 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2803 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation); | |
2804 unsigned int flags = WS_TABSTOP; | |
2805 | |
2806 if (EQ (orient, Qleft) || EQ (orient, Qright)) | |
2807 { | |
2808 flags |= TCS_VERTICAL | TCS_MULTILINE; | |
2809 } | |
2810 if (EQ (orient, Qright) || EQ (orient, Qbottom)) | |
2811 { | |
2812 flags |= TCS_BOTTOM; | |
2813 } | |
2814 | |
2815 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
2816 pointer_bg, dest_mask, domain, WC_TABCONTROL, | |
2817 /* borders don't suit tabs so well */ | |
2818 flags, 0); | |
2819 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | |
2820 /* add items to the tab */ | |
2821 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) | |
2822 { | |
2823 add_tab_item (image_instance, wnd, XCAR (rest), domain, i); | |
2824 if (gui_item_selected_p (XCAR (rest))) | |
2825 selected = i; | |
2826 i++; | |
2827 } | |
2828 SendMessage (wnd, TCM_SETCURSEL, selected, 0); | |
2829 } | |
2830 | |
2831 /* set the properties of a tab control */ | |
2832 static void | |
2833 mswindows_tab_control_update (Lisp_Object image_instance) | |
2834 { | |
2835 /* This function can GC if IN_REDISPLAY is false. */ | |
2836 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2837 | |
2838 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) | |
2839 { | |
2840 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | |
2841 int i = 0, selected = 0; | |
2842 Lisp_Object rest; | |
2843 | |
2844 /* delete the pre-existing items */ | |
2845 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); | |
2846 | |
2847 /* add items to the tab */ | |
2848 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))) | |
2849 { | |
2850 add_tab_item (image_instance, wnd, XCAR (rest), | |
2851 IMAGE_INSTANCE_FRAME (ii), i); | |
2852 if (gui_item_selected_p (XCAR (rest))) | |
2853 selected = i; | |
2854 i++; | |
2855 } | |
2856 SendMessage (wnd, TCM_SETCURSEL, selected, 0); | |
2857 } | |
2858 } | 2353 } |
2859 | 2354 |
2860 /* instantiate a static control possible for putting other things in */ | 2355 /* instantiate a static control possible for putting other things in */ |
2861 static void | 2356 static void |
2862 mswindows_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2357 mswindows_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2863 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2358 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2864 int dest_mask, Lisp_Object domain) | 2359 int dest_mask, Lisp_Object domain) |
2865 { | 2360 { |
2866 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2361 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2867 pointer_bg, dest_mask, domain, "STATIC", | 2362 pointer_bg, dest_mask, domain, "STATIC", |
2868 0, WS_EX_STATICEDGE); | 2363 0, WS_EX_STATICEDGE); |
2869 } | 2364 } |
2365 | |
2366 #if 0 | |
2367 /* instantiate a static control possible for putting other things in */ | |
2368 static void | |
2369 mswindows_group_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | |
2370 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | |
2371 int dest_mask, Lisp_Object domain) | |
2372 { | |
2373 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | |
2374 pointer_bg, dest_mask, domain, "BUTTON", | |
2375 WS_GROUP | BS_GROUPBOX | WS_BORDER, | |
2376 WS_EX_CLIENTEDGE ); | |
2377 } | |
2378 #endif | |
2870 | 2379 |
2871 /* instantiate a scrollbar control */ | 2380 /* instantiate a scrollbar control */ |
2872 static void | 2381 static void |
2873 mswindows_scrollbar_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2382 mswindows_scrollbar_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2874 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2383 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2875 int dest_mask, Lisp_Object domain) | 2384 int dest_mask, Lisp_Object domain) |
2876 { | 2385 { |
2877 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2386 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2878 pointer_bg, dest_mask, domain, "SCROLLBAR", | 2387 pointer_bg, dest_mask, domain, "SCROLLBAR", |
2879 WS_TABSTOP, WS_EX_CLIENTEDGE); | 2388 0, |
2389 WS_EX_CLIENTEDGE ); | |
2880 } | 2390 } |
2881 | 2391 |
2882 /* instantiate a combo control */ | 2392 /* instantiate a combo control */ |
2883 static void | 2393 static void |
2884 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2394 mswindows_combo_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2885 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2395 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2886 int dest_mask, Lisp_Object domain) | 2396 int dest_mask, Lisp_Object domain) |
2887 { | 2397 { |
2888 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2398 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2889 HWND wnd; | 2399 HANDLE wnd; |
2890 Lisp_Object rest; | 2400 Lisp_Object rest; |
2891 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties), | |
2892 Q_items, Qnil); | |
2893 int len, height; | |
2894 | 2401 |
2895 /* Maybe ought to generalise this more but it may be very windows | 2402 /* Maybe ought to generalise this more but it may be very windows |
2896 specific. In windows the window height of a combo box is the | 2403 specific. In windows the window height of a combo box is the |
2897 height when the combo box is open. Thus we need to set the height | 2404 height when the combo box is open. Thus we need to set the height |
2898 before creating the window and then reset it to a single line | 2405 before creating the window and then reset it to a single line |
2899 after the window is created so that redisplay does the right | 2406 after the window is created so that redisplay does the right |
2900 thing. */ | 2407 thing. */ |
2901 widget_instantiate (image_instance, instantiator, pointer_fg, | |
2902 pointer_bg, dest_mask, domain); | |
2903 | |
2904 /* We now have everything right apart from the height. */ | |
2905 default_face_font_info (domain, 0, 0, &height, 0, 0); | |
2906 GET_LIST_LENGTH (data, len); | |
2907 | |
2908 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len; | |
2909 IMAGE_INSTANCE_HEIGHT (ii) = height; | |
2910 | |
2911 /* Now create the widget. */ | |
2912 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2408 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2913 pointer_bg, dest_mask, domain, "COMBOBOX", | 2409 pointer_bg, dest_mask, domain, "COMBOBOX", |
2914 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN | 2410 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN |
2915 | CBS_AUTOHSCROLL | 2411 | CBS_AUTOHSCROLL |
2916 | CBS_HASSTRINGS | WS_VSCROLL, | 2412 | CBS_HASSTRINGS | WS_VSCROLL, |
2917 WS_EX_CLIENTEDGE); | 2413 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT); |
2918 /* Reset the height. layout will probably do this safely, but better make sure. */ | 2414 /* reset the height */ |
2919 image_instance_layout (image_instance, | 2415 widget_text_to_pixel_conversion (domain, |
2920 IMAGE_UNSPECIFIED_GEOMETRY, | 2416 IMAGE_INSTANCE_WIDGET_FACE (ii), 1, 0, |
2921 IMAGE_UNSPECIFIED_GEOMETRY, | 2417 &IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii), 0); |
2922 domain); | |
2923 | |
2924 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2418 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2925 /* add items to the combo box */ | 2419 /* add items to the combo box */ |
2926 SendMessage (wnd, CB_RESETCONTENT, 0, 0); | 2420 SendMessage (wnd, CB_RESETCONTENT, 0, 0); |
2927 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) | 2421 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) |
2928 { | 2422 { |
2929 Extbyte* lparam; | 2423 Extbyte* lparam; |
2930 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest), | 2424 GET_C_STRING_OS_DATA_ALLOCA (XCAR (rest), lparam); |
2931 C_STRING_ALLOCA, lparam, | |
2932 Qnative); | |
2933 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) | 2425 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) |
2934 signal_simple_error ("error adding combo entries", instantiator); | 2426 signal_simple_error ("error adding combo entries", instantiator); |
2935 } | 2427 } |
2936 } | 2428 } |
2937 | 2429 |
2938 /* get properties of a control */ | 2430 /* get properties of a control */ |
2939 static Lisp_Object | 2431 static Lisp_Object |
2940 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) | 2432 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) |
2941 { | 2433 { |
2942 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2434 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2943 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2435 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2944 /* get the text from a control */ | 2436 /* get the text from a control */ |
2945 if (EQ (prop, Q_text)) | 2437 if (EQ (prop, Q_text)) |
2946 { | 2438 { |
2947 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); | 2439 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); |
2948 Extbyte *buf = (Extbyte*) alloca (len+1); | 2440 Extbyte* buf =alloca (len+1); |
2949 | 2441 |
2950 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); | 2442 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); |
2951 return build_ext_string (buf, Qnative); | 2443 return build_ext_string (buf, FORMAT_OS); |
2952 } | 2444 } |
2953 return Qunbound; | 2445 return Qunbound; |
2954 } | 2446 } |
2955 | 2447 |
2956 /* get properties of a button */ | 2448 /* get properties of a button */ |
2957 static Lisp_Object | 2449 static Lisp_Object |
2958 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) | 2450 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) |
2959 { | 2451 { |
2960 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2452 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2961 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2453 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2962 /* check the state of a button */ | 2454 /* check the state of a button */ |
2963 if (EQ (prop, Q_selected)) | 2455 if (EQ (prop, Q_selected)) |
2964 { | 2456 { |
2965 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) | 2457 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) |
2966 return Qt; | 2458 return Qt; |
2970 return Qunbound; | 2462 return Qunbound; |
2971 } | 2463 } |
2972 | 2464 |
2973 /* get properties of a combo box */ | 2465 /* get properties of a combo box */ |
2974 static Lisp_Object | 2466 static Lisp_Object |
2975 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop) | 2467 mswindows_combo_property (Lisp_Object image_instance, Lisp_Object prop) |
2976 { | 2468 { |
2977 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2469 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2978 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2470 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2979 /* get the text from a control */ | 2471 /* get the text from a control */ |
2980 if (EQ (prop, Q_text)) | 2472 if (EQ (prop, Q_text)) |
2981 { | 2473 { |
2982 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); | 2474 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); |
2983 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); | 2475 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); |
2984 Extbyte* buf = (Extbyte*) alloca (len+1); | 2476 Extbyte* buf = alloca (len+1); |
2985 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); | 2477 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); |
2986 return build_ext_string (buf, Qnative); | 2478 return build_ext_string (buf, FORMAT_OS); |
2987 } | 2479 } |
2988 return Qunbound; | 2480 return Qunbound; |
2989 } | 2481 } |
2990 | 2482 |
2483 /* set the properties of a control */ | |
2484 static Lisp_Object | |
2485 mswindows_widget_set_property (Lisp_Object image_instance, Lisp_Object prop, | |
2486 Lisp_Object val) | |
2487 { | |
2488 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | |
2489 | |
2490 if (EQ (prop, Q_text)) | |
2491 { | |
2492 Extbyte* lparam=0; | |
2493 CHECK_STRING (val); | |
2494 GET_C_STRING_OS_DATA_ALLOCA (val, lparam); | |
2495 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
2496 WM_SETTEXT, 0, (LPARAM)lparam); | |
2497 return Qt; | |
2498 } | |
2499 return Qunbound; | |
2500 } | |
2501 | |
2991 /* set the properties of a progres guage */ | 2502 /* set the properties of a progres guage */ |
2992 static void | 2503 static Lisp_Object |
2993 mswindows_progress_gauge_update (Lisp_Object image_instance) | 2504 mswindows_progress_set_property (Lisp_Object image_instance, Lisp_Object prop, |
2994 { | 2505 Lisp_Object val) |
2995 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2506 { |
2996 | 2507 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2997 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) | 2508 |
2998 { | 2509 if (EQ (prop, Q_percent)) |
2999 Lisp_Object val; | 2510 { |
3000 #ifdef ERROR_CHECK_GLYPHS | |
3001 assert (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))); | |
3002 #endif | |
3003 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value; | |
3004 #ifdef DEBUG_WIDGET_OUTPUT | |
3005 printf ("progress gauge displayed value on %p updated to %ld\n", | |
3006 WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | |
3007 XINT(val)); | |
3008 #endif | |
3009 CHECK_INT (val); | 2511 CHECK_INT (val); |
3010 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2512 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
3011 PBM_SETPOS, (WPARAM)XINT (val), 0); | 2513 PBM_SETPOS, (WPARAM)XINT (val), 0); |
3012 } | 2514 return Qt; |
3013 } | 2515 } |
3014 | 2516 return Qunbound; |
3015 LRESULT WINAPI | 2517 } |
3016 mswindows_control_wnd_proc (HWND hwnd, UINT msg, | |
3017 WPARAM wParam, LPARAM lParam) | |
3018 { | |
3019 switch (msg) | |
3020 { | |
3021 case WM_NOTIFY: | |
3022 case WM_COMMAND: | |
3023 case WM_CTLCOLORBTN: | |
3024 case WM_CTLCOLORLISTBOX: | |
3025 case WM_CTLCOLOREDIT: | |
3026 case WM_CTLCOLORSTATIC: | |
3027 case WM_CTLCOLORSCROLLBAR: | |
3028 | |
3029 return mswindows_wnd_proc (GetParent (hwnd), msg, wParam, lParam); | |
3030 default: | |
3031 return DefWindowProc (hwnd, msg, wParam, lParam); | |
3032 } | |
3033 } | |
3034 | |
3035 #endif /* HAVE_WIDGETS */ | |
3036 | 2518 |
3037 | 2519 |
3038 /************************************************************************/ | 2520 /************************************************************************/ |
3039 /* initialization */ | 2521 /* initialization */ |
3040 /************************************************************************/ | 2522 /************************************************************************/ |
3047 } | 2529 } |
3048 | 2530 |
3049 void | 2531 void |
3050 console_type_create_glyphs_mswindows (void) | 2532 console_type_create_glyphs_mswindows (void) |
3051 { | 2533 { |
3052 /* image methods - display */ | 2534 /* image methods */ |
2535 | |
3053 CONSOLE_HAS_METHOD (mswindows, print_image_instance); | 2536 CONSOLE_HAS_METHOD (mswindows, print_image_instance); |
3054 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance); | 2537 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance); |
3055 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow); | 2538 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow); |
3056 CONSOLE_HAS_METHOD (mswindows, map_subwindow); | 2539 CONSOLE_HAS_METHOD (mswindows, map_subwindow); |
3057 CONSOLE_HAS_METHOD (mswindows, update_subwindow); | 2540 CONSOLE_HAS_METHOD (mswindows, update_subwindow); |
3058 CONSOLE_HAS_METHOD (mswindows, resize_subwindow); | |
3059 CONSOLE_HAS_METHOD (mswindows, update_widget); | |
3060 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); | 2541 CONSOLE_HAS_METHOD (mswindows, image_instance_equal); |
3061 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); | 2542 CONSOLE_HAS_METHOD (mswindows, image_instance_hash); |
3062 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); | 2543 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage); |
3063 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); | 2544 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file); |
3064 | |
3065 /* image methods - printer */ | |
3066 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_image_instance); | |
3067 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_image_instance); | |
3068 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_equal); | |
3069 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_hash); | |
3070 CONSOLE_INHERITS_METHOD (msprinter, mswindows, init_image_instance_from_eimage); | |
3071 CONSOLE_INHERITS_METHOD (msprinter, mswindows, locate_pixmap_file); | |
3072 } | 2545 } |
3073 | 2546 |
3074 void | 2547 void |
3075 image_instantiator_format_create_glyphs_mswindows (void) | 2548 image_instantiator_format_create_glyphs_mswindows (void) |
3076 { | 2549 { |
3077 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, nothing); | |
3078 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, string); | |
3079 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, formatted_string); | |
3080 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, inherit); | |
3081 /* image-instantiator types */ | 2550 /* image-instantiator types */ |
3082 INITIALIZE_DEVICE_IIFORMAT (mswindows, xbm); | |
3083 INITIALIZE_DEVICE_IIFORMAT (msprinter, xbm); | |
3084 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate); | |
3085 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xbm, instantiate); | |
3086 #ifdef HAVE_XPM | 2551 #ifdef HAVE_XPM |
3087 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm); | 2552 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm); |
3088 INITIALIZE_DEVICE_IIFORMAT (msprinter, xpm); | |
3089 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate); | 2553 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate); |
3090 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xpm, instantiate); | |
3091 #endif | 2554 #endif |
2555 INITIALIZE_DEVICE_IIFORMAT (mswindows, xbm); | |
2556 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate); | |
3092 #ifdef HAVE_XFACE | 2557 #ifdef HAVE_XFACE |
3093 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface); | 2558 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface); |
3094 INITIALIZE_DEVICE_IIFORMAT (msprinter, xface); | |
3095 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate); | 2559 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate); |
3096 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xface, instantiate); | |
3097 #endif | 2560 #endif |
3098 #ifdef HAVE_JPEG | |
3099 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, jpeg); | |
3100 #endif | |
3101 #ifdef HAVE_TIFF | |
3102 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, tiff); | |
3103 #endif | |
3104 #ifdef HAVE_PNG | |
3105 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, png); | |
3106 #endif | |
3107 #ifdef HAVE_GIF | |
3108 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, gif); | |
3109 #endif | |
3110 #ifdef HAVE_WIDGETS | |
3111 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget); | |
3112 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property); | |
3113 /* layout widget */ | |
3114 IIFORMAT_VALID_CONSOLE (mswindows, layout); | |
3115 INITIALIZE_DEVICE_IIFORMAT (mswindows, native_layout); | |
3116 IIFORMAT_HAS_DEVMETHOD (mswindows, native_layout, instantiate); | |
3117 /* button widget */ | |
3118 INITIALIZE_DEVICE_IIFORMAT (mswindows, button); | 2561 INITIALIZE_DEVICE_IIFORMAT (mswindows, button); |
3119 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property); | 2562 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property); |
3120 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate); | 2563 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate); |
3121 IIFORMAT_HAS_DEVMETHOD (mswindows, button, update); | 2564 |
3122 /* edit-field widget */ | 2565 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit); |
3123 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit_field); | 2566 IIFORMAT_HAS_DEVMETHOD (mswindows, edit, instantiate); |
3124 IIFORMAT_HAS_DEVMETHOD (mswindows, edit_field, instantiate); | 2567 |
3125 /* subwindow */ | |
3126 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow); | 2568 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow); |
3127 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate); | 2569 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate); |
3128 /* label */ | 2570 |
2571 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget); | |
2572 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property); | |
2573 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, set_property); | |
2574 #if 0 | |
2575 INITIALIZE_DEVICE_IIFORMAT (mswindows, group); | |
2576 IIFORMAT_HAS_DEVMETHOD (mswindows, group, instantiate); | |
2577 #endif | |
3129 INITIALIZE_DEVICE_IIFORMAT (mswindows, label); | 2578 INITIALIZE_DEVICE_IIFORMAT (mswindows, label); |
3130 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate); | 2579 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate); |
3131 /* combo box */ | 2580 |
3132 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo_box); | 2581 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo); |
3133 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, property); | 2582 IIFORMAT_HAS_DEVMETHOD (mswindows, combo, property); |
3134 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, instantiate); | 2583 IIFORMAT_HAS_DEVMETHOD (mswindows, combo, instantiate); |
3135 /* scrollbar */ | 2584 |
3136 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar); | 2585 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar); |
3137 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate); | 2586 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate); |
3138 /* progress gauge */ | 2587 |
3139 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress_gauge); | 2588 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress); |
3140 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, update); | 2589 IIFORMAT_HAS_DEVMETHOD (mswindows, progress, set_property); |
3141 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, instantiate); | 2590 IIFORMAT_HAS_DEVMETHOD (mswindows, progress, instantiate); |
3142 /* tree view widget */ | 2591 |
3143 INITIALIZE_DEVICE_IIFORMAT (mswindows, tree_view); | |
3144 /* IIFORMAT_HAS_DEVMETHOD (mswindows, progress, set_property);*/ | |
3145 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, instantiate); | |
3146 /* tab control widget */ | |
3147 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control); | |
3148 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate); | |
3149 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, update); | |
3150 #endif | |
3151 /* windows bitmap format */ | |
3152 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp"); | 2592 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp"); |
2593 | |
3153 IIFORMAT_HAS_METHOD (bmp, validate); | 2594 IIFORMAT_HAS_METHOD (bmp, validate); |
3154 IIFORMAT_HAS_METHOD (bmp, normalize); | 2595 IIFORMAT_HAS_METHOD (bmp, normalize); |
3155 IIFORMAT_HAS_METHOD (bmp, possible_dest_types); | 2596 IIFORMAT_HAS_METHOD (bmp, possible_dest_types); |
3156 IIFORMAT_HAS_METHOD (bmp, instantiate); | 2597 IIFORMAT_HAS_METHOD (bmp, instantiate); |
3157 | 2598 |
3158 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string); | 2599 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string); |
3159 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string); | 2600 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string); |
3160 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, bmp); | 2601 |
3161 | |
3162 /* mswindows resources */ | |
3163 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource, | 2602 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource, |
3164 "mswindows-resource"); | 2603 "mswindows-resource"); |
3165 | 2604 |
3166 IIFORMAT_HAS_METHOD (mswindows_resource, validate); | 2605 IIFORMAT_HAS_METHOD (mswindows_resource, validate); |
3167 IIFORMAT_HAS_METHOD (mswindows_resource, normalize); | 2606 IIFORMAT_HAS_METHOD (mswindows_resource, normalize); |
3168 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types); | 2607 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types); |
3169 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate); | 2608 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate); |
3170 | 2609 |
3171 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type, | 2610 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type, |
3172 check_valid_resource_symbol); | 2611 check_valid_resource_symbol); |
3173 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id); | 2612 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id); |
3174 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string); | 2613 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string); |
3175 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, mswindows_resource); | |
3176 } | 2614 } |
3177 | 2615 |
3178 void | 2616 void |
3179 vars_of_glyphs_mswindows (void) | 2617 vars_of_glyphs_mswindows (void) |
3180 { | 2618 { |
2619 Fprovide (Qbmp); | |
2620 Fprovide (Qmswindows_resource); | |
3181 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /* | 2621 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /* |
3182 A list of the directories in which mswindows bitmap files may be found. | 2622 A list of the directories in which mswindows bitmap files may be found. |
3183 This is used by the `make-image-instance' function. | 2623 This is used by the `make-image-instance' function. |
3184 */ ); | 2624 */ ); |
3185 Vmswindows_bitmap_file_path = Qnil; | 2625 Vmswindows_bitmap_file_path = Qnil; |
2626 | |
2627 Fprovide (Qbutton); | |
2628 Fprovide (Qedit); | |
2629 Fprovide (Qcombo); | |
2630 Fprovide (Qscrollbar); | |
2631 Fprovide (Qlabel); | |
2632 Fprovide (Qprogress); | |
3186 } | 2633 } |
3187 | 2634 |
3188 void | 2635 void |
3189 complex_vars_of_glyphs_mswindows (void) | 2636 complex_vars_of_glyphs_mswindows (void) |
3190 { | 2637 { |