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