comparison src/glyphs-x.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
147 Lisp_Object domain); 147 Lisp_Object domain);
148 148
149 #ifdef HAVE_WIDGETS 149 #ifdef HAVE_WIDGETS
150 static void 150 static void
151 update_widget_face (widget_value* wv, 151 update_widget_face (widget_value* wv,
152 struct Lisp_Image_Instance* ii, Lisp_Object domain); 152 Lisp_Image_Instance* ii, Lisp_Object domain);
153 static void 153 static void
154 update_tab_widget_face (widget_value* wv, 154 update_tab_widget_face (widget_value* wv,
155 struct Lisp_Image_Instance* ii, Lisp_Object domain); 155 Lisp_Image_Instance* ii, Lisp_Object domain);
156 #endif 156 #endif
157 157
158 #include "bitmaps.h" 158 #include "bitmaps.h"
159 159
160 160
231 /* use our quantize table to allocate the colors */ 231 /* use our quantize table to allocate the colors */
232 pixcount = 32; 232 pixcount = 32;
233 *pixtbl = xnew_array (unsigned long, pixcount); 233 *pixtbl = xnew_array (unsigned long, pixcount);
234 *npixels = 0; 234 *npixels = 0;
235 235
236 /* ### should implement a sort by popularity to assure proper allocation */ 236 /* #### should implement a sort by popularity to assure proper allocation */
237 n = *npixels; 237 n = *npixels;
238 for (i = 0; i < qtable->num_active_colors; i++) 238 for (i = 0; i < qtable->num_active_colors; i++)
239 { 239 {
240 XColor color; 240 XColor color;
241 int res; 241 int res;
357 } 357 }
358 358
359 359
360 360
361 static void 361 static void
362 x_print_image_instance (struct Lisp_Image_Instance *p, 362 x_print_image_instance (Lisp_Image_Instance *p,
363 Lisp_Object printcharfun, 363 Lisp_Object printcharfun,
364 int escapeflag) 364 int escapeflag)
365 { 365 {
366 char buf[100]; 366 char buf[100];
367 367
387 #ifdef DEBUG_WIDGETS 387 #ifdef DEBUG_WIDGETS
388 extern int debug_widget_instances; 388 extern int debug_widget_instances;
389 #endif 389 #endif
390 390
391 static void 391 static void
392 x_finalize_image_instance (struct Lisp_Image_Instance *p) 392 x_finalize_image_instance (Lisp_Image_Instance *p)
393 { 393 {
394 if (!p->data) 394 if (!p->data)
395 return; 395 return;
396 396
397 if (DEVICE_LIVE_P (XDEVICE (p->device))) 397 if (DEVICE_LIVE_P (XDEVICE (p->device)))
471 xfree (p->data); 471 xfree (p->data);
472 p->data = 0; 472 p->data = 0;
473 } 473 }
474 474
475 static int 475 static int
476 x_image_instance_equal (struct Lisp_Image_Instance *p1, 476 x_image_instance_equal (Lisp_Image_Instance *p1,
477 struct Lisp_Image_Instance *p2, int depth) 477 Lisp_Image_Instance *p2, int depth)
478 { 478 {
479 switch (IMAGE_INSTANCE_TYPE (p1)) 479 switch (IMAGE_INSTANCE_TYPE (p1))
480 { 480 {
481 case IMAGE_MONO_PIXMAP: 481 case IMAGE_MONO_PIXMAP:
482 case IMAGE_COLOR_PIXMAP: 482 case IMAGE_COLOR_PIXMAP:
491 491
492 return 1; 492 return 1;
493 } 493 }
494 494
495 static unsigned long 495 static unsigned long
496 x_image_instance_hash (struct Lisp_Image_Instance *p, int depth) 496 x_image_instance_hash (Lisp_Image_Instance *p, int depth)
497 { 497 {
498 switch (IMAGE_INSTANCE_TYPE (p)) 498 switch (IMAGE_INSTANCE_TYPE (p))
499 { 499 {
500 case IMAGE_MONO_PIXMAP: 500 case IMAGE_MONO_PIXMAP:
501 case IMAGE_COLOR_PIXMAP: 501 case IMAGE_COLOR_PIXMAP:
511 method. It is assumed that the device slot within the image 511 method. It is assumed that the device slot within the image
512 instance is already set -- this is the case when instantiate 512 instance is already set -- this is the case when instantiate
513 methods are called. */ 513 methods are called. */
514 514
515 static void 515 static void
516 x_initialize_pixmap_image_instance (struct Lisp_Image_Instance *ii, 516 x_initialize_pixmap_image_instance (Lisp_Image_Instance *ii,
517 int slices, 517 int slices,
518 enum image_instance_type type) 518 enum image_instance_type type)
519 { 519 {
520 ii->data = xnew_and_zero (struct x_image_instance_data); 520 ii->data = xnew_and_zero (struct x_image_instance_data);
521 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices; 521 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices;
562 (XSTRING_BYTE (name, 1) == '/' || 562 (XSTRING_BYTE (name, 1) == '/' ||
563 (XSTRING_BYTE (name, 1) == '.' && 563 (XSTRING_BYTE (name, 1) == '.' &&
564 (XSTRING_BYTE (name, 2) == '/'))))) 564 (XSTRING_BYTE (name, 2) == '/')))))
565 { 565 {
566 if (!NILP (Ffile_readable_p (name))) 566 if (!NILP (Ffile_readable_p (name)))
567 return name; 567 return Fexpand_file_name (name, Qnil);
568 else 568 else
569 return Qnil; 569 return Qnil;
570 } 570 }
571 571
572 if (NILP (Vdefault_x_device)) 572 if (NILP (Vdefault_x_device))
831 831
832 #### This should be able to handle conversion into `pointer'. 832 #### This should be able to handle conversion into `pointer'.
833 Use the same code as for `xpm'. */ 833 Use the same code as for `xpm'. */
834 834
835 static void 835 static void
836 init_image_instance_from_x_image (struct Lisp_Image_Instance *ii, 836 init_image_instance_from_x_image (Lisp_Image_Instance *ii,
837 XImage *ximage, 837 XImage *ximage,
838 int dest_mask, 838 int dest_mask,
839 Colormap cmap, 839 Colormap cmap,
840 unsigned long *pixels, 840 unsigned long *pixels,
841 int npixels, 841 int npixels,
891 IMAGE_INSTANCE_X_PIXELS (ii) = pixels; 891 IMAGE_INSTANCE_X_PIXELS (ii) = pixels;
892 IMAGE_INSTANCE_X_NPIXELS (ii) = npixels; 892 IMAGE_INSTANCE_X_NPIXELS (ii) = npixels;
893 } 893 }
894 894
895 static void 895 static void
896 image_instance_add_x_image (struct Lisp_Image_Instance *ii, 896 image_instance_add_x_image (Lisp_Image_Instance *ii,
897 XImage *ximage, 897 XImage *ximage,
898 int slice, 898 int slice,
899 Lisp_Object instantiator) 899 Lisp_Object instantiator)
900 { 900 {
901 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 901 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
926 926
927 IMAGE_INSTANCE_X_PIXMAP_SLICE (ii, slice) = pixmap; 927 IMAGE_INSTANCE_X_PIXMAP_SLICE (ii, slice) = pixmap;
928 } 928 }
929 929
930 static void 930 static void
931 x_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii, 931 x_init_image_instance_from_eimage (Lisp_Image_Instance *ii,
932 int width, int height, 932 int width, int height,
933 int slices, 933 int slices,
934 unsigned char *eimage, 934 unsigned char *eimage,
935 int dest_mask, 935 int dest_mask,
936 Lisp_Object instantiator, 936 Lisp_Object instantiator,
999 999
1000 /* Given inline data for a mono pixmap, initialize the given 1000 /* Given inline data for a mono pixmap, initialize the given
1001 image instance accordingly. */ 1001 image instance accordingly. */
1002 1002
1003 static void 1003 static void
1004 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii, 1004 init_image_instance_from_xbm_inline (Lisp_Image_Instance *ii,
1005 int width, int height, 1005 int width, int height,
1006 /* Note that data is in ext-format! */ 1006 /* Note that data is in ext-format! */
1007 CONST char *bits, 1007 CONST char *bits,
1008 Lisp_Object instantiator, 1008 Lisp_Object instantiator,
1009 Lisp_Object pointer_fg, 1009 Lisp_Object pointer_fg,
1144 /* Note that data is in ext-format! */ 1144 /* Note that data is in ext-format! */
1145 CONST char *bits) 1145 CONST char *bits)
1146 { 1146 {
1147 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); 1147 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
1148 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); 1148 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
1149 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1149 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1150 Pixmap mask = 0; 1150 Pixmap mask = 0;
1151 CONST char *gcc_may_you_rot_in_hell;
1152 1151
1153 if (!NILP (mask_data)) 1152 if (!NILP (mask_data))
1154 { 1153 {
1155 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (mask_data))), 1154 CONST char *ext_data;
1156 gcc_may_you_rot_in_hell); 1155
1157 mask = 1156 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
1158 pixmap_from_xbm_inline (IMAGE_INSTANCE_DEVICE (ii), 1157 C_STRING_ALLOCA, ext_data,
1159 XINT (XCAR (mask_data)), 1158 Qbinary);
1160 XINT (XCAR (XCDR (mask_data))), 1159 mask = pixmap_from_xbm_inline (IMAGE_INSTANCE_DEVICE (ii),
1161 (CONST unsigned char *) 1160 XINT (XCAR (mask_data)),
1162 gcc_may_you_rot_in_hell); 1161 XINT (XCAR (XCDR (mask_data))),
1162 (CONST unsigned char *) ext_data);
1163 } 1163 }
1164 1164
1165 init_image_instance_from_xbm_inline (ii, width, height, bits, 1165 init_image_instance_from_xbm_inline (ii, width, height, bits,
1166 instantiator, pointer_fg, pointer_bg, 1166 instantiator, pointer_fg, pointer_bg,
1167 dest_mask, mask, mask_file); 1167 dest_mask, mask, mask_file);
1173 x_xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1173 x_xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1174 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1174 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1175 int dest_mask, Lisp_Object domain) 1175 int dest_mask, Lisp_Object domain)
1176 { 1176 {
1177 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1177 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1178 CONST char *gcc_go_home; 1178 CONST char *ext_data;
1179 1179
1180 assert (!NILP (data)); 1180 assert (!NILP (data));
1181 1181
1182 GET_C_STRING_BINARY_DATA_ALLOCA (XCAR (XCDR (XCDR (data))), 1182 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))),
1183 gcc_go_home); 1183 C_STRING_ALLOCA, ext_data,
1184 Qbinary);
1184 1185
1185 xbm_instantiate_1 (image_instance, instantiator, pointer_fg, 1186 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
1186 pointer_bg, dest_mask, XINT (XCAR (data)), 1187 pointer_bg, dest_mask, XINT (XCAR (data)),
1187 XINT (XCAR (XCDR (data))), gcc_go_home); 1188 XINT (XCAR (XCDR (data))), ext_data);
1188 } 1189 }
1189 1190
1190 1191
1191 #ifdef HAVE_XPM 1192 #ifdef HAVE_XPM
1192 1193
1290 x_xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1291 x_xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1291 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1292 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1292 int dest_mask, Lisp_Object domain) 1293 int dest_mask, Lisp_Object domain)
1293 { 1294 {
1294 /* This function can GC */ 1295 /* This function can GC */
1295 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1296 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1296 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1297 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1297 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1298 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1298 Display *dpy; 1299 Display *dpy;
1299 Screen *xs; 1300 Screen *xs;
1300 Colormap cmap; 1301 Colormap cmap;
1663 CONST char * volatile emsg = 0; 1664 CONST char * volatile emsg = 0;
1664 CONST char * volatile dstring; 1665 CONST char * volatile dstring;
1665 1666
1666 assert (!NILP (data)); 1667 assert (!NILP (data));
1667 1668
1668 GET_C_STRING_BINARY_DATA_ALLOCA (data, dstring); 1669 TO_EXTERNAL_FORMAT (LISP_STRING, data,
1670 C_STRING_ALLOCA, dstring,
1671 Qbinary);
1669 1672
1670 if ((p = strchr (dstring, ':'))) 1673 if ((p = strchr (dstring, ':')))
1671 { 1674 {
1672 dstring = p + 1; 1675 dstring = p + 1;
1673 } 1676 }
1835 1838
1836 alist = tagged_vector_to_alist (instantiator); 1839 alist = tagged_vector_to_alist (instantiator);
1837 if (dest_mask & IMAGE_POINTER_MASK) 1840 if (dest_mask & IMAGE_POINTER_MASK)
1838 { 1841 {
1839 CONST char *name_ext; 1842 CONST char *name_ext;
1840 GET_C_STRING_FILENAME_DATA_ALLOCA (data, name_ext); 1843 TO_EXTERNAL_FORMAT (LISP_STRING, data,
1844 C_STRING_ALLOCA, name_ext,
1845 Qfile_name);
1841 if (XmuCursorNameToIndex (name_ext) != -1) 1846 if (XmuCursorNameToIndex (name_ext) != -1)
1842 { 1847 {
1843 result = alist_to_tagged_vector (Qcursor_font, alist); 1848 result = alist_to_tagged_vector (Qcursor_font, alist);
1844 is_cursor_font = 1; 1849 is_cursor_font = 1;
1845 } 1850 }
1922 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1927 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1923 int dest_mask, Lisp_Object domain) 1928 int dest_mask, Lisp_Object domain)
1924 { 1929 {
1925 /* This function can GC */ 1930 /* This function can GC */
1926 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1931 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1927 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1932 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1928 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1933 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1929 Display *dpy; 1934 Display *dpy;
1930 XColor fg, bg; 1935 XColor fg, bg;
1931 Font source, mask; 1936 Font source, mask;
1932 char source_name[MAXPATHLEN], mask_name[MAXPATHLEN], dummy; 1937 char source_name[MAXPATHLEN], mask_name[MAXPATHLEN], dummy;
2020 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2025 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2021 int dest_mask, Lisp_Object domain) 2026 int dest_mask, Lisp_Object domain)
2022 { 2027 {
2023 /* This function can GC */ 2028 /* This function can GC */
2024 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 2029 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
2025 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2030 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2026 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 2031 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
2027 Display *dpy; 2032 Display *dpy;
2028 int i; 2033 int i;
2029 CONST char *name_ext; 2034 CONST char *name_ext;
2030 Lisp_Object foreground, background; 2035 Lisp_Object foreground, background;
2035 dpy = DEVICE_X_DISPLAY (XDEVICE (device)); 2040 dpy = DEVICE_X_DISPLAY (XDEVICE (device));
2036 2041
2037 if (!(dest_mask & IMAGE_POINTER_MASK)) 2042 if (!(dest_mask & IMAGE_POINTER_MASK))
2038 incompatible_image_types (instantiator, dest_mask, IMAGE_POINTER_MASK); 2043 incompatible_image_types (instantiator, dest_mask, IMAGE_POINTER_MASK);
2039 2044
2040 GET_C_STRING_FILENAME_DATA_ALLOCA (data, name_ext); 2045 TO_EXTERNAL_FORMAT (LISP_STRING, data,
2046 C_STRING_ALLOCA, name_ext,
2047 Qfile_name);
2041 if ((i = XmuCursorNameToIndex (name_ext)) == -1) 2048 if ((i = XmuCursorNameToIndex (name_ext)) == -1)
2042 signal_simple_error ("Unrecognized cursor-font name", data); 2049 signal_simple_error ("Unrecognized cursor-font name", data);
2043 2050
2044 x_initialize_pixmap_image_instance (ii, 1, IMAGE_POINTER); 2051 x_initialize_pixmap_image_instance (ii, 1, IMAGE_POINTER);
2045 IMAGE_INSTANCE_X_CURSOR (ii) = XCreateFontCursor (dpy, i); 2052 IMAGE_INSTANCE_X_CURSOR (ii) = XCreateFontCursor (dpy, i);
2054 2061
2055 static int 2062 static int
2056 x_colorize_image_instance (Lisp_Object image_instance, 2063 x_colorize_image_instance (Lisp_Object image_instance,
2057 Lisp_Object foreground, Lisp_Object background) 2064 Lisp_Object foreground, Lisp_Object background)
2058 { 2065 {
2059 struct Lisp_Image_Instance *p; 2066 Lisp_Image_Instance *p;
2060 2067
2061 p = XIMAGE_INSTANCE (image_instance); 2068 p = XIMAGE_INSTANCE (image_instance);
2062 2069
2063 switch (IMAGE_INSTANCE_TYPE (p)) 2070 switch (IMAGE_INSTANCE_TYPE (p))
2064 { 2071 {
2107 /************************************************************************/ 2114 /************************************************************************/
2108 2115
2109 /* unmap the image if it is a widget. This is used by redisplay via 2116 /* unmap the image if it is a widget. This is used by redisplay via
2110 redisplay_unmap_subwindows */ 2117 redisplay_unmap_subwindows */
2111 static void 2118 static void
2112 x_unmap_subwindow (struct Lisp_Image_Instance *p) 2119 x_unmap_subwindow (Lisp_Image_Instance *p)
2113 { 2120 {
2114 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW) 2121 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
2115 { 2122 {
2116 XUnmapWindow 2123 XUnmapWindow
2117 (IMAGE_INSTANCE_X_SUBWINDOW_DISPLAY (p), 2124 (IMAGE_INSTANCE_X_SUBWINDOW_DISPLAY (p),
2124 } 2131 }
2125 2132
2126 /* map the subwindow. This is used by redisplay via 2133 /* map the subwindow. This is used by redisplay via
2127 redisplay_output_subwindow */ 2134 redisplay_output_subwindow */
2128 static void 2135 static void
2129 x_map_subwindow (struct Lisp_Image_Instance *p, int x, int y, 2136 x_map_subwindow (Lisp_Image_Instance *p, int x, int y,
2130 struct display_glyph_area* dga) 2137 struct display_glyph_area* dga)
2131 { 2138 {
2132 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW) 2139 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
2133 { 2140 {
2134 Window subwindow = IMAGE_INSTANCE_X_SUBWINDOW_ID (p); 2141 Window subwindow = IMAGE_INSTANCE_X_SUBWINDOW_ID (p);
2153 } 2160 }
2154 2161
2155 /* 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
2156 needs to be checked and all appropriate widgets updated */ 2163 needs to be checked and all appropriate widgets updated */
2157 static void 2164 static void
2158 x_update_subwindow (struct Lisp_Image_Instance *p) 2165 x_update_subwindow (Lisp_Image_Instance *p)
2159 { 2166 {
2160 #ifdef HAVE_WIDGETS 2167 #ifdef HAVE_WIDGETS
2161 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) 2168 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
2162 { 2169 {
2163 widget_value* wv = gui_items_to_widget_values 2170 widget_value* wv = gui_items_to_widget_values
2186 x_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2193 x_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2187 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2194 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2188 int dest_mask, Lisp_Object domain) 2195 int dest_mask, Lisp_Object domain)
2189 { 2196 {
2190 /* This function can GC */ 2197 /* This function can GC */
2191 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2198 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2192 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 2199 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
2193 Lisp_Object frame = FW_FRAME (domain); 2200 Lisp_Object frame = FW_FRAME (domain);
2194 struct frame* f = XFRAME (frame); 2201 struct frame* f = XFRAME (frame);
2195 Display *dpy; 2202 Display *dpy;
2196 Screen *xs; 2203 Screen *xs;
2242 Subwindows are not currently implemented. 2249 Subwindows are not currently implemented.
2243 */ 2250 */
2244 (subwindow, property, data)) 2251 (subwindow, property, data))
2245 { 2252 {
2246 Atom property_atom; 2253 Atom property_atom;
2247 struct Lisp_Subwindow *sw; 2254 Lisp_Subwindow *sw;
2248 Display *dpy; 2255 Display *dpy;
2249 2256
2250 CHECK_SUBWINDOW (subwindow); 2257 CHECK_SUBWINDOW (subwindow);
2251 CHECK_STRING (property); 2258 CHECK_STRING (property);
2252 CHECK_STRING (data); 2259 CHECK_STRING (data);
2264 return property; 2271 return property;
2265 } 2272 }
2266 #endif 2273 #endif
2267 2274
2268 static void 2275 static void
2269 x_resize_subwindow (struct Lisp_Image_Instance* ii, int w, int h) 2276 x_resize_subwindow (Lisp_Image_Instance* ii, int w, int h)
2270 { 2277 {
2271 if (IMAGE_INSTANCE_TYPE (ii) == IMAGE_SUBWINDOW) 2278 if (IMAGE_INSTANCE_TYPE (ii) == IMAGE_SUBWINDOW)
2272 { 2279 {
2273 XResizeWindow (IMAGE_INSTANCE_X_SUBWINDOW_DISPLAY (ii), 2280 XResizeWindow (IMAGE_INSTANCE_X_SUBWINDOW_DISPLAY (ii),
2274 IMAGE_INSTANCE_X_SUBWINDOW_ID (ii), 2281 IMAGE_INSTANCE_X_SUBWINDOW_ID (ii),
2276 } 2283 }
2277 else /* must be a widget */ 2284 else /* must be a widget */
2278 { 2285 {
2279 Arg al[2]; 2286 Arg al[2];
2280 2287
2281 if (!XtIsRealized (IMAGE_INSTANCE_X_WIDGET_ID (ii))) 2288 if ( !XtIsManaged(IMAGE_INSTANCE_X_WIDGET_ID (ii))
2289 ||
2290 IMAGE_INSTANCE_X_WIDGET_ID (ii)->core.being_destroyed )
2282 { 2291 {
2283 Lisp_Object sw; 2292 Lisp_Object sw;
2284 XSETIMAGE_INSTANCE (sw, ii); 2293 XSETIMAGE_INSTANCE (sw, ii);
2285 signal_simple_error ("XEmacs bug: subwindow is not realized", sw); 2294 signal_simple_error ("XEmacs bug: subwindow is deleted", sw);
2286 } 2295 }
2287 2296
2288 XtSetArg (al [0], XtNwidth, (Dimension)w); 2297 XtSetArg (al [0], XtNwidth, (Dimension)w);
2289 XtSetArg (al [1], XtNheight, (Dimension)h); 2298 XtSetArg (al [1], XtNheight, (Dimension)h);
2290 XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 2); 2299 XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 2);
2297 /************************************************************************/ 2306 /************************************************************************/
2298 /* widgets */ 2307 /* widgets */
2299 /************************************************************************/ 2308 /************************************************************************/
2300 2309
2301 static void 2310 static void
2302 update_widget_face (widget_value* wv, struct Lisp_Image_Instance *ii, 2311 update_widget_face (widget_value* wv, Lisp_Image_Instance *ii,
2303 Lisp_Object domain) 2312 Lisp_Object domain)
2304 { 2313 {
2305 #ifdef LWLIB_WIDGETS_MOTIF 2314 #ifdef LWLIB_WIDGETS_MOTIF
2306 XmFontList fontList; 2315 XmFontList fontList;
2307 #endif 2316 #endif
2334 IMAGE_INSTANCE_WIDGET_FACE (ii), 2343 IMAGE_INSTANCE_WIDGET_FACE (ii),
2335 domain)))); 2344 domain))));
2336 } 2345 }
2337 2346
2338 static void 2347 static void
2339 update_tab_widget_face (widget_value* wv, struct Lisp_Image_Instance *ii, 2348 update_tab_widget_face (widget_value* wv, Lisp_Image_Instance *ii,
2340 Lisp_Object domain) 2349 Lisp_Object domain)
2341 { 2350 {
2342 if (wv->contents) 2351 if (wv->contents)
2343 { 2352 {
2344 widget_value* val = wv->contents, *cur; 2353 widget_value* val = wv->contents, *cur;
2364 x_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2373 x_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2365 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2374 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2366 int dest_mask, Lisp_Object domain, 2375 int dest_mask, Lisp_Object domain,
2367 CONST char* type, widget_value* wv) 2376 CONST char* type, widget_value* wv)
2368 { 2377 {
2369 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2378 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2370 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), pixel; 2379 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii), pixel;
2371 struct device* d = XDEVICE (device); 2380 struct device* d = XDEVICE (device);
2372 Lisp_Object frame = FW_FRAME (domain); 2381 Lisp_Object frame = FW_FRAME (domain);
2373 struct frame* f = XFRAME (frame); 2382 struct frame* f = XFRAME (frame);
2374 char* nm=0; 2383 char* nm=0;
2386 instantiation for a widget. But we can go ahead and do it without 2395 instantiation for a widget. But we can go ahead and do it without
2387 checking because there is always a generic instantiator. */ 2396 checking because there is always a generic instantiator. */
2388 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET; 2397 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
2389 2398
2390 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) 2399 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
2391 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm); 2400 TO_EXTERNAL_FORMAT (LISP_STRING, IMAGE_INSTANCE_WIDGET_TEXT (ii),
2401 C_STRING_ALLOCA, nm,
2402 Qnative);
2392 2403
2393 ii->data = xnew_and_zero (struct x_subwindow_data); 2404 ii->data = xnew_and_zero (struct x_subwindow_data);
2394 2405
2395 /* Create a clip window to contain the subwidget. Incredibly the 2406 /* Create a clip window to contain the subwidget. Incredibly the
2396 XEmacs manager seems to be the most appropriate widget for 2407 XEmacs manager seems to be the most appropriate widget for
2473 2484
2474 static Lisp_Object 2485 static Lisp_Object
2475 x_widget_set_property (Lisp_Object image_instance, Lisp_Object prop, 2486 x_widget_set_property (Lisp_Object image_instance, Lisp_Object prop,
2476 Lisp_Object val) 2487 Lisp_Object val)
2477 { 2488 {
2478 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2489 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2479 2490
2480 /* Modify the text properties of the widget */ 2491 /* Modify the text properties of the widget */
2481 if (EQ (prop, Q_text)) 2492 if (EQ (prop, Q_text))
2482 { 2493 {
2483 char* str; 2494 char* str;
2484 widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii)); 2495 widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
2485 CHECK_STRING (val); 2496 CHECK_STRING (val);
2486 GET_C_STRING_OS_DATA_ALLOCA (val, str); 2497 TO_EXTERNAL_FORMAT (LISP_STRING, val,
2498 C_STRING_ALLOCA, str,
2499 Qnative);
2487 wv->value = str; 2500 wv->value = str;
2488 lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (ii), wv, False); 2501 lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (ii), wv, False);
2489 } 2502 }
2490 2503
2491 /* Modify the text properties of the widget */ 2504 /* Modify the text properties of the widget */
2500 2513
2501 /* get properties of a control */ 2514 /* get properties of a control */
2502 static Lisp_Object 2515 static Lisp_Object
2503 x_widget_property (Lisp_Object image_instance, Lisp_Object prop) 2516 x_widget_property (Lisp_Object image_instance, Lisp_Object prop)
2504 { 2517 {
2505 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2518 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2506 /* get the text from a control */ 2519 /* get the text from a control */
2507 if (EQ (prop, Q_text)) 2520 if (EQ (prop, Q_text))
2508 { 2521 {
2509 widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii)); 2522 widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
2510 return build_ext_string (wv->value, FORMAT_OS); 2523 return build_ext_string (wv->value, Qnative);
2511 } 2524 }
2512 return Qunbound; 2525 return Qunbound;
2513 } 2526 }
2514 2527
2515 /* Instantiate a button widget. Unfortunately instantiated widgets are 2528 /* Instantiate a button widget. Unfortunately instantiated widgets are
2521 static void 2534 static void
2522 x_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2535 x_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2523 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2536 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2524 int dest_mask, Lisp_Object domain) 2537 int dest_mask, Lisp_Object domain)
2525 { 2538 {
2526 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2539 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2527 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); 2540 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2528 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); 2541 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
2529 widget_value* wv = xmalloc_widget_value (); 2542 widget_value* wv = xmalloc_widget_value ();
2530 2543
2531 button_item_to_widget_value (gui, wv, 1, 1); 2544 button_item_to_widget_value (gui, wv, 1, 1);
2538 2551
2539 x_widget_instantiate (image_instance, instantiator, pointer_fg, 2552 x_widget_instantiate (image_instance, instantiator, pointer_fg,
2540 pointer_bg, dest_mask, domain, "button", wv); 2553 pointer_bg, dest_mask, domain, "button", wv);
2541 2554
2542 /* add the image if one was given */ 2555 /* add the image if one was given */
2543 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)) 2556 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)
2557 && IMAGE_INSTANCE_PIXMAP_TYPE_P (XIMAGE_INSTANCE (glyph)))
2544 { 2558 {
2545 Arg al [2]; 2559 Arg al [2];
2546 int ac =0; 2560 int ac =0;
2547 #ifdef LWLIB_WIDGETS_MOTIF 2561 #ifdef LWLIB_WIDGETS_MOTIF
2548 XtSetArg (al [ac], XmNlabelType, XmPIXMAP); ac++; 2562 XtSetArg (al [ac], XmNlabelType, XmPIXMAP); ac++;
2556 2570
2557 /* get properties of a button */ 2571 /* get properties of a button */
2558 static Lisp_Object 2572 static Lisp_Object
2559 x_button_property (Lisp_Object image_instance, Lisp_Object prop) 2573 x_button_property (Lisp_Object image_instance, Lisp_Object prop)
2560 { 2574 {
2561 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2575 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2562 /* check the state of a button */ 2576 /* check the state of a button */
2563 if (EQ (prop, Q_selected)) 2577 if (EQ (prop, Q_selected))
2564 { 2578 {
2565 widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii)); 2579 widget_value* wv = lw_get_all_values (IMAGE_INSTANCE_X_WIDGET_LWID (ii));
2566 2580
2576 static void 2590 static void
2577 x_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2591 x_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2578 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2592 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2579 int dest_mask, Lisp_Object domain) 2593 int dest_mask, Lisp_Object domain)
2580 { 2594 {
2581 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2595 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2582 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); 2596 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2583 widget_value* wv = xmalloc_widget_value (); 2597 widget_value* wv = xmalloc_widget_value ();
2584 2598
2585 button_item_to_widget_value (gui, wv, 1, 1); 2599 button_item_to_widget_value (gui, wv, 1, 1);
2586 2600
2591 /* set the properties of a progres guage */ 2605 /* set the properties of a progres guage */
2592 static Lisp_Object 2606 static Lisp_Object
2593 x_progress_gauge_set_property (Lisp_Object image_instance, Lisp_Object prop, 2607 x_progress_gauge_set_property (Lisp_Object image_instance, Lisp_Object prop,
2594 Lisp_Object val) 2608 Lisp_Object val)
2595 { 2609 {
2596 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2610 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2597 2611
2598 if (EQ (prop, Q_percent)) 2612 if (EQ (prop, Q_percent))
2599 { 2613 {
2600 Arg al [1]; 2614 Arg al [1];
2601 CHECK_INT (val); 2615 CHECK_INT (val);
2610 static void 2624 static void
2611 x_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2625 x_edit_field_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2612 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2626 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2613 int dest_mask, Lisp_Object domain) 2627 int dest_mask, Lisp_Object domain)
2614 { 2628 {
2615 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2629 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2616 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); 2630 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2617 widget_value* wv = xmalloc_widget_value (); 2631 widget_value* wv = xmalloc_widget_value ();
2618 2632
2619 button_item_to_widget_value (gui, wv, 1, 1); 2633 button_item_to_widget_value (gui, wv, 1, 1);
2620 2634
2627 static void 2641 static void
2628 x_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2642 x_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2629 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2643 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2630 int dest_mask, Lisp_Object domain) 2644 int dest_mask, Lisp_Object domain)
2631 { 2645 {
2632 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2646 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2633 widget_value * wv = 0; 2647 widget_value * wv = 0;
2634 /* This is not done generically because of sizing problems under 2648 /* This is not done generically because of sizing problems under
2635 mswindows. */ 2649 mswindows. */
2636 widget_instantiate (image_instance, instantiator, pointer_fg, 2650 widget_instantiate (image_instance, instantiator, pointer_fg,
2637 pointer_bg, dest_mask, domain); 2651 pointer_bg, dest_mask, domain);
2646 static void 2660 static void
2647 x_tab_control_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2661 x_tab_control_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2648 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2662 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2649 int dest_mask, Lisp_Object domain) 2663 int dest_mask, Lisp_Object domain)
2650 { 2664 {
2651 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2665 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2652 widget_value * wv = 2666 widget_value * wv =
2653 gui_items_to_widget_values (IMAGE_INSTANCE_WIDGET_ITEMS (ii)); 2667 gui_items_to_widget_values (IMAGE_INSTANCE_WIDGET_ITEMS (ii));
2654 2668
2655 update_tab_widget_face (wv, ii, 2669 update_tab_widget_face (wv, ii,
2656 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); 2670 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii));
2662 /* set the properties of a tab control */ 2676 /* set the properties of a tab control */
2663 static Lisp_Object 2677 static Lisp_Object
2664 x_tab_control_set_property (Lisp_Object image_instance, Lisp_Object prop, 2678 x_tab_control_set_property (Lisp_Object image_instance, Lisp_Object prop,
2665 Lisp_Object val) 2679 Lisp_Object val)
2666 { 2680 {
2667 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2681 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2668 2682
2669 if (EQ (prop, Q_items)) 2683 if (EQ (prop, Q_items))
2670 { 2684 {
2671 widget_value * wv = 0; 2685 widget_value * wv = 0;
2672 check_valid_item_list_1 (val); 2686 check_valid_item_list_1 (val);
2693 static void 2707 static void
2694 x_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2708 x_label_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2695 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2709 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2696 int dest_mask, Lisp_Object domain) 2710 int dest_mask, Lisp_Object domain)
2697 { 2711 {
2698 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2712 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2699 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); 2713 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2700 widget_value* wv = xmalloc_widget_value (); 2714 widget_value* wv = xmalloc_widget_value ();
2701 2715
2702 button_item_to_widget_value (gui, wv, 1, 1); 2716 button_item_to_widget_value (gui, wv, 1, 1);
2703 2717
2856 vector3 (Qxbm, Q_data, \ 2870 vector3 (Qxbm, Q_data, \
2857 list3 (make_int (name##_width), \ 2871 list3 (make_int (name##_width), \
2858 make_int (name##_height), \ 2872 make_int (name##_height), \
2859 make_ext_string (name##_bits, \ 2873 make_ext_string (name##_bits, \
2860 sizeof (name##_bits), \ 2874 sizeof (name##_bits), \
2861 FORMAT_BINARY))), \ 2875 Qbinary))), \
2862 Qglobal, Qx, Qnil) 2876 Qglobal, Qx, Qnil)
2863 2877
2864 BUILD_GLYPH_INST (Vtruncation_glyph, truncator); 2878 BUILD_GLYPH_INST (Vtruncation_glyph, truncator);
2865 BUILD_GLYPH_INST (Vcontinuation_glyph, continuer); 2879 BUILD_GLYPH_INST (Vcontinuation_glyph, continuer);
2866 BUILD_GLYPH_INST (Vxemacs_logo, xemacs); 2880 BUILD_GLYPH_INST (Vxemacs_logo, xemacs);