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