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