1 /* mswindows-specific glyph objects.
2 Copyright (C) 1998, 1999, 2000 Andy Piper.
4 This file is part of XEmacs.
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Synched up with: Not in FSF. */
23 /* written by Andy Piper <andy@xemacs.org> plagerising bits from
30 #define OEMRESOURCE /* Define OCR_ and friend constants */
31 #include "console-msw.h"
32 #include "glyphs-msw.h"
33 #include "objects-msw.h"
46 #include "file-coding.h"
54 #define WIDGET_GLYPH_SLOT 0
56 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing);
57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string);
58 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
59 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit);
60 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout);
62 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
65 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff);
68 DECLARE_IMAGE_INSTANTIATOR_FORMAT (png);
71 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif);
74 DEFINE_DEVICE_IIFORMAT (mswindows, xpm);
75 DEFINE_DEVICE_IIFORMAT (msprinter, xpm);
77 DEFINE_DEVICE_IIFORMAT (mswindows, xbm);
78 DEFINE_DEVICE_IIFORMAT (msprinter, xbm);
80 DEFINE_DEVICE_IIFORMAT (mswindows, xface);
81 DEFINE_DEVICE_IIFORMAT (msprinter, xface);
83 DEFINE_DEVICE_IIFORMAT (mswindows, button);
84 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field);
85 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow);
86 DEFINE_DEVICE_IIFORMAT (mswindows, widget);
87 DEFINE_DEVICE_IIFORMAT (mswindows, label);
88 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar);
89 DEFINE_DEVICE_IIFORMAT (mswindows, combo_box);
90 DEFINE_DEVICE_IIFORMAT (mswindows, progress_gauge);
91 DEFINE_DEVICE_IIFORMAT (mswindows, tree_view);
92 DEFINE_DEVICE_IIFORMAT (mswindows, tab_control);
94 DEFINE_IMAGE_INSTANTIATOR_FORMAT (bmp);
96 Lisp_Object Vmswindows_bitmap_file_path;
97 static COLORREF transparent_color = RGB (1,1,1);
99 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource);
100 Lisp_Object Q_resource_type, Q_resource_id;
101 Lisp_Object Qmswindows_resource;
104 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii,
106 enum image_instance_type type);
108 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image,
112 * Given device D, retrieve compatible device context. D can be either
113 * mswindows or an msprinter device.
116 get_device_compdc (struct device *d)
118 if (DEVICE_MSWINDOWS_P (d))
119 return DEVICE_MSWINDOWS_HCDC (d);
121 return DEVICE_MSPRINTER_HCDC (d);
124 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3)))
126 /************************************************************************/
127 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
129 /************************************************************************/
130 static BITMAPINFO* convert_EImage_to_DIBitmap (Lisp_Object device,
131 int width, int height,
134 unsigned char** bmp_data)
136 struct device *d = XDEVICE (device);
140 BITMAPINFO* bmp_info;
141 unsigned char *ip, *dp;
143 if (GetDeviceCaps (get_device_compdc (d), BITSPIXEL) > 0)
145 int bpline = BPLINE(width * 3);
146 /* FIXME: we can do this because 24bpp implies no color table, once
147 * we start palettizing this is no longer true. The X versions of
148 * this function quantises to 256 colors or bit masks down to a
149 * long. Windows can actually handle rgb triples in the raw so I
150 * don't see much point trying to optimize down to the best
151 * structure - unless it has memory / color allocation implications
153 bmp_info=xnew_and_zero (BITMAPINFO);
160 bmp_info->bmiHeader.biBitCount=24; /* just RGB triples for now */
161 bmp_info->bmiHeader.biCompression=BI_RGB; /* just RGB triples for now */
162 bmp_info->bmiHeader.biSizeImage=width*height*3;
164 /* bitmap data needs to be in blue, green, red triples - in that
165 order, eimage is in RGB format so we need to convert */
166 *bmp_data = xnew_array_and_zero (unsigned char, bpline * height);
167 *bit_count = bpline * height;
176 for (i = height-1; i >= 0; i--) {
177 dp = (*bmp_data) + (i * bpline);
178 for (j = 0; j < width; j++) {
186 else /* scale to 256 colors */
190 int bpline = BPLINE (width * 3);
191 /* Quantize the image and get a histogram while we're at it.
192 Do this first to save memory */
193 qtable = build_EImage_quantable(pic, width, height, 256);
194 if (qtable == NULL) return NULL;
196 /* use our quantize table to allocate the colors */
197 ncolors = qtable->num_active_colors;
198 bmp_info=(BITMAPINFO*)xmalloc_and_zero (sizeof(BITMAPINFOHEADER) +
199 sizeof(RGBQUAD) * ncolors);
206 colortbl=(RGBQUAD*)(((unsigned char*)bmp_info)+sizeof(BITMAPINFOHEADER));
208 bmp_info->bmiHeader.biBitCount=8;
209 bmp_info->bmiHeader.biCompression=BI_RGB;
210 bmp_info->bmiHeader.biSizeImage=bpline*height;
211 bmp_info->bmiHeader.biClrUsed=ncolors;
212 bmp_info->bmiHeader.biClrImportant=ncolors;
214 *bmp_data = (unsigned char *) xmalloc_and_zero (bpline * height);
215 *bit_count = bpline * height;
224 /* build up an RGBQUAD colortable */
225 for (i = 0; i < qtable->num_active_colors; i++)
227 colortbl[i].rgbRed = (BYTE) qtable->rm[i];
228 colortbl[i].rgbGreen = (BYTE) qtable->gm[i];
229 colortbl[i].rgbBlue = (BYTE) qtable->bm[i];
230 colortbl[i].rgbReserved = 0;
233 /* now build up the data. picture has to be upside-down and
234 back-to-front for msw bitmaps */
236 for (i = height-1; i >= 0; i--)
238 dp = (*bmp_data) + (i * bpline);
239 for (j = 0; j < width; j++)
244 *dp++ = QUANT_GET_COLOR (qtable,rd,gr,bl);
249 /* fix up the standard stuff */
250 bmp_info->bmiHeader.biWidth=width;
251 bmp_info->bmiHeader.biHeight=height;
252 bmp_info->bmiHeader.biPlanes=1;
253 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
254 bmp_info->bmiHeader.biXPelsPerMeter=0; /* unless you know better */
255 bmp_info->bmiHeader.biYPelsPerMeter=0;
260 /* Given a pixmap filename, look through all of the "standard" places
261 where the file might be located. Return a full pathname if found;
262 otherwise, return Qnil. */
265 mswindows_locate_pixmap_file (Lisp_Object name)
267 /* This function can GC if IN_REDISPLAY is false */
270 /* Check non-absolute pathnames with a directory component relative to
271 the search path; that's the way Xt does it. */
272 if (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 0)) ||
273 (XSTRING_BYTE (name, 0) == '.' &&
274 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) ||
275 (XSTRING_BYTE (name, 1) == '.' &&
276 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2)))))))
278 if (!NILP (Ffile_readable_p (name)))
279 return Fexpand_file_name (name, Qnil);
284 if (locate_file (Vmswindows_bitmap_file_path, name, Qnil, &found, R_OK) < 0)
286 Lisp_Object temp = list1 (Vdata_directory);
290 locate_file (temp, name, Qnil, &found, R_OK);
298 /* Initialize an image instance from a bitmap
300 DEST_MASK specifies the mask of allowed image types.
302 If this fails, signal an error. INSTANTIATOR is only used
303 in the error message. */
306 init_image_instance_from_dibitmap (Lisp_Image_Instance *ii,
307 BITMAPINFO *bmp_info,
312 Lisp_Object instantiator,
313 int x_hot, int y_hot,
316 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
317 struct device *d = XDEVICE (device);
319 enum image_instance_type type;
323 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
324 type = IMAGE_COLOR_PIXMAP;
325 else if (dest_mask & IMAGE_POINTER_MASK)
326 type = IMAGE_POINTER;
328 incompatible_image_types (instantiator, dest_mask,
329 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
331 hdc = get_device_compdc (d);
332 bitmap = CreateDIBSection (hdc,
338 if (!bitmap || !bmp_buf)
339 signal_simple_error ("Unable to create bitmap", instantiator);
341 /* copy in the actual bitmap */
342 memcpy (bmp_buf, bmp_data, bmp_bits);
344 mswindows_initialize_dibitmap_image_instance (ii, slices, type);
346 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
347 find_keyword_in_vector (instantiator, Q_file);
349 /* Fixup a set of bitmaps. */
350 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
352 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
353 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth;
354 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight;
355 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
356 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot);
357 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), y_hot);
361 mswindows_initialize_image_instance_mask (ii, hdc);
364 if (type == IMAGE_POINTER)
366 mswindows_initialize_image_instance_icon(ii, TRUE);
371 image_instance_add_dibitmap (Lisp_Image_Instance *ii,
372 BITMAPINFO *bmp_info,
376 Lisp_Object instantiator)
378 struct device *d = XDEVICE (IMAGE_INSTANCE_DEVICE (ii));
381 HBITMAP bitmap = CreateDIBSection (get_device_compdc (d),
387 if (!bitmap || !bmp_buf)
388 signal_simple_error ("Unable to create bitmap", instantiator);
390 /* copy in the actual bitmap */
391 memcpy (bmp_buf, bmp_data, bmp_bits);
392 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap;
396 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii,
397 int width, int height,
399 unsigned char *eimage,
401 Lisp_Object instantiator,
404 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
405 BITMAPINFO* bmp_info;
406 unsigned char* bmp_data;
411 CHECK_MSGDI_DEVICE (device);
413 /* this is a hack but MaskBlt and TransparentBlt are not supported
414 on most windows variants */
415 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
416 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain)));
418 for (slice = 0; slice < slices; slice++)
420 /* build a bitmap from the eimage */
421 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height,
422 eimage + (width * height * 3 * slice),
423 &bmp_bits, &bmp_data)))
425 signal_simple_error ("EImage to DIBitmap conversion failed",
429 /* Now create the pixmap and set up the image instance */
431 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
432 bmp_data, bmp_bits, slices, instantiator,
435 image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice,
444 set_mono_pixel (unsigned char* bits,
445 int bpline, int height,
446 int x, int y, int white)
449 unsigned char bitnum;
450 /* Find the byte on which this scanline begins */
451 i = (height - y - 1) * bpline;
452 /* Find the byte containing this pixel */
454 /* Which bit is it? */
455 bitnum = (unsigned char) (7 - (x & 7));
456 if (white) /* Turn it on */
457 bits[i] |= (1 << bitnum);
458 else /* Turn it off */
459 bits[i] &= ~(1 << bitnum);
463 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image,
468 unsigned char *dibits, *and_bits;
469 BITMAPINFO *bmp_info =
470 (BITMAPINFO*) xmalloc_and_zero (sizeof (BITMAPINFO) + sizeof (RGBQUAD));
472 int height = IMAGE_INSTANCE_PIXMAP_HEIGHT (image);
474 int maskbpline = BPLINE ((IMAGE_INSTANCE_PIXMAP_WIDTH (image) + 7) / 8);
475 int bpline = BPLINE (IMAGE_INSTANCE_PIXMAP_WIDTH (image) * 3);
480 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
481 bmp_info->bmiHeader.biHeight = height;
482 bmp_info->bmiHeader.biPlanes = 1;
483 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
484 bmp_info->bmiHeader.biBitCount = 1;
485 bmp_info->bmiHeader.biCompression = BI_RGB;
486 bmp_info->bmiHeader.biClrUsed = 2;
487 bmp_info->bmiHeader.biClrImportant = 2;
488 bmp_info->bmiHeader.biSizeImage = height * maskbpline;
489 bmp_info->bmiColors[0].rgbRed = 0;
490 bmp_info->bmiColors[0].rgbGreen = 0;
491 bmp_info->bmiColors[0].rgbBlue = 0;
492 bmp_info->bmiColors[0].rgbReserved = 0;
493 bmp_info->bmiColors[1].rgbRed = 255;
494 bmp_info->bmiColors[1].rgbGreen = 255;
495 bmp_info->bmiColors[1].rgbBlue = 255;
496 bmp_info->bmiColors[0].rgbReserved = 0;
498 if (!(mask = CreateDIBSection (hcdc,
508 old = SelectObject (hcdc, IMAGE_INSTANCE_MSWINDOWS_BITMAP (image));
509 /* build up an in-memory set of bits to mess with */
512 bmp_info->bmiHeader.biWidth=IMAGE_INSTANCE_PIXMAP_WIDTH (image);
513 bmp_info->bmiHeader.biHeight = -height;
514 bmp_info->bmiHeader.biPlanes = 1;
515 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
516 bmp_info->bmiHeader.biBitCount = 24;
517 bmp_info->bmiHeader.biCompression = BI_RGB;
518 bmp_info->bmiHeader.biClrUsed = 0;
519 bmp_info->bmiHeader.biClrImportant = 0;
520 bmp_info->bmiHeader.biSizeImage = height * bpline;
522 dibits = (unsigned char*) xmalloc_and_zero (bpline * height);
524 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
529 DIB_RGB_COLORS) <= 0)
535 /* now set the colored bits in the mask and transparent ones to
536 black in the original */
537 for (i=0; i<IMAGE_INSTANCE_PIXMAP_WIDTH (image); i++)
539 for (j=0; j<height; j++)
541 unsigned char* idx = &dibits[j * bpline + i * 3];
543 if (RGB (idx[2], idx[1], idx[0]) == transparent_color)
545 idx[0] = idx[1] = idx[2] = 0;
546 set_mono_pixel (and_bits, maskbpline, height, i, j, TRUE);
550 set_mono_pixel (and_bits, maskbpline, height, i, j, FALSE);
556 IMAGE_INSTANCE_MSWINDOWS_BITMAP (image),
566 SelectObject(hcdc, old);
568 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask;
572 mswindows_initialize_image_instance_icon (Lisp_Image_Instance* image,
577 /* we rely on windows to do any resizing necessary */
578 x_icon.fIcon=cursor ? FALSE : TRUE;
579 x_icon.xHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (image));
580 x_icon.yHotspot=XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (image));
581 x_icon.hbmMask=IMAGE_INSTANCE_MSWINDOWS_MASK (image);
582 x_icon.hbmColor=IMAGE_INSTANCE_MSWINDOWS_BITMAP (image);
584 IMAGE_INSTANCE_MSWINDOWS_ICON (image)=
585 CreateIconIndirect (&x_icon);
589 create_resized_bitmap (HBITMAP curbmp, struct frame *f,
596 HDC hcdc = get_device_compdc (XDEVICE (FRAME_DEVICE (f)));
597 HDC hdcDst = CreateCompatibleDC (hcdc);
599 old1 = SelectObject (hcdc, curbmp);
601 newbmp = CreateCompatibleBitmap (hcdc, newx, newy);
603 old2 = SelectObject (hdcDst, newbmp);
605 if (!StretchBlt (hdcDst, 0, 0, newx, newy,
611 DeleteObject (newbmp);
616 SelectObject (hdcDst, old2);
617 SelectObject (hcdc, old1);
624 mswindows_create_resized_bitmap (Lisp_Image_Instance* ii,
628 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii),
630 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
631 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
636 mswindows_create_resized_mask (Lisp_Image_Instance* ii,
640 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii) == NULL)
643 return create_resized_bitmap (IMAGE_INSTANCE_MSWINDOWS_MASK (ii),
645 IMAGE_INSTANCE_PIXMAP_WIDTH (ii),
646 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii),
650 #if 0 /* Currently unused */
652 mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii,
656 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy);
657 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy);
662 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii))
663 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii));
664 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii))
665 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (ii));
667 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = newbmp;
668 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = newmask;
669 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = newx;
670 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = newy;
676 /**********************************************************************
678 **********************************************************************/
688 static struct color_symbol*
689 extract_xpm_color_names (Lisp_Object device,
691 Lisp_Object color_symbol_alist,
694 /* This function can GC */
696 Lisp_Object results = Qnil;
698 struct color_symbol *colortbl;
699 struct gcpro gcpro1, gcpro2;
701 GCPRO2 (results, device);
703 /* We built up results to be (("name" . #<color>) ...) so that if an
704 error happens we don't lose any malloc()ed data, or more importantly,
705 leave any pixels allocated in the server. */
707 LIST_LOOP (rest, color_symbol_alist)
709 Lisp_Object cons = XCAR (rest);
710 Lisp_Object name = XCAR (cons);
711 Lisp_Object value = XCDR (cons);
717 (value, device, encode_error_behavior_flag (ERROR_ME_NOT));
720 assert (COLOR_SPECIFIERP (value));
721 value = Fspecifier_instance (value, domain, Qnil, Qnil);
725 results = noseeum_cons (noseeum_cons (name, value), results);
728 UNGCPRO; /* no more evaluation */
731 if (i == 0) return 0;
733 colortbl = xnew_array_and_zero (struct color_symbol, i);
737 Lisp_Object cons = XCAR (results);
739 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
741 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (cons),
742 C_STRING_ALLOCA, colortbl[j].name,
744 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */
745 free_cons (XCONS (cons));
747 results = XCDR (results);
748 free_cons (XCONS (cons));
753 static int xpm_to_eimage (Lisp_Object image, const Extbyte *buffer,
754 unsigned char** data,
755 int* width, int* height,
756 int* x_hot, int* y_hot,
758 struct color_symbol* color_symbols,
763 int result, i, j, transp_idx, maskbpline;
766 COLORREF color; /* the american spelling virus hits again .. */
771 xpminfo.valuemask=XpmHotspot;
774 result = XpmCreateXpmImageFromBuffer ((char*)buffer,
783 signal_simple_error ("Invalid XPM data", image);
787 signal_double_file_error ("Parsing pixmap data",
788 "out of memory", image);
792 signal_double_file_error_2 ("Parsing pixmap data",
794 make_int (result), image);
798 *width = xpmimage.width;
799 *height = xpmimage.height;
800 maskbpline = BPLINE ((~7UL & (unsigned long)(*width + 7)) / 8);
802 *data = xnew_array_and_zero (unsigned char, *width * *height * 3);
806 XpmFreeXpmImage (&xpmimage);
807 XpmFreeXpmInfo (&xpminfo);
811 /* build a color table to speed things up */
812 colortbl = xnew_array_and_zero (COLORREF, xpmimage.ncolors);
816 XpmFreeXpmImage (&xpmimage);
817 XpmFreeXpmInfo (&xpminfo);
821 for (i=0; i<xpmimage.ncolors; i++)
824 /* pick up symbolic colors in preference */
825 if (xpmimage.colorTable[i].symbolic)
827 if (!strcasecmp (xpmimage.colorTable[i].symbolic,"BgColor")
829 !strcasecmp (xpmimage.colorTable[i].symbolic,"None"))
832 colortbl[i]=transparent_color;
834 goto label_found_color;
836 else if (color_symbols)
838 for (j = 0; j<nsymbols; j++)
840 if (!strcmp (xpmimage.colorTable[i].symbolic,
841 color_symbols[j].name ))
843 colortbl[i]=color_symbols[j].color;
844 goto label_found_color;
848 else if (xpmimage.colorTable[i].c_color == 0)
853 /* pick up transparencies */
854 if (!strcasecmp (xpmimage.colorTable[i].c_color,"None"))
857 colortbl[i]=transparent_color;
859 goto label_found_color;
861 /* finally pick up a normal color spec */
862 if (xpmimage.colorTable[i].c_color)
865 mswindows_string_to_color (xpmimage.colorTable[i].c_color);
866 goto label_found_color;
872 XpmFreeXpmImage (&xpmimage);
873 XpmFreeXpmInfo (&xpminfo);
879 /* convert the image */
882 for (i = 0; i< *width * *height; i++)
884 color = colortbl[*sptr++];
886 /* split out the 0x02bbggrr colorref into an rgb triple */
887 *dptr++=GetRValue (color); /* red */
888 *dptr++=GetGValue (color); /* green */
889 *dptr++=GetBValue (color); /* blue */
892 *x_hot=xpminfo.x_hotspot;
893 *y_hot=xpminfo.y_hotspot;
895 XpmFreeXpmImage (&xpmimage);
896 XpmFreeXpmInfo (&xpminfo);
902 mswindows_xpm_instantiate (Lisp_Object image_instance,
903 Lisp_Object instantiator,
904 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
905 int dest_mask, Lisp_Object domain)
907 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
908 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
909 const Extbyte *bytes;
911 unsigned char *eimage;
912 int width, height, x_hot, y_hot;
913 BITMAPINFO* bmp_info;
914 unsigned char* bmp_data;
916 int nsymbols=0, transp;
917 struct color_symbol* color_symbols=NULL;
919 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
920 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
923 CHECK_MSGDI_DEVICE (device);
925 assert (!NILP (data));
927 TO_EXTERNAL_FORMAT (LISP_STRING, data,
928 ALLOCA, (bytes, len),
931 /* in case we have color symbols */
932 color_symbols = extract_xpm_color_names (device, domain,
933 color_symbol_alist, &nsymbols);
935 /* convert to an eimage to make processing easier */
936 if (!xpm_to_eimage (image_instance, bytes, &eimage, &width, &height,
937 &x_hot, &y_hot, &transp, color_symbols, nsymbols))
939 signal_simple_error ("XPM to EImage conversion failed",
947 xfree (color_symbols[nsymbols].name);
949 xfree(color_symbols);
952 /* build a bitmap from the eimage */
953 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage,
954 &bmp_bits, &bmp_data)))
956 signal_simple_error ("XPM to EImage conversion failed",
961 /* Now create the pixmap and set up the image instance */
962 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
963 bmp_data, bmp_bits, 1, instantiator,
964 x_hot, y_hot, transp);
969 #endif /* HAVE_XPM */
971 /**********************************************************************
973 **********************************************************************/
976 bmp_validate (Lisp_Object instantiator)
978 file_or_data_must_be_present (instantiator);
982 bmp_normalize (Lisp_Object inst, Lisp_Object console_type)
984 return simple_image_type_normalize (inst, console_type, Qbmp);
988 bmp_possible_dest_types (void)
990 return IMAGE_COLOR_PIXMAP_MASK;
994 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
995 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
996 int dest_mask, Lisp_Object domain)
998 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
999 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1000 const Extbyte *bytes;
1002 BITMAPFILEHEADER* bmp_file_header;
1003 BITMAPINFO* bmp_info;
1006 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1008 CHECK_MSGDI_DEVICE (device);
1010 assert (!NILP (data));
1012 TO_EXTERNAL_FORMAT (LISP_STRING, data,
1013 ALLOCA, (bytes, len),
1016 /* Then slurp the image into memory, decoding along the way.
1017 The result is the image in a simple one-byte-per-pixel
1020 bmp_file_header=(BITMAPFILEHEADER*)bytes;
1021 bmp_info = (BITMAPINFO*)(bytes + sizeof(BITMAPFILEHEADER));
1022 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
1023 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
1025 /* Now create the pixmap and set up the image instance */
1026 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
1027 bmp_data, bmp_bits, 1, instantiator,
1032 /**********************************************************************
1034 **********************************************************************/
1037 mswindows_resource_validate (Lisp_Object instantiator)
1039 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
1041 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
1043 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
1044 signal_simple_error ("Must supply :file, :resource-id and :resource-type",
1049 mswindows_resource_normalize (Lisp_Object inst, Lisp_Object console_type)
1051 /* This function can call lisp */
1052 Lisp_Object file = Qnil;
1053 struct gcpro gcpro1, gcpro2;
1054 Lisp_Object alist = Qnil;
1056 GCPRO2 (file, alist);
1058 file = potential_pixmap_file_instantiator (inst, Q_file, Q_data,
1061 if (CONSP (file)) /* failure locating filename */
1062 signal_double_file_error ("Opening pixmap file",
1063 "no such file or directory",
1066 if (NILP (file)) /* no conversion necessary */
1067 RETURN_UNGCPRO (inst);
1069 alist = tagged_vector_to_alist (inst);
1072 alist = remassq_no_quit (Q_file, alist);
1073 alist = Fcons (Fcons (Q_file, file), alist);
1077 Lisp_Object result = alist_to_tagged_vector (Qmswindows_resource, alist);
1079 RETURN_UNGCPRO (result);
1084 mswindows_resource_possible_dest_types (void)
1086 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
1096 #define OCR_ICOCUR 32647
1097 #define OIC_SAMPLE 32512
1098 #define OIC_HAND 32513
1099 #define OIC_QUES 32514
1100 #define OIC_BANG 32515
1101 #define OIC_NOTE 32516
1102 #define OIC_WINLOGO 32517
1103 #if defined (__CYGWIN32__) && CYGWIN_VERSION_DLL_MAJOR < 21
1104 #define LR_SHARED 0x8000
1108 static const resource_t bitmap_table[] =
1111 { "close", OBM_CLOSE },
1112 { "uparrow", OBM_UPARROW },
1113 { "dnarrow", OBM_DNARROW },
1114 { "rgarrow", OBM_RGARROW },
1115 { "lfarrow", OBM_LFARROW },
1116 { "reduce", OBM_REDUCE },
1117 { "zoom", OBM_ZOOM },
1118 { "restore", OBM_RESTORE },
1119 { "reduced", OBM_REDUCED },
1120 { "zoomd", OBM_ZOOMD },
1121 { "restored", OBM_RESTORED },
1122 { "uparrowd", OBM_UPARROWD },
1123 { "dnarrowd", OBM_DNARROWD },
1124 { "rgarrowd", OBM_RGARROWD },
1125 { "lfarrowd", OBM_LFARROWD },
1126 { "mnarrow", OBM_MNARROW },
1127 { "combo", OBM_COMBO },
1128 { "uparrowi", OBM_UPARROWI },
1129 { "dnarrowi", OBM_DNARROWI },
1130 { "rgarrowi", OBM_RGARROWI },
1131 { "lfarrowi", OBM_LFARROWI },
1132 { "size", OBM_SIZE },
1133 { "btsize", OBM_BTSIZE },
1134 { "check", OBM_CHECK },
1135 { "checkboxes", OBM_CHECKBOXES },
1136 { "btncorners" , OBM_BTNCORNERS },
1140 static const resource_t cursor_table[] =
1143 { "normal", OCR_NORMAL },
1144 { "ibeam", OCR_IBEAM },
1145 { "wait", OCR_WAIT },
1146 { "cross", OCR_CROSS },
1148 /* { "icon", OCR_ICON }, */
1149 { "sizenwse", OCR_SIZENWSE },
1150 { "sizenesw", OCR_SIZENESW },
1151 { "sizewe", OCR_SIZEWE },
1152 { "sizens", OCR_SIZENS },
1153 { "sizeall", OCR_SIZEALL },
1154 /* { "icour", OCR_ICOCUR }, */
1159 static const resource_t icon_table[] =
1162 { "sample", OIC_SAMPLE },
1163 { "hand", OIC_HAND },
1164 { "ques", OIC_QUES },
1165 { "bang", OIC_BANG },
1166 { "note", OIC_NOTE },
1167 { "winlogo", OIC_WINLOGO },
1171 static int resource_name_to_resource (Lisp_Object name, int type)
1173 const resource_t* res = (type == IMAGE_CURSOR ? cursor_table
1174 : type == IMAGE_ICON ? icon_table
1181 else if (!STRINGP (name))
1183 signal_simple_error ("invalid resource identifier", name);
1188 TO_EXTERNAL_FORMAT (LISP_STRING, name,
1189 C_STRING_ALLOCA, nm,
1191 if (!strcasecmp ((char*)res->name, nm))
1192 return res->resource_id;
1193 } while ((++res)->name);
1198 resource_symbol_to_type (Lisp_Object data)
1200 if (EQ (data, Qcursor))
1201 return IMAGE_CURSOR;
1202 else if (EQ (data, Qicon))
1204 else if (EQ (data, Qbitmap))
1205 return IMAGE_BITMAP;
1211 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1212 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1213 int dest_mask, Lisp_Object domain)
1215 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1216 unsigned int type = 0;
1217 HANDLE himage = NULL;
1219 HINSTANCE hinst = NULL;
1221 enum image_instance_type iitype;
1223 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1225 Lisp_Object file = find_keyword_in_vector (instantiator, Q_file);
1226 Lisp_Object resource_type = find_keyword_in_vector (instantiator,
1228 Lisp_Object resource_id = find_keyword_in_vector (instantiator,
1233 CHECK_MSGDI_DEVICE (device);
1235 type = resource_symbol_to_type (resource_type);
1237 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_CURSOR)
1238 iitype = IMAGE_POINTER;
1239 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
1240 iitype = IMAGE_COLOR_PIXMAP;
1242 incompatible_image_types (instantiator, dest_mask,
1243 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
1245 /* mess with the keyword info we were provided with */
1249 TO_EXTERNAL_FORMAT (LISP_STRING, file,
1253 CYGWIN_WIN32_PATH (f, fname);
1258 if (NILP (resource_id))
1259 resid = (LPCTSTR)fname;
1262 hinst = LoadLibraryEx (fname, NULL,
1263 LOAD_LIBRARY_AS_DATAFILE);
1264 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
1268 TO_EXTERNAL_FORMAT (LISP_STRING, resource_id,
1269 C_STRING_ALLOCA, resid,
1273 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id,
1275 signal_simple_error ("Invalid resource identifier", resource_id);
1277 /* load the image */
1278 if (!(himage = LoadImage (hinst, resid, type, 0, 0,
1279 LR_CREATEDIBSECTION | LR_DEFAULTSIZE |
1281 (!NILP (file) ? LR_LOADFROMFILE : 0))))
1283 signal_simple_error ("Cannot load image", instantiator);
1287 FreeLibrary (hinst);
1289 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype);
1291 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file;
1292 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
1293 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON);
1294 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
1295 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CYCURSOR : SM_CYICON);
1296 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
1298 /* hey, we've got an icon type thing so we can reverse engineer the
1300 if (type != IMAGE_BITMAP)
1302 GetIconInfo ((HICON)himage, &iconinfo);
1303 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = iconinfo.hbmColor;
1304 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = iconinfo.hbmMask;
1305 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), iconinfo.xHotspot);
1306 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), iconinfo.yHotspot);
1307 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = (HICON) himage;
1311 IMAGE_INSTANCE_MSWINDOWS_ICON (ii) = NULL;
1312 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = (HBITMAP) himage;
1313 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
1314 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
1315 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
1320 check_valid_resource_symbol (Lisp_Object data)
1322 CHECK_SYMBOL (data);
1323 if (!resource_symbol_to_type (data))
1324 signal_simple_error ("invalid resource type", data);
1328 check_valid_resource_id (Lisp_Object data)
1330 if (!resource_name_to_resource (data, IMAGE_CURSOR)
1332 !resource_name_to_resource (data, IMAGE_ICON)
1334 !resource_name_to_resource (data, IMAGE_BITMAP))
1335 signal_simple_error ("invalid resource identifier", data);
1338 /**********************************************************************
1340 **********************************************************************/
1341 #ifndef HAVE_X_WINDOWS
1342 /* $XConsortium: RdBitF.c,v 1.10 94/04/17 20:16:13 kaleb Exp $ */
1346 Copyright (c) 1988 X Consortium
1348 Permission is hereby granted, free of charge, to any person obtaining a copy
1349 of this software and associated documentation files (the "Software"), to deal
1350 in the Software without restriction, including without limitation the rights
1351 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1352 copies of the Software, and to permit persons to whom the Software is
1353 furnished to do so, subject to the following conditions:
1355 The above copyright notice and this permission notice shall be included in
1356 all copies or substantial portions of the Software.
1358 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1359 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1360 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1361 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
1362 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1363 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1365 Except as contained in this notice, the name of the X Consortium shall not be
1366 used in advertising or otherwise to promote the sale, use or other dealings
1367 in this Software without prior written authorization from the X Consortium.
1372 * This file contains miscellaneous utility routines and is not part of the
1375 * Public entry points:
1377 * XmuReadBitmapData read data from FILE descriptor
1378 * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files
1381 * Note that this file and ../X/XRdBitF.c look very similar.... Keep them
1382 * that way (but don't use common source code so that people can have one
1383 * without the other).
1388 * Based on an optimized version provided by Jim Becker, August 5, 1988.
1390 #ifndef BitmapSuccess
1391 #define BitmapSuccess 0
1392 #define BitmapOpenFailed 1
1393 #define BitmapFileInvalid 2
1394 #define BitmapNoMemory 3
1396 #define MAX_SIZE 255
1398 /* shared data for the image read/parse logic */
1399 static short hexTable[256]; /* conversion value */
1400 static int initialized = FALSE; /* easier to fill in at run time */
1403 * Table index for the hex values. Initialized once, first time.
1404 * Used for translation value or delimiter significance lookup.
1410 * We build the table at run time for several reasons:
1412 * 1. portable to non-ASCII machines.
1413 * 2. still reentrant since we set the init flag after setting table.
1414 * 3. easier to extend.
1415 * 4. less prone to bugs.
1417 hexTable['0'] = 0; hexTable['1'] = 1;
1418 hexTable['2'] = 2; hexTable['3'] = 3;
1419 hexTable['4'] = 4; hexTable['5'] = 5;
1420 hexTable['6'] = 6; hexTable['7'] = 7;
1421 hexTable['8'] = 8; hexTable['9'] = 9;
1422 hexTable['A'] = 10; hexTable['B'] = 11;
1423 hexTable['C'] = 12; hexTable['D'] = 13;
1424 hexTable['E'] = 14; hexTable['F'] = 15;
1425 hexTable['a'] = 10; hexTable['b'] = 11;
1426 hexTable['c'] = 12; hexTable['d'] = 13;
1427 hexTable['e'] = 14; hexTable['f'] = 15;
1429 /* delimiters of significance are flagged w/ negative value */
1430 hexTable[' '] = -1; hexTable[','] = -1;
1431 hexTable['}'] = -1; hexTable['\n'] = -1;
1432 hexTable['\t'] = -1;
1438 * read next hex value in the input stream, return -1 if EOF
1441 NextInt (FILE *fstream)
1448 /* loop, accumulate hex value until find delimiter */
1449 /* skip any initial delimiters found in read stream */
1457 /* trim high bits, check type and accumulate */
1459 if (isascii(ch) && isxdigit(ch)) {
1460 value = (value << 4) + hexTable[ch];
1462 } else if ((hexTable[ch]) < 0 && gotone)
1471 * The data returned by the following routine is always in left-most byte
1472 * first and left-most bit first. If it doesn't return BitmapSuccess then
1473 * its arguments won't have been touched. This routine should look as much
1474 * like the Xlib routine XReadBitmapfile as possible.
1476 int read_bitmap_data (FILE* fstream, unsigned int *width,
1477 unsigned int *height, unsigned char **datap,
1478 int *x_hot, int *y_hot)
1480 unsigned char *data = NULL; /* working variable */
1481 char line[MAX_SIZE]; /* input line from file */
1482 int size; /* number of bytes of data */
1483 char name_and_type[MAX_SIZE]; /* an input line */
1484 char *type; /* for parsing */
1485 int value; /* from an input line */
1486 int version10p; /* boolean, old format */
1487 int padding; /* to handle alignment */
1488 int bytes_per_line; /* per scanline of data */
1489 unsigned int ww = 0; /* width */
1490 unsigned int hh = 0; /* height */
1491 int hx = -1; /* x hotspot */
1492 int hy = -1; /* y hotspot */
1494 #define Xmalloc(size) malloc(size)
1496 /* first time initialization */
1497 if (initialized == FALSE) initHexTable();
1499 /* error cleanup and return macro */
1500 #define RETURN(code) { if (data) free (data); return code; }
1502 while (fgets(line, MAX_SIZE, fstream)) {
1503 if (strlen(line) == MAX_SIZE-1) {
1504 RETURN (BitmapFileInvalid);
1506 if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
1507 if (!(type = strrchr(name_and_type, '_')))
1508 type = name_and_type;
1512 if (!strcmp("width", type))
1513 ww = (unsigned int) value;
1514 if (!strcmp("height", type))
1515 hh = (unsigned int) value;
1516 if (!strcmp("hot", type)) {
1517 if (type-- == name_and_type || type-- == name_and_type)
1519 if (!strcmp("x_hot", type))
1521 if (!strcmp("y_hot", type))
1527 if (sscanf(line, "static short %s = {", name_and_type) == 1)
1529 else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
1531 else if (sscanf(line, "static char %s = {", name_and_type) == 1)
1536 if (!(type = strrchr(name_and_type, '_')))
1537 type = name_and_type;
1541 if (strcmp("bits[]", type))
1545 RETURN (BitmapFileInvalid);
1547 if ((ww % 16) && ((ww % 16) < 9) && version10p)
1552 bytes_per_line = (ww+7)/8 + padding;
1554 size = bytes_per_line * hh;
1555 data = (unsigned char *) Xmalloc ((unsigned int) size);
1557 RETURN (BitmapNoMemory);
1563 for (bytes=0, ptr=data; bytes<size; (bytes += 2)) {
1564 if ((value = NextInt(fstream)) < 0)
1565 RETURN (BitmapFileInvalid);
1567 if (!padding || ((bytes+2) % bytes_per_line))
1568 *(ptr++) = value >> 8;
1574 for (bytes=0, ptr=data; bytes<size; bytes++, ptr++) {
1575 if ((value = NextInt(fstream)) < 0)
1576 RETURN (BitmapFileInvalid);
1584 RETURN (BitmapFileInvalid);
1591 if (x_hot) *x_hot = hx;
1592 if (y_hot) *y_hot = hy;
1594 RETURN (BitmapSuccess);
1598 int read_bitmap_data_from_file (const char *filename, unsigned int *width,
1599 unsigned int *height, unsigned char **datap,
1600 int *x_hot, int *y_hot)
1605 if ((fstream = fopen (filename, "r")) == NULL) {
1606 return BitmapOpenFailed;
1608 status = read_bitmap_data (fstream, width, height, datap, x_hot, y_hot);
1612 #endif /* HAVE_X_WINDOWS */
1614 /* this table flips four bits around. */
1615 static int flip_table[] =
1617 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
1620 /* the bitmap data comes in the following format: Widths are padded to
1621 a multiple of 8. Scan lines are stored in increasing byte order
1622 from left to right, little-endian within a byte. 0 = white, 1 =
1623 black. It must be converted to the following format: Widths are
1624 padded to a multiple of 16. Scan lines are stored in increasing
1625 byte order from left to right, big-endian within a byte. 0 =
1626 black, 1 = white. */
1628 xbm_create_bitmap_from_data (HDC hdc, char *data,
1629 unsigned int width, unsigned int height,
1630 int mask, COLORREF fg, COLORREF bg)
1632 int old_width = (width + 7)/8;
1633 int new_width = BPLINE (2*((width + 15)/16));
1634 unsigned char *offset;
1636 unsigned char *new_data, *new_offset;
1638 BITMAPINFO *bmp_info =
1639 (BITMAPINFO*) xmalloc_and_zero (sizeof(BITMAPINFO) + sizeof(RGBQUAD));
1645 new_data = (unsigned char *) xmalloc_and_zero (height * new_width);
1653 for (i=0; i<height; i++)
1655 offset = data + i*old_width;
1656 new_offset = new_data + i*new_width;
1658 for (j=0; j<old_width; j++)
1660 int byte = offset[j];
1661 new_offset[j] = ~ (unsigned char)
1662 ((flip_table[byte & 0xf] << 4) + flip_table[byte >> 4]);
1666 /* if we want a mask invert the bits */
1669 new_offset = &new_data[height * new_width];
1670 while (new_offset-- != new_data)
1672 *new_offset ^= 0xff;
1676 bmp_info->bmiHeader.biWidth=width;
1677 bmp_info->bmiHeader.biHeight=-(LONG)height;
1678 bmp_info->bmiHeader.biPlanes=1;
1679 bmp_info->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
1680 bmp_info->bmiHeader.biBitCount=1;
1681 bmp_info->bmiHeader.biCompression=BI_RGB;
1682 bmp_info->bmiHeader.biClrUsed = 2;
1683 bmp_info->bmiHeader.biClrImportant = 2;
1684 bmp_info->bmiHeader.biSizeImage = height * new_width;
1685 bmp_info->bmiColors[0].rgbRed = GetRValue (fg);
1686 bmp_info->bmiColors[0].rgbGreen = GetGValue (fg);
1687 bmp_info->bmiColors[0].rgbBlue = GetBValue (fg);
1688 bmp_info->bmiColors[0].rgbReserved = 0;
1689 bmp_info->bmiColors[1].rgbRed = GetRValue (bg);
1690 bmp_info->bmiColors[1].rgbGreen = GetGValue (bg);
1691 bmp_info->bmiColors[1].rgbBlue = GetBValue (bg);
1692 bmp_info->bmiColors[1].rgbReserved = 0;
1694 bitmap = CreateDIBSection (hdc,
1702 if (!bitmap || !bmp_buf)
1708 /* copy in the actual bitmap */
1709 memcpy (bmp_buf, new_data, height * new_width);
1715 /* Given inline data for a mono pixmap, initialize the given
1716 image instance accordingly. */
1719 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii,
1720 int width, int height,
1721 /* Note that data is in ext-format! */
1723 Lisp_Object instantiator,
1724 Lisp_Object pointer_fg,
1725 Lisp_Object pointer_bg,
1728 Lisp_Object mask_filename)
1730 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1731 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground);
1732 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background);
1733 enum image_instance_type type;
1734 COLORREF black = PALETTERGB (0,0,0);
1735 COLORREF white = PALETTERGB (255,255,255);
1738 CHECK_MSGDI_DEVICE (device);
1740 hdc = get_device_compdc (XDEVICE (device));
1742 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) &&
1743 (dest_mask & IMAGE_COLOR_PIXMAP_MASK))
1745 if (!NILP (foreground) || !NILP (background))
1746 type = IMAGE_COLOR_PIXMAP;
1748 type = IMAGE_MONO_PIXMAP;
1750 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
1751 type = IMAGE_MONO_PIXMAP;
1752 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
1753 type = IMAGE_COLOR_PIXMAP;
1754 else if (dest_mask & IMAGE_POINTER_MASK)
1755 type = IMAGE_POINTER;
1757 incompatible_image_types (instantiator, dest_mask,
1758 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
1759 | IMAGE_POINTER_MASK);
1761 mswindows_initialize_dibitmap_image_instance (ii, 1, type);
1763 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
1764 find_keyword_in_vector (instantiator, Q_file);
1765 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
1766 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
1767 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
1768 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), 0);
1769 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), 0);
1770 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = mask ? mask :
1771 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
1772 TRUE, black, white);
1776 case IMAGE_MONO_PIXMAP:
1777 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
1778 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
1779 FALSE, black, black);
1782 case IMAGE_COLOR_PIXMAP:
1784 COLORREF fg = black;
1785 COLORREF bg = white;
1787 if (!NILP (foreground) && !COLOR_INSTANCEP (foreground))
1789 Fmake_color_instance (foreground, device,
1790 encode_error_behavior_flag (ERROR_ME));
1792 if (COLOR_INSTANCEP (foreground))
1793 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
1795 if (!NILP (background) && !COLOR_INSTANCEP (background))
1797 Fmake_color_instance (background, device,
1798 encode_error_behavior_flag (ERROR_ME));
1800 if (COLOR_INSTANCEP (background))
1801 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
1803 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
1804 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
1806 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
1807 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
1814 COLORREF fg = black;
1815 COLORREF bg = white;
1817 if (NILP (foreground))
1818 foreground = pointer_fg;
1819 if (NILP (background))
1820 background = pointer_bg;
1822 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) =
1823 find_keyword_in_vector (instantiator, Q_hotspot_x);
1824 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) =
1825 find_keyword_in_vector (instantiator, Q_hotspot_y);
1826 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
1827 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
1828 if (COLOR_INSTANCEP (foreground))
1829 fg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (foreground));
1830 if (COLOR_INSTANCEP (background))
1831 bg = COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (background));
1833 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) =
1834 xbm_create_bitmap_from_data (hdc, (Extbyte *) bits, width, height,
1836 mswindows_initialize_image_instance_icon (ii, TRUE);
1846 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
1847 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1848 int dest_mask, int width, int height,
1849 /* Note that data is in ext-format! */
1852 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
1853 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
1854 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1855 HDC hdc = get_device_compdc (XDEVICE (IMAGE_INSTANCE_DEVICE (ii)));
1858 if (!NILP (mask_data))
1860 const char *ext_data;
1862 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
1863 C_STRING_ALLOCA, ext_data,
1865 mask = xbm_create_bitmap_from_data (hdc,
1866 (unsigned char *) ext_data,
1867 XINT (XCAR (mask_data)),
1868 XINT (XCAR (XCDR (mask_data))),
1871 PALETTERGB (255,255,255));
1874 init_image_instance_from_xbm_inline (ii, width, height, bits,
1875 instantiator, pointer_fg, pointer_bg,
1876 dest_mask, mask, mask_file);
1879 /* Instantiate method for XBM's. */
1882 mswindows_xbm_instantiate (Lisp_Object image_instance,
1883 Lisp_Object instantiator,
1884 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1885 int dest_mask, Lisp_Object domain)
1887 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1888 const char *ext_data;
1890 assert (!NILP (data));
1892 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))),
1893 C_STRING_ALLOCA, ext_data,
1896 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
1897 pointer_bg, dest_mask, XINT (XCAR (data)),
1898 XINT (XCAR (XCDR (data))), ext_data);
1902 /**********************************************************************
1904 **********************************************************************/
1906 /* This is about to get redefined! */
1909 /* We have to define SYSV32 so that compface.h includes string.h
1910 instead of strings.h. */
1915 #include <compface.h>
1919 /* JMP_BUF cannot be used here because if it doesn't get defined
1920 to jmp_buf we end up with a conflicting type error with the
1921 definition in compface.h */
1922 extern jmp_buf comp_env;
1926 mswindows_xface_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1927 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1928 int dest_mask, Lisp_Object domain)
1930 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1932 char *p, *bits, *bp;
1933 const char * volatile emsg = 0;
1934 const char * volatile dstring;
1936 assert (!NILP (data));
1938 TO_EXTERNAL_FORMAT (LISP_STRING, data,
1939 C_STRING_ALLOCA, dstring,
1942 if ((p = strchr (dstring, ':')))
1947 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */
1948 if (!(stattis = setjmp (comp_env)))
1950 UnCompAll ((char *) dstring);
1957 emsg = "uncompface: internal error";
1960 emsg = "uncompface: insufficient or invalid data";
1963 emsg = "uncompface: excess data ignored";
1968 signal_simple_error_2 (emsg, data, Qimage);
1970 bp = bits = (char *) alloca (PIXELS / 8);
1972 /* the compface library exports char F[], which uses a single byte per
1973 pixel to represent a 48x48 bitmap. Yuck. */
1974 for (i = 0, p = F; i < (PIXELS / 8); ++i)
1977 /* reverse the bit order of each byte... */
1978 for (b = n = 0; b < 8; ++b)
1985 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
1986 pointer_bg, dest_mask, 48, 48, bits);
1988 #endif /* HAVE_XFACE */
1991 /************************************************************************/
1992 /* image instance methods */
1993 /************************************************************************/
1996 mswindows_print_image_instance (Lisp_Image_Instance *p,
1997 Lisp_Object printcharfun,
2002 switch (IMAGE_INSTANCE_TYPE (p))
2004 case IMAGE_MONO_PIXMAP:
2005 case IMAGE_COLOR_PIXMAP:
2007 sprintf (buf, " (0x%lx",
2008 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
2009 write_c_string (buf, printcharfun);
2010 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
2012 sprintf (buf, "/0x%lx",
2013 (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
2014 write_c_string (buf, printcharfun);
2016 write_c_string (")", printcharfun);
2024 #ifdef DEBUG_WIDGETS
2025 extern int debug_widget_instances;
2029 mswindows_finalize_image_instance (Lisp_Image_Instance *p)
2031 if (DEVICE_LIVE_P (XDEVICE (p->device)))
2033 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET
2035 IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
2037 #ifdef DEBUG_WIDGETS
2038 debug_widget_instances--;
2039 stderr_out ("widget destroyed, %d left\n", debug_widget_instances);
2041 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
2043 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p));
2044 DestroyWindow (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p));
2045 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0;
2051 if (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p))
2052 disable_glyph_animated_timeout (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p));
2054 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p))
2056 for (i = 0; i < IMAGE_INSTANCE_PIXMAP_MAXSLICE (p); i++)
2058 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i))
2059 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i));
2060 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i) = 0;
2062 xfree (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p));
2063 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p) = 0;
2065 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
2066 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p));
2067 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0;
2068 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p))
2069 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p));
2070 IMAGE_INSTANCE_MSWINDOWS_ICON (p) = 0;
2081 /************************************************************************/
2082 /* subwindow and widget support */
2083 /************************************************************************/
2086 mswindows_widget_hfont (Lisp_Image_Instance *p,
2089 Lisp_Object face = IMAGE_INSTANCE_WIDGET_FACE (p);
2090 int under = FACE_UNDERLINE_P (face, domain);
2091 int strike = FACE_STRIKETHRU_P (face, domain);
2092 Lisp_Object font = query_string_font (IMAGE_INSTANCE_WIDGET_TEXT (p),
2095 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike);
2098 /* unmap the image if it is a widget. This is used by redisplay via
2099 redisplay_unmap_subwindows */
2101 mswindows_unmap_subwindow (Lisp_Image_Instance *p)
2103 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
2105 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2108 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE
2109 | SWP_NOSENDCHANGING);
2110 if (GetFocus() == WIDGET_INSTANCE_MSWINDOWS_HANDLE (p))
2111 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p)));
2115 /* map the subwindow. This is used by redisplay via
2116 redisplay_output_subwindow */
2118 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y,
2119 struct display_glyph_area* dga)
2121 /* move the window before mapping it ... */
2122 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2124 x, y, dga->width, dga->height,
2126 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2127 /* ... adjust the child ... */
2128 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2130 -dga->xoffset, -dga->yoffset, 0, 0,
2131 SWP_NOZORDER | SWP_NOSIZE
2132 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2133 /* ... now map it - we are not allowed to move it at the same time. */
2134 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2137 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE
2138 | SWP_SHOWWINDOW | SWP_NOCOPYBITS
2139 | SWP_NOSENDCHANGING);
2142 /* resize the subwindow instance */
2144 mswindows_resize_subwindow (Lisp_Image_Instance* ii, int w, int h)
2146 /* Set the size of the control .... */
2147 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2150 SWP_NOZORDER | SWP_NOMOVE
2151 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2154 /* Simply resize the window here. */
2156 mswindows_update_subwindow (Lisp_Image_Instance *p)
2158 mswindows_resize_subwindow (p,
2159 IMAGE_INSTANCE_WIDTH (p),
2160 IMAGE_INSTANCE_HEIGHT (p));
2163 /* when you click on a widget you may activate another widget this
2164 needs to be checked and all appropriate widgets updated */
2166 mswindows_update_widget (Lisp_Image_Instance *p)
2168 /* Possibly update the face font and colors. */
2169 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p))
2171 /* set the widget font from the widget face */
2172 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2174 (WPARAM) mswindows_widget_hfont
2175 (p, IMAGE_INSTANCE_SUBWINDOW_FRAME (p)),
2176 MAKELPARAM (TRUE, 0));
2178 /* Possibly update the dimensions. */
2179 if (IMAGE_INSTANCE_SIZE_CHANGED (p))
2181 mswindows_resize_subwindow (p,
2182 IMAGE_INSTANCE_WIDTH (p),
2183 IMAGE_INSTANCE_HEIGHT (p));
2185 /* Possibly update the text in the widget. */
2186 if (IMAGE_INSTANCE_TEXT_CHANGED (p))
2189 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (p),
2190 C_STRING_ALLOCA, lparam,
2192 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2193 WM_SETTEXT, 0, (LPARAM)lparam);
2197 /* register widgets into our hastable so that we can cope with the
2198 callbacks. The hashtable is weak so deregistration is handled
2201 mswindows_register_gui_item (Lisp_Object gui, Lisp_Object domain)
2203 Lisp_Object frame = FW_FRAME (domain);
2204 struct frame* f = XFRAME (frame);
2205 int id = gui_item_id_hash (FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f),
2208 Fputhash (make_int (id),
2209 XGUI_ITEM (gui)->callback,
2210 FRAME_MSWINDOWS_WIDGET_HASH_TABLE (f));
2215 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain)
2217 return mswindows_register_gui_item (XIMAGE_INSTANCE_WIDGET_ITEM (instance),
2222 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2223 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2224 int dest_mask, Lisp_Object domain)
2226 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2227 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
2228 Lisp_Object frame = FW_FRAME (domain);
2231 CHECK_MSWINDOWS_DEVICE (device);
2233 /* have to set the type this late in case there is no device
2234 instantiation for a widget */
2235 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
2236 /* Allocate space for the clip window */
2237 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
2239 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
2242 XEMACS_CONTROL_CLASS,
2244 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
2245 0, /* starting x position */
2246 0, /* starting y position */
2247 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2248 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2250 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2252 NULL, /* must be null for this class */
2254 signal_simple_error ("window creation failed with code",
2255 make_int (GetLastError()));
2257 wnd = CreateWindow( "STATIC",
2260 0, /* starting x position */
2261 0, /* starting y position */
2262 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2263 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2264 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii),
2267 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2271 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
2272 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
2276 mswindows_image_instance_equal (Lisp_Image_Instance *p1,
2277 Lisp_Image_Instance *p2, int depth)
2279 switch (IMAGE_INSTANCE_TYPE (p1))
2281 case IMAGE_MONO_PIXMAP:
2282 case IMAGE_COLOR_PIXMAP:
2284 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p1)
2285 != IMAGE_INSTANCE_MSWINDOWS_BITMAP (p2))
2296 static unsigned long
2297 mswindows_image_instance_hash (Lisp_Image_Instance *p, int depth)
2299 switch (IMAGE_INSTANCE_TYPE (p))
2301 case IMAGE_MONO_PIXMAP:
2302 case IMAGE_COLOR_PIXMAP:
2304 return (unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p);
2311 /* Set all the slots in an image instance structure to reasonable
2312 default values. This is used somewhere within an instantiate
2313 method. It is assumed that the device slot within the image
2314 instance is already set -- this is the case when instantiate
2315 methods are called. */
2318 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii,
2320 enum image_instance_type type)
2322 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
2323 IMAGE_INSTANCE_TYPE (ii) = type;
2324 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
2325 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
2326 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
2327 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
2328 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
2329 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
2330 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices;
2331 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (ii) =
2332 xnew_array_and_zero (HBITMAP, slices);
2338 /************************************************************************/
2340 /************************************************************************/
2342 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2343 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2344 int dest_mask, Lisp_Object domain,
2345 const char* class, int flags, int exflags)
2347 /* this function can call lisp */
2348 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2349 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style;
2350 Lisp_Object frame = FW_FRAME (domain);
2354 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2355 Lisp_Gui_Item* pgui = XGUI_ITEM (gui);
2357 CHECK_MSWINDOWS_DEVICE (device);
2359 if (!gui_item_active_p (gui))
2360 flags |= WS_DISABLED;
2362 style = pgui->style;
2364 if (!NILP (pgui->callback))
2366 id = mswindows_register_widget_instance (image_instance, domain);
2369 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
2370 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (ii),
2371 C_STRING_ALLOCA, nm,
2374 /* allocate space for the clip window and then allocate the clip window */
2375 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
2377 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
2379 WS_EX_CONTROLPARENT, /* EX flags */
2380 XEMACS_CONTROL_CLASS,
2382 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
2383 0, /* starting x position */
2384 0, /* starting y position */
2385 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2386 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2388 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2389 (HMENU)id, /* No menu */
2390 NULL, /* must be null for this class */
2392 signal_simple_error ("window creation failed with code",
2393 make_int (GetLastError()));
2395 if ((wnd = CreateWindowEx(
2396 exflags /* | WS_EX_NOPARENTNOTIFY*/,
2399 flags | WS_CHILD | WS_VISIBLE,
2400 0, /* starting x position */
2401 0, /* starting y position */
2402 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2403 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2405 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii),
2406 (HMENU)id, /* No menu */
2409 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2412 signal_simple_error ("window creation failed with code",
2413 make_int (GetLastError()));
2415 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
2416 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
2417 /* set the widget font from the widget face */
2418 SendMessage (wnd, WM_SETFONT,
2419 (WPARAM) mswindows_widget_hfont (ii, domain),
2420 MAKELPARAM (TRUE, 0));
2423 /* Instantiate a button widget. Unfortunately instantiated widgets are
2424 particular to a frame since they need to have a parent. It's not
2425 like images where you just select the image into the context you
2426 want to display it in and BitBlt it. So image instances can have a
2427 many-to-one relationship with things you see, whereas widgets can
2428 only be one-to-one (i.e. per frame) */
2430 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2431 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2432 int dest_mask, Lisp_Object domain)
2434 /* This function can call lisp */
2435 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2437 int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback
2438 only. Since we seem to want nothing beyond BN_CLICK,
2439 the style is perhaps not necessary -- kkm */
2441 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2442 Lisp_Gui_Item* pgui = XGUI_ITEM (gui);
2443 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
2447 if (!IMAGE_INSTANCEP (glyph))
2448 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1);
2450 if (IMAGE_INSTANCEP (glyph))
2451 flags |= XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
2452 BS_BITMAP : BS_ICON;
2455 style = pgui->style;
2457 /* #### consider using the default face for radio and toggle
2459 if (EQ (style, Qradio))
2461 flags |= BS_RADIOBUTTON;
2463 else if (EQ (style, Qtoggle))
2465 flags |= BS_AUTOCHECKBOX;
2469 flags |= BS_DEFPUSHBUTTON;
2472 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2473 pointer_bg, dest_mask, domain, "BUTTON",
2476 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2477 /* set the checked state */
2478 if (gui_item_selected_p (gui))
2479 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
2481 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
2482 /* add the image if one was given */
2483 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)
2485 IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph)))
2487 SendMessage (wnd, BM_SETIMAGE,
2488 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
2489 IMAGE_BITMAP : IMAGE_ICON),
2490 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
2491 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) :
2492 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph)));
2496 /* Update the state of a button. */
2498 mswindows_button_update (Lisp_Object image_instance)
2500 /* This function can GC if IN_REDISPLAY is false. */
2501 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2503 /* buttons checked or otherwise */
2504 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (ii)))
2505 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2506 BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
2508 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2509 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
2512 /* instantiate an edit control */
2514 mswindows_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2515 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2516 int dest_mask, Lisp_Object domain)
2518 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2519 pointer_bg, dest_mask, domain, "EDIT",
2520 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP
2521 | WS_BORDER, WS_EX_CLIENTEDGE);
2524 /* instantiate a progress gauge */
2526 mswindows_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2527 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2528 int dest_mask, Lisp_Object domain)
2531 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2532 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2533 pointer_bg, dest_mask, domain, PROGRESS_CLASS,
2534 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE);
2535 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2536 /* set the colors */
2537 #ifdef PBS_SETBKCOLOR
2538 SendMessage (wnd, PBS_SETBKCOLOR, 0,
2539 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR
2542 (XIMAGE_INSTANCE_WIDGET_FACE (ii),
2543 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii))))));
2545 #ifdef PBS_SETBARCOLOR
2546 SendMessage (wnd, PBS_SETBARCOLOR, 0,
2547 (L:PARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR
2550 (XIMAGE_INSTANCE_WIDGET_FACE (ii),
2551 XIMAGE_INSTANCE_SUBWINDOW_FRAME (ii))))));
2555 /* instantiate a tree view widget */
2556 static HTREEITEM add_tree_item (Lisp_Object image_instance,
2557 HWND wnd, HTREEITEM parent, Lisp_Object item,
2558 int children, Lisp_Object domain)
2560 TV_INSERTSTRUCT tvitem;
2563 tvitem.hParent = parent;
2564 tvitem.hInsertAfter = TVI_LAST;
2565 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN;
2566 tvitem.item.cChildren = children;
2568 if (GUI_ITEMP (item))
2570 tvitem.item.lParam = mswindows_register_gui_item (item, domain);
2571 tvitem.item.mask |= TVIF_PARAM;
2572 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
2573 C_STRING_ALLOCA, tvitem.item.pszText,
2577 TO_EXTERNAL_FORMAT (LISP_STRING, item,
2578 C_STRING_ALLOCA, tvitem.item.pszText,
2581 tvitem.item.cchTextMax = strlen (tvitem.item.pszText);
2583 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM,
2584 0, (LPARAM)&tvitem)) == 0)
2585 signal_simple_error ("error adding tree view entry", item);
2590 static void add_tree_item_list (Lisp_Object image_instance,
2591 HWND wnd, HTREEITEM parent, Lisp_Object list,
2596 /* get the first item */
2597 parent = add_tree_item (image_instance, wnd, parent, XCAR (list), TRUE, domain);
2598 /* recursively add items to the tree view */
2599 LIST_LOOP (rest, XCDR (list))
2601 if (LISTP (XCAR (rest)))
2602 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain);
2604 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain);
2609 mswindows_tree_view_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2610 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2611 int dest_mask, Lisp_Object domain)
2616 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2617 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2618 pointer_bg, dest_mask, domain, WC_TREEVIEW,
2619 WS_TABSTOP | WS_BORDER | PBS_SMOOTH
2620 | TVS_HASLINES | TVS_HASBUTTONS,
2623 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2626 parent = add_tree_item (image_instance, wnd, NULL,
2627 XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)),
2630 /* recursively add items to the tree view */
2631 /* add items to the tab */
2632 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2634 if (LISTP (XCAR (rest)))
2635 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain);
2637 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain);
2641 /* instantiate a tab control */
2642 static TC_ITEM* add_tab_item (Lisp_Object image_instance,
2643 HWND wnd, Lisp_Object item,
2644 Lisp_Object domain, int i)
2646 TC_ITEM tvitem, *ret;
2648 tvitem.mask = TCIF_TEXT;
2650 if (GUI_ITEMP (item))
2652 tvitem.lParam = mswindows_register_gui_item (item, domain);
2653 tvitem.mask |= TCIF_PARAM;
2654 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
2655 C_STRING_ALLOCA, tvitem.pszText,
2660 CHECK_STRING (item);
2661 TO_EXTERNAL_FORMAT (LISP_STRING, item,
2662 C_STRING_ALLOCA, tvitem.pszText,
2666 tvitem.cchTextMax = strlen (tvitem.pszText);
2668 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM,
2669 i, (LPARAM)&tvitem)) < 0)
2670 signal_simple_error ("error adding tab entry", item);
2676 mswindows_tab_control_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2677 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2678 int dest_mask, Lisp_Object domain)
2680 /* This function can call lisp */
2683 int i = 0, selected = 0;
2684 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2685 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
2686 unsigned int flags = WS_TABSTOP;
2688 if (EQ (orient, Qleft) || EQ (orient, Qright))
2690 flags |= TCS_VERTICAL | TCS_MULTILINE;
2692 if (EQ (orient, Qright) || EQ (orient, Qbottom))
2694 flags |= TCS_BOTTOM;
2697 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2698 pointer_bg, dest_mask, domain, WC_TABCONTROL,
2699 /* borders don't suit tabs so well */
2701 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2702 /* add items to the tab */
2703 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2705 add_tab_item (image_instance, wnd, XCAR (rest), domain, i);
2706 if (gui_item_selected_p (XCAR (rest)))
2710 SendMessage (wnd, TCM_SETCURSEL, selected, 0);
2713 /* set the properties of a tab control */
2715 mswindows_tab_control_update (Lisp_Object image_instance)
2717 /* This function can GC if IN_REDISPLAY is false. */
2718 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2720 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
2722 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2723 int i = 0, selected = 0;
2726 /* delete the pre-existing items */
2727 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0);
2729 /* Pick up the items we recorded earlier. We do this here so
2730 that the callbacks get set up with the new items. */
2731 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
2732 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii);
2733 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
2734 /* add items to the tab */
2735 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2737 add_tab_item (image_instance, wnd, XCAR (rest),
2738 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii), i);
2739 if (gui_item_selected_p (XCAR (rest)))
2743 SendMessage (wnd, TCM_SETCURSEL, selected, 0);
2747 /* instantiate a static control possible for putting other things in */
2749 mswindows_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2750 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2751 int dest_mask, Lisp_Object domain)
2753 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2754 pointer_bg, dest_mask, domain, "STATIC",
2755 0, WS_EX_STATICEDGE);
2758 /* instantiate a scrollbar control */
2760 mswindows_scrollbar_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2761 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2762 int dest_mask, Lisp_Object domain)
2764 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2765 pointer_bg, dest_mask, domain, "SCROLLBAR",
2766 WS_TABSTOP, WS_EX_CLIENTEDGE);
2769 /* instantiate a combo control */
2771 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2772 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2773 int dest_mask, Lisp_Object domain)
2775 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2778 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties),
2782 /* Maybe ought to generalise this more but it may be very windows
2783 specific. In windows the window height of a combo box is the
2784 height when the combo box is open. Thus we need to set the height
2785 before creating the window and then reset it to a single line
2786 after the window is created so that redisplay does the right
2788 widget_instantiate (image_instance, instantiator, pointer_fg,
2789 pointer_bg, dest_mask, domain);
2791 /* We now have everything right apart from the height. */
2792 default_face_font_info (domain, 0, 0, &height, 0, 0);
2793 GET_LIST_LENGTH (data, len);
2795 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len;
2796 IMAGE_INSTANCE_HEIGHT (ii) = height;
2798 /* Now create the widget. */
2799 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2800 pointer_bg, dest_mask, domain, "COMBOBOX",
2801 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN
2803 | CBS_HASSTRINGS | WS_VSCROLL,
2805 /* Reset the height. layout will probably do this safely, but better make sure. */
2806 image_instance_layout (image_instance,
2807 IMAGE_UNSPECIFIED_GEOMETRY,
2808 IMAGE_UNSPECIFIED_GEOMETRY,
2811 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2812 /* add items to the combo box */
2813 SendMessage (wnd, CB_RESETCONTENT, 0, 0);
2814 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil))
2817 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest),
2818 C_STRING_ALLOCA, lparam,
2820 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR)
2821 signal_simple_error ("error adding combo entries", instantiator);
2825 /* get properties of a control */
2827 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop)
2829 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2830 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2831 /* get the text from a control */
2832 if (EQ (prop, Q_text))
2834 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0);
2835 Extbyte *buf = (Extbyte*) alloca (len+1);
2837 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf);
2838 return build_ext_string (buf, Qnative);
2843 /* get properties of a button */
2845 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop)
2847 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2848 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2849 /* check the state of a button */
2850 if (EQ (prop, Q_selected))
2852 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED)
2860 /* get properties of a combo box */
2862 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop)
2864 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2865 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2866 /* get the text from a control */
2867 if (EQ (prop, Q_text))
2869 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0);
2870 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0);
2871 Extbyte* buf = (Extbyte*) alloca (len+1);
2872 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf);
2873 return build_ext_string (buf, Qnative);
2878 /* set the properties of a progres guage */
2880 mswindows_progress_gauge_update (Lisp_Object image_instance)
2882 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2884 if (IMAGE_INSTANCE_WIDGET_PERCENT_CHANGED (ii))
2886 /* #### I'm not convinced we should store this in the plist. */
2887 Lisp_Object val = Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii),
2890 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2891 PBM_SETPOS, (WPARAM)XINT (val), 0);
2896 mswindows_control_wnd_proc (HWND hwnd, UINT msg,
2897 WPARAM wParam, LPARAM lParam)
2903 case WM_CTLCOLORBTN:
2904 case WM_CTLCOLORLISTBOX:
2905 case WM_CTLCOLOREDIT:
2906 case WM_CTLCOLORSTATIC:
2907 case WM_CTLCOLORSCROLLBAR:
2909 return mswindows_wnd_proc (GetParent (hwnd), msg, wParam, lParam);
2911 return DefWindowProc (hwnd, msg, wParam, lParam);
2915 #endif /* HAVE_WIDGETS */
2918 /************************************************************************/
2919 /* initialization */
2920 /************************************************************************/
2923 syms_of_glyphs_mswindows (void)
2925 defkeyword (&Q_resource_id, ":resource-id");
2926 defkeyword (&Q_resource_type, ":resource-type");
2930 console_type_create_glyphs_mswindows (void)
2932 /* image methods - display */
2933 CONSOLE_HAS_METHOD (mswindows, print_image_instance);
2934 CONSOLE_HAS_METHOD (mswindows, finalize_image_instance);
2935 CONSOLE_HAS_METHOD (mswindows, unmap_subwindow);
2936 CONSOLE_HAS_METHOD (mswindows, map_subwindow);
2937 CONSOLE_HAS_METHOD (mswindows, update_subwindow);
2938 CONSOLE_HAS_METHOD (mswindows, resize_subwindow);
2939 CONSOLE_HAS_METHOD (mswindows, update_widget);
2940 CONSOLE_HAS_METHOD (mswindows, image_instance_equal);
2941 CONSOLE_HAS_METHOD (mswindows, image_instance_hash);
2942 CONSOLE_HAS_METHOD (mswindows, init_image_instance_from_eimage);
2943 CONSOLE_HAS_METHOD (mswindows, locate_pixmap_file);
2945 /* image methods - printer */
2946 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_image_instance);
2947 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_image_instance);
2948 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_equal);
2949 CONSOLE_INHERITS_METHOD (msprinter, mswindows, image_instance_hash);
2950 CONSOLE_INHERITS_METHOD (msprinter, mswindows, init_image_instance_from_eimage);
2951 CONSOLE_INHERITS_METHOD (msprinter, mswindows, locate_pixmap_file);
2955 image_instantiator_format_create_glyphs_mswindows (void)
2957 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, nothing);
2958 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, string);
2959 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, layout);
2960 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, formatted_string);
2961 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, inherit);
2962 /* image-instantiator types */
2963 INITIALIZE_DEVICE_IIFORMAT (mswindows, xbm);
2964 INITIALIZE_DEVICE_IIFORMAT (msprinter, xbm);
2965 IIFORMAT_HAS_DEVMETHOD (mswindows, xbm, instantiate);
2966 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xbm, instantiate);
2968 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm);
2969 INITIALIZE_DEVICE_IIFORMAT (msprinter, xpm);
2970 IIFORMAT_HAS_DEVMETHOD (mswindows, xpm, instantiate);
2971 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xpm, instantiate);
2974 INITIALIZE_DEVICE_IIFORMAT (mswindows, xface);
2975 INITIALIZE_DEVICE_IIFORMAT (msprinter, xface);
2976 IIFORMAT_HAS_DEVMETHOD (mswindows, xface, instantiate);
2977 IIFORMAT_INHERITS_DEVMETHOD (msprinter, mswindows, xface, instantiate);
2980 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, jpeg);
2983 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, tiff);
2986 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, png);
2989 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, gif);
2993 INITIALIZE_DEVICE_IIFORMAT (mswindows, button);
2994 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property);
2995 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate);
2996 IIFORMAT_HAS_DEVMETHOD (mswindows, button, update);
2998 INITIALIZE_DEVICE_IIFORMAT (mswindows, edit_field);
2999 IIFORMAT_HAS_DEVMETHOD (mswindows, edit_field, instantiate);
3001 INITIALIZE_DEVICE_IIFORMAT (mswindows, subwindow);
3002 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate);
3004 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget);
3005 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property);
3008 INITIALIZE_DEVICE_IIFORMAT (mswindows, label);
3009 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate);
3012 INITIALIZE_DEVICE_IIFORMAT (mswindows, combo_box);
3013 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, property);
3014 IIFORMAT_HAS_DEVMETHOD (mswindows, combo_box, instantiate);
3017 INITIALIZE_DEVICE_IIFORMAT (mswindows, scrollbar);
3018 IIFORMAT_HAS_DEVMETHOD (mswindows, scrollbar, instantiate);
3020 /* progress gauge */
3021 INITIALIZE_DEVICE_IIFORMAT (mswindows, progress_gauge);
3022 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, update);
3023 IIFORMAT_HAS_DEVMETHOD (mswindows, progress_gauge, instantiate);
3025 /* tree view widget */
3026 INITIALIZE_DEVICE_IIFORMAT (mswindows, tree_view);
3027 /* IIFORMAT_HAS_DEVMETHOD (mswindows, progress, set_property);*/
3028 IIFORMAT_HAS_DEVMETHOD (mswindows, tree_view, instantiate);
3030 /* tab control widget */
3031 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control);
3032 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate);
3033 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, update);
3035 /* windows bitmap format */
3036 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
3037 IIFORMAT_HAS_METHOD (bmp, validate);
3038 IIFORMAT_HAS_METHOD (bmp, normalize);
3039 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);
3040 IIFORMAT_HAS_METHOD (bmp, instantiate);
3042 IIFORMAT_VALID_KEYWORD (bmp, Q_data, check_valid_string);
3043 IIFORMAT_VALID_KEYWORD (bmp, Q_file, check_valid_string);
3044 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, bmp);
3046 /* mswindows resources */
3047 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource,
3048 "mswindows-resource");
3050 IIFORMAT_HAS_METHOD (mswindows_resource, validate);
3051 IIFORMAT_HAS_METHOD (mswindows_resource, normalize);
3052 IIFORMAT_HAS_METHOD (mswindows_resource, possible_dest_types);
3053 IIFORMAT_HAS_METHOD (mswindows_resource, instantiate);
3055 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_type,
3056 check_valid_resource_symbol);
3057 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_resource_id, check_valid_resource_id);
3058 IIFORMAT_VALID_KEYWORD (mswindows_resource, Q_file, check_valid_string);
3059 IIFORMAT_VALID_CONSOLE2 (mswindows, msprinter, mswindows_resource);
3063 vars_of_glyphs_mswindows (void)
3065 DEFVAR_LISP ("mswindows-bitmap-file-path", &Vmswindows_bitmap_file_path /*
3066 A list of the directories in which mswindows bitmap files may be found.
3067 This is used by the `make-image-instance' function.
3069 Vmswindows_bitmap_file_path = Qnil;
3073 complex_vars_of_glyphs_mswindows (void)