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