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