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