Mercurial > hg > xemacs-beta
comparison src/glyphs-msw.c @ 440:8de8e3f6228a r21-2-28
Import from CVS: tag r21-2-28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:33:38 +0200 |
parents | 84b14dcb0985 |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
439:357dd071b03c | 440:8de8e3f6228a |
---|---|
96 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource); | 96 DEFINE_IMAGE_INSTANTIATOR_FORMAT (mswindows_resource); |
97 Lisp_Object Q_resource_type, Q_resource_id; | 97 Lisp_Object Q_resource_type, Q_resource_id; |
98 Lisp_Object Qmswindows_resource; | 98 Lisp_Object Qmswindows_resource; |
99 | 99 |
100 static void | 100 static void |
101 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii, | 101 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, |
102 int slices, | 102 int slices, |
103 enum image_instance_type type); | 103 enum image_instance_type type); |
104 static void | 104 static void |
105 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image, | 105 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, |
106 struct frame* f); | 106 struct frame* f); |
107 | |
108 COLORREF mswindows_string_to_color (CONST char *name); | |
109 | 107 |
110 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) | 108 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) |
111 | 109 |
112 /************************************************************************/ | 110 /************************************************************************/ |
113 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ | 111 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ |
257 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) || | 255 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 1)) || |
258 (XSTRING_BYTE (name, 1) == '.' && | 256 (XSTRING_BYTE (name, 1) == '.' && |
259 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2))))))) | 257 (IS_DIRECTORY_SEP(XSTRING_BYTE (name, 2))))))) |
260 { | 258 { |
261 if (!NILP (Ffile_readable_p (name))) | 259 if (!NILP (Ffile_readable_p (name))) |
262 return name; | 260 return Fexpand_file_name (name, Qnil); |
263 else | 261 else |
264 return Qnil; | 262 return Qnil; |
265 } | 263 } |
266 | 264 |
267 if (locate_file (Vmswindows_bitmap_file_path, name, Qnil, &found, R_OK) < 0) | 265 if (locate_file (Vmswindows_bitmap_file_path, name, Qnil, &found, R_OK) < 0) |
284 | 282 |
285 If this fails, signal an error. INSTANTIATOR is only used | 283 If this fails, signal an error. INSTANTIATOR is only used |
286 in the error message. */ | 284 in the error message. */ |
287 | 285 |
288 static void | 286 static void |
289 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii, | 287 init_image_instance_from_dibitmap (Lisp_Image_Instance *ii, |
290 BITMAPINFO *bmp_info, | 288 BITMAPINFO *bmp_info, |
291 int dest_mask, | 289 int dest_mask, |
292 void *bmp_data, | 290 void *bmp_data, |
293 int bmp_bits, | 291 int bmp_bits, |
294 int slices, | 292 int slices, |
358 mswindows_initialize_image_instance_icon(ii, TRUE); | 356 mswindows_initialize_image_instance_icon(ii, TRUE); |
359 } | 357 } |
360 } | 358 } |
361 | 359 |
362 static void | 360 static void |
363 image_instance_add_dibitmap (struct Lisp_Image_Instance *ii, | 361 image_instance_add_dibitmap (Lisp_Image_Instance *ii, |
364 BITMAPINFO *bmp_info, | 362 BITMAPINFO *bmp_info, |
365 void *bmp_data, | 363 void *bmp_data, |
366 int bmp_bits, | 364 int bmp_bits, |
367 int slice, | 365 int slice, |
368 Lisp_Object instantiator) | 366 Lisp_Object instantiator) |
385 memcpy (bmp_buf, bmp_data, bmp_bits); | 383 memcpy (bmp_buf, bmp_data, bmp_bits); |
386 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap; | 384 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap; |
387 } | 385 } |
388 | 386 |
389 static void | 387 static void |
390 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii, | 388 mswindows_init_image_instance_from_eimage (Lisp_Image_Instance *ii, |
391 int width, int height, | 389 int width, int height, |
392 int slices, | 390 int slices, |
393 unsigned char *eimage, | 391 unsigned char *eimage, |
394 int dest_mask, | 392 int dest_mask, |
395 Lisp_Object instantiator, | 393 Lisp_Object instantiator, |
452 else /* Turn it off */ | 450 else /* Turn it off */ |
453 bits[i] &= ~(1<<bitnum); | 451 bits[i] &= ~(1<<bitnum); |
454 } | 452 } |
455 | 453 |
456 static void | 454 static void |
457 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image, | 455 mswindows_initialize_image_instance_mask (Lisp_Image_Instance* image, |
458 struct frame* f) | 456 struct frame* f) |
459 { | 457 { |
460 HBITMAP mask; | 458 HBITMAP mask; |
461 HGDIOBJ old = NULL; | 459 HGDIOBJ old = NULL; |
462 HDC hcdc = FRAME_MSWINDOWS_CDC (f); | 460 HDC hcdc = FRAME_MSWINDOWS_CDC (f); |
563 | 561 |
564 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; | 562 IMAGE_INSTANCE_MSWINDOWS_MASK (image) = mask; |
565 } | 563 } |
566 | 564 |
567 void | 565 void |
568 mswindows_initialize_image_instance_icon (struct Lisp_Image_Instance* image, | 566 mswindows_initialize_image_instance_icon (Lisp_Image_Instance* image, |
569 int cursor) | 567 int cursor) |
570 { | 568 { |
571 ICONINFO x_icon; | 569 ICONINFO x_icon; |
572 | 570 |
573 /* we rely on windows to do any resizing necessary */ | 571 /* we rely on windows to do any resizing necessary */ |
580 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= | 578 IMAGE_INSTANCE_MSWINDOWS_ICON (image)= |
581 CreateIconIndirect (&x_icon); | 579 CreateIconIndirect (&x_icon); |
582 } | 580 } |
583 | 581 |
584 HBITMAP | 582 HBITMAP |
585 mswindows_create_resized_bitmap (struct Lisp_Image_Instance* ii, | 583 mswindows_create_resized_bitmap (Lisp_Image_Instance* ii, |
586 struct frame* f, | 584 struct frame* f, |
587 int newx, int newy) | 585 int newx, int newy) |
588 { | 586 { |
589 HBITMAP newbmp; | 587 HBITMAP newbmp; |
590 HGDIOBJ old1, old2; | 588 HGDIOBJ old1, old2; |
614 | 612 |
615 return newbmp; | 613 return newbmp; |
616 } | 614 } |
617 | 615 |
618 HBITMAP | 616 HBITMAP |
619 mswindows_create_resized_mask (struct Lisp_Image_Instance* ii, | 617 mswindows_create_resized_mask (Lisp_Image_Instance* ii, |
620 struct frame* f, | 618 struct frame* f, |
621 int newx, int newy) | 619 int newx, int newy) |
622 { | 620 { |
623 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) | 621 if (IMAGE_INSTANCE_MSWINDOWS_MASK (ii)) |
624 { | 622 { |
652 | 650 |
653 return NULL; | 651 return NULL; |
654 } | 652 } |
655 | 653 |
656 int | 654 int |
657 mswindows_resize_dibitmap_instance (struct Lisp_Image_Instance* ii, | 655 mswindows_resize_dibitmap_instance (Lisp_Image_Instance* ii, |
658 struct frame* f, | 656 struct frame* f, |
659 int newx, int newy) | 657 int newx, int newy) |
660 { | 658 { |
661 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy); | 659 HBITMAP newbmp = mswindows_create_resized_bitmap (ii, f, newx, newy); |
662 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy); | 660 HBITMAP newmask = mswindows_create_resized_mask (ii, f, newx, newy); |
740 { | 738 { |
741 Lisp_Object cons = XCAR (results); | 739 Lisp_Object cons = XCAR (results); |
742 colortbl[j].color = | 740 colortbl[j].color = |
743 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons))); | 741 COLOR_INSTANCE_MSWINDOWS_COLOR (XCOLOR_INSTANCE (XCDR (cons))); |
744 | 742 |
745 GET_C_STRING_OS_DATA_ALLOCA (XCAR (cons), colortbl[j].name); | 743 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (cons), |
744 C_STRING_ALLOCA, colortbl[j].name, | |
745 Qnative); | |
746 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */ | 746 colortbl[j].name = xstrdup (colortbl[j].name); /* mustn't lose this when we return */ |
747 free_cons (XCONS (cons)); | 747 free_cons (XCONS (cons)); |
748 cons = results; | 748 cons = results; |
749 results = XCDR (results); | 749 results = XCDR (results); |
750 free_cons (XCONS (cons)); | 750 free_cons (XCONS (cons)); |
904 mswindows_xpm_instantiate (Lisp_Object image_instance, | 904 mswindows_xpm_instantiate (Lisp_Object image_instance, |
905 Lisp_Object instantiator, | 905 Lisp_Object instantiator, |
906 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 906 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
907 int dest_mask, Lisp_Object domain) | 907 int dest_mask, Lisp_Object domain) |
908 { | 908 { |
909 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 909 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
910 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 910 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
911 CONST Extbyte *bytes; | 911 CONST Extbyte *bytes; |
912 Extcount len; | 912 Extcount len; |
913 unsigned char *eimage; | 913 unsigned char *eimage; |
914 int width, height, x_hot, y_hot; | 914 int width, height, x_hot, y_hot; |
925 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) | 925 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) |
926 signal_simple_error ("Not an mswindows device", device); | 926 signal_simple_error ("Not an mswindows device", device); |
927 | 927 |
928 assert (!NILP (data)); | 928 assert (!NILP (data)); |
929 | 929 |
930 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len); | 930 TO_EXTERNAL_FORMAT (LISP_STRING, data, |
931 ALLOCA, (bytes, len), | |
932 Qbinary); | |
931 | 933 |
932 /* in case we have color symbols */ | 934 /* in case we have color symbols */ |
933 color_symbols = extract_xpm_color_names (device, domain, | 935 color_symbols = extract_xpm_color_names (device, domain, |
934 color_symbol_alist, &nsymbols); | 936 color_symbol_alist, &nsymbols); |
935 | 937 |
994 static void | 996 static void |
995 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 997 bmp_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
996 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 998 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
997 int dest_mask, Lisp_Object domain) | 999 int dest_mask, Lisp_Object domain) |
998 { | 1000 { |
999 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1001 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1000 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 1002 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
1001 CONST Extbyte *bytes; | 1003 CONST Extbyte *bytes; |
1002 Extcount len; | 1004 Extcount len; |
1003 BITMAPFILEHEADER* bmp_file_header; | 1005 BITMAPFILEHEADER* bmp_file_header; |
1004 BITMAPINFO* bmp_info; | 1006 BITMAPINFO* bmp_info; |
1009 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) | 1011 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) |
1010 signal_simple_error ("Not an mswindows device", device); | 1012 signal_simple_error ("Not an mswindows device", device); |
1011 | 1013 |
1012 assert (!NILP (data)); | 1014 assert (!NILP (data)); |
1013 | 1015 |
1014 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len); | 1016 TO_EXTERNAL_FORMAT (LISP_STRING, data, |
1017 ALLOCA, (bytes, len), | |
1018 Qbinary); | |
1015 | 1019 |
1016 /* Then slurp the image into memory, decoding along the way. | 1020 /* Then slurp the image into memory, decoding along the way. |
1017 The result is the image in a simple one-byte-per-pixel | 1021 The result is the image in a simple one-byte-per-pixel |
1018 format. */ | 1022 format. */ |
1019 | 1023 |
1183 signal_simple_error ("invalid resource identifier", name); | 1187 signal_simple_error ("invalid resource identifier", name); |
1184 } | 1188 } |
1185 | 1189 |
1186 do { | 1190 do { |
1187 Extbyte* nm=0; | 1191 Extbyte* nm=0; |
1188 GET_C_STRING_OS_DATA_ALLOCA (name, nm); | 1192 TO_EXTERNAL_FORMAT (LISP_STRING, name, |
1193 C_STRING_ALLOCA, nm, | |
1194 Qnative); | |
1189 if (!strcasecmp ((char*)res->name, nm)) | 1195 if (!strcasecmp ((char*)res->name, nm)) |
1190 return res->resource_id; | 1196 return res->resource_id; |
1191 } while ((++res)->name); | 1197 } while ((++res)->name); |
1192 return 0; | 1198 return 0; |
1193 } | 1199 } |
1208 static void | 1214 static void |
1209 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1215 mswindows_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1210 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1216 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1211 int dest_mask, Lisp_Object domain) | 1217 int dest_mask, Lisp_Object domain) |
1212 { | 1218 { |
1213 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1219 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1214 unsigned int type = 0; | 1220 unsigned int type = 0; |
1215 HANDLE himage = NULL; | 1221 HANDLE himage = NULL; |
1216 LPCTSTR resid=0; | 1222 LPCTSTR resid=0; |
1217 HINSTANCE hinst = NULL; | 1223 HINSTANCE hinst = NULL; |
1218 ICONINFO iconinfo; | 1224 ICONINFO iconinfo; |
1243 | 1249 |
1244 /* mess with the keyword info we were provided with */ | 1250 /* mess with the keyword info we were provided with */ |
1245 if (!NILP (file)) | 1251 if (!NILP (file)) |
1246 { | 1252 { |
1247 Extbyte* f=0; | 1253 Extbyte* f=0; |
1248 GET_C_STRING_FILENAME_DATA_ALLOCA (file, f); | 1254 TO_EXTERNAL_FORMAT (LISP_STRING, file, |
1255 C_STRING_ALLOCA, f, | |
1256 Qfile_name); | |
1249 #ifdef __CYGWIN32__ | 1257 #ifdef __CYGWIN32__ |
1250 CYGWIN_WIN32_PATH (f, fname); | 1258 CYGWIN_WIN32_PATH (f, fname); |
1251 #else | 1259 #else |
1252 fname = f; | 1260 fname = f; |
1253 #endif | 1261 #endif |
1260 LOAD_LIBRARY_AS_DATAFILE); | 1268 LOAD_LIBRARY_AS_DATAFILE); |
1261 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, | 1269 resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, |
1262 type)); | 1270 type)); |
1263 | 1271 |
1264 if (!resid) | 1272 if (!resid) |
1265 GET_C_STRING_OS_DATA_ALLOCA (resource_id, resid); | 1273 TO_EXTERNAL_FORMAT (LISP_STRING, resource_id, |
1274 C_STRING_ALLOCA, resid, | |
1275 Qnative); | |
1266 } | 1276 } |
1267 } | 1277 } |
1268 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, | 1278 else if (!(resid = MAKEINTRESOURCE (resource_name_to_resource (resource_id, |
1269 type)))) | 1279 type)))) |
1270 signal_simple_error ("Invalid resource identifier", resource_id); | 1280 signal_simple_error ("Invalid resource identifier", resource_id); |
1709 | 1719 |
1710 /* Given inline data for a mono pixmap, initialize the given | 1720 /* Given inline data for a mono pixmap, initialize the given |
1711 image instance accordingly. */ | 1721 image instance accordingly. */ |
1712 | 1722 |
1713 static void | 1723 static void |
1714 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii, | 1724 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii, |
1715 int width, int height, | 1725 int width, int height, |
1716 /* Note that data is in ext-format! */ | 1726 /* Note that data is in ext-format! */ |
1717 CONST char *bits, | 1727 CONST char *bits, |
1718 Lisp_Object instantiator, | 1728 Lisp_Object instantiator, |
1719 Lisp_Object pointer_fg, | 1729 Lisp_Object pointer_fg, |
1845 /* Note that data is in ext-format! */ | 1855 /* Note that data is in ext-format! */ |
1846 CONST char *bits) | 1856 CONST char *bits) |
1847 { | 1857 { |
1848 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); | 1858 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); |
1849 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); | 1859 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); |
1850 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 1860 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
1851 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME | 1861 struct frame* f = XFRAME (DEVICE_SELECTED_FRAME |
1852 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii)))); | 1862 (XDEVICE (IMAGE_INSTANCE_DEVICE (ii)))); |
1853 HDC hdc = FRAME_MSWINDOWS_CDC (f); | 1863 HDC hdc = FRAME_MSWINDOWS_CDC (f); |
1854 HBITMAP mask = 0; | 1864 HBITMAP mask = 0; |
1855 CONST char *gcc_may_you_rot_in_hell; | |
1856 | 1865 |
1857 if (!NILP (mask_data)) | 1866 if (!NILP (mask_data)) |
1858 { | 1867 { |
1859 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (mask_data))), | 1868 CONST char *ext_data; |
1860 gcc_may_you_rot_in_hell); | 1869 |
1861 mask = | 1870 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))), |
1862 xbm_create_bitmap_from_data ( hdc, | 1871 C_STRING_ALLOCA, ext_data, |
1863 (unsigned char *) | 1872 Qbinary); |
1864 gcc_may_you_rot_in_hell, | 1873 mask = xbm_create_bitmap_from_data (hdc, |
1865 XINT (XCAR (mask_data)), | 1874 (unsigned char *) ext_data, |
1866 XINT (XCAR (XCDR (mask_data))), FALSE, | 1875 XINT (XCAR (mask_data)), |
1867 PALETTERGB (0,0,0), | 1876 XINT (XCAR (XCDR (mask_data))), |
1868 PALETTERGB (255,255,255)); | 1877 FALSE, |
1878 PALETTERGB (0,0,0), | |
1879 PALETTERGB (255,255,255)); | |
1869 } | 1880 } |
1870 | 1881 |
1871 init_image_instance_from_xbm_inline (ii, width, height, bits, | 1882 init_image_instance_from_xbm_inline (ii, width, height, bits, |
1872 instantiator, pointer_fg, pointer_bg, | 1883 instantiator, pointer_fg, pointer_bg, |
1873 dest_mask, mask, mask_file); | 1884 dest_mask, mask, mask_file); |
1880 Lisp_Object instantiator, | 1891 Lisp_Object instantiator, |
1881 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1892 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1882 int dest_mask, Lisp_Object domain) | 1893 int dest_mask, Lisp_Object domain) |
1883 { | 1894 { |
1884 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 1895 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
1885 CONST char *gcc_go_home; | 1896 CONST char *ext_data; |
1886 | 1897 |
1887 assert (!NILP (data)); | 1898 assert (!NILP (data)); |
1888 | 1899 |
1889 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (data))), | 1900 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))), |
1890 gcc_go_home); | 1901 C_STRING_ALLOCA, ext_data, |
1902 Qbinary); | |
1891 | 1903 |
1892 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, | 1904 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, |
1893 pointer_bg, dest_mask, XINT (XCAR (data)), | 1905 pointer_bg, dest_mask, XINT (XCAR (data)), |
1894 XINT (XCAR (XCDR (data))), gcc_go_home); | 1906 XINT (XCAR (XCDR (data))), ext_data); |
1895 } | 1907 } |
1896 | 1908 |
1897 #ifdef HAVE_XFACE | 1909 #ifdef HAVE_XFACE |
1898 /********************************************************************** | 1910 /********************************************************************** |
1899 * X-Face * | 1911 * X-Face * |
1929 CONST char * volatile emsg = 0; | 1941 CONST char * volatile emsg = 0; |
1930 CONST char * volatile dstring; | 1942 CONST char * volatile dstring; |
1931 | 1943 |
1932 assert (!NILP (data)); | 1944 assert (!NILP (data)); |
1933 | 1945 |
1934 GET_C_STRING_BINARY_DATA_ALLOCA (data, dstring); | 1946 TO_EXTERNAL_FORMAT (LISP_STRING, data, |
1947 C_STRING_ALLOCA, dstring, | |
1948 Qbinary); | |
1935 | 1949 |
1936 if ((p = strchr (dstring, ':'))) | 1950 if ((p = strchr (dstring, ':'))) |
1937 { | 1951 { |
1938 dstring = p + 1; | 1952 dstring = p + 1; |
1939 } | 1953 } |
1985 /************************************************************************/ | 1999 /************************************************************************/ |
1986 /* image instance methods */ | 2000 /* image instance methods */ |
1987 /************************************************************************/ | 2001 /************************************************************************/ |
1988 | 2002 |
1989 static void | 2003 static void |
1990 mswindows_print_image_instance (struct Lisp_Image_Instance *p, | 2004 mswindows_print_image_instance (Lisp_Image_Instance *p, |
1991 Lisp_Object printcharfun, | 2005 Lisp_Object printcharfun, |
1992 int escapeflag) | 2006 int escapeflag) |
1993 { | 2007 { |
1994 char buf[100]; | 2008 char buf[100]; |
1995 | 2009 |
2018 #ifdef DEBUG_WIDGETS | 2032 #ifdef DEBUG_WIDGETS |
2019 extern int debug_widget_instances; | 2033 extern int debug_widget_instances; |
2020 #endif | 2034 #endif |
2021 | 2035 |
2022 static void | 2036 static void |
2023 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p) | 2037 mswindows_finalize_image_instance (Lisp_Image_Instance *p) |
2024 { | 2038 { |
2025 if (DEVICE_LIVE_P (XDEVICE (p->device))) | 2039 if (DEVICE_LIVE_P (XDEVICE (p->device))) |
2026 { | 2040 { |
2027 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET | 2041 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET |
2028 || | 2042 || |
2074 | 2088 |
2075 /************************************************************************/ | 2089 /************************************************************************/ |
2076 /* subwindow and widget support */ | 2090 /* subwindow and widget support */ |
2077 /************************************************************************/ | 2091 /************************************************************************/ |
2078 | 2092 |
2093 static HFONT | |
2094 mswindows_widget_hfont (Lisp_Image_Instance *p, | |
2095 Lisp_Object domain) | |
2096 { | |
2097 Lisp_Object face = IMAGE_INSTANCE_WIDGET_FACE (p); | |
2098 int under = FACE_UNDERLINE_P (face, domain); | |
2099 int strike = FACE_STRIKETHRU_P (face, domain); | |
2100 Lisp_Object font = query_string_font (IMAGE_INSTANCE_WIDGET_TEXT (p), | |
2101 face, domain); | |
2102 | |
2103 return mswindows_get_hfont (XFONT_INSTANCE (font), under, strike); | |
2104 } | |
2105 | |
2079 /* unmap the image if it is a widget. This is used by redisplay via | 2106 /* unmap the image if it is a widget. This is used by redisplay via |
2080 redisplay_unmap_subwindows */ | 2107 redisplay_unmap_subwindows */ |
2081 static void | 2108 static void |
2082 mswindows_unmap_subwindow (struct Lisp_Image_Instance *p) | 2109 mswindows_unmap_subwindow (Lisp_Image_Instance *p) |
2083 { | 2110 { |
2084 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) | 2111 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) |
2085 { | 2112 { |
2086 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | 2113 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), |
2087 NULL, | 2114 NULL, |
2088 0, 0, 0, 0, | 2115 0, 0, 0, 0, |
2089 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE | 2116 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE |
2090 | SWP_NOSENDCHANGING); | 2117 | SWP_NOSENDCHANGING); |
2118 if (GetFocus() == WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)) | |
2119 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p))); | |
2091 } | 2120 } |
2092 } | 2121 } |
2093 | 2122 |
2094 /* map the subwindow. This is used by redisplay via | 2123 /* map the subwindow. This is used by redisplay via |
2095 redisplay_output_subwindow */ | 2124 redisplay_output_subwindow */ |
2096 static void | 2125 static void |
2097 mswindows_map_subwindow (struct Lisp_Image_Instance *p, int x, int y, | 2126 mswindows_map_subwindow (Lisp_Image_Instance *p, int x, int y, |
2098 struct display_glyph_area* dga) | 2127 struct display_glyph_area* dga) |
2099 { | 2128 { |
2100 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p))); | |
2101 /* move the window before mapping it ... */ | 2129 /* move the window before mapping it ... */ |
2102 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), | 2130 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), |
2103 NULL, | 2131 NULL, |
2104 x, y, dga->width, dga->height, | 2132 x, y, dga->width, dga->height, |
2105 SWP_NOZORDER | 2133 SWP_NOZORDER |
2119 | SWP_NOSENDCHANGING); | 2147 | SWP_NOSENDCHANGING); |
2120 } | 2148 } |
2121 | 2149 |
2122 /* resize the subwindow instance */ | 2150 /* resize the subwindow instance */ |
2123 static void | 2151 static void |
2124 mswindows_resize_subwindow (struct Lisp_Image_Instance* ii, int w, int h) | 2152 mswindows_resize_subwindow (Lisp_Image_Instance* ii, int w, int h) |
2125 { | 2153 { |
2126 /* Set the size of the control .... */ | 2154 /* Set the size of the control .... */ |
2127 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2155 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2128 NULL, | 2156 NULL, |
2129 0, 0, w, h, | 2157 0, 0, w, h, |
2132 } | 2160 } |
2133 | 2161 |
2134 /* when you click on a widget you may activate another widget this | 2162 /* when you click on a widget you may activate another widget this |
2135 needs to be checked and all appropriate widgets updated */ | 2163 needs to be checked and all appropriate widgets updated */ |
2136 static void | 2164 static void |
2137 mswindows_update_subwindow (struct Lisp_Image_Instance *p) | 2165 mswindows_update_subwindow (Lisp_Image_Instance *p) |
2138 { | 2166 { |
2139 /* Now do widget specific updates. */ | 2167 /* Now do widget specific updates. */ |
2140 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) | 2168 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) |
2141 { | 2169 { |
2142 /* buttons checked or otherwise */ | 2170 /* buttons checked or otherwise */ |
2151 } | 2179 } |
2152 | 2180 |
2153 /* set the widget font from the widget face */ | 2181 /* set the widget font from the widget face */ |
2154 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), | 2182 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), |
2155 WM_SETFONT, | 2183 WM_SETFONT, |
2156 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT | 2184 (WPARAM) mswindows_widget_hfont |
2157 (XFONT_INSTANCE (query_string_font | 2185 (p, IMAGE_INSTANCE_SUBWINDOW_FRAME (p)), |
2158 (IMAGE_INSTANCE_WIDGET_TEXT (p), | |
2159 IMAGE_INSTANCE_WIDGET_FACE (p), | |
2160 IMAGE_INSTANCE_SUBWINDOW_FRAME (p)))), | |
2161 MAKELPARAM (TRUE, 0)); | 2186 MAKELPARAM (TRUE, 0)); |
2162 } | 2187 } |
2163 } | 2188 } |
2164 | 2189 |
2165 /* register widgets into our hastable so that we can cope with the | 2190 /* register widgets into our hastable so that we can cope with the |
2189 static void | 2214 static void |
2190 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2215 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2191 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2216 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2192 int dest_mask, Lisp_Object domain) | 2217 int dest_mask, Lisp_Object domain) |
2193 { | 2218 { |
2194 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2219 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2195 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); | 2220 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); |
2196 struct device* d = XDEVICE (device); | 2221 struct device* d = XDEVICE (device); |
2197 Lisp_Object frame = FW_FRAME (domain); | 2222 Lisp_Object frame = FW_FRAME (domain); |
2198 HWND wnd; | 2223 HWND wnd; |
2199 | 2224 |
2241 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); | 2266 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); |
2242 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; | 2267 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
2243 } | 2268 } |
2244 | 2269 |
2245 static int | 2270 static int |
2246 mswindows_image_instance_equal (struct Lisp_Image_Instance *p1, | 2271 mswindows_image_instance_equal (Lisp_Image_Instance *p1, |
2247 struct Lisp_Image_Instance *p2, int depth) | 2272 Lisp_Image_Instance *p2, int depth) |
2248 { | 2273 { |
2249 switch (IMAGE_INSTANCE_TYPE (p1)) | 2274 switch (IMAGE_INSTANCE_TYPE (p1)) |
2250 { | 2275 { |
2251 case IMAGE_MONO_PIXMAP: | 2276 case IMAGE_MONO_PIXMAP: |
2252 case IMAGE_COLOR_PIXMAP: | 2277 case IMAGE_COLOR_PIXMAP: |
2262 | 2287 |
2263 return 1; | 2288 return 1; |
2264 } | 2289 } |
2265 | 2290 |
2266 static unsigned long | 2291 static unsigned long |
2267 mswindows_image_instance_hash (struct Lisp_Image_Instance *p, int depth) | 2292 mswindows_image_instance_hash (Lisp_Image_Instance *p, int depth) |
2268 { | 2293 { |
2269 switch (IMAGE_INSTANCE_TYPE (p)) | 2294 switch (IMAGE_INSTANCE_TYPE (p)) |
2270 { | 2295 { |
2271 case IMAGE_MONO_PIXMAP: | 2296 case IMAGE_MONO_PIXMAP: |
2272 case IMAGE_COLOR_PIXMAP: | 2297 case IMAGE_COLOR_PIXMAP: |
2283 method. It is assumed that the device slot within the image | 2308 method. It is assumed that the device slot within the image |
2284 instance is already set -- this is the case when instantiate | 2309 instance is already set -- this is the case when instantiate |
2285 methods are called. */ | 2310 methods are called. */ |
2286 | 2311 |
2287 static void | 2312 static void |
2288 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii, | 2313 mswindows_initialize_dibitmap_image_instance (Lisp_Image_Instance *ii, |
2289 int slices, | 2314 int slices, |
2290 enum image_instance_type type) | 2315 enum image_instance_type type) |
2291 { | 2316 { |
2292 ii->data = xnew_and_zero (struct mswindows_image_instance_data); | 2317 ii->data = xnew_and_zero (struct mswindows_image_instance_data); |
2293 IMAGE_INSTANCE_TYPE (ii) = type; | 2318 IMAGE_INSTANCE_TYPE (ii) = type; |
2313 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2338 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2314 int dest_mask, Lisp_Object domain, | 2339 int dest_mask, Lisp_Object domain, |
2315 CONST char* class, int flags, int exflags) | 2340 CONST char* class, int flags, int exflags) |
2316 { | 2341 { |
2317 /* this function can call lisp */ | 2342 /* this function can call lisp */ |
2318 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2343 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2319 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; | 2344 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; |
2320 struct device* d = XDEVICE (device); | 2345 struct device* d = XDEVICE (device); |
2321 Lisp_Object frame = FW_FRAME (domain); | 2346 Lisp_Object frame = FW_FRAME (domain); |
2322 Extbyte* nm=0; | 2347 Extbyte* nm=0; |
2323 HWND wnd; | 2348 HWND wnd; |
2324 int id = 0xffff; | 2349 int id = 0xffff; |
2325 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2350 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2326 struct Lisp_Gui_Item* pgui = XGUI_ITEM (gui); | 2351 Lisp_Gui_Item* pgui = XGUI_ITEM (gui); |
2327 | 2352 |
2328 if (!DEVICE_MSWINDOWS_P (d)) | 2353 if (!DEVICE_MSWINDOWS_P (d)) |
2329 signal_simple_error ("Not an mswindows device", device); | 2354 signal_simple_error ("Not an mswindows device", device); |
2330 | 2355 |
2331 if (!gui_item_active_p (gui)) | 2356 if (!gui_item_active_p (gui)) |
2337 { | 2362 { |
2338 id = mswindows_register_widget_instance (image_instance, domain); | 2363 id = mswindows_register_widget_instance (image_instance, domain); |
2339 } | 2364 } |
2340 | 2365 |
2341 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) | 2366 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) |
2342 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm); | 2367 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (ii), |
2368 C_STRING_ALLOCA, nm, | |
2369 Qnative); | |
2343 | 2370 |
2344 /* allocate space for the clip window and then allocate the clip window */ | 2371 /* allocate space for the clip window and then allocate the clip window */ |
2345 ii->data = xnew_and_zero (struct mswindows_subwindow_data); | 2372 ii->data = xnew_and_zero (struct mswindows_subwindow_data); |
2346 | 2373 |
2347 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) | 2374 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) |
2384 | 2411 |
2385 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; | 2412 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; |
2386 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); | 2413 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); |
2387 /* set the widget font from the widget face */ | 2414 /* set the widget font from the widget face */ |
2388 SendMessage (wnd, WM_SETFONT, | 2415 SendMessage (wnd, WM_SETFONT, |
2389 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT | 2416 (WPARAM) mswindows_widget_hfont (ii, domain), |
2390 (XFONT_INSTANCE (query_string_font | |
2391 (IMAGE_INSTANCE_WIDGET_TEXT (ii), | |
2392 IMAGE_INSTANCE_WIDGET_FACE (ii), | |
2393 domain))), | |
2394 MAKELPARAM (TRUE, 0)); | 2417 MAKELPARAM (TRUE, 0)); |
2395 } | 2418 } |
2396 | 2419 |
2397 /* Instantiate a button widget. Unfortunately instantiated widgets are | 2420 /* Instantiate a button widget. Unfortunately instantiated widgets are |
2398 particular to a frame since they need to have a parent. It's not | 2421 particular to a frame since they need to have a parent. It's not |
2404 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2427 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2405 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2428 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2406 int dest_mask, Lisp_Object domain) | 2429 int dest_mask, Lisp_Object domain) |
2407 { | 2430 { |
2408 /* this function can call lisp */ | 2431 /* this function can call lisp */ |
2409 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2432 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2410 HWND wnd; | 2433 HWND wnd; |
2411 int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback | 2434 int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback |
2412 only. Since we seem to want nothing beyond BN_CLICK, | 2435 only. Since we seem to want nothing beyond BN_CLICK, |
2413 the style is perhaps not necessary -- kkm */ | 2436 the style is perhaps not necessary -- kkm */ |
2414 Lisp_Object style; | 2437 Lisp_Object style; |
2415 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2438 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2416 struct Lisp_Gui_Item* pgui = XGUI_ITEM (gui); | 2439 Lisp_Gui_Item* pgui = XGUI_ITEM (gui); |
2417 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); | 2440 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); |
2418 | 2441 |
2419 if (!NILP (glyph)) | 2442 if (!NILP (glyph)) |
2420 { | 2443 { |
2421 if (!IMAGE_INSTANCEP (glyph)) | 2444 if (!IMAGE_INSTANCEP (glyph)) |
2442 { | 2465 { |
2443 flags |= BS_DEFPUSHBUTTON; | 2466 flags |= BS_DEFPUSHBUTTON; |
2444 } | 2467 } |
2445 | 2468 |
2446 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2469 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2447 pointer_bg, dest_mask, domain, "BUTTON", | 2470 pointer_bg, dest_mask, domain, "BUTTON", |
2448 flags, 0); | 2471 flags, 0); |
2449 | 2472 |
2450 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2473 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2451 /* set the checked state */ | 2474 /* set the checked state */ |
2452 if (gui_item_selected_p (gui)) | 2475 if (gui_item_selected_p (gui)) |
2453 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); | 2476 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); |
2454 else | 2477 else |
2455 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); | 2478 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); |
2456 /* add the image if one was given */ | 2479 /* add the image if one was given */ |
2457 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)) | 2480 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph) |
2481 && | |
2482 IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph))) | |
2458 { | 2483 { |
2459 SendMessage (wnd, BM_SETIMAGE, | 2484 SendMessage (wnd, BM_SETIMAGE, |
2460 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | 2485 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? |
2461 IMAGE_BITMAP : IMAGE_ICON), | 2486 IMAGE_BITMAP : IMAGE_ICON), |
2462 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? | 2487 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? |
2482 mswindows_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2507 mswindows_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2483 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2508 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2484 int dest_mask, Lisp_Object domain) | 2509 int dest_mask, Lisp_Object domain) |
2485 { | 2510 { |
2486 HWND wnd; | 2511 HWND wnd; |
2487 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2512 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2488 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2513 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2489 pointer_bg, dest_mask, domain, PROGRESS_CLASS, | 2514 pointer_bg, dest_mask, domain, PROGRESS_CLASS, |
2490 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE); | 2515 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE); |
2491 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2516 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2492 /* set the colors */ | 2517 /* set the colors */ |
2523 | 2548 |
2524 if (GUI_ITEMP (item)) | 2549 if (GUI_ITEMP (item)) |
2525 { | 2550 { |
2526 tvitem.item.lParam = mswindows_register_gui_item (item, domain); | 2551 tvitem.item.lParam = mswindows_register_gui_item (item, domain); |
2527 tvitem.item.mask |= TVIF_PARAM; | 2552 tvitem.item.mask |= TVIF_PARAM; |
2528 GET_C_STRING_OS_DATA_ALLOCA (XGUI_ITEM (item)->name, | 2553 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, |
2529 tvitem.item.pszText); | 2554 C_STRING_ALLOCA, tvitem.item.pszText, |
2555 Qnative); | |
2530 } | 2556 } |
2531 else | 2557 else |
2532 GET_C_STRING_OS_DATA_ALLOCA (item, tvitem.item.pszText); | 2558 TO_EXTERNAL_FORMAT (LISP_STRING, item, |
2559 C_STRING_ALLOCA, tvitem.item.pszText, | |
2560 Qnative); | |
2533 | 2561 |
2534 tvitem.item.cchTextMax = strlen (tvitem.item.pszText); | 2562 tvitem.item.cchTextMax = strlen (tvitem.item.pszText); |
2535 | 2563 |
2536 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM, | 2564 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM, |
2537 0, (LPARAM)&tvitem)) == 0) | 2565 0, (LPARAM)&tvitem)) == 0) |
2564 int dest_mask, Lisp_Object domain) | 2592 int dest_mask, Lisp_Object domain) |
2565 { | 2593 { |
2566 Lisp_Object rest; | 2594 Lisp_Object rest; |
2567 HWND wnd; | 2595 HWND wnd; |
2568 HTREEITEM parent; | 2596 HTREEITEM parent; |
2569 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2597 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2570 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2598 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2571 pointer_bg, dest_mask, domain, WC_TREEVIEW, | 2599 pointer_bg, dest_mask, domain, WC_TREEVIEW, |
2572 WS_TABSTOP | WS_BORDER | PBS_SMOOTH | 2600 WS_TABSTOP | WS_BORDER | PBS_SMOOTH |
2573 | TVS_HASLINES | TVS_HASBUTTONS, | 2601 | TVS_HASLINES | TVS_HASBUTTONS, |
2574 WS_EX_CLIENTEDGE); | 2602 WS_EX_CLIENTEDGE); |
2602 | 2630 |
2603 if (GUI_ITEMP (item)) | 2631 if (GUI_ITEMP (item)) |
2604 { | 2632 { |
2605 tvitem.lParam = mswindows_register_gui_item (item, domain); | 2633 tvitem.lParam = mswindows_register_gui_item (item, domain); |
2606 tvitem.mask |= TCIF_PARAM; | 2634 tvitem.mask |= TCIF_PARAM; |
2607 GET_C_STRING_OS_DATA_ALLOCA (XGUI_ITEM (item)->name, | 2635 TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name, |
2608 tvitem.pszText); | 2636 C_STRING_ALLOCA, tvitem.pszText, |
2637 Qnative); | |
2609 } | 2638 } |
2610 else | 2639 else |
2611 { | 2640 { |
2612 CHECK_STRING (item); | 2641 CHECK_STRING (item); |
2613 GET_C_STRING_OS_DATA_ALLOCA (item, tvitem.pszText); | 2642 TO_EXTERNAL_FORMAT (LISP_STRING, item, |
2643 C_STRING_ALLOCA, tvitem.pszText, | |
2644 Qnative); | |
2614 } | 2645 } |
2615 | 2646 |
2616 tvitem.cchTextMax = strlen (tvitem.pszText); | 2647 tvitem.cchTextMax = strlen (tvitem.pszText); |
2617 | 2648 |
2618 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM, | 2649 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM, |
2628 int dest_mask, Lisp_Object domain) | 2659 int dest_mask, Lisp_Object domain) |
2629 { | 2660 { |
2630 Lisp_Object rest; | 2661 Lisp_Object rest; |
2631 HWND wnd; | 2662 HWND wnd; |
2632 int i = 0; | 2663 int i = 0; |
2633 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2664 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2634 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation); | 2665 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation); |
2635 unsigned int flags = WS_TABSTOP; | 2666 unsigned int flags = WS_TABSTOP; |
2636 | 2667 |
2637 if (EQ (orient, Qleft) || EQ (orient, Qright)) | 2668 if (EQ (orient, Qleft) || EQ (orient, Qright)) |
2638 { | 2669 { |
2660 /* set the properties of a tab control */ | 2691 /* set the properties of a tab control */ |
2661 static Lisp_Object | 2692 static Lisp_Object |
2662 mswindows_tab_control_set_property (Lisp_Object image_instance, Lisp_Object prop, | 2693 mswindows_tab_control_set_property (Lisp_Object image_instance, Lisp_Object prop, |
2663 Lisp_Object val) | 2694 Lisp_Object val) |
2664 { | 2695 { |
2665 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2696 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2666 | 2697 |
2667 if (EQ (prop, Q_items)) | 2698 if (EQ (prop, Q_items)) |
2668 { | 2699 { |
2669 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2700 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2670 int i = 0; | 2701 int i = 0; |
2717 static void | 2748 static void |
2718 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 2749 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
2719 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2750 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2720 int dest_mask, Lisp_Object domain) | 2751 int dest_mask, Lisp_Object domain) |
2721 { | 2752 { |
2722 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2753 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2723 HANDLE wnd; | 2754 HANDLE wnd; |
2724 Lisp_Object rest; | 2755 Lisp_Object rest; |
2725 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties), | 2756 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties), |
2726 Q_items, Qnil); | 2757 Q_items, Qnil); |
2727 int len, height; | 2758 int len, height; |
2739 default_face_font_info (domain, 0, 0, &height, 0, 0); | 2770 default_face_font_info (domain, 0, 0, &height, 0, 0); |
2740 GET_LIST_LENGTH (data, len); | 2771 GET_LIST_LENGTH (data, len); |
2741 | 2772 |
2742 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len; | 2773 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len; |
2743 IMAGE_INSTANCE_HEIGHT (ii) = height; | 2774 IMAGE_INSTANCE_HEIGHT (ii) = height; |
2744 | 2775 |
2745 /* Now create the widget. */ | 2776 /* Now create the widget. */ |
2746 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, | 2777 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, |
2747 pointer_bg, dest_mask, domain, "COMBOBOX", | 2778 pointer_bg, dest_mask, domain, "COMBOBOX", |
2748 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN | 2779 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN |
2749 | CBS_AUTOHSCROLL | 2780 | CBS_AUTOHSCROLL |
2750 | CBS_HASSTRINGS | WS_VSCROLL, | 2781 | CBS_HASSTRINGS | WS_VSCROLL, |
2751 WS_EX_CLIENTEDGE); | 2782 WS_EX_CLIENTEDGE); |
2752 /* Reset the height. layout will probably do this safely, but better make sure. */ | 2783 /* Reset the height. layout will probably do this safely, but better make sure. */ |
2753 image_instance_layout (image_instance, | 2784 image_instance_layout (image_instance, |
2754 IMAGE_UNSPECIFIED_GEOMETRY, | 2785 IMAGE_UNSPECIFIED_GEOMETRY, |
2755 IMAGE_UNSPECIFIED_GEOMETRY, | 2786 IMAGE_UNSPECIFIED_GEOMETRY, |
2756 domain); | 2787 domain); |
2757 | 2788 |
2758 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2789 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2759 /* add items to the combo box */ | 2790 /* add items to the combo box */ |
2760 SendMessage (wnd, CB_RESETCONTENT, 0, 0); | 2791 SendMessage (wnd, CB_RESETCONTENT, 0, 0); |
2761 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) | 2792 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) |
2762 { | 2793 { |
2763 Extbyte* lparam; | 2794 Extbyte* lparam; |
2764 GET_C_STRING_OS_DATA_ALLOCA (XCAR (rest), lparam); | 2795 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (rest), |
2796 C_STRING_ALLOCA, lparam, | |
2797 Qnative); | |
2765 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) | 2798 if (SendMessage (wnd, CB_ADDSTRING, 0, (LPARAM)lparam) == CB_ERR) |
2766 signal_simple_error ("error adding combo entries", instantiator); | 2799 signal_simple_error ("error adding combo entries", instantiator); |
2767 } | 2800 } |
2768 } | 2801 } |
2769 | 2802 |
2770 /* get properties of a control */ | 2803 /* get properties of a control */ |
2771 static Lisp_Object | 2804 static Lisp_Object |
2772 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) | 2805 mswindows_widget_property (Lisp_Object image_instance, Lisp_Object prop) |
2773 { | 2806 { |
2774 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2807 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2775 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2808 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2776 /* get the text from a control */ | 2809 /* get the text from a control */ |
2777 if (EQ (prop, Q_text)) | 2810 if (EQ (prop, Q_text)) |
2778 { | 2811 { |
2779 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); | 2812 Extcount len = SendMessage (wnd, WM_GETTEXTLENGTH, 0, 0); |
2780 Extbyte* buf =alloca (len+1); | 2813 Extbyte* buf =alloca (len+1); |
2781 | 2814 |
2782 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); | 2815 SendMessage (wnd, WM_GETTEXT, (WPARAM)len+1, (LPARAM) buf); |
2783 return build_ext_string (buf, FORMAT_OS); | 2816 return build_ext_string (buf, Qnative); |
2784 } | 2817 } |
2785 return Qunbound; | 2818 return Qunbound; |
2786 } | 2819 } |
2787 | 2820 |
2788 /* get properties of a button */ | 2821 /* get properties of a button */ |
2789 static Lisp_Object | 2822 static Lisp_Object |
2790 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) | 2823 mswindows_button_property (Lisp_Object image_instance, Lisp_Object prop) |
2791 { | 2824 { |
2792 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2825 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2793 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2826 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2794 /* check the state of a button */ | 2827 /* check the state of a button */ |
2795 if (EQ (prop, Q_selected)) | 2828 if (EQ (prop, Q_selected)) |
2796 { | 2829 { |
2797 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) | 2830 if (SendMessage (wnd, BM_GETSTATE, 0, 0) & BST_CHECKED) |
2804 | 2837 |
2805 /* get properties of a combo box */ | 2838 /* get properties of a combo box */ |
2806 static Lisp_Object | 2839 static Lisp_Object |
2807 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop) | 2840 mswindows_combo_box_property (Lisp_Object image_instance, Lisp_Object prop) |
2808 { | 2841 { |
2809 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2842 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2810 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); | 2843 HANDLE wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); |
2811 /* get the text from a control */ | 2844 /* get the text from a control */ |
2812 if (EQ (prop, Q_text)) | 2845 if (EQ (prop, Q_text)) |
2813 { | 2846 { |
2814 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); | 2847 long item = SendMessage (wnd, CB_GETCURSEL, 0, 0); |
2815 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); | 2848 Extcount len = SendMessage (wnd, CB_GETLBTEXTLEN, (WPARAM)item, 0); |
2816 Extbyte* buf = alloca (len+1); | 2849 Extbyte* buf = alloca (len+1); |
2817 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); | 2850 SendMessage (wnd, CB_GETLBTEXT, (WPARAM)item, (LPARAM)buf); |
2818 return build_ext_string (buf, FORMAT_OS); | 2851 return build_ext_string (buf, Qnative); |
2819 } | 2852 } |
2820 return Qunbound; | 2853 return Qunbound; |
2821 } | 2854 } |
2822 | 2855 |
2823 /* set the properties of a control */ | 2856 /* set the properties of a control */ |
2824 static Lisp_Object | 2857 static Lisp_Object |
2825 mswindows_widget_set_property (Lisp_Object image_instance, Lisp_Object prop, | 2858 mswindows_widget_set_property (Lisp_Object image_instance, Lisp_Object prop, |
2826 Lisp_Object val) | 2859 Lisp_Object val) |
2827 { | 2860 { |
2828 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2861 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2829 | 2862 |
2830 if (EQ (prop, Q_text)) | 2863 if (EQ (prop, Q_text)) |
2831 { | 2864 { |
2832 Extbyte* lparam=0; | 2865 Extbyte* lparam=0; |
2833 CHECK_STRING (val); | 2866 CHECK_STRING (val); |
2834 GET_C_STRING_OS_DATA_ALLOCA (val, lparam); | 2867 TO_EXTERNAL_FORMAT (LISP_STRING, val, |
2868 C_STRING_ALLOCA, lparam, | |
2869 Qnative); | |
2835 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2870 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |
2836 WM_SETTEXT, 0, (LPARAM)lparam); | 2871 WM_SETTEXT, 0, (LPARAM)lparam); |
2837 /* We don't return Qt here so that other widget methods can be | 2872 /* We don't return Qt here so that other widget methods can be |
2838 called afterwards. */ | 2873 called afterwards. */ |
2839 } | 2874 } |
2843 /* set the properties of a progres guage */ | 2878 /* set the properties of a progres guage */ |
2844 static Lisp_Object | 2879 static Lisp_Object |
2845 mswindows_progress_gauge_set_property (Lisp_Object image_instance, Lisp_Object prop, | 2880 mswindows_progress_gauge_set_property (Lisp_Object image_instance, Lisp_Object prop, |
2846 Lisp_Object val) | 2881 Lisp_Object val) |
2847 { | 2882 { |
2848 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2883 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2849 | 2884 |
2850 if (EQ (prop, Q_percent)) | 2885 if (EQ (prop, Q_percent)) |
2851 { | 2886 { |
2852 CHECK_INT (val); | 2887 CHECK_INT (val); |
2853 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), | 2888 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), |