comparison src/glyphs-gtk.c @ 2054:91d4c8c65a0f

[xemacs-hg @ 2004-05-02 04:06:51 by malcolmp] Fix warnings and errors when building GTK using C++ and --use-union-type.
author malcolmp
date Sun, 02 May 2004 04:07:01 +0000
parents 7473844a83d3
children 16489ca72b3d
comparison
equal deleted inserted replaced
2053:11e709117623 2054:91d4c8c65a0f
89 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif); 89 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif);
90 #endif 90 #endif
91 91
92 #ifdef HAVE_XFACE 92 #ifdef HAVE_XFACE
93 DEFINE_DEVICE_IIFORMAT (gtk, xface); 93 DEFINE_DEVICE_IIFORMAT (gtk, xface);
94 Lisp_Object Qxface;
95 #endif 94 #endif
96 95
97 #ifdef HAVE_XPM 96 #ifdef HAVE_XPM
98 DEFINE_DEVICE_IIFORMAT (gtk, xpm); 97 DEFINE_DEVICE_IIFORMAT (gtk, xpm);
99 #endif 98 #endif
127 Lisp_Object pointer_fg, 126 Lisp_Object pointer_fg,
128 Lisp_Object pointer_bg, 127 Lisp_Object pointer_bg,
129 int dest_mask, 128 int dest_mask,
130 Lisp_Object domain); 129 Lisp_Object domain);
131 130
132 static gint cursor_name_to_index (const char *name); 131 static GdkCursorType cursor_name_to_index (const char *name);
133 132
134 #ifndef BitmapSuccess 133 #ifndef BitmapSuccess
135 #define BitmapSuccess 0 134 #define BitmapSuccess 0
136 #define BitmapOpenFailed 1 135 #define BitmapOpenFailed 1
137 #define BitmapFileInvalid 2 136 #define BitmapFileInvalid 2
354 if (IMAGE_INSTANCE_GTK_MASK (p)) 353 if (IMAGE_INSTANCE_GTK_MASK (p))
355 write_fmt_string (printcharfun, "/0x%lx", 354 write_fmt_string (printcharfun, "/0x%lx",
356 (unsigned long) IMAGE_INSTANCE_GTK_MASK (p)); 355 (unsigned long) IMAGE_INSTANCE_GTK_MASK (p));
357 write_c_string (printcharfun, ")"); 356 write_c_string (printcharfun, ")");
358 break; 357 break;
359 #if HAVE_SUBWINDOWS 358 #ifdef HAVE_SUBWINDOWS
360 case IMAGE_SUBWINDOW: 359 case IMAGE_SUBWINDOW:
361 /* #### implement me */ 360 /* #### implement me */
362 #endif 361 #endif
363 default: 362 default:
364 break; 363 break;
378 #ifdef HAVE_WIDGETS 377 #ifdef HAVE_WIDGETS
379 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) 378 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
380 { 379 {
381 if (IMAGE_INSTANCE_SUBWINDOW_ID (p)) 380 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
382 { 381 {
383 gtk_widget_destroy (IMAGE_INSTANCE_SUBWINDOW_ID (p)); 382 gtk_widget_destroy ((GtkWidget*) IMAGE_INSTANCE_SUBWINDOW_ID (p));
384 383
385 /* We can release the callbacks again. */ 384 /* We can release the callbacks again. */
386 /* #### FIXME! */ 385 /* #### FIXME! */
387 /* ungcpro_popup_callbacks (...); */ 386 /* ungcpro_popup_callbacks (...); */
388 387
460 case IMAGE_COLOR_PIXMAP: 459 case IMAGE_COLOR_PIXMAP:
461 case IMAGE_POINTER: 460 case IMAGE_POINTER:
462 if (IMAGE_INSTANCE_GTK_COLORMAP (p1) != IMAGE_INSTANCE_GTK_COLORMAP (p2) || 461 if (IMAGE_INSTANCE_GTK_COLORMAP (p1) != IMAGE_INSTANCE_GTK_COLORMAP (p2) ||
463 IMAGE_INSTANCE_GTK_NPIXELS (p1) != IMAGE_INSTANCE_GTK_NPIXELS (p2)) 462 IMAGE_INSTANCE_GTK_NPIXELS (p1) != IMAGE_INSTANCE_GTK_NPIXELS (p2))
464 return 0; 463 return 0;
465 #if HAVE_SUBWINDOWS 464 #ifdef HAVE_SUBWINDOWS
466 case IMAGE_SUBWINDOW: 465 case IMAGE_SUBWINDOW:
467 /* #### implement me */ 466 /* #### implement me */
468 #endif 467 #endif
469 break; 468 break;
470 default: 469 default:
481 { 480 {
482 case IMAGE_MONO_PIXMAP: 481 case IMAGE_MONO_PIXMAP:
483 case IMAGE_COLOR_PIXMAP: 482 case IMAGE_COLOR_PIXMAP:
484 case IMAGE_POINTER: 483 case IMAGE_POINTER:
485 return IMAGE_INSTANCE_GTK_NPIXELS (p); 484 return IMAGE_INSTANCE_GTK_NPIXELS (p);
486 #if HAVE_SUBWINDOWS 485 #ifdef HAVE_SUBWINDOWS
487 case IMAGE_SUBWINDOW: 486 case IMAGE_SUBWINDOW:
488 /* #### implement me */ 487 /* #### implement me */
489 return 0; 488 return 0;
490 #endif 489 #endif
491 default: 490 default:
1014 { 1013 {
1015 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data); 1014 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
1016 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file); 1015 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
1017 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1016 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1018 GdkPixmap *mask = 0; 1017 GdkPixmap *mask = 0;
1019 const char *gcc_may_you_rot_in_hell; 1018 const Extbyte *gcc_may_you_rot_in_hell;
1020 1019
1021 if (!NILP (mask_data)) 1020 if (!NILP (mask_data))
1022 { 1021 {
1023 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))), 1022 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
1024 C_STRING_ALLOCA, gcc_may_you_rot_in_hell, 1023 C_STRING_ALLOCA, gcc_may_you_rot_in_hell,
1025 Qfile_name); 1024 Qfile_name);
1026 mask = 1025 mask =
1027 pixmap_from_xbm_inline (IMAGE_INSTANCE_DEVICE (ii), 1026 pixmap_from_xbm_inline (IMAGE_INSTANCE_DEVICE (ii),
1028 XINT (XCAR (mask_data)), 1027 XINT (XCAR (mask_data)),
1029 XINT (XCAR (XCDR (mask_data))), 1028 XINT (XCAR (XCDR (mask_data))),
1030 (const unsigned char *)
1031 gcc_may_you_rot_in_hell); 1029 gcc_may_you_rot_in_hell);
1032 } 1030 }
1033 1031
1034 init_image_instance_from_xbm_inline (ii, width, height, bits, 1032 init_image_instance_from_xbm_inline (ii, width, height, bits,
1035 instantiator, pointer_fg, pointer_bg, 1033 instantiator, pointer_fg, pointer_bg,
1150 return tempfile; 1148 return tempfile;
1151 } 1149 }
1152 1150
1153 struct color_symbol 1151 struct color_symbol
1154 { 1152 {
1155 char* name; 1153 Ibyte* name;
1156 GdkColor color; 1154 GdkColor color;
1157 }; 1155 };
1158 1156
1159 static struct color_symbol* 1157 static struct color_symbol*
1160 extract_xpm_color_names (Lisp_Object device, 1158 extract_xpm_color_names (Lisp_Object device,
1208 { 1206 {
1209 Lisp_Object cons = XCAR (results); 1207 Lisp_Object cons = XCAR (results);
1210 colortbl[j].color = 1208 colortbl[j].color =
1211 * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (XCDR (cons))); 1209 * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
1212 1210
1213 colortbl[j].name = (char *) XSTRING_DATA (XCAR (cons)); 1211 colortbl[j].name = XSTRING_DATA (XCAR (cons));
1214 free_cons (XCONS (cons)); 1212 free_cons (cons);
1215 cons = results; 1213 cons = results;
1216 results = XCDR (results); 1214 results = XCDR (results);
1217 free_cons (XCONS (cons)); 1215 free_cons (cons);
1218 } 1216 }
1219 return colortbl; 1217 return colortbl;
1220 } 1218 }
1221 1219
1222 static void 1220 static void
1239 GdkColor *transparent_color = NULL; 1237 GdkColor *transparent_color = NULL;
1240 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator, 1238 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
1241 Q_color_symbols); 1239 Q_color_symbols);
1242 enum image_instance_type type; 1240 enum image_instance_type type;
1243 int force_mono; 1241 int force_mono;
1244 unsigned int w, h; 1242 gint w, h;
1245 Lisp_Object tempfile = Qnil; 1243 Lisp_Object tempfile = Qnil;
1246 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 1244 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1247 1245
1248 if (!DEVICE_GTK_P (XDEVICE (device))) 1246 if (!DEVICE_GTK_P (XDEVICE (device)))
1249 gui_error ("Not a Gtk device", device); 1247 gui_error ("Not a Gtk device", device);
1274 /* Need to get the transparent color here */ 1272 /* Need to get the transparent color here */
1275 color_symbols = extract_xpm_color_names (device, domain, color_symbol_alist, 1273 color_symbols = extract_xpm_color_names (device, domain, color_symbol_alist,
1276 &nsymbols); 1274 &nsymbols);
1277 for (i = 0; i < nsymbols; i++) 1275 for (i = 0; i < nsymbols; i++)
1278 { 1276 {
1279 if (!qxestrcasecmp ("BgColor", color_symbols[i].name) || 1277 if (!qxestrcasecmp_c (color_symbols[i].name, "BgColor") ||
1280 !qxestrcasecmp ("None", color_symbols[i].name)) 1278 !qxestrcasecmp_c (color_symbols[i].name, "None"))
1281 { 1279 {
1282 transparent_color = &color_symbols[i].color; 1280 transparent_color = &color_symbols[i].color;
1283 } 1281 }
1284 } 1282 }
1285 1283
1480 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK; 1478 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
1481 } 1479 }
1482 1480
1483 extern guint symbol_to_enum (Lisp_Object, GtkType); 1481 extern guint symbol_to_enum (Lisp_Object, GtkType);
1484 1482
1485 static guint resource_name_to_resource (Lisp_Object name, int type) 1483 static guint resource_name_to_resource (Lisp_Object name, image_instance_type type)
1486 { 1484 {
1487 if (type == IMAGE_POINTER) 1485 if (type == IMAGE_POINTER)
1488 return (symbol_to_enum (name, GTK_TYPE_GDK_CURSOR_TYPE)); 1486 return (symbol_to_enum (name, GTK_TYPE_GDK_CURSOR_TYPE));
1489 else 1487 else
1490 return (0); 1488 return (0);
1491 } 1489 }
1492 1490
1493 static int 1491 static image_instance_type
1494 resource_symbol_to_type (Lisp_Object data) 1492 resource_symbol_to_type (Lisp_Object data)
1495 { 1493 {
1496 if (EQ (data, Qcursor)) 1494 if (EQ (data, Qcursor))
1497 return IMAGE_POINTER; 1495 return IMAGE_POINTER;
1498 #if 0 1496 #if 0
1500 return IMAGE_ICON; 1498 return IMAGE_ICON;
1501 else if (EQ (data, Qbitmap)) 1499 else if (EQ (data, Qbitmap))
1502 return IMAGE_BITMAP; 1500 return IMAGE_BITMAP;
1503 #endif 1501 #endif
1504 else 1502 else
1505 return 0; 1503 return IMAGE_UNKNOWN;
1506 } 1504 }
1507 1505
1508 static void 1506 static void
1509 gtk_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1507 gtk_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1510 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1508 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1511 int dest_mask, Lisp_Object domain) 1509 int dest_mask, Lisp_Object domain)
1512 { 1510 {
1513 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1511 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1514 GdkCursor *c = NULL; 1512 GdkCursor *c = NULL;
1515 unsigned int type = 0; 1513 image_instance_type type;
1516 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1514 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1517 Lisp_Object resource_type = find_keyword_in_vector (instantiator, Q_resource_type); 1515 Lisp_Object resource_type = find_keyword_in_vector (instantiator, Q_resource_type);
1518 Lisp_Object resource_id = find_keyword_in_vector (instantiator, Q_resource_id); 1516 Lisp_Object resource_id = find_keyword_in_vector (instantiator, Q_resource_id);
1519 1517
1520 if (!DEVICE_GTK_P (XDEVICE (device))) 1518 if (!DEVICE_GTK_P (XDEVICE (device)))
1532 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK); 1530 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
1533 #endif 1531 #endif
1534 1532
1535 /* mess with the keyword info we were provided with */ 1533 /* mess with the keyword info we were provided with */
1536 gtk_initialize_pixmap_image_instance (ii, 1, type); 1534 gtk_initialize_pixmap_image_instance (ii, 1, type);
1537 c = gdk_cursor_new (resource_name_to_resource (resource_id, type)); 1535 c = gdk_cursor_new ((GdkCursorType) resource_name_to_resource (resource_id, type));
1538 IMAGE_INSTANCE_GTK_CURSOR (ii) = c; 1536 IMAGE_INSTANCE_GTK_CURSOR (ii) = c;
1539 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = resource_id; 1537 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = resource_id;
1540 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = 10; 1538 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = 10;
1541 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = 10; 1539 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = 10;
1542 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1; 1540 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
1853 } 1851 }
1854 return(converted); 1852 return(converted);
1855 } 1853 }
1856 1854
1857 /* This is basically the equivalent of XmuCursorNameToIndex */ 1855 /* This is basically the equivalent of XmuCursorNameToIndex */
1858 static gint 1856 static GdkCursorType
1859 cursor_name_to_index (const char *name) 1857 cursor_name_to_index (const char *name)
1860 { 1858 {
1861 int i; 1859 int i;
1862 static char *the_gdk_cursors[GDK_NUM_GLYPHS]; 1860 static char *the_gdk_cursors[GDK_NUM_GLYPHS];
1863 1861
1917 for (i = 0; i < GDK_NUM_GLYPHS; i++) 1915 for (i = 0; i < GDK_NUM_GLYPHS; i++)
1918 { 1916 {
1919 if (!the_gdk_cursors[i]) continue; 1917 if (!the_gdk_cursors[i]) continue;
1920 if (!strcmp (the_gdk_cursors[i], name)) 1918 if (!strcmp (the_gdk_cursors[i], name))
1921 { 1919 {
1922 return (i); 1920 return (GdkCursorType) i;
1923 } 1921 }
1924 } 1922 }
1925 return(-1); 1923 return (GdkCursorType) -1;
1926 } 1924 }
1927 1925
1928 static void 1926 static void
1929 cursor_font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 1927 cursor_font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
1930 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 1928 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
1932 { 1930 {
1933 /* This function can GC */ 1931 /* This function can GC */
1934 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 1932 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
1935 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 1933 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
1936 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii); 1934 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
1937 int i; 1935 GdkCursorType i;
1938 const char *name_ext; 1936 const char *name_ext;
1939 Lisp_Object foreground, background; 1937 Lisp_Object foreground, background;
1940 1938
1941 if (!DEVICE_GTK_P (XDEVICE (device))) 1939 if (!DEVICE_GTK_P (XDEVICE (device)))
1942 gui_error ("Not a Gtk device", device); 1940 gui_error ("Not a Gtk device", device);
2105 structural change. As such it will nuke all added values so we 2103 structural change. As such it will nuke all added values so we
2106 need to update most other things after the items have changed.*/ 2104 need to update most other things after the items have changed.*/
2107 gtk_widget_show_all (IMAGE_INSTANCE_GTK_CLIPWIDGET (p)); 2105 gtk_widget_show_all (IMAGE_INSTANCE_GTK_CLIPWIDGET (p));
2108 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) 2106 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
2109 { 2107 {
2110 Lisp_Object image_instance = wrap_image_instance (p);
2111
2112
2113 /* Need to update GtkArgs that might have changed... */ 2108 /* Need to update GtkArgs that might have changed... */
2114 /* #### FIXME!!! */ 2109 /* #### FIXME!!! */
2110 /*Lisp_Object image_instance = wrap_image_instance (p); */
2115 } 2111 }
2116 else 2112 else
2117 { 2113 {
2118 /* #### FIXME!!! */ 2114 /* #### FIXME!!! */
2119 /* No items changed, so do nothing, right? */ 2115 /* No items changed, so do nothing, right? */
2706 Fadd_spec_to_specifier \ 2702 Fadd_spec_to_specifier \
2707 (GLYPH_IMAGE (XGLYPH (variable)), \ 2703 (GLYPH_IMAGE (XGLYPH (variable)), \
2708 vector3 (Qxbm, Q_data, \ 2704 vector3 (Qxbm, Q_data, \
2709 list3 (make_int (name##_width), \ 2705 list3 (make_int (name##_width), \
2710 make_int (name##_height), \ 2706 make_int (name##_height), \
2711 make_ext_string (name##_bits, \ 2707 make_ext_string ((Extbyte*) name##_bits, \
2712 sizeof (name##_bits), \ 2708 sizeof (name##_bits), \
2713 Qbinary))), \ 2709 Qbinary))), \
2714 Qglobal, Qgtk, Qnil) 2710 Qglobal, Qgtk, Qnil)
2715 2711
2716 BUILD_GLYPH_INST (Vtruncation_glyph, truncator); 2712 BUILD_GLYPH_INST (Vtruncation_glyph, truncator);
2755 GdkGCValues gcv; 2751 GdkGCValues gcv;
2756 GdkGC *gc; 2752 GdkGC *gc;
2757 2753
2758 gcv.foreground = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (foreground)); 2754 gcv.foreground = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (foreground));
2759 gcv.background = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (background)); 2755 gcv.background = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (background));
2760 gc = gdk_gc_new_with_values (new_pxmp, &gcv, GDK_GC_BACKGROUND | GDK_GC_FOREGROUND); 2756 gc = gdk_gc_new_with_values (new_pxmp, &gcv,
2757 (GdkGCValuesMask) (GDK_GC_BACKGROUND | GDK_GC_FOREGROUND));
2761 2758
2762 XCopyPlane (GDK_WINDOW_XDISPLAY (draw), 2759 XCopyPlane (GDK_WINDOW_XDISPLAY (draw),
2763 GDK_WINDOW_XWINDOW (IMAGE_INSTANCE_GTK_PIXMAP (p)), 2760 GDK_WINDOW_XWINDOW (IMAGE_INSTANCE_GTK_PIXMAP (p)),
2764 GDK_WINDOW_XWINDOW (new_pxmp), 2761 GDK_WINDOW_XWINDOW (new_pxmp),
2765 GDK_GC_XGC (gc), 0, 0, 2762 GDK_GC_XGC (gc), 0, 0,