comparison src/glyphs-msw.c @ 424:11054d720c21 r21-2-20

Import from CVS: tag r21-2-20
author cvs
date Mon, 13 Aug 2007 11:26:11 +0200
parents 95016f13131a
children
comparison
equal deleted inserted replaced
423:28d9c139be4c 424:11054d720c21
1 /* mswindows-specific glyph objects. 1 /* mswindows-specific glyph objects.
2 Copyright (C) 1998, 99 Andy Piper. 2 Copyright (C) 1998, 1999 Andy Piper.
3 3
4 This file is part of XEmacs. 4 This file is part of XEmacs.
5 5
6 XEmacs is free software; you can redistribute it and/or modify it 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 7 under the terms of the GNU General Public License as published by the
55 55
56 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing); 56 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing);
57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string); 57 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string);
58 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string); 58 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
59 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit); 59 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit);
60 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout);
60 #ifdef HAVE_JPEG 61 #ifdef HAVE_JPEG
61 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg); 62 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
62 #endif 63 #endif
63 #ifdef HAVE_TIFF 64 #ifdef HAVE_TIFF
64 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff); 65 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff);
76 #ifdef HAVE_XFACE 77 #ifdef HAVE_XFACE
77 DEFINE_DEVICE_IIFORMAT (mswindows, xface); 78 DEFINE_DEVICE_IIFORMAT (mswindows, xface);
78 #endif 79 #endif
79 DEFINE_DEVICE_IIFORMAT (mswindows, button); 80 DEFINE_DEVICE_IIFORMAT (mswindows, button);
80 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field); 81 DEFINE_DEVICE_IIFORMAT (mswindows, edit_field);
81 #if 0
82 DEFINE_DEVICE_IIFORMAT (mswindows, group);
83 #endif
84 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow); 82 DEFINE_DEVICE_IIFORMAT (mswindows, subwindow);
85 DEFINE_DEVICE_IIFORMAT (mswindows, widget); 83 DEFINE_DEVICE_IIFORMAT (mswindows, widget);
86 DEFINE_DEVICE_IIFORMAT (mswindows, label); 84 DEFINE_DEVICE_IIFORMAT (mswindows, label);
87 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar); 85 DEFINE_DEVICE_IIFORMAT (mswindows, scrollbar);
88 DEFINE_DEVICE_IIFORMAT (mswindows, combo_box); 86 DEFINE_DEVICE_IIFORMAT (mswindows, combo_box);
99 Lisp_Object Q_resource_type, Q_resource_id; 97 Lisp_Object Q_resource_type, Q_resource_id;
100 Lisp_Object Qmswindows_resource; 98 Lisp_Object Qmswindows_resource;
101 99
102 static void 100 static void
103 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii, 101 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
104 enum image_instance_type type); 102 int slices,
103 enum image_instance_type type);
105 static void 104 static void
106 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image, 105 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image,
107 struct frame* f); 106 struct frame* f);
108 107
109 COLORREF mswindows_string_to_color (CONST char *name); 108 COLORREF mswindows_string_to_color (CONST char *name);
110 void check_valid_item_list_1 (Lisp_Object items);
111 109
112 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3))) 110 #define BPLINE(width) ((int)(~3UL & (unsigned long)((width) +3)))
113 111
114 /************************************************************************/ 112 /************************************************************************/
115 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/ 113 /* convert from a series of RGB triples to a BITMAPINFO formated for the*/
291 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii, 289 init_image_instance_from_dibitmap (struct Lisp_Image_Instance *ii,
292 BITMAPINFO *bmp_info, 290 BITMAPINFO *bmp_info,
293 int dest_mask, 291 int dest_mask,
294 void *bmp_data, 292 void *bmp_data,
295 int bmp_bits, 293 int bmp_bits,
294 int slices,
296 Lisp_Object instantiator, 295 Lisp_Object instantiator,
297 int x_hot, int y_hot, 296 int x_hot, int y_hot,
298 int create_mask) 297 int create_mask)
299 { 298 {
300 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 299 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
332 signal_simple_error ("Unable to create bitmap", instantiator); 331 signal_simple_error ("Unable to create bitmap", instantiator);
333 332
334 /* copy in the actual bitmap */ 333 /* copy in the actual bitmap */
335 memcpy (bmp_buf, bmp_data, bmp_bits); 334 memcpy (bmp_buf, bmp_data, bmp_bits);
336 335
337 mswindows_initialize_dibitmap_image_instance (ii, type); 336 mswindows_initialize_dibitmap_image_instance (ii, slices, type);
338 337
339 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = 338 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
340 find_keyword_in_vector (instantiator, Q_file); 339 find_keyword_in_vector (instantiator, Q_file);
341 340
341 /* Fixup a set of bitmaps. */
342 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap; 342 IMAGE_INSTANCE_MSWINDOWS_BITMAP (ii) = bitmap;
343
343 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL; 344 IMAGE_INSTANCE_MSWINDOWS_MASK (ii) = NULL;
344 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth; 345 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = bmp_info->bmiHeader.biWidth;
345 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight; 346 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = bmp_info->bmiHeader.biHeight;
346 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount; 347 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = bmp_info->bmiHeader.biBitCount;
347 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot); 348 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), x_hot);
357 mswindows_initialize_image_instance_icon(ii, TRUE); 358 mswindows_initialize_image_instance_icon(ii, TRUE);
358 } 359 }
359 } 360 }
360 361
361 static void 362 static void
363 image_instance_add_dibitmap (struct Lisp_Image_Instance *ii,
364 BITMAPINFO *bmp_info,
365 void *bmp_data,
366 int bmp_bits,
367 int slice,
368 Lisp_Object instantiator)
369 {
370 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
371 struct device *d = XDEVICE (device);
372 struct frame *f = XFRAME (DEVICE_SELECTED_FRAME (d));
373 void* bmp_buf=0;
374 HDC hdc = FRAME_MSWINDOWS_CDC (f);
375 HBITMAP bitmap = CreateDIBSection (hdc,
376 bmp_info,
377 DIB_RGB_COLORS,
378 &bmp_buf,
379 0,0);
380
381 if (!bitmap || !bmp_buf)
382 signal_simple_error ("Unable to create bitmap", instantiator);
383
384 /* copy in the actual bitmap */
385 memcpy (bmp_buf, bmp_data, bmp_bits);
386 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (ii, slice) = bitmap;
387 }
388
389 static void
362 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii, 390 mswindows_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
363 int width, int height, 391 int width, int height,
392 int slices,
364 unsigned char *eimage, 393 unsigned char *eimage,
365 int dest_mask, 394 int dest_mask,
366 Lisp_Object instantiator, 395 Lisp_Object instantiator,
367 Lisp_Object domain) 396 Lisp_Object domain)
368 { 397 {
369 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 398 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
370 BITMAPINFO* bmp_info; 399 BITMAPINFO* bmp_info;
371 unsigned char* bmp_data; 400 unsigned char* bmp_data;
372 int bmp_bits; 401 int bmp_bits;
373 COLORREF bkcolor; 402 COLORREF bkcolor;
403 int slice;
374 404
375 if (!DEVICE_MSWINDOWS_P (XDEVICE (device))) 405 if (!DEVICE_MSWINDOWS_P (XDEVICE (device)))
376 signal_simple_error ("Not an mswindows device", device); 406 signal_simple_error ("Not an mswindows device", device);
377 407
378 /* this is a hack but MaskBlt and TransparentBlt are not supported 408 /* this is a hack but MaskBlt and TransparentBlt are not supported
379 on most windows variants */ 409 on most windows variants */
380 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR 410 bkcolor = COLOR_INSTANCE_MSWINDOWS_COLOR
381 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain))); 411 (XCOLOR_INSTANCE (FACE_BACKGROUND (Vdefault_face, domain)));
382 412
383 /* build a bitmap from the eimage */ 413 for (slice = 0; slice < slices; slice++)
384 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height, eimage, 414 {
385 &bmp_bits, &bmp_data))) 415 /* build a bitmap from the eimage */
386 { 416 if (!(bmp_info=convert_EImage_to_DIBitmap (device, width, height,
387 signal_simple_error ("EImage to DIBitmap conversion failed", 417 eimage + (width * height * 3 * slice),
388 instantiator); 418 &bmp_bits, &bmp_data)))
389 } 419 {
390 420 signal_simple_error ("EImage to DIBitmap conversion failed",
391 /* Now create the pixmap and set up the image instance */ 421 instantiator);
392 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 422 }
393 bmp_data, bmp_bits, instantiator, 423
394 0, 0, 0); 424 /* Now create the pixmap and set up the image instance */
395 425 if (slice == 0)
396 xfree (bmp_info); 426 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
397 xfree (bmp_data); 427 bmp_data, bmp_bits, slices, instantiator,
428 0, 0, 0);
429 else
430 image_instance_add_dibitmap (ii, bmp_info, bmp_data, bmp_bits, slice,
431 instantiator);
432
433 xfree (bmp_info);
434 xfree (bmp_data);
435 }
398 } 436 }
399 437
400 static void set_mono_pixel ( unsigned char* bits, 438 static void set_mono_pixel ( unsigned char* bits,
401 int bpline, int height, 439 int bpline, int height,
402 int x, int y, int white ) 440 int x, int y, int white )
921 } 959 }
922 xfree (eimage); 960 xfree (eimage);
923 961
924 /* Now create the pixmap and set up the image instance */ 962 /* Now create the pixmap and set up the image instance */
925 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 963 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
926 bmp_data, bmp_bits, instantiator, 964 bmp_data, bmp_bits, 1, instantiator,
927 x_hot, y_hot, transp); 965 x_hot, y_hot, transp);
928 966
929 xfree (bmp_info); 967 xfree (bmp_info);
930 xfree (bmp_data); 968 xfree (bmp_data);
931 } 969 }
984 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits; 1022 bmp_data = (Extbyte*)bytes + bmp_file_header->bfOffBits;
985 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits; 1023 bmp_bits = bmp_file_header->bfSize - bmp_file_header->bfOffBits;
986 1024
987 /* Now create the pixmap and set up the image instance */ 1025 /* Now create the pixmap and set up the image instance */
988 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask, 1026 init_image_instance_from_dibitmap (ii, bmp_info, dest_mask,
989 bmp_data, bmp_bits, instantiator, 1027 bmp_data, bmp_bits, 1, instantiator,
990 0, 0, 0); 1028 0, 0, 0);
991 } 1029 }
992 1030
993 1031
994 /********************************************************************** 1032 /**********************************************************************
1239 } 1277 }
1240 1278
1241 if (hinst) 1279 if (hinst)
1242 FreeLibrary (hinst); 1280 FreeLibrary (hinst);
1243 1281
1244 mswindows_initialize_dibitmap_image_instance (ii, iitype); 1282 mswindows_initialize_dibitmap_image_instance (ii, 1, iitype);
1245 1283
1246 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file; 1284 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = file;
1247 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = 1285 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) =
1248 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON); 1286 GetSystemMetrics (type == IMAGE_CURSOR ? SM_CXCURSOR : SM_CXICON);
1249 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = 1287 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) =
1721 else 1759 else
1722 incompatible_image_types (instantiator, dest_mask, 1760 incompatible_image_types (instantiator, dest_mask,
1723 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK 1761 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
1724 | IMAGE_POINTER_MASK); 1762 | IMAGE_POINTER_MASK);
1725 1763
1726 mswindows_initialize_dibitmap_image_instance (ii, type); 1764 mswindows_initialize_dibitmap_image_instance (ii, 1, type);
1727 1765
1728 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = 1766 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
1729 find_keyword_in_vector (instantiator, Q_file); 1767 find_keyword_in_vector (instantiator, Q_file);
1730 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width; 1768 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
1731 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height; 1769 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
1982 default: 2020 default:
1983 break; 2021 break;
1984 } 2022 }
1985 } 2023 }
1986 2024
2025 #ifdef DEBUG_WIDGETS
2026 extern int debug_widget_instances;
2027 #endif
2028
1987 static void 2029 static void
1988 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p) 2030 mswindows_finalize_image_instance (struct Lisp_Image_Instance *p)
1989 { 2031 {
1990 if (DEVICE_LIVE_P (XDEVICE (p->device))) 2032 if (DEVICE_LIVE_P (XDEVICE (p->device)))
1991 { 2033 {
1992 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET 2034 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET
1993 || 2035 ||
1994 IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW) 2036 IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
1995 { 2037 {
2038 #ifdef DEBUG_WIDGETS
2039 debug_widget_instances--;
2040 stderr_out ("widget destroyed, %d left\n", debug_widget_instances);
2041 #endif
1996 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) 2042 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
1997 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p)); 2043 {
1998 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0; 2044 DestroyWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p));
2045 DestroyWindow (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p));
2046 IMAGE_INSTANCE_SUBWINDOW_ID (p) = 0;
2047 }
1999 } 2048 }
2000 else if (p->data) 2049 else if (p->data)
2001 { 2050 {
2002 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)) 2051 int i;
2003 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP (p)); 2052 if (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p))
2004 IMAGE_INSTANCE_MSWINDOWS_BITMAP (p) = 0; 2053 disable_glyph_animated_timeout (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p));
2054
2055 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p))
2056 {
2057 for (i = 0; i < IMAGE_INSTANCE_PIXMAP_MAXSLICE (p); i++)
2058 {
2059 if (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i))
2060 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i));
2061 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICE (p, i) = 0;
2062 }
2063 xfree (IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p));
2064 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (p) = 0;
2065 }
2005 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p)) 2066 if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
2006 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p)); 2067 DeleteObject (IMAGE_INSTANCE_MSWINDOWS_MASK (p));
2007 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0; 2068 IMAGE_INSTANCE_MSWINDOWS_MASK (p) = 0;
2008 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p)) 2069 if (IMAGE_INSTANCE_MSWINDOWS_ICON (p))
2009 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p)); 2070 DestroyIcon (IMAGE_INSTANCE_MSWINDOWS_ICON (p));
2027 static void 2088 static void
2028 mswindows_unmap_subwindow (struct Lisp_Image_Instance *p) 2089 mswindows_unmap_subwindow (struct Lisp_Image_Instance *p)
2029 { 2090 {
2030 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) 2091 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
2031 { 2092 {
2032 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2093 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2033 NULL, 2094 NULL,
2034 0, 0, 0, 0, 2095 0, 0, 0, 0,
2035 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE 2096 SWP_HIDEWINDOW | SWP_NOMOVE | SWP_NOSIZE
2036 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); 2097 | SWP_NOSENDCHANGING);
2037 } 2098 }
2038 } 2099 }
2039 2100
2040 /* map the subwindow. This is used by redisplay via 2101 /* map the subwindow. This is used by redisplay via
2041 redisplay_output_subwindow */ 2102 redisplay_output_subwindow */
2042 static void 2103 static void
2043 mswindows_map_subwindow (struct Lisp_Image_Instance *p, int x, int y) 2104 mswindows_map_subwindow (struct Lisp_Image_Instance *p, int x, int y,
2044 { 2105 struct display_glyph_area* dga)
2045 /* ShowWindow (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), SW_SHOW);*/ 2106 {
2046 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2107 /* move the window before mapping it ... */
2108 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2047 NULL, 2109 NULL,
2048 x, y, 0, 0, 2110 x, y, dga->width, dga->height,
2049 SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOSIZE 2111 SWP_NOZORDER
2050 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); 2112 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2113 /* ... adjust the child ... */
2114 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2115 NULL,
2116 -dga->xoffset, -dga->yoffset, 0, 0,
2117 SWP_NOZORDER | SWP_NOSIZE
2118 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2119 /* ... now map it - we are not allowed to move it at the same time. */
2120 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2121 NULL,
2122 0, 0, 0, 0,
2123 SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE
2124 | SWP_SHOWWINDOW | SWP_NOCOPYBITS
2125 | SWP_NOSENDCHANGING);
2051 } 2126 }
2052 2127
2053 /* resize the subwindow instance */ 2128 /* resize the subwindow instance */
2054 static void 2129 static void
2055 mswindows_resize_subwindow (struct Lisp_Image_Instance* ii, int w, int h) 2130 mswindows_resize_subwindow (struct Lisp_Image_Instance* ii, int w, int h)
2056 { 2131 {
2132 /* Set the size of the control .... */
2057 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), 2133 SetWindowPos (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2058 NULL, 2134 NULL,
2059 0, 0, w, h, 2135 0, 0, w, h,
2060 SWP_NOZORDER | SWP_NOMOVE 2136 SWP_NOZORDER | SWP_NOMOVE
2061 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING); 2137 | SWP_NOCOPYBITS | SWP_NOSENDCHANGING);
2069 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) 2145 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
2070 { 2146 {
2071 /* buttons checked or otherwise */ 2147 /* buttons checked or otherwise */
2072 if ( EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qbutton)) 2148 if ( EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qbutton))
2073 { 2149 {
2074 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_SINGLE_ITEM (p))) 2150 if (gui_item_selected_p (IMAGE_INSTANCE_WIDGET_ITEM (p)))
2075 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2151 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2076 BM_SETCHECK, (WPARAM)BST_CHECKED, 0); 2152 BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
2077 else 2153 else
2078 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2154 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2079 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); 2155 BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
2080 } 2156 }
2157
2158 /* set the widget font from the widget face */
2159 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2160 WM_SETFONT,
2161 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT
2162 (XFONT_INSTANCE (widget_face_font_info
2163 (IMAGE_INSTANCE_SUBWINDOW_FRAME (p),
2164 IMAGE_INSTANCE_WIDGET_FACE (p),
2165 0, 0))),
2166 MAKELPARAM (TRUE, 0));
2081 } 2167 }
2082 } 2168 }
2083 2169
2084 /* register widgets into our hastable so that we can cope with the 2170 /* register widgets into our hastable so that we can cope with the
2085 callbacks. The hashtable is weak so deregistration is handled 2171 callbacks. The hashtable is weak so deregistration is handled
2099 } 2185 }
2100 2186
2101 static int 2187 static int
2102 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain) 2188 mswindows_register_widget_instance (Lisp_Object instance, Lisp_Object domain)
2103 { 2189 {
2104 return mswindows_register_gui_item (XIMAGE_INSTANCE_WIDGET_SINGLE_ITEM (instance), 2190 return mswindows_register_gui_item (XIMAGE_INSTANCE_WIDGET_ITEM (instance),
2105 domain); 2191 domain);
2106 } 2192 }
2107 2193
2108 static void 2194 static void
2109 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2195 mswindows_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2120 signal_simple_error ("Not an mswindows device", device); 2206 signal_simple_error ("Not an mswindows device", device);
2121 2207
2122 /* have to set the type this late in case there is no device 2208 /* have to set the type this late in case there is no device
2123 instantiation for a widget */ 2209 instantiation for a widget */
2124 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW; 2210 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
2211 /* Allocate space for the clip window */
2212 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
2213
2214 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
2215 = CreateWindowEx(
2216 0, /* EX flags */
2217 XEMACS_CONTROL_CLASS,
2218 0, /* text */
2219 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
2220 0, /* starting x position */
2221 0, /* starting y position */
2222 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2223 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2224 /* parent window */
2225 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2226 NULL, /* No menu */
2227 NULL, /* must be null for this class */
2228 NULL)) == NULL)
2229 signal_simple_error ("window creation failed with code",
2230 make_int (GetLastError()));
2125 2231
2126 wnd = CreateWindow( "STATIC", 2232 wnd = CreateWindow( "STATIC",
2127 "", 2233 "",
2128 WS_CHILD, 2234 WS_CHILD,
2129 0, /* starting x position */ 2235 0, /* starting x position */
2130 0, /* starting y position */ 2236 0, /* starting y position */
2131 IMAGE_INSTANCE_WIDGET_WIDTH (ii), 2237 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2132 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), 2238 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2133 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), /* parent window */ 2239 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii),
2134 0, 2240 0,
2135 (HINSTANCE) 2241 (HINSTANCE)
2136 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 2242 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2137 GWL_HINSTANCE), 2243 GWL_HINSTANCE),
2138 NULL); 2244 NULL);
2183 instance is already set -- this is the case when instantiate 2289 instance is already set -- this is the case when instantiate
2184 methods are called. */ 2290 methods are called. */
2185 2291
2186 static void 2292 static void
2187 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii, 2293 mswindows_initialize_dibitmap_image_instance (struct Lisp_Image_Instance *ii,
2294 int slices,
2188 enum image_instance_type type) 2295 enum image_instance_type type)
2189 { 2296 {
2190 ii->data = xnew_and_zero (struct mswindows_image_instance_data); 2297 ii->data = xnew_and_zero (struct mswindows_image_instance_data);
2191 IMAGE_INSTANCE_TYPE (ii) = type; 2298 IMAGE_INSTANCE_TYPE (ii) = type;
2192 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil; 2299 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
2193 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil; 2300 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
2194 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil; 2301 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
2195 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil; 2302 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
2196 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil; 2303 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
2197 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil; 2304 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
2305 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices;
2306 IMAGE_INSTANCE_MSWINDOWS_BITMAP_SLICES (ii) =
2307 xnew_array_and_zero (HBITMAP, slices);
2198 } 2308 }
2199 2309
2200 2310
2311 #ifdef HAVE_WIDGETS
2312
2201 /************************************************************************/ 2313 /************************************************************************/
2202 /* widgets */ 2314 /* widgets */
2203 /************************************************************************/ 2315 /************************************************************************/
2204 static void 2316 static void
2205 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2317 mswindows_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2206 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2318 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2207 int dest_mask, Lisp_Object domain, 2319 int dest_mask, Lisp_Object domain,
2208 CONST char* class, int flags, int exflags) 2320 CONST char* class, int flags, int exflags)
2209 { 2321 {
2322 /* this function can call lisp */
2210 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2323 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2211 #if 0
2212 struct Lisp_Image_Instance *groupii = 0;
2213 Lisp_Object group = find_keyword_in_vector (instantiator, Q_group);
2214 #endif
2215 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style; 2324 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), style;
2216 struct device* d = XDEVICE (device); 2325 struct device* d = XDEVICE (device);
2217 Lisp_Object frame = FW_FRAME (domain); 2326 Lisp_Object frame = FW_FRAME (domain);
2218 Extbyte* nm=0; 2327 Extbyte* nm=0;
2219 HWND wnd; 2328 HWND wnd;
2221 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); 2330 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2222 struct Lisp_Gui_Item* pgui = XGUI_ITEM (gui); 2331 struct Lisp_Gui_Item* pgui = XGUI_ITEM (gui);
2223 2332
2224 if (!DEVICE_MSWINDOWS_P (d)) 2333 if (!DEVICE_MSWINDOWS_P (d))
2225 signal_simple_error ("Not an mswindows device", device); 2334 signal_simple_error ("Not an mswindows device", device);
2226 #if 0 2335
2227 /* if the user specified another glyph as a group pick up the
2228 instance in our domain. */
2229 if (!NILP (group))
2230 {
2231 if (SYMBOLP (group))
2232 group = XSYMBOL (group)->value;
2233 group = glyph_image_instance (group, domain, ERROR_ME, 1);
2234 groupii = XIMAGE_INSTANCE (group);
2235 }
2236 #endif
2237 if (!gui_item_active_p (gui)) 2336 if (!gui_item_active_p (gui))
2238 flags |= WS_DISABLED; 2337 flags |= WS_DISABLED;
2239 2338
2240 style = pgui->style; 2339 style = pgui->style;
2241 2340
2247 instantiation for a widget */ 2346 instantiation for a widget */
2248 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET; 2347 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
2249 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) 2348 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
2250 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm); 2349 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm);
2251 2350
2252 wnd = CreateWindowEx( 2351 /* allocate space for the clip window and then allocate the clip window */
2253 exflags /* | WS_EX_NOPARENTNOTIFY*/, 2352 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
2254 class, 2353
2255 nm, 2354 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
2256 flags | WS_CHILD, 2355 = CreateWindowEx(
2257 0, /* starting x position */ 2356 0, /* EX flags */
2258 0, /* starting y position */ 2357 XEMACS_CONTROL_CLASS,
2259 IMAGE_INSTANCE_WIDGET_WIDTH (ii), 2358 0, /* text */
2260 IMAGE_INSTANCE_WIDGET_HEIGHT (ii), 2359 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
2261 /* parent window */ 2360 0, /* starting x position */
2262 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 2361 0, /* starting y position */
2263 (HMENU)id, /* No menu */ 2362 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2264 (HINSTANCE) 2363 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2265 GetWindowLong (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), 2364 /* parent window */
2266 GWL_HINSTANCE), 2365 FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2267 NULL); 2366 (HMENU)id, /* No menu */
2367 NULL, /* must be null for this class */
2368 NULL)) == NULL)
2369 signal_simple_error ("window creation failed with code",
2370 make_int (GetLastError()));
2371
2372 if ((wnd = CreateWindowEx(
2373 exflags /* | WS_EX_NOPARENTNOTIFY*/,
2374 class,
2375 nm,
2376 flags | WS_CHILD | WS_VISIBLE,
2377 0, /* starting x position */
2378 0, /* starting y position */
2379 IMAGE_INSTANCE_WIDGET_WIDTH (ii),
2380 IMAGE_INSTANCE_WIDGET_HEIGHT (ii),
2381 /* parent window */
2382 IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii),
2383 (HMENU)id, /* No menu */
2384 (HINSTANCE)
2385 GetWindowLong
2386 (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)),
2387 GWL_HINSTANCE),
2388 NULL)) == NULL)
2389 signal_simple_error ("window creation failed with code",
2390 make_int (GetLastError()));
2268 2391
2269 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; 2392 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
2270 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); 2393 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
2271 /* set the widget font from the widget face */ 2394 /* set the widget font from the widget face */
2272 SendMessage (wnd, WM_SETFONT, 2395 SendMessage (wnd, WM_SETFONT,
2287 static void 2410 static void
2288 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2411 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2289 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2412 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2290 int dest_mask, Lisp_Object domain) 2413 int dest_mask, Lisp_Object domain)
2291 { 2414 {
2415 /* this function can call lisp */
2292 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2416 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2293 HWND wnd; 2417 HWND wnd;
2294 int flags = BS_NOTIFY; 2418 int flags = BS_NOTIFY;
2295 Lisp_Object style; 2419 Lisp_Object style;
2296 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); 2420 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2390 #endif 2514 #endif
2391 } 2515 }
2392 2516
2393 /* instantiate a tree view widget */ 2517 /* instantiate a tree view widget */
2394 static HTREEITEM add_tree_item (Lisp_Object image_instance, 2518 static HTREEITEM add_tree_item (Lisp_Object image_instance,
2395 HWND wnd, HTREEITEM parent, Lisp_Object entry, 2519 HWND wnd, HTREEITEM parent, Lisp_Object item,
2396 int children, Lisp_Object domain) 2520 int children, Lisp_Object domain)
2397 { 2521 {
2398 TV_INSERTSTRUCT tvitem; 2522 TV_INSERTSTRUCT tvitem;
2399 HTREEITEM ret; 2523 HTREEITEM ret;
2400 2524
2401 tvitem.hParent = parent; 2525 tvitem.hParent = parent;
2402 tvitem.hInsertAfter = TVI_LAST; 2526 tvitem.hInsertAfter = TVI_LAST;
2403 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN; 2527 tvitem.item.mask = TVIF_TEXT | TVIF_CHILDREN;
2404 tvitem.item.cChildren = children; 2528 tvitem.item.cChildren = children;
2405 2529
2406 if (VECTORP (entry)) 2530 if (GUI_ITEMP (item))
2407 { 2531 {
2408 /* we always maintain the real gui item at the head of the 2532 tvitem.item.lParam = mswindows_register_gui_item (item, domain);
2409 list. We have to put them in the list in the first place
2410 because the whole model assumes that the glyph instances have
2411 references to all the associated data. If we didn't do this
2412 GC would bite us badly. */
2413 Lisp_Object gui = gui_parse_item_keywords_no_errors (entry);
2414 if (CONSP (XIMAGE_INSTANCE_WIDGET_ITEM (image_instance)))
2415 {
2416 Lisp_Object rest =
2417 Fcons (gui, XCDR (XIMAGE_INSTANCE_WIDGET_ITEM (image_instance)));
2418 Fsetcdr (XIMAGE_INSTANCE_WIDGET_ITEM (image_instance), rest);
2419 }
2420 else
2421 {
2422 XIMAGE_INSTANCE_WIDGET_ITEM (image_instance) =
2423 Fcons (XIMAGE_INSTANCE_WIDGET_ITEM (image_instance), gui);
2424 }
2425
2426 tvitem.item.lParam = mswindows_register_gui_item (gui, domain);
2427 tvitem.item.mask |= TVIF_PARAM; 2533 tvitem.item.mask |= TVIF_PARAM;
2428 GET_C_STRING_OS_DATA_ALLOCA (XGUI_ITEM (gui)->name, 2534 GET_C_STRING_OS_DATA_ALLOCA (XGUI_ITEM (item)->name,
2429 tvitem.item.pszText); 2535 tvitem.item.pszText);
2430 } 2536 }
2431 else 2537 else
2432 GET_C_STRING_OS_DATA_ALLOCA (entry, tvitem.item.pszText); 2538 GET_C_STRING_OS_DATA_ALLOCA (item, tvitem.item.pszText);
2433 2539
2434 tvitem.item.cchTextMax = strlen (tvitem.item.pszText); 2540 tvitem.item.cchTextMax = strlen (tvitem.item.pszText);
2435 2541
2436 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM, 2542 if ((ret = (HTREEITEM)SendMessage (wnd, TVM_INSERTITEM,
2437 0, (LPARAM)&tvitem)) == 0) 2543 0, (LPARAM)&tvitem)) == 0)
2438 signal_simple_error ("error adding tree view entry", entry); 2544 signal_simple_error ("error adding tree view entry", item);
2439 2545
2440 return ret; 2546 return ret;
2441 } 2547 }
2442 2548
2443 static void add_tree_item_list (Lisp_Object image_instance, 2549 static void add_tree_item_list (Lisp_Object image_instance,
2474 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT); 2580 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT);
2475 2581
2476 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2582 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2477 2583
2478 /* define a root */ 2584 /* define a root */
2479 parent = add_tree_item (image_instance, 2585 parent = add_tree_item (image_instance, wnd, NULL,
2480 wnd, NULL, IMAGE_INSTANCE_WIDGET_TEXT (ii), TRUE, 2586 XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)),
2481 domain); 2587 TRUE, domain);
2482 2588
2483 /* recursively add items to the tree view */ 2589 /* recursively add items to the tree view */
2484 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) 2590 /* add items to the tab */
2591 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2485 { 2592 {
2486 if (LISTP (XCAR (rest))) 2593 if (LISTP (XCAR (rest)))
2487 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain); 2594 add_tree_item_list (image_instance, wnd, parent, XCAR (rest), domain);
2488 else 2595 else
2489 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain); 2596 add_tree_item (image_instance, wnd, parent, XCAR (rest), FALSE, domain);
2490 } 2597 }
2491 } 2598 }
2492 2599
2493 /* instantiate a tab control */ 2600 /* instantiate a tab control */
2494 static TC_ITEM* add_tab_item (Lisp_Object image_instance, 2601 static TC_ITEM* add_tab_item (Lisp_Object image_instance,
2495 HWND wnd, Lisp_Object entry, 2602 HWND wnd, Lisp_Object item,
2496 Lisp_Object domain, int index) 2603 Lisp_Object domain, int index)
2497 { 2604 {
2498 TC_ITEM tvitem, *ret; 2605 TC_ITEM tvitem, *ret;
2499 2606
2500 tvitem.mask = TCIF_TEXT; 2607 tvitem.mask = TCIF_TEXT;
2501 2608
2502 if (VECTORP (entry)) 2609 if (GUI_ITEMP (item))
2503 { 2610 {
2504 /* we always maintain the real gui item at the head of the 2611 tvitem.lParam = mswindows_register_gui_item (item, domain);
2505 list. We have to put them in the list in the first place
2506 because the whole model assumes that the glyph instances have
2507 references to all the associated data. If we didn't do this
2508 GC would bite us badly. */
2509 Lisp_Object gui = gui_parse_item_keywords_no_errors (entry);
2510 if (CONSP (XIMAGE_INSTANCE_WIDGET_ITEM (image_instance)))
2511 {
2512 Lisp_Object rest =
2513 Fcons (gui, XCDR (XIMAGE_INSTANCE_WIDGET_ITEM (image_instance)));
2514 Fsetcdr (XIMAGE_INSTANCE_WIDGET_ITEM (image_instance), rest);
2515 }
2516 else
2517 {
2518 XIMAGE_INSTANCE_WIDGET_ITEM (image_instance) =
2519 Fcons (XIMAGE_INSTANCE_WIDGET_ITEM (image_instance), gui);
2520 }
2521
2522 tvitem.lParam = mswindows_register_gui_item (gui, domain);
2523 tvitem.mask |= TCIF_PARAM; 2612 tvitem.mask |= TCIF_PARAM;
2524 GET_C_STRING_OS_DATA_ALLOCA (XGUI_ITEM (gui)->name, 2613 GET_C_STRING_OS_DATA_ALLOCA (XGUI_ITEM (item)->name,
2525 tvitem.pszText); 2614 tvitem.pszText);
2526 } 2615 }
2527 else 2616 else
2528 GET_C_STRING_OS_DATA_ALLOCA (entry, tvitem.pszText); 2617 {
2618 CHECK_STRING (item);
2619 GET_C_STRING_OS_DATA_ALLOCA (item, tvitem.pszText);
2620 }
2529 2621
2530 tvitem.cchTextMax = strlen (tvitem.pszText); 2622 tvitem.cchTextMax = strlen (tvitem.pszText);
2531 2623
2532 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM, 2624 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM,
2533 index, (LPARAM)&tvitem)) < 0) 2625 index, (LPARAM)&tvitem)) < 0)
2534 signal_simple_error ("error adding tab entry", entry); 2626 signal_simple_error ("error adding tab entry", item);
2535 2627
2536 return ret; 2628 return ret;
2537 } 2629 }
2538 2630
2539 static void 2631 static void
2551 WS_TABSTOP, 2643 WS_TABSTOP,
2552 WS_EX_CONTROLPARENT); 2644 WS_EX_CONTROLPARENT);
2553 2645
2554 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2646 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2555 /* add items to the tab */ 2647 /* add items to the tab */
2556 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) 2648 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2557 { 2649 {
2558 add_tab_item (image_instance, wnd, XCAR (rest), domain, index); 2650 add_tab_item (image_instance, wnd, XCAR (rest), domain, index);
2559 index++; 2651 index++;
2560 } 2652 }
2561 } 2653 }
2575 check_valid_item_list_1 (val); 2667 check_valid_item_list_1 (val);
2576 2668
2577 /* delete the pre-existing items */ 2669 /* delete the pre-existing items */
2578 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); 2670 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0);
2579 2671
2672 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
2673 Fcons (XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)),
2674 parse_gui_item_tree_children (val));
2675
2580 /* add items to the tab */ 2676 /* add items to the tab */
2581 LIST_LOOP (rest, val) 2677 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2582 { 2678 {
2583 add_tab_item (image_instance, wnd, XCAR (rest), 2679 add_tab_item (image_instance, wnd, XCAR (rest),
2584 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii), index); 2680 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii), index);
2585 index++; 2681 index++;
2586 } 2682 }
2599 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2695 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2600 pointer_bg, dest_mask, domain, "STATIC", 2696 pointer_bg, dest_mask, domain, "STATIC",
2601 0, WS_EX_STATICEDGE); 2697 0, WS_EX_STATICEDGE);
2602 } 2698 }
2603 2699
2604 #if 0
2605 /* instantiate a static control possible for putting other things in */
2606 static void
2607 mswindows_group_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2608 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2609 int dest_mask, Lisp_Object domain)
2610 {
2611 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2612 pointer_bg, dest_mask, domain, "BUTTON",
2613 WS_GROUP | BS_GROUPBOX | WS_BORDER,
2614 WS_EX_CLIENTEDGE );
2615 }
2616 #endif
2617
2618 /* instantiate a scrollbar control */ 2700 /* instantiate a scrollbar control */
2619 static void 2701 static void
2620 mswindows_scrollbar_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2702 mswindows_scrollbar_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2621 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2703 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2622 int dest_mask, Lisp_Object domain) 2704 int dest_mask, Lisp_Object domain)
2634 int dest_mask, Lisp_Object domain) 2716 int dest_mask, Lisp_Object domain)
2635 { 2717 {
2636 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2718 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2637 HANDLE wnd; 2719 HANDLE wnd;
2638 Lisp_Object rest; 2720 Lisp_Object rest;
2721 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties),
2722 Q_items, Qnil);
2723 int len;
2724 GET_LIST_LENGTH (data, len);
2639 2725
2640 /* Maybe ought to generalise this more but it may be very windows 2726 /* Maybe ought to generalise this more but it may be very windows
2641 specific. In windows the window height of a combo box is the 2727 specific. In windows the window height of a combo box is the
2642 height when the combo box is open. Thus we need to set the height 2728 height when the combo box is open. Thus we need to set the height
2643 before creating the window and then reset it to a single line 2729 before creating the window and then reset it to a single line
2644 after the window is created so that redisplay does the right 2730 after the window is created so that redisplay does the right
2645 thing. */ 2731 thing. */
2732 widget_instantiate_1 (image_instance, instantiator, pointer_fg,
2733 pointer_bg, dest_mask, domain, len + 1, 0, 0);
2734
2646 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2735 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2647 pointer_bg, dest_mask, domain, "COMBOBOX", 2736 pointer_bg, dest_mask, domain, "COMBOBOX",
2648 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN 2737 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN
2649 | CBS_AUTOHSCROLL 2738 | CBS_AUTOHSCROLL
2650 | CBS_HASSTRINGS | WS_VSCROLL, 2739 | CBS_HASSTRINGS | WS_VSCROLL,
2752 return Qt; 2841 return Qt;
2753 } 2842 }
2754 return Qunbound; 2843 return Qunbound;
2755 } 2844 }
2756 2845
2846 LRESULT WINAPI
2847 mswindows_control_wnd_proc (HWND hwnd, UINT message,
2848 WPARAM wParam, LPARAM lParam)
2849 {
2850 switch (message)
2851 {
2852 case WM_NOTIFY:
2853 case WM_COMMAND:
2854 case WM_CTLCOLORBTN:
2855 case WM_CTLCOLORLISTBOX:
2856 case WM_CTLCOLOREDIT:
2857 case WM_CTLCOLORSTATIC:
2858 case WM_CTLCOLORSCROLLBAR:
2859
2860 return mswindows_wnd_proc (GetParent (hwnd), message, wParam, lParam);
2861 default:
2862 return DefWindowProc (hwnd, message, wParam, lParam);
2863 }
2864 }
2865
2866 #endif /* HAVE_WIDGETS */
2867
2757 2868
2758 /************************************************************************/ 2869 /************************************************************************/
2759 /* initialization */ 2870 /* initialization */
2760 /************************************************************************/ 2871 /************************************************************************/
2761 2872
2786 void 2897 void
2787 image_instantiator_format_create_glyphs_mswindows (void) 2898 image_instantiator_format_create_glyphs_mswindows (void)
2788 { 2899 {
2789 IIFORMAT_VALID_CONSOLE (mswindows, nothing); 2900 IIFORMAT_VALID_CONSOLE (mswindows, nothing);
2790 IIFORMAT_VALID_CONSOLE (mswindows, string); 2901 IIFORMAT_VALID_CONSOLE (mswindows, string);
2902 IIFORMAT_VALID_CONSOLE (mswindows, layout);
2791 IIFORMAT_VALID_CONSOLE (mswindows, formatted_string); 2903 IIFORMAT_VALID_CONSOLE (mswindows, formatted_string);
2792 IIFORMAT_VALID_CONSOLE (mswindows, inherit); 2904 IIFORMAT_VALID_CONSOLE (mswindows, inherit);
2793 /* image-instantiator types */ 2905 /* image-instantiator types */
2794 #ifdef HAVE_XPM 2906 #ifdef HAVE_XPM
2795 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm); 2907 INITIALIZE_DEVICE_IIFORMAT (mswindows, xpm);
2811 IIFORMAT_VALID_CONSOLE (mswindows, png); 2923 IIFORMAT_VALID_CONSOLE (mswindows, png);
2812 #endif 2924 #endif
2813 #ifdef HAVE_GIF 2925 #ifdef HAVE_GIF
2814 IIFORMAT_VALID_CONSOLE (mswindows, gif); 2926 IIFORMAT_VALID_CONSOLE (mswindows, gif);
2815 #endif 2927 #endif
2928 #ifdef HAVE_WIDGETS
2816 /* button widget */ 2929 /* button widget */
2817 INITIALIZE_DEVICE_IIFORMAT (mswindows, button); 2930 INITIALIZE_DEVICE_IIFORMAT (mswindows, button);
2818 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property); 2931 IIFORMAT_HAS_DEVMETHOD (mswindows, button, property);
2819 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate); 2932 IIFORMAT_HAS_DEVMETHOD (mswindows, button, instantiate);
2820 2933
2825 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate); 2938 IIFORMAT_HAS_DEVMETHOD (mswindows, subwindow, instantiate);
2826 2939
2827 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget); 2940 INITIALIZE_DEVICE_IIFORMAT (mswindows, widget);
2828 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property); 2941 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, property);
2829 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, set_property); 2942 IIFORMAT_HAS_DEVMETHOD (mswindows, widget, set_property);
2830 #if 0 2943
2831 INITIALIZE_DEVICE_IIFORMAT (mswindows, group);
2832 IIFORMAT_HAS_DEVMETHOD (mswindows, group, instantiate);
2833 #endif
2834 /* label */ 2944 /* label */
2835 INITIALIZE_DEVICE_IIFORMAT (mswindows, label); 2945 INITIALIZE_DEVICE_IIFORMAT (mswindows, label);
2836 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate); 2946 IIFORMAT_HAS_DEVMETHOD (mswindows, label, instantiate);
2837 2947
2838 /* combo box */ 2948 /* combo box */
2856 2966
2857 /* tab control widget */ 2967 /* tab control widget */
2858 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control); 2968 INITIALIZE_DEVICE_IIFORMAT (mswindows, tab_control);
2859 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate); 2969 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, instantiate);
2860 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, set_property); 2970 IIFORMAT_HAS_DEVMETHOD (mswindows, tab_control, set_property);
2861 2971 #endif
2862 /* windows bitmap format */ 2972 /* windows bitmap format */
2863 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp"); 2973 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (bmp, "bmp");
2864 IIFORMAT_HAS_METHOD (bmp, validate); 2974 IIFORMAT_HAS_METHOD (bmp, validate);
2865 IIFORMAT_HAS_METHOD (bmp, normalize); 2975 IIFORMAT_HAS_METHOD (bmp, normalize);
2866 IIFORMAT_HAS_METHOD (bmp, possible_dest_types); 2976 IIFORMAT_HAS_METHOD (bmp, possible_dest_types);