annotate src/glyphs-gtk.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents 2e5e2ccbeed2
children 2923009caf47
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
714
02339d4ebed4 [xemacs-hg @ 2001-12-23 20:28:19 by wmperry]
wmperry
parents: 691
diff changeset
1 /* GTK-specific Lisp objects.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4 Copyright (C) 1995 Tinker Systems
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
5 Copyright (C) 1995, 1996, 2001 Ben Wing
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 Copyright (C) 1995 Sun Microsystems
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12 Free Software Foundation; either version 2, or (at your option) any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13 later version.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18 for more details.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25 /* Synched up with: Not in FSF. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 /* Original author: Jamie Zawinski for 19.8
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 font-truename stuff added by Jamie Zawinski for 19.10
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 subwindow support added by Chuck Thompson
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 additional XPM support added by Chuck Thompson
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 initial X-Face support added by Stig
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32 rewritten/restructured by Ben Wing for 19.12/19.13
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33 GIF/JPEG support added by Ben Wing for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
34 PNG support added by Bill Perry for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
35 Improved GIF/JPEG support added by Bill Perry for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36 Cleanup/simplification of error handling by Ben Wing for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 Pointer/icon overhaul, more restructuring by Ben Wing for 19.14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38 GIF support changed to external GIFlib 3.1 by Jareth Hein for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39 Many changes for color work and optimizations by Jareth Hein for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 Switch of GIF/JPEG/PNG to new EImage intermediate code by Jareth Hein for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 TIFF code by Jareth Hein for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 GIF/JPEG/PNG/TIFF code moved to new glyph-eimage.c for 21.0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43 Gtk version by William Perry for 21.1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45 TODO:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 Support the GrayScale, StaticColor and StaticGray visual classes.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 Convert images.el to C and stick it in here?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 #include "lstream.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 #include "console-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 #include "glyphs.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 #include "glyphs-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 #include "objects-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 #include "gui-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 #include "ui-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 #include "buffer.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 #include "window.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 #include "frame.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 #include "insdel.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64 #include "opaque.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 #include "faces.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 #include "imgproc.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 #include "sysfile.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 #include <setjmp.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73 #include "file-coding.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
75 #if INTBITS == 32
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76 # define FOUR_BYTE_TYPE unsigned int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 #elif LONGBITS == 32
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 # define FOUR_BYTE_TYPE unsigned long
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 #elif SHORTBITS == 32
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 # define FOUR_BYTE_TYPE unsigned short
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82 #error What kind of strange-ass system are we running on?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85 DECLARE_IMAGE_INSTANTIATOR_FORMAT (nothing);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 DECLARE_IMAGE_INSTANTIATOR_FORMAT (string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 DECLARE_IMAGE_INSTANTIATOR_FORMAT (formatted_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88 DECLARE_IMAGE_INSTANTIATOR_FORMAT (inherit);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 #ifdef HAVE_JPEG
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 DECLARE_IMAGE_INSTANTIATOR_FORMAT (jpeg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 #ifdef HAVE_TIFF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 DECLARE_IMAGE_INSTANTIATOR_FORMAT (tiff);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 #ifdef HAVE_PNG
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 DECLARE_IMAGE_INSTANTIATOR_FORMAT (png);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 #ifdef HAVE_GIF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 DECLARE_IMAGE_INSTANTIATOR_FORMAT (gif);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 #ifdef HAVE_XFACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 DEFINE_DEVICE_IIFORMAT (gtk, xface);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 Lisp_Object Qxface;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 DEFINE_DEVICE_IIFORMAT (gtk, xpm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111 DEFINE_DEVICE_IIFORMAT (gtk, xbm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 DEFINE_DEVICE_IIFORMAT (gtk, subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114 DEFINE_IMAGE_INSTANTIATOR_FORMAT (cursor_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 Lisp_Object Qcursor_font;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 DEFINE_IMAGE_INSTANTIATOR_FORMAT (font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 DEFINE_IMAGE_INSTANTIATOR_FORMAT (autodetect);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 DECLARE_IMAGE_INSTANTIATOR_FORMAT (layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 DEFINE_DEVICE_IIFORMAT (gtk, widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 DEFINE_DEVICE_IIFORMAT (gtk, native_layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 DEFINE_DEVICE_IIFORMAT (gtk, button);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 DEFINE_DEVICE_IIFORMAT (gtk, progress_gauge);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 DEFINE_DEVICE_IIFORMAT (gtk, edit_field);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 DEFINE_DEVICE_IIFORMAT (gtk, combo_box);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 DEFINE_DEVICE_IIFORMAT (gtk, tab_control);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 DEFINE_DEVICE_IIFORMAT (gtk, label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 static void update_widget_face (GtkWidget *w, Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 Lisp_Object domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 static void cursor_font_instantiate (Lisp_Object image_instance,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 Lisp_Object pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 Lisp_Object domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 static gint cursor_name_to_index (const char *name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 #ifndef BitmapSuccess
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 #define BitmapSuccess 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 #define BitmapOpenFailed 1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 #define BitmapFileInvalid 2
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 #define BitmapNoMemory 3
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 #include "bitmaps.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 DEFINE_IMAGE_INSTANTIATOR_FORMAT (gtk_resource);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 Lisp_Object Qgtk_resource;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 Lisp_Object Qgtk_widget_instantiate_internal, Qgtk_widget_property_internal;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 Lisp_Object Qgtk_widget_redisplay_internal, Qgtk_widget_set_style;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162 /* image instance methods */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 /* convert from a series of RGB triples to an XImage formated for the */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 /* proper display */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 static GdkImage *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 convert_EImage_to_GDKImage (Lisp_Object device, int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171 unsigned char *pic, unsigned long **pixtbl,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 int *npixels)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 GdkColormap *cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 GdkVisual *vis;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 GdkImage *outimg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 int depth, byte_cnt, i, j;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 int rd,gr,bl,q;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 unsigned char *data, *ip, *dp = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 quant_table *qtable = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 union {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 FOUR_BYTE_TYPE val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 char cp[4];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 } conv;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 cmap = DEVICE_GTK_COLORMAP (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 vis = DEVICE_GTK_VISUAL (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 depth = DEVICE_GTK_DEPTH(XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 if (vis->type == GDK_VISUAL_GRAYSCALE || vis->type == GDK_VISUAL_STATIC_COLOR ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 vis->type == GDK_VISUAL_STATIC_GRAY)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 /* #### Implement me!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194 return NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 if (vis->type == GDK_VISUAL_PSEUDO_COLOR)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 /* Quantize the image and get a histogram while we're at it.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 Do this first to save memory */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 qtable = build_EImage_quantable(pic, width, height, 256);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 if (qtable == NULL) return NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 /* The first parameter (GdkWindow *) is allowed to be NULL if we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 ** specify the depth */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 outimg = gdk_image_new (GDK_IMAGE_FASTEST, vis, width, height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 if (!outimg) return NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 byte_cnt = outimg->bpp;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213 data = (unsigned char *) outimg->mem;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 if (!data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 gdk_image_destroy (outimg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 return NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221 if (vis->type == GDK_VISUAL_PSEUDO_COLOR)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 unsigned long pixarray[256];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 int pixcount, n;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225 /* use our quantize table to allocate the colors */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 pixcount = 32;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 *pixtbl = xnew_array (unsigned long, pixcount);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 *npixels = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
229
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 /* ### should implement a sort by popularity to assure proper allocation */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 n = *npixels;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232 for (i = 0; i < qtable->num_active_colors; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
234 GdkColor color;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 int res;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 color.red = qtable->rm[i] ? qtable->rm[i] << 8 : 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 color.green = qtable->gm[i] ? qtable->gm[i] << 8 : 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 color.blue = qtable->bm[i] ? qtable->bm[i] << 8 : 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 res = allocate_nearest_color (cmap, vis, &color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 if (res > 0 && res < 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243 DO_REALLOC(*pixtbl, pixcount, n+1, unsigned long);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 (*pixtbl)[n] = color.pixel;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 n++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 pixarray[i] = color.pixel;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 *npixels = n;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250 ip = pic;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 for (i = 0; i < height; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253 dp = data + (i * outimg->bpl);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 for (j = 0; j < width; j++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 rd = *ip++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 gr = *ip++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 bl = *ip++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 conv.val = pixarray[QUANT_GET_COLOR(qtable,rd,gr,bl)];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 #if WORDS_BIGENDIAN
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 if (outimg->byte_order == GDK_MSB_FIRST)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 for (q = 3; q >= 4-byte_cnt; q--) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 if (outimg->byte_order == GDK_MSB_FIRST)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 for (q = byte_cnt-1; q >= 0; q--) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 for (q = 0; q < byte_cnt; q++) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273 xfree(qtable);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 } else {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 unsigned long rshift,gshift,bshift,rbits,gbits,bbits,junk;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 junk = vis->red_mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 rshift = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 while ((junk & 0x1) == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 rshift ++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 rbits = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 while (junk != 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 rbits++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 junk = vis->green_mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 gshift = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 while ((junk & 0x1) == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 gshift ++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 gbits = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 while (junk != 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 gbits++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 junk = vis->blue_mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 bshift = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 while ((junk & 0x1) == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 bshift ++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 bbits = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 while (junk != 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 junk = junk >> 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 bbits++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 ip = pic;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 for (i = 0; i < height; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 dp = data + (i * outimg->bpl);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 for (j = 0; j < width; j++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 if (rbits > 8)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 rd = *ip++ << (rbits - 8);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 rd = *ip++ >> (8 - rbits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 if (gbits > 8)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 gr = *ip++ << (gbits - 8);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 gr = *ip++ >> (8 - gbits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 if (bbits > 8)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 bl = *ip++ << (bbits - 8);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 bl = *ip++ >> (8 - bbits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 conv.val = (rd << rshift) | (gr << gshift) | (bl << bshift);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 #if WORDS_BIGENDIAN
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 if (outimg->byte_order == GDK_MSB_FIRST)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 for (q = 3; q >= 4-byte_cnt; q--) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 if (outimg->byte_order == GDK_MSB_FIRST)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 for (q = byte_cnt-1; q >= 0; q--) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 for (q = 0; q < byte_cnt; q++) *dp++ = conv.cp[q];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
346 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
347 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
348 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349 return outimg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
350 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
353 gtk_print_image_instance (struct Lisp_Image_Instance *p,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 Lisp_Object printcharfun,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355 int escapeflag)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 char buf[100];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 switch (IMAGE_INSTANCE_TYPE (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
360 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
361 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 sprintf (buf, " (0x%lx", (unsigned long) IMAGE_INSTANCE_GTK_PIXMAP (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365 write_c_string (buf, printcharfun);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 if (IMAGE_INSTANCE_GTK_MASK (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
367 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
368 sprintf (buf, "/0x%lx", (unsigned long) IMAGE_INSTANCE_GTK_MASK (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 write_c_string (buf, printcharfun);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 write_c_string (")", printcharfun);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373 #if HAVE_SUBWINDOWS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 case IMAGE_SUBWINDOW:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375 /* #### implement me */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
379 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
380 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
381
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 gtk_finalize_image_instance (struct Lisp_Image_Instance *p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 if (!p->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388 if (DEVICE_LIVE_P (XDEVICE (p->device)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 if (0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
391 ;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395 if (IMAGE_INSTANCE_SUBWINDOW_ID (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397 gtk_widget_destroy (IMAGE_INSTANCE_SUBWINDOW_ID (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
398
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 /* We can release the callbacks again. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 /* #### FIXME! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 /* ungcpro_popup_callbacks (...); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
403 /* IMAGE_INSTANCE_GTK_WIDGET_ID (p) = 0; */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404 IMAGE_INSTANCE_GTK_CLIPWIDGET (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 else if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 abort();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 if (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 disable_glyph_animated_timeout (IMAGE_INSTANCE_PIXMAP_TIMEOUT (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 if (IMAGE_INSTANCE_GTK_MASK (p) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 IMAGE_INSTANCE_GTK_MASK (p) != IMAGE_INSTANCE_GTK_PIXMAP (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 gdk_pixmap_unref (IMAGE_INSTANCE_GTK_MASK (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 IMAGE_INSTANCE_PIXMAP_MASK (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 if (IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425 for (i = 0; i < IMAGE_INSTANCE_PIXMAP_MAXSLICE (p); i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 if (IMAGE_INSTANCE_GTK_PIXMAP_SLICE (p,i))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 gdk_pixmap_unref (IMAGE_INSTANCE_GTK_PIXMAP_SLICE (p,i));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 IMAGE_INSTANCE_GTK_PIXMAP_SLICE (p, i) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431 xfree (IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 IMAGE_INSTANCE_GTK_PIXMAP_SLICES (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435 if (IMAGE_INSTANCE_GTK_CURSOR (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437 gdk_cursor_destroy (IMAGE_INSTANCE_GTK_CURSOR (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 IMAGE_INSTANCE_GTK_CURSOR (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 if (IMAGE_INSTANCE_GTK_NPIXELS (p) != 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 XFreeColors (dpy,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 IMAGE_INSTANCE_GTK_COLORMAP (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 IMAGE_INSTANCE_GTK_PIXELS (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 IMAGE_INSTANCE_GTK_NPIXELS (p), 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 IMAGE_INSTANCE_GTK_NPIXELS (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 if (IMAGE_INSTANCE_TYPE (p) != IMAGE_WIDGET
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 && IMAGE_INSTANCE_TYPE (p) != IMAGE_SUBWINDOW
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457 && IMAGE_INSTANCE_GTK_PIXELS (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 xfree (IMAGE_INSTANCE_GTK_PIXELS (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 IMAGE_INSTANCE_GTK_PIXELS (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 xfree (p->data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 p->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
466
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 gtk_image_instance_equal (struct Lisp_Image_Instance *p1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 struct Lisp_Image_Instance *p2, int depth)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
470 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
471 switch (IMAGE_INSTANCE_TYPE (p1))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 if (IMAGE_INSTANCE_GTK_COLORMAP (p1) != IMAGE_INSTANCE_GTK_COLORMAP (p2) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 IMAGE_INSTANCE_GTK_NPIXELS (p1) != IMAGE_INSTANCE_GTK_NPIXELS (p2))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 #if HAVE_SUBWINDOWS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 case IMAGE_SUBWINDOW:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 /* #### implement me */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
483 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
488 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
490
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491 static unsigned long
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
492 gtk_image_instance_hash (struct Lisp_Image_Instance *p, int depth)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
494 switch (IMAGE_INSTANCE_TYPE (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
495 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
496 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
497 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
498 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
499 return IMAGE_INSTANCE_GTK_NPIXELS (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 #if HAVE_SUBWINDOWS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 case IMAGE_SUBWINDOW:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
502 /* #### implement me */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
508 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
509
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
510 /* Set all the slots in an image instance structure to reasonable
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 default values. This is used somewhere within an instantiate
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
512 method. It is assumed that the device slot within the image
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
513 instance is already set -- this is the case when instantiate
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
514 methods are called. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517 gtk_initialize_pixmap_image_instance (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518 int slices,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
519 enum image_instance_type type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
520 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
521 ii->data = xnew_and_zero (struct gtk_image_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
522 IMAGE_INSTANCE_PIXMAP_MAXSLICE (ii) = slices;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
523 IMAGE_INSTANCE_GTK_PIXMAP_SLICES (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
524 xnew_array_and_zero (GdkPixmap *, slices);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
525 IMAGE_INSTANCE_TYPE (ii) = type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
526 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527 IMAGE_INSTANCE_PIXMAP_MASK_FILENAME (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
529 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
530 IMAGE_INSTANCE_PIXMAP_FG (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 IMAGE_INSTANCE_PIXMAP_BG (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
536 /* pixmap file functions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539 /* Where bitmaps are; initialized from resource database */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540 Lisp_Object Vgtk_bitmap_file_path;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542 #ifndef BITMAPDIR
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543 #define BITMAPDIR "/usr/include/X11/bitmaps"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
545
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
546 /* Given a pixmap filename, look through all of the "standard" places
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
547 where the file might be located. Return a full pathname if found;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548 otherwise, return Qnil. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
549
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
550 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551 gtk_locate_pixmap_file (Lisp_Object name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
552 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
553 /* This function can GC if IN_REDISPLAY is false */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
554
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
555 /* Check non-absolute pathnames with a directory component relative to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
556 the search path; that's the way Xt does it. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557 /* #### Unix-specific */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558 if (XSTRING_BYTE (name, 0) == '/' ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
559 (XSTRING_BYTE (name, 0) == '.' &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560 (XSTRING_BYTE (name, 1) == '/' ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
561 (XSTRING_BYTE (name, 1) == '.' &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
562 (XSTRING_BYTE (name, 2) == '/')))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
563 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
564 if (!NILP (Ffile_readable_p (name)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565 return name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
567 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
568 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
569
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570 if (NILP (Vdefault_gtk_device))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
571 /* This may occur during intialization. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
572 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
573
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574 if (NILP (Vgtk_bitmap_file_path))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576 Vgtk_bitmap_file_path = nconc2 (Vgtk_bitmap_file_path,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577 (decode_path (BITMAPDIR)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581 Lisp_Object found;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582 if (locate_file (Vgtk_bitmap_file_path, name, Qnil, &found, R_OK) < 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584 Lisp_Object temp = list1 (Vdata_directory);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585 struct gcpro gcpro1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
587 GCPRO1 (temp);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
588 locate_file (temp, name, Qnil, &found, R_OK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592 return found;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 locate_pixmap_file (Lisp_Object name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
598 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
599 return gtk_locate_pixmap_file (name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
600 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
601
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
602
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
603 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
604 /* cursor functions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
605 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
606
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
607 /* Check that this server supports cursors of size WIDTH * HEIGHT. If
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
608 not, signal an error. INSTANTIATOR is only used in the error
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
609 message. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
610
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
611 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
612 check_pointer_sizes (unsigned int width, unsigned int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
613 Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
614 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
615 /* #### BILL!!! There is no way to call XQueryBestCursor from Gdk! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
616 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
617 unsigned int best_width, best_height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
618 if (! XQueryBestCursor (DisplayOfScreen (xs), RootWindowOfScreen (xs),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
619 width, height, &best_width, &best_height))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
620 /* this means that an X error of some sort occurred (we trap
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
621 these so they're not fatal). */
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
622 gui_error ("XQueryBestCursor() failed?", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
623
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
624 if (width > best_width || height > best_height)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
625 signal_ferror_with_frob (Qgui_error, instantiator,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
626 "pointer too large (%dx%d): "
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
627 "server requires %dx%d or smaller",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
628 width, height, best_width, best_height);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
629 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
630 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
631
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
632 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
633 generate_cursor_fg_bg (Lisp_Object device, Lisp_Object *foreground,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
634 Lisp_Object *background, GdkColor *xfg, GdkColor *xbg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
635 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
636 if (!NILP (*foreground) && !COLOR_INSTANCEP (*foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
637 *foreground =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
638 Fmake_color_instance (*foreground, device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
639 encode_error_behavior_flag (ERROR_ME));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
640 if (COLOR_INSTANCEP (*foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
641 *xfg = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (*foreground));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
642 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
643 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
644 xfg->pixel = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
645 xfg->red = xfg->green = xfg->blue = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
646 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
647
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
648 if (!NILP (*background) && !COLOR_INSTANCEP (*background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
649 *background =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
650 Fmake_color_instance (*background, device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
651 encode_error_behavior_flag (ERROR_ME));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
652 if (COLOR_INSTANCEP (*background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
653 *xbg = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (*background));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
654 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
655 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
656 xbg->pixel = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
657 xbg->red = xbg->green = xbg->blue = ~0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
658 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
659 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
660
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
661 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
662 maybe_recolor_cursor (Lisp_Object image_instance, Lisp_Object foreground,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
663 Lisp_Object background)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
664 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
665 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
666 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
667 Lisp_Object device = XIMAGE_INSTANCE_DEVICE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
668 GdkColor xfg, xbg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
669
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
670 generate_cursor_fg_bg (device, &foreground, &background, &xfg, &xbg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
671 if (!NILP (foreground) || !NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
672 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
673 XRecolorCursor (DEVICE_X_DISPLAY (XDEVICE (device)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
674 XIMAGE_INSTANCE_GTK_CURSOR (image_instance),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
675 &xfg, &xbg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
676 XIMAGE_INSTANCE_PIXMAP_FG (image_instance) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
677 XIMAGE_INSTANCE_PIXMAP_BG (image_instance) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
678 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
679 #else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
680 /* stderr_out ("Don't know how to recolor cursors in Gtk!\n"); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
681 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
682 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
683
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
684
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
685 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
686 /* color pixmap functions */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
687 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
688
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
689 /* Initialize an image instance from an XImage.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
690
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
691 DEST_MASK specifies the mask of allowed image types.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
692
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
693 PIXELS and NPIXELS specify an array of pixels that are used in
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
694 the image. These need to be kept around for the duration of the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
695 image. When the image instance is freed, XFreeColors() will
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
696 automatically be called on all the pixels specified here; thus,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
697 you should have allocated the pixels yourself using XAllocColor()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
698 or the like. The array passed in is used directly without
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
699 being copied, so it should be heap data created with xmalloc().
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
700 It will be freed using xfree() when the image instance is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
701 destroyed.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
702
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
703 If this fails, signal an error. INSTANTIATOR is only used
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
704 in the error message.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
705
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
706 #### This should be able to handle conversion into `pointer'.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
707 Use the same code as for `xpm'. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
708
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
709 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
710 init_image_instance_from_gdk_image (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
711 GdkImage *gdk_image,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
712 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
713 GdkColormap *cmap,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
714 unsigned long *pixels,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
715 int npixels,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
716 int slices,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
717 Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
718 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
719 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
720 GdkGC *gc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
721 GdkWindow *d;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
722 GdkPixmap *pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
723
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
724 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
725 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
726
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
727 d = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
728
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
729 if (!(dest_mask & IMAGE_COLOR_PIXMAP_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
730 incompatible_image_types (instantiator, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
731 IMAGE_COLOR_PIXMAP_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
732
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
733 pixmap = gdk_pixmap_new (d, gdk_image->width, gdk_image->height, gdk_image->depth);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
734 if (!pixmap)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
735 gui_error ("Unable to create pixmap", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
736
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
737 gc = gdk_gc_new (pixmap);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
738 if (!gc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
739 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
740 gdk_pixmap_unref (pixmap);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
741 gui_error ("Unable to create GC", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
742 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
743
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
744 gdk_draw_image (GDK_DRAWABLE (pixmap), gc, gdk_image,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
745 0, 0, 0, 0, gdk_image->width, gdk_image->height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
746
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
747 gdk_gc_destroy (gc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
748
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
749 gtk_initialize_pixmap_image_instance (ii, slices, IMAGE_COLOR_PIXMAP);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
750
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
751 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
752 find_keyword_in_vector (instantiator, Q_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
753
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
754 IMAGE_INSTANCE_GTK_PIXMAP (ii) = pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
755 IMAGE_INSTANCE_GTK_MASK (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
756 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = gdk_image->width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
757 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = gdk_image->height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
758 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = gdk_image->depth;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
759 IMAGE_INSTANCE_GTK_COLORMAP (ii) = cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
760 IMAGE_INSTANCE_GTK_PIXELS (ii) = pixels;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
761 IMAGE_INSTANCE_GTK_NPIXELS (ii) = npixels;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
762 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
763
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
764 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
765 void init_image_instance_from_gdk_pixmap (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
766 struct device *device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
767 GdkPixmap *gdk_pixmap,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
768 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
769 Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
770 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
771 GdkWindow *d;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
772 gint width, height, depth;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
773
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
774 if (!DEVICE_GTK_P (device))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
775 abort ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
776
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
777 IMAGE_INSTANCE_DEVICE (ii) = device;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
778 IMAGE_INSTANCE_TYPE (ii) = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
779
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
780 d = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
781
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
782 if (!(dest_mask & IMAGE_COLOR_PIXMAP_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
783 incompatible_image_types (instantiator, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
784 IMAGE_COLOR_PIXMAP_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
785
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
786 gtk_initialize_pixmap_image_instance (ii, IMAGE_COLOR_PIXMAP);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
787
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
788 gdk_window_get_geometry (gdk_pixmap, NULL, NULL, &width, &height, &depth);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
789
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
790 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
791 IMAGE_INSTANCE_GTK_PIXMAP (ii) = gdk_pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
792 IMAGE_INSTANCE_GTK_MASK (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
793 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
794 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
795 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = depth;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
796 IMAGE_INSTANCE_GTK_COLORMAP (ii) = gdk_window_get_colormap (gdk_pixmap);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
797 IMAGE_INSTANCE_GTK_PIXELS (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
798 IMAGE_INSTANCE_GTK_NPIXELS (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
799 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
800 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
801
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
802 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
803 image_instance_add_gdk_image (Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
804 GdkImage *gdk_image,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
805 int slice,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
806 Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
807 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
808 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
809 GdkWindow *d;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
810 GdkPixmap *pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
811 GdkGC *gc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
812
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
813 d = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
814
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
815 pixmap = gdk_pixmap_new (d, gdk_image->width, gdk_image->height, gdk_image->depth);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
816
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
817 if (!pixmap)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
818 gui_error ("Unable to create pixmap", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
819
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
820 gc = gdk_gc_new (pixmap);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
821
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
822 if (!gc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
823 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
824 gdk_pixmap_unref (pixmap);
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
825 gui_error ("Unable to create GC", instantiator);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
826 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
827
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
828 gdk_draw_image (GDK_DRAWABLE (pixmap), gc, gdk_image, 0, 0, 0, 0,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
829 gdk_image->width, gdk_image->height);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
830
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
831 gdk_gc_destroy (gc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
832
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
833 IMAGE_INSTANCE_GTK_PIXMAP_SLICE (ii, slice) = pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
834 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
835
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
836 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
837 gtk_init_image_instance_from_eimage (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
838 int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
839 int slices,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
840 unsigned char *eimage,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
841 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
842 Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
843 Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
844 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
845 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
846 GdkColormap *cmap = DEVICE_GTK_COLORMAP (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
847 unsigned long *pixtbl = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
848 int npixels = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
849 int slice;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
850 GdkImage* gdk_image;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
851
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
852
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
853 for (slice = 0; slice < slices; slice++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
854 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
855 gdk_image = convert_EImage_to_GDKImage (device, width, height, eimage,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
856 &pixtbl, &npixels);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
857 if (!gdk_image)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
858 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
859 if (pixtbl) xfree (pixtbl);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
860 signal_image_error("EImage to GdkImage conversion failed", instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
861 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
862
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
863 if (slice == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
864 /* Now create the pixmap and set up the image instance */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
865 init_image_instance_from_gdk_image (ii, gdk_image, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
866 cmap, pixtbl, npixels, slices,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
867 instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
868 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
869 image_instance_add_gdk_image (ii, gdk_image, slice, instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
870
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
871 if (gdk_image)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
872 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
873 gdk_image_destroy (gdk_image);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
874 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
875 gdk_image = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
876 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
877 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
878
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
879 /* Given inline data for a mono pixmap, create and return the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
880 corresponding X object. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
881
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
882 static GdkPixmap *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
883 pixmap_from_xbm_inline (Lisp_Object device, int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
884 /* Note that data is in ext-format! */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
885 const Extbyte *bits)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
886 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
887 return (gdk_bitmap_create_from_data (GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device))),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
888 (char *) bits, width, height));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
889 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
890
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
891 /* Given inline data for a mono pixmap, initialize the given
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
892 image instance accordingly. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
893
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
894 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
895 init_image_instance_from_xbm_inline (struct Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
896 int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
897 /* Note that data is in ext-format! */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
898 const char *bits,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
899 Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
900 Lisp_Object pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
901 Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
902 int dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
903 GdkPixmap *mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
904 Lisp_Object mask_filename)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
905 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
906 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
907 Lisp_Object foreground = find_keyword_in_vector (instantiator, Q_foreground);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
908 Lisp_Object background = find_keyword_in_vector (instantiator, Q_background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
909 GdkColor fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
910 GdkColor bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
911 enum image_instance_type type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
912 GdkWindow *draw = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
913 GdkColormap *cmap = DEVICE_GTK_COLORMAP (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
914 GdkColor black;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
915 GdkColor white;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
916
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
917 gdk_color_black(cmap, &black);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
918 gdk_color_white(cmap, &white);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
919
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
920 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
921 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
922
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
923 if ((dest_mask & IMAGE_MONO_PIXMAP_MASK) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
924 (dest_mask & IMAGE_COLOR_PIXMAP_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
925 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
926 if (!NILP (foreground) || !NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
927 type = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
928 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
929 type = IMAGE_MONO_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
930 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
931 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
932 type = IMAGE_MONO_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
933 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
934 type = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
935 else if (dest_mask & IMAGE_POINTER_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
936 type = IMAGE_POINTER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
937 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
938 incompatible_image_types (instantiator, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
939 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
940 | IMAGE_POINTER_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
941
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
942 gtk_initialize_pixmap_image_instance (ii, 1, type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
943 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
944 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
945 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
946 find_keyword_in_vector (instantiator, Q_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
947
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
948 switch (type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
949 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
950 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
951 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
952 IMAGE_INSTANCE_GTK_PIXMAP (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
953 pixmap_from_xbm_inline (device, width, height, (Extbyte *) bits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
954 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
955 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
956
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
957 case IMAGE_COLOR_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
958 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
959 gint d = DEVICE_GTK_DEPTH (XDEVICE(device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
960
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
961 if (!NILP (foreground) && !COLOR_INSTANCEP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
962 foreground =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
963 Fmake_color_instance (foreground, device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
964 encode_error_behavior_flag (ERROR_ME));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
965
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
966 if (COLOR_INSTANCEP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
967 fg = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (foreground));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
968
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
969 if (!NILP (background) && !COLOR_INSTANCEP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
970 background =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
971 Fmake_color_instance (background, device,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
972 encode_error_behavior_flag (ERROR_ME));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
973
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
974 if (COLOR_INSTANCEP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
975 bg = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (background));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
976
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
977 /* We used to duplicate the pixels using XAllocColor(), to protect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
978 against their getting freed. Just as easy to just store the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
979 color instances here and GC-protect them, so this doesn't
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
980 happen. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
981 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
982 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
983 IMAGE_INSTANCE_GTK_PIXMAP (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
984 gdk_pixmap_create_from_data (draw, (char *) bits, width, height, d, &fg, &bg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
985 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = d;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
986 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
987 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
988
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
989 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
990 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
991 GdkColor fg_color, bg_color;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
992 GdkPixmap *source;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
993
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
994 check_pointer_sizes (width, height, instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
995
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
996 source = gdk_pixmap_create_from_data (draw, (char *) bits, width, height, 1, &black, &white);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
997
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
998 if (NILP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
999 foreground = pointer_fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1000 if (NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1001 background = pointer_bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1002 generate_cursor_fg_bg (device, &foreground, &background,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1003 &fg_color, &bg_color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1004
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1005 IMAGE_INSTANCE_PIXMAP_FG (ii) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1006 IMAGE_INSTANCE_PIXMAP_BG (ii) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1007 IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1008 find_keyword_in_vector (instantiator, Q_hotspot_x);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1009 IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1010 find_keyword_in_vector (instantiator, Q_hotspot_y);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1011 IMAGE_INSTANCE_GTK_CURSOR (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1012 gdk_cursor_new_from_pixmap (source, mask, &fg_color, &bg_color,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1013 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)) ?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1014 XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii)) : 0,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1015 !NILP (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)) ?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1016 XINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii)) : 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1017 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1018 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1019
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1020 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1021 abort ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1022 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1023 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1024
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1025 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1026 xbm_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1027 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1028 int dest_mask, int width, int height,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1029 /* Note that data is in ext-format! */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1030 const char *bits)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1031 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1032 Lisp_Object mask_data = find_keyword_in_vector (instantiator, Q_mask_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1033 Lisp_Object mask_file = find_keyword_in_vector (instantiator, Q_mask_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1034 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1035 GdkPixmap *mask = 0;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1036 const char *gcc_may_you_rot_in_hell;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1037
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1038 if (!NILP (mask_data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1039 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1040 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (mask_data))),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1041 C_STRING_ALLOCA, gcc_may_you_rot_in_hell,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1042 Qfile_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1043 mask =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1044 pixmap_from_xbm_inline (IMAGE_INSTANCE_DEVICE (ii),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1045 XINT (XCAR (mask_data)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1046 XINT (XCAR (XCDR (mask_data))),
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1047 (const unsigned char *)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1048 gcc_may_you_rot_in_hell);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1049 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1050
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1051 init_image_instance_from_xbm_inline (ii, width, height, bits,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1052 instantiator, pointer_fg, pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1053 dest_mask, mask, mask_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1054 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1055
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1056 /* Instantiate method for XBM's. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1057
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1058 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1059 gtk_xbm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1060 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1061 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1062 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1063 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1064 const char *gcc_go_home;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1065
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1066 assert (!NILP (data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1067
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1068 TO_EXTERNAL_FORMAT (LISP_STRING, XCAR (XCDR (XCDR (data))),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1069 C_STRING_ALLOCA, gcc_go_home,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1070 Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1071
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1072 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1073 pointer_bg, dest_mask, XINT (XCAR (data)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1074 XINT (XCAR (XCDR (data))), gcc_go_home);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1075 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1076
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1077
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1078 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1079 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1080 * XPM *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1081 **********************************************************************/
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1082 static Lisp_Object
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1083 write_lisp_string_to_temp_file (Lisp_Object string)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1084 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1085 Lisp_Object instream, outstream;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1086 Lstream *istr, *ostr;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1087 Char_Binary tempbuf[1024]; /* some random amount */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1088 int fubar = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1089 FILE *tmpfil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1090 static Extbyte_dynarr *conversion_out_dynarr;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1091 Bytecount bstart, bend;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1092 Lisp_Object tempfile;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1093 struct gcpro gcpro1, gcpro2, grpro3;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1094 Lisp_Object conv_out_stream;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1095 Lstream *costr;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1096 struct gcpro gcpro4;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1097
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1098 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1099 if (!conversion_out_dynarr)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1100 conversion_out_dynarr = Dynarr_new (Extbyte);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1101 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1102 Dynarr_reset (conversion_out_dynarr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1103
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1104 /* Create the temporary file ... */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1105 tempfile = Fmake_temp_name (build_string ("/tmp/emacs"));
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1106 tmpfil = qxe_fopen (XSTRING_DATA (tempfile), "w");
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1107 if (!tmpfil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1108 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1109 if (tmpfil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1110 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1111 int old_errno = errno;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1112 retry_fclose (tmpfil);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1113 qxe_unlink (XSTRING_DATA (tempfile));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1114 errno = old_errno;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1115 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1116 report_file_error ("Creating temp file", tempfile);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1117 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1118
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1119 CHECK_STRING (string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1120 get_string_range_byte (string, Qnil, Qnil, &bstart, &bend,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1121 GB_HISTORICAL_STRING_BEHAVIOR);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1122 instream = make_lisp_string_input_stream (string, bstart, bend);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1123 istr = XLSTREAM (instream);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1124 /* setup the out stream */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1125 outstream =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1126 make_dynarr_output_stream ((unsigned_char_dynarr *) conversion_out_dynarr);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1127 ostr = XLSTREAM (outstream);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1128 /* setup the conversion stream */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1129 conv_out_stream =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1130 make_coding_output_stream (ostr, Qbinary, CODING_ENCODE);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1131 costr = XLSTREAM (conv_out_stream);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1132 GCPRO4 (tempfile, instream, outstream, conv_out_stream);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1133
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1134 /* Get the data while doing the conversion */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1135 while (1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1136 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1137 int size_in_bytes = Lstream_read (istr, tempbuf, sizeof (tempbuf));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1138 if (!size_in_bytes)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1139 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1140 /* It does seem the flushes are necessary... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1141 Lstream_write (costr, tempbuf, size_in_bytes);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1142 Lstream_flush (costr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1143 Lstream_flush (ostr);
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1144 if (retry_fwrite ((unsigned char *)Dynarr_atp(conversion_out_dynarr, 0),
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1145 Dynarr_length(conversion_out_dynarr), 1, tmpfil) != 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1146 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1147 fubar = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1148 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1149 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1150 /* reset the dynarr */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1151 Lstream_rewind(ostr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1152 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1153
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1154 if (retry_fclose (tmpfil) != 0)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1155 fubar = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1156 Lstream_close (istr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1157 Lstream_close (costr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1158 Lstream_close (ostr);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1159
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1160 Lstream_delete (istr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1161 Lstream_delete (ostr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1162 Lstream_delete (costr);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1163
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1164 if (fubar)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1165 report_file_error ("Writing temp file", tempfile);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1166
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1167 UNGCPRO;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1168 return tempfile;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1169 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1170
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1171 struct color_symbol
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1172 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1173 char* name;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1174 GdkColor color;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1175 };
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1176
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1177 static struct color_symbol*
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1178 extract_xpm_color_names (Lisp_Object device,
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1179 Lisp_Object domain,
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1180 Lisp_Object color_symbol_alist,
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1181 int* nsymbols)
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1182 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1183 /* This function can GC */
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1184 Lisp_Object rest;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1185 Lisp_Object results = Qnil;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1186 int i, j;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1187 struct color_symbol *colortbl;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1188 struct gcpro gcpro1, gcpro2;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1189
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1190 GCPRO2 (results, device);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1191
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1192 /* We built up results to be (("name" . #<color>) ...) so that if an
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1193 error happens we don't lose any malloc()ed data, or more importantly,
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1194 leave any pixels allocated in the server. */
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1195 i = 0;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1196 LIST_LOOP (rest, color_symbol_alist)
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1197 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1198 Lisp_Object cons = XCAR (rest);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1199 Lisp_Object name = XCAR (cons);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1200 Lisp_Object value = XCDR (cons);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1201 if (NILP (value))
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1202 continue;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1203 if (STRINGP (value))
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1204 value =
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1205 Fmake_color_instance
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1206 (value, device, encode_error_behavior_flag (ERROR_ME_NOT));
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1207 else
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1208 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1209 assert (COLOR_SPECIFIERP (value));
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1210 value = Fspecifier_instance (value, domain, Qnil, Qnil);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1211 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1212
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1213 if (NILP (value))
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1214 continue;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1215 results = noseeum_cons (noseeum_cons (name, value), results);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1216 i++;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1217 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1218 UNGCPRO; /* no more evaluation */
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1219
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1220 *nsymbols=i;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1221 if (i == 0) return 0;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1222
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1223 colortbl = xnew_array_and_zero (struct color_symbol, i);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1224
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1225 for (j=0; j<i; j++)
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1226 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1227 Lisp_Object cons = XCAR (results);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1228 colortbl[j].color =
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1229 * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (XCDR (cons)));
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1230
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1231 colortbl[j].name = (char *) XSTRING_DATA (XCAR (cons));
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1232 free_cons (XCONS (cons));
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1233 cons = results;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1234 results = XCDR (results);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1235 free_cons (XCONS (cons));
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1236 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1237 return colortbl;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1238 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1239
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1240 static void
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1241 gtk_xpm_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1242 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1243 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1244 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1245 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1246 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1247 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1248 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1249 GdkColormap *cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1250 int depth;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1251 GdkVisual *visual;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1252 GdkPixmap *pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1253 GdkPixmap *mask = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1254 GdkWindow *window = 0;
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1255 int nsymbols = 0, i = 0;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1256 struct color_symbol *color_symbols = NULL;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1257 GdkColor *transparent_color = NULL;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1258 Lisp_Object color_symbol_alist = find_keyword_in_vector (instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1259 Q_color_symbols);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1260 enum image_instance_type type;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1261 int force_mono;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1262 unsigned int w, h;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1263 Lisp_Object tempfile = Qnil;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1264 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1265
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1266 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1267 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1268
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1269 if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1270 type = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1271 else if (dest_mask & IMAGE_MONO_PIXMAP_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1272 type = IMAGE_MONO_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1273 else if (dest_mask & IMAGE_POINTER_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1274 type = IMAGE_POINTER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1275 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1276 incompatible_image_types (instantiator, dest_mask,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1277 IMAGE_MONO_PIXMAP_MASK | IMAGE_COLOR_PIXMAP_MASK
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1278 | IMAGE_POINTER_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1279 force_mono = (type != IMAGE_COLOR_PIXMAP);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1280
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1281 GCPRO4 (device, data, color_symbol_alist, tempfile);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1282
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1283 window = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (device)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1284 cmap = DEVICE_GTK_COLORMAP (XDEVICE (device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1285 depth = DEVICE_GTK_DEPTH (XDEVICE (device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1286 visual = DEVICE_GTK_VISUAL (XDEVICE (device));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1287
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1288 gtk_initialize_pixmap_image_instance (ii, 1, type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1289
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1290 assert (!NILP (data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1291
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1292 /* Need to get the transparent color here */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1293 color_symbols = extract_xpm_color_names (device, domain, color_symbol_alist,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1294 &nsymbols);
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1295 for (i = 0; i < nsymbols; i++)
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1296 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1297 if (!qxestrcasecmp ("BgColor", color_symbols[i].name) ||
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1298 !qxestrcasecmp ("None", color_symbols[i].name))
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1299 {
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1300 transparent_color = &color_symbols[i].color;
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1301 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1302 }
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1303
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1304 tempfile = write_lisp_string_to_temp_file (data);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1305 {
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1306 Extbyte *tempfileout;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1307
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1308 LISP_STRING_TO_EXTERNAL (tempfile, tempfileout, Qfile_name);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1309 pixmap = gdk_pixmap_create_from_xpm (window, &mask, transparent_color,
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1310 tempfileout);
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1311 }
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1312 qxe_unlink (XSTRING_DATA (tempfile));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1313
739
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1314 if (color_symbols) xfree (color_symbols);
2e5e2ccbeed2 [xemacs-hg @ 2002-02-02 13:42:53 by wmperry]
wmperry
parents: 714
diff changeset
1315
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1316 if (!pixmap)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1317 signal_image_error ("Error reading pixmap", data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1318
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1319 gdk_window_get_geometry (pixmap, NULL, NULL, &w, &h, &depth);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1320
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1321 IMAGE_INSTANCE_GTK_PIXMAP (ii) = pixmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1322 IMAGE_INSTANCE_GTK_MASK (ii) = mask;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1323 IMAGE_INSTANCE_GTK_COLORMAP (ii) = cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1324 IMAGE_INSTANCE_GTK_PIXELS (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1325 IMAGE_INSTANCE_GTK_NPIXELS (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1326 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = w;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1327 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = h;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1328 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1329 find_keyword_in_vector (instantiator, Q_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1330
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1331 switch (type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1332 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1333 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1334 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1335
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1336 case IMAGE_COLOR_PIXMAP:
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1337 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = depth;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1338 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1339
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1340 case IMAGE_POINTER:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1341 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1342 GdkColor fg, bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1343 unsigned int xhot, yhot;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1344
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1345 /* #### Gtk does not give us access to the hotspots of a pixmap */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1346 xhot = yhot = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1347 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_X (ii), xhot);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1348 XSETINT (IMAGE_INSTANCE_PIXMAP_HOTSPOT_Y (ii), yhot);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1349
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1350 check_pointer_sizes (w, h, instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1351
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1352 /* If the loaded pixmap has colors allocated (meaning it came from an
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1353 XPM file), then use those as the default colors for the cursor we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1354 create. Otherwise, default to pointer_fg and pointer_bg.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1355 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1356 if (depth > 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1357 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1358 warn_when_safe (Qunimplemented, Qnotice,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1359 "GTK does not support XPM cursors...\n");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1360 IMAGE_INSTANCE_GTK_CURSOR (ii) = gdk_cursor_new (GDK_COFFEE_MUG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1361 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1362 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1363 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1364 generate_cursor_fg_bg (device, &pointer_fg, &pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1365 &fg, &bg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1366 IMAGE_INSTANCE_PIXMAP_FG (ii) = pointer_fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1367 IMAGE_INSTANCE_PIXMAP_BG (ii) = pointer_bg;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1368 IMAGE_INSTANCE_GTK_CURSOR (ii) =
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1369 gdk_cursor_new_from_pixmap (pixmap, mask, &fg, &bg, xhot, yhot);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1370 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1371 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1372
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1373 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1374
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1375 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1376 abort ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1377 }
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1378
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1379 UNGCPRO;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1380 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1381 #endif /* HAVE_XPM */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1382
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1383
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1384 #ifdef HAVE_XFACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1385
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1386 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1387 * X-Face *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1388 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1389 #if defined(EXTERN)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1390 /* This is about to get redefined! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1391 #undef EXTERN
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1392 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1393 /* We have to define SYSV32 so that compface.h includes string.h
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1394 instead of strings.h. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1395 #define SYSV32
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1396 #ifdef __cplusplus
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1397 extern "C" {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1398 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1399 #include <compface.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1400 #ifdef __cplusplus
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1401 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1402 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1403 /* JMP_BUF cannot be used here because if it doesn't get defined
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1404 to jmp_buf we end up with a conflicting type error with the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1405 definition in compface.h */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1406 extern jmp_buf comp_env;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1407 #undef SYSV32
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1408
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1409 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1410 gtk_xface_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1411 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1412 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1413 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1414 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1415 int i, stattis;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1416 char *p, *bits, *bp;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1417 const char * volatile emsg = 0;
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1418 const char * volatile dstring;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1419
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1420 assert (!NILP (data));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1421
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1422 LISP_STRING_TO_EXTERNAL (data, dstring, Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1423
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1424 if ((p = strchr (dstring, ':')))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1425 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1426 dstring = p + 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1427 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1428
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1429 /* Must use setjmp not SETJMP because we used jmp_buf above not JMP_BUF */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1430 if (!(stattis = setjmp (comp_env)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1431 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1432 UnCompAll ((char *) dstring);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1433 UnGenFace ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1434 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1435
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1436 switch (stattis)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1437 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1438 case -2:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1439 emsg = "uncompface: internal error";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1440 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1441 case -1:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1442 emsg = "uncompface: insufficient or invalid data";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1443 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1444 case 1:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1445 emsg = "uncompface: excess data ignored";
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1446 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1447 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1448
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1449 if (emsg)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1450 gui_error_2 (emsg, data, Qimage);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1451
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1452 bp = bits = (char *) alloca (PIXELS / 8);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1453
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1454 /* the compface library exports char F[], which uses a single byte per
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1455 pixel to represent a 48x48 bitmap. Yuck. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1456 for (i = 0, p = F; i < (PIXELS / 8); ++i)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1457 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1458 int n, b;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1459 /* reverse the bit order of each byte... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1460 for (b = n = 0; b < 8; ++b)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1461 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1462 n |= ((*p++) << b);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1463 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1464 *bp++ = (char) n;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1465 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1466
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1467 xbm_instantiate_1 (image_instance, instantiator, pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1468 pointer_bg, dest_mask, 48, 48, bits);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1469 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1470
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1471 #endif /* HAVE_XFACE */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1472
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1473 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1474 * RESOURCES *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1475 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1476
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1477 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1478 gtk_resource_validate (Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1479 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1480 if ((NILP (find_keyword_in_vector (instantiator, Q_file))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1481 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1482 NILP (find_keyword_in_vector (instantiator, Q_resource_id)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1483 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1484 NILP (find_keyword_in_vector (instantiator, Q_resource_type)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1485 sferror ("Must supply :file, :resource-id and :resource-type",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1486 instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1487 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1488
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1489 static Lisp_Object
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1490 gtk_resource_normalize (Lisp_Object inst, Lisp_Object console_type,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1491 Lisp_Object dest_mask)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1492 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1493 return shared_resource_normalize (inst, console_type, dest_mask,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1494 Qgtk_resource);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1495 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1496
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1497 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1498 gtk_resource_possible_dest_types (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1499 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1500 return IMAGE_POINTER_MASK | IMAGE_COLOR_PIXMAP_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1501 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1502
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1503 extern guint symbol_to_enum (Lisp_Object, GtkType);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1504
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1505 static guint resource_name_to_resource (Lisp_Object name, int type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1506 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1507 if (type == IMAGE_POINTER)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1508 return (symbol_to_enum (name, GTK_TYPE_GDK_CURSOR_TYPE));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1509 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1510 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1511 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1512
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1513 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1514 resource_symbol_to_type (Lisp_Object data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1515 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1516 if (EQ (data, Qcursor))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1517 return IMAGE_POINTER;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1518 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1519 else if (EQ (data, Qicon))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1520 return IMAGE_ICON;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1521 else if (EQ (data, Qbitmap))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1522 return IMAGE_BITMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1523 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1524 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1525 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1526 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1527
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1528 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1529 gtk_resource_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1530 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1531 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1532 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1533 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1534 GdkCursor *c = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1535 unsigned int type = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1536 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1537 Lisp_Object resource_type = find_keyword_in_vector (instantiator, Q_resource_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1538 Lisp_Object resource_id = find_keyword_in_vector (instantiator, Q_resource_id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1539
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1540 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1541 gui_error ("Not a GTK device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1542
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1543 type = resource_symbol_to_type (resource_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1544
595
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1545 #if 0
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1546 if (dest_mask & IMAGE_POINTER_MASK && type == IMAGE_POINTER_MASK)
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1547 iitype = IMAGE_POINTER;
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1548 else if (dest_mask & IMAGE_COLOR_PIXMAP_MASK)
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1549 iitype = IMAGE_COLOR_PIXMAP;
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1550 else
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1551 incompatible_image_types (instantiator, dest_mask,
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1552 IMAGE_COLOR_PIXMAP_MASK | IMAGE_POINTER_MASK);
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1553 #endif
fec27b06b4e5 [xemacs-hg @ 2001-05-31 14:45:08 by wmperry]
wmperry
parents: 563
diff changeset
1554
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1555 /* mess with the keyword info we were provided with */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1556 gtk_initialize_pixmap_image_instance (ii, 1, type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1557 c = gdk_cursor_new (resource_name_to_resource (resource_id, type));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1558 IMAGE_INSTANCE_GTK_CURSOR (ii) = c;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1559 IMAGE_INSTANCE_PIXMAP_FILENAME (ii) = resource_id;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1560 IMAGE_INSTANCE_PIXMAP_WIDTH (ii) = 10;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1561 IMAGE_INSTANCE_PIXMAP_HEIGHT (ii) = 10;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1562 IMAGE_INSTANCE_PIXMAP_DEPTH (ii) = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1563 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1564
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1565 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1566 check_valid_resource_symbol (Lisp_Object data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1567 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1568 CHECK_SYMBOL (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1569 if (!resource_symbol_to_type (data))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1570 invalid_constant ("invalid resource type", data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1571 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1572
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1573 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1574 check_valid_resource_id (Lisp_Object data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1575 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1576 if (!resource_name_to_resource (data, IMAGE_POINTER)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1577 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1578 !resource_name_to_resource (data, IMAGE_COLOR_PIXMAP)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1579 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1580 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1581 !resource_name_to_resource (data, IMAGE_BITMAP)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1582 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1583 )
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1584 invalid_constant ("invalid resource identifier", data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1585 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1586
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1587 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1588 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1589 check_valid_string_or_int (Lisp_Object data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1590 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1591 if (!INTP (data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1592 CHECK_STRING (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1593 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1594 CHECK_INT (data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1595 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1596 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1597
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1598
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1599 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1600 * Autodetect *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1601 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1602
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1603 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1604 autodetect_validate (Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1605 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1606 data_must_be_present (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1607 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1608
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1609 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1610 autodetect_normalize (Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1611 Lisp_Object console_type,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1612 Lisp_Object dest_mask)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1613 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1614 Lisp_Object file = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1615 Lisp_Object filename = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1616 Lisp_Object data = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1617 struct gcpro gcpro1, gcpro2, gcpro3;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1618 Lisp_Object alist = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1619
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1620 GCPRO3 (filename, data, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1621
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1622 if (NILP (file)) /* no conversion necessary */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1623 RETURN_UNGCPRO (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1624
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1625 alist = tagged_vector_to_alist (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1626
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1627 filename = locate_pixmap_file (file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1628 if (!NILP (filename))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1629 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1630 int xhot, yhot;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1631 /* #### Apparently some versions of XpmReadFileToData, which is
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1632 called by pixmap_to_lisp_data, don't return an error value
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1633 if the given file is not a valid XPM file. Instead, they
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1634 just seg fault. It is definitely caused by passing a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1635 bitmap. To try and avoid this we check for bitmaps first. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1636
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1637 data = bitmap_to_lisp_data (filename, &xhot, &yhot, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1638
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1639 if (!EQ (data, Qt))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1640 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1641 alist = remassq_no_quit (Q_data, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1642 alist = Fcons (Fcons (Q_file, filename),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1643 Fcons (Fcons (Q_data, data), alist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1644 if (xhot != -1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1645 alist = Fcons (Fcons (Q_hotspot_x, make_int (xhot)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1646 alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1647 if (yhot != -1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1648 alist = Fcons (Fcons (Q_hotspot_y, make_int (yhot)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1649 alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1650
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1651 alist = xbm_mask_file_munging (alist, filename, Qnil, console_type);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1652
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1653 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1654 Lisp_Object result = alist_to_tagged_vector (Qxbm, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1655 free_alist (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1656 RETURN_UNGCPRO (result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1657 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1658 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1659
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1660 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1661 data = pixmap_to_lisp_data (filename, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1662
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1663 if (!EQ (data, Qt))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1664 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1665 alist = remassq_no_quit (Q_data, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1666 alist = Fcons (Fcons (Q_file, filename),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1667 Fcons (Fcons (Q_data, data), alist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1668 alist = Fcons (Fcons (Q_color_symbols,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1669 evaluate_xpm_color_symbols ()),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1670 alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1671 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1672 Lisp_Object result = alist_to_tagged_vector (Qxpm, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1673 free_alist (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1674 RETURN_UNGCPRO (result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1675 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1676 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1677 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1678 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1679
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1680 /* If we couldn't convert it, just put it back as it is.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1681 We might try to further frob it later as a cursor-font
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1682 specification. (We can't do that now because we don't know
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1683 what dest-types it's going to be instantiated into.) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1684 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1685 Lisp_Object result = alist_to_tagged_vector (Qautodetect, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1686 free_alist (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1687 RETURN_UNGCPRO (result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1688 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1689 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1690
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1691 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1692 autodetect_possible_dest_types (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1693 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1694 return
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1695 IMAGE_MONO_PIXMAP_MASK |
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1696 IMAGE_COLOR_PIXMAP_MASK |
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1697 IMAGE_POINTER_MASK |
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1698 IMAGE_TEXT_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1699 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1700
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1701 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1702 autodetect_instantiate (Lisp_Object image_instance,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1703 Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1704 Lisp_Object pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1705 Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1706 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1707 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1708 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1709 struct gcpro gcpro1, gcpro2, gcpro3;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1710 Lisp_Object alist = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1711 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1712 int is_cursor_font = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1713
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1714 GCPRO3 (data, alist, result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1715
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1716 alist = tagged_vector_to_alist (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1717 if (dest_mask & IMAGE_POINTER_MASK)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1718 {
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1719 const char *name_ext;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1720
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1721 TO_EXTERNAL_FORMAT (LISP_STRING, data,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1722 C_STRING_ALLOCA, name_ext,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1723 Qfile_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1724
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1725 if (cursor_name_to_index (name_ext) != -1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1726 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1727 result = alist_to_tagged_vector (Qcursor_font, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1728 is_cursor_font = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1729 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1730 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1731
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1732 if (!is_cursor_font)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1733 result = alist_to_tagged_vector (Qstring, alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1734 free_alist (alist);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1735
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1736 if (is_cursor_font)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1737 cursor_font_instantiate (image_instance, result, pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1738 pointer_bg, dest_mask, domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1739 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1740 string_instantiate (image_instance, result, pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1741 pointer_bg, dest_mask, domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1742
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1743 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1744 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1745
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1746
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1747 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1748 * Font *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1749 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1750
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1751 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1752 font_validate (Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1753 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1754 data_must_be_present (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1755 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1756
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1757 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1758 font_possible_dest_types (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1759 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1760 return IMAGE_POINTER_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1761 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1762
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1763 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1764 font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1765 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1766 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1767 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1768 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1769 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1770 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1771 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1772 GdkColor fg, bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1773 GdkFont *source, *mask;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1774 char source_name[PATH_MAX], mask_name[PATH_MAX], dummy;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1775 int source_char, mask_char;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1776 int count;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1777 Lisp_Object foreground, background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1778
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1779 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1780 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1781
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1782 if (!STRINGP (data) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1783 strncmp ("FONT ", (char *) XSTRING_DATA (data), 5))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1784 invalid_argument ("Invalid font-glyph instantiator",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1785 instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1786
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1787 if (!(dest_mask & IMAGE_POINTER_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1788 incompatible_image_types (instantiator, dest_mask, IMAGE_POINTER_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1789
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1790 foreground = find_keyword_in_vector (instantiator, Q_foreground);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1791 if (NILP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1792 foreground = pointer_fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1793 background = find_keyword_in_vector (instantiator, Q_background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1794 if (NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1795 background = pointer_bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1796
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1797 generate_cursor_fg_bg (device, &foreground, &background, &fg, &bg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1798
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1799 count = sscanf ((char *) XSTRING_DATA (data),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1800 "FONT %s %d %s %d %c",
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1801 source_name, &source_char,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1802 mask_name, &mask_char, &dummy);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1803 /* Allow "%s %d %d" as well... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1804 if (count == 3 && (1 == sscanf (mask_name, "%d %c", &mask_char, &dummy)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1805 count = 4, mask_name[0] = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1806
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1807 if (count != 2 && count != 4)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1808 syntax_error ("invalid cursor specification", data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1809 source = gdk_font_load (source_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1810 if (! source)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1811 gui_error_2 ("couldn't load font",
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1812 build_string (source_name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1813 data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1814 if (count == 2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1815 mask = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1816 else if (!mask_name[0])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1817 mask = source;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1818 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1819 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1820 mask = gdk_font_load (mask_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1821 if (!mask)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1822 /* continuable */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1823 Fsignal (Qgui_error, list3 (build_msg_string ("couldn't load font"),
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1824 build_string (mask_name), data));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1825 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1826 if (!mask)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1827 mask_char = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1828
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1829 /* #### call XQueryTextExtents() and check_pointer_sizes() here. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1830
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1831 gtk_initialize_pixmap_image_instance (ii, 1, IMAGE_POINTER);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1832
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1833 IMAGE_INSTANCE_GTK_CURSOR (ii) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1834
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1835 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1836 /* #### BILL!!! There is no way to call this function from Gdk */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1837 XCreateGlyphCursor (dpy, source, mask, source_char, mask_char,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1838 &fg, &bg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1839 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1840 XIMAGE_INSTANCE_PIXMAP_FG (image_instance) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1841 XIMAGE_INSTANCE_PIXMAP_BG (image_instance) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1842
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1843 gdk_font_unref (source);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1844 if (mask && mask != source) gdk_font_unref (mask);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1845 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1846
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1847
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1848 /**********************************************************************
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1849 * Cursor-Font *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1850 **********************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1851
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1852 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1853 cursor_font_validate (Lisp_Object instantiator)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1854 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1855 data_must_be_present (instantiator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1856 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1857
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1858 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1859 cursor_font_possible_dest_types (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1860 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1861 return IMAGE_POINTER_MASK;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1862 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1863
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1864 static char *__downcase (const char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1865 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1866 char *converted = strdup(name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1867 char *work = converted;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1868
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1869 while (*work)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1870 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1871 *work = tolower(*work);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1872 work++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1873 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1874 return(converted);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1875 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1876
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1877 /* This is basically the equivalent of XmuCursorNameToIndex */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1878 static gint
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1879 cursor_name_to_index (const char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1880 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1881 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1882 static char *the_gdk_cursors[GDK_NUM_GLYPHS];
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1883
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1884 if (!the_gdk_cursors[GDK_BASED_ARROW_UP])
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1885 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1886 /* Need to initialize the array */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1887 /* Supposedly since this array is static it should be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1888 initialized to NULLs for us, but I'm very paranoid. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1889 for (i = 0; i < GDK_NUM_GLYPHS; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1890 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1891 the_gdk_cursors[i] = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1892 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1893
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1894 #define FROB_CURSOR(x) the_gdk_cursors[GDK_##x] = __downcase(#x)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1895 FROB_CURSOR(ARROW); FROB_CURSOR(BASED_ARROW_DOWN);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1896 FROB_CURSOR(BASED_ARROW_UP); FROB_CURSOR(BOAT);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1897 FROB_CURSOR(BOGOSITY); FROB_CURSOR(BOTTOM_LEFT_CORNER);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1898 FROB_CURSOR(BOTTOM_RIGHT_CORNER); FROB_CURSOR(BOTTOM_SIDE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1899 FROB_CURSOR(BOTTOM_TEE); FROB_CURSOR(BOX_SPIRAL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1900 FROB_CURSOR(CENTER_PTR); FROB_CURSOR(CIRCLE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1901 FROB_CURSOR(CLOCK); FROB_CURSOR(COFFEE_MUG);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1902 FROB_CURSOR(CROSS); FROB_CURSOR(CROSS_REVERSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1903 FROB_CURSOR(CROSSHAIR); FROB_CURSOR(DIAMOND_CROSS);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1904 FROB_CURSOR(DOT); FROB_CURSOR(DOTBOX);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1905 FROB_CURSOR(DOUBLE_ARROW); FROB_CURSOR(DRAFT_LARGE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1906 FROB_CURSOR(DRAFT_SMALL); FROB_CURSOR(DRAPED_BOX);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1907 FROB_CURSOR(EXCHANGE); FROB_CURSOR(FLEUR);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1908 FROB_CURSOR(GOBBLER); FROB_CURSOR(GUMBY);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1909 FROB_CURSOR(HAND1); FROB_CURSOR(HAND2);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1910 FROB_CURSOR(HEART); FROB_CURSOR(ICON);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1911 FROB_CURSOR(IRON_CROSS); FROB_CURSOR(LEFT_PTR);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1912 FROB_CURSOR(LEFT_SIDE); FROB_CURSOR(LEFT_TEE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1913 FROB_CURSOR(LEFTBUTTON); FROB_CURSOR(LL_ANGLE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1914 FROB_CURSOR(LR_ANGLE); FROB_CURSOR(MAN);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1915 FROB_CURSOR(MIDDLEBUTTON); FROB_CURSOR(MOUSE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1916 FROB_CURSOR(PENCIL); FROB_CURSOR(PIRATE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1917 FROB_CURSOR(PLUS); FROB_CURSOR(QUESTION_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1918 FROB_CURSOR(RIGHT_PTR); FROB_CURSOR(RIGHT_SIDE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1919 FROB_CURSOR(RIGHT_TEE); FROB_CURSOR(RIGHTBUTTON);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1920 FROB_CURSOR(RTL_LOGO); FROB_CURSOR(SAILBOAT);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1921 FROB_CURSOR(SB_DOWN_ARROW); FROB_CURSOR(SB_H_DOUBLE_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1922 FROB_CURSOR(SB_LEFT_ARROW); FROB_CURSOR(SB_RIGHT_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1923 FROB_CURSOR(SB_UP_ARROW); FROB_CURSOR(SB_V_DOUBLE_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1924 FROB_CURSOR(SHUTTLE); FROB_CURSOR(SIZING);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1925 FROB_CURSOR(SPIDER); FROB_CURSOR(SPRAYCAN);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1926 FROB_CURSOR(STAR); FROB_CURSOR(TARGET);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1927 FROB_CURSOR(TCROSS); FROB_CURSOR(TOP_LEFT_ARROW);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1928 FROB_CURSOR(TOP_LEFT_CORNER); FROB_CURSOR(TOP_RIGHT_CORNER);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1929 FROB_CURSOR(TOP_SIDE); FROB_CURSOR(TOP_TEE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1930 FROB_CURSOR(TREK); FROB_CURSOR(UL_ANGLE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1931 FROB_CURSOR(UMBRELLA); FROB_CURSOR(UR_ANGLE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1932 FROB_CURSOR(WATCH); FROB_CURSOR(XTERM);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1933 FROB_CURSOR(X_CURSOR);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1934 #undef FROB_CURSOR
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1935 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1936
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1937 for (i = 0; i < GDK_NUM_GLYPHS; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1938 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1939 if (!the_gdk_cursors[i]) continue;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1940 if (!strcmp (the_gdk_cursors[i], name))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1941 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1942 return (i);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1943 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1944 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1945 return(-1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1946 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1947
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1948 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1949 cursor_font_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1950 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1951 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1952 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1953 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1954 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1955 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1956 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1957 int i;
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 739
diff changeset
1958 const char *name_ext;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1959 Lisp_Object foreground, background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1960
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1961 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1962 gui_error ("Not a Gtk device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1963
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1964 if (!(dest_mask & IMAGE_POINTER_MASK))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1965 incompatible_image_types (instantiator, dest_mask, IMAGE_POINTER_MASK);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1966
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1967 TO_EXTERNAL_FORMAT (LISP_STRING, data,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1968 C_STRING_ALLOCA, name_ext,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1969 Qfile_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1970
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1971 if ((i = cursor_name_to_index (name_ext)) == -1)
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
1972 invalid_argument ("Unrecognized cursor-font name", data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1973
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1974 gtk_initialize_pixmap_image_instance (ii, 1, IMAGE_POINTER);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1975 IMAGE_INSTANCE_GTK_CURSOR (ii) = gdk_cursor_new (i);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1976 foreground = find_keyword_in_vector (instantiator, Q_foreground);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1977 if (NILP (foreground))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1978 foreground = pointer_fg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1979 background = find_keyword_in_vector (instantiator, Q_background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1980 if (NILP (background))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1981 background = pointer_bg;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1982 maybe_recolor_cursor (image_instance, foreground, background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1983 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1984
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1985 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1986 gtk_colorize_image_instance (Lisp_Object image_instance,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1987 Lisp_Object foreground, Lisp_Object background);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1988
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1989
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1990 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1991 /* subwindow and widget support */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1992 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1993
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1994 /* unmap the image if it is a widget. This is used by redisplay via
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1995 redisplay_unmap_subwindows */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1996 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1997 gtk_unmap_subwindow (Lisp_Image_Instance *p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1998 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1999 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2000 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2001 /* We don't support subwindows, but we do support widgets... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2002 abort ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2003 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2004 else /* must be a widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2005 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2006 /* Since we are being unmapped we want the enclosing frame to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2007 get focus. The losing with simple scrolling but is the safest
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2008 thing to do. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2009 if (IMAGE_INSTANCE_GTK_CLIPWIDGET (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2010 gtk_widget_unmap (IMAGE_INSTANCE_GTK_CLIPWIDGET (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2011 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2012 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2013
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2014 /* map the subwindow. This is used by redisplay via
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2015 redisplay_output_subwindow */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2016 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2017 gtk_map_subwindow (Lisp_Image_Instance *p, int x, int y,
691
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2018 struct display_glyph_area* dga)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2019 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2020 assert (dga->width > 0 && dga->height > 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2021
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2022 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_SUBWINDOW)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2023 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2024 /* No subwindow support... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2025 abort ();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2026 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2027 else /* must be a widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2028 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2029 struct frame *f = XFRAME (IMAGE_INSTANCE_FRAME (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2030 GtkWidget *wid = IMAGE_INSTANCE_GTK_CLIPWIDGET (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2031 GtkAllocation a;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2032
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2033 if (!wid) return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2034
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2035 a.x = x + IMAGE_INSTANCE_GTK_WIDGET_XOFFSET (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2036 a.y = y + IMAGE_INSTANCE_GTK_WIDGET_YOFFSET (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2037 a.width = dga->width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2038 a.height = dga->height;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2039
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2040 if ((a.width != wid->allocation.width) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2041 (a.height != wid->allocation.height))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2042 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2043 gtk_widget_size_allocate (IMAGE_INSTANCE_GTK_CLIPWIDGET (p), &a);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2044 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2045
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2046 /* #### FIXME DAMMIT */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2047 if ((wid->allocation.x != -dga->xoffset) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2048 (wid->allocation.y != -dga->yoffset))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2049 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2050 guint32 old_flags = GTK_WIDGET_FLAGS (FRAME_GTK_TEXT_WIDGET (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2051
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2052 /* Fucking GtkFixed widget queues a resize when you add a widget.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2053 ** But only if it is visible.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2054 ** losers.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2055 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2056 GTK_WIDGET_FLAGS(FRAME_GTK_TEXT_WIDGET (f)) &= ~GTK_VISIBLE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2057 if (IMAGE_INSTANCE_GTK_ALREADY_PUT(p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2058 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2059 gtk_fixed_move (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2060 wid,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2061 -dga->xoffset, -dga->yoffset);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2062 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2063 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2064 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2065 IMAGE_INSTANCE_GTK_ALREADY_PUT(p) = TRUE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2066 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2067 wid,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2068 -dga->xoffset, -dga->yoffset);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2069 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2070 GTK_WIDGET_FLAGS(FRAME_GTK_TEXT_WIDGET (f)) = old_flags;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2071 }
691
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2072 else
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2073 {
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2074 if (IMAGE_INSTANCE_GTK_ALREADY_PUT(p))
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2075 {
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2076 /* Do nothing... */
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2077 }
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2078 else
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2079 {
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2080 /* Must make sure we have put the image at least once! */
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2081 IMAGE_INSTANCE_GTK_ALREADY_PUT(p) = TRUE;
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2082 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)),
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2083 wid,
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2084 -dga->xoffset, -dga->yoffset);
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2085 }
1df69dc58840 [xemacs-hg @ 2001-12-13 20:53:20 by wmperry]
wmperry
parents: 608
diff changeset
2086 }
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2087
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2088 if (!IMAGE_INSTANCE_SUBWINDOW_DISPLAYEDP (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2089 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2090 gtk_widget_map (wid);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2091 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2092
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2093 gtk_widget_draw (wid, NULL);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2094 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2095 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2096
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2097 /* when you click on a widget you may activate another widget this
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2098 needs to be checked and all appropriate widgets updated */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2099 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2100 gtk_redisplay_subwindow (Lisp_Image_Instance *p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2101 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2102 /* Update the subwindow size if necessary. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2103 if (IMAGE_INSTANCE_SIZE_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2104 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2105 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2106 XResizeWindow (IMAGE_INSTANCE_X_SUBWINDOW_DISPLAY (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2107 IMAGE_INSTANCE_X_SUBWINDOW_ID (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2108 IMAGE_INSTANCE_WIDTH (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2109 IMAGE_INSTANCE_HEIGHT (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2110 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2111 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2112 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2113
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2114 /* Update all attributes that have changed. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2115 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2116 gtk_redisplay_widget (Lisp_Image_Instance *p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2117 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2118 /* This function can GC if IN_REDISPLAY is false. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2119
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2120 if (!IMAGE_INSTANCE_GTK_CLIPWIDGET (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2121 return;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2122
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2123 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2124 /* First get the items if they have changed since this is a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2125 structural change. As such it will nuke all added values so we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2126 need to update most other things after the items have changed.*/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2127 gtk_widget_show_all (IMAGE_INSTANCE_GTK_CLIPWIDGET (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2128 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2129 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2130 Lisp_Object image_instance;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2131
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2132 XSETIMAGE_INSTANCE (image_instance, p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2133
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2134 /* Need to update GtkArgs that might have changed... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2135 /* #### FIXME!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2136 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2137 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2138 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2139 /* #### FIXME!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2140 /* No items changed, so do nothing, right? */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2141 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2142
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2143 /* Possibly update the colors and font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2144 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2145 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2146 /* #### This is not sufficient because it will not cope with widgets
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2147 that are not currently visible. Once redisplay has done the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2148 visible ones it will clear this flag so that when new ones
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2149 become visible they will not be updated. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2150 XFRAME (IMAGE_INSTANCE_FRAME (p))->faces_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2151 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2152 XFRAME (IMAGE_INSTANCE_FRAME (p))->frame_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2153 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2154 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2155 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2156 /* #### Write this function BILL! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2157 update_widget_face (NULL, p, IMAGE_INSTANCE_FRAME (p));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2158 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2159
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2160 /* Possibly update the text. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2161 if (IMAGE_INSTANCE_TEXT_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2162 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2163 char* str;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2164 Lisp_Object val = IMAGE_INSTANCE_WIDGET_TEXT (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2165 LISP_STRING_TO_EXTERNAL (val, str, Qnative);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2166
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2167 /* #### Need to special case each type of GtkWidget here! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2168 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2169
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2170 /* Possibly update the size. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2171 if (IMAGE_INSTANCE_SIZE_CHANGED (p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2172 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2173 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2174 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2175 IMAGE_INSTANCE_TEXT_CHANGED (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2176 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2177 assert (IMAGE_INSTANCE_GTK_WIDGET_ID (p) &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2178 IMAGE_INSTANCE_GTK_CLIPWIDGET (p)) ;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2179
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2180 /* #### Resize the widget! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2181 /* gtk_widget_size_allocate () */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2182 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2183
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2184 /* Adjust offsets within the frame. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2185 if (XFRAME (IMAGE_INSTANCE_FRAME (p))->size_changed)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2186 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2187 /* I don't think we need to do anything for Gtk here... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2188 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2189
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2190 /* now modify the widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2191 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2192 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2193
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2194 /* instantiate and gtk type subwindow */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2195 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2196 gtk_subwindow_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2197 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2198 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2199 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2200 /* This function can GC */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2201 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2202 Lisp_Object device = IMAGE_INSTANCE_DEVICE (ii);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2203
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2204 if (!DEVICE_GTK_P (XDEVICE (device)))
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2205 gui_error ("Not a GTK device", device);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2206
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2207 IMAGE_INSTANCE_TYPE (ii) = IMAGE_SUBWINDOW;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2208
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2209 ii->data = xnew_and_zero (struct gtk_subwindow_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2210
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2211 /* Create a window for clipping */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2212 IMAGE_INSTANCE_GTK_CLIPWINDOW (ii) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2213
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2214 /* Now put the subwindow inside the clip window. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2215 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void *) NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2216 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2217
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2218 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2219
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2220 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2221 /* widgets */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2222 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2223 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2224 update_widget_face (GtkWidget *w, Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2225 Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2226 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2227 if (0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2228 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2229 GtkStyle *style = gtk_widget_get_style (w);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2230 Lisp_Object pixel = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2231 GdkColor *fcolor, *bcolor;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2232
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2233 style = gtk_style_copy (style);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2234
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2235 /* Update the foreground. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2236 pixel = FACE_FOREGROUND (IMAGE_INSTANCE_WIDGET_FACE (ii), domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2237 fcolor = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (pixel));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2238
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2239 /* Update the background. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2240 pixel = FACE_BACKGROUND (IMAGE_INSTANCE_WIDGET_FACE (ii), domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2241 bcolor = COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (pixel));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2242
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2243 /* Update the font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2244 /* #### FIXME!!! Need to copy the widgets style, dick with it, and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2245 ** set the widgets style to the new style...
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2246 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2247 gtk_widget_set_style (w, style);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2248
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2249 /* #### Megahack - but its just getting too complicated to do this
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2250 in the right place. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2251 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2252 if (EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qtab_control))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2253 update_tab_widget_face (wv, ii, domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2254 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2255 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2256 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2257
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2258 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2259 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2260 update_tab_widget_face (GtkWidget *w, Lisp_Image_Instance *ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2261 Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2262 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2263 if (wv->contents)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2264 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2265 widget_value* val = wv->contents, *cur;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2266
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2267 /* Give each child label the correct foreground color. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2268 Lisp_Object pixel = FACE_FOREGROUND
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2269 (IMAGE_INSTANCE_WIDGET_FACE (ii),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2270 domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2271 XColor fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (pixel));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2272 lw_add_widget_value_arg (val, XtNtabForeground, fcolor.pixel);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2273 wv->change = VISIBLE_CHANGE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2274 val->change = VISIBLE_CHANGE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2275
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2276 for (cur = val->next; cur; cur = cur->next)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2277 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2278 cur->change = VISIBLE_CHANGE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2279 if (cur->value)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2280 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2281 lw_copy_widget_value_args (val, cur);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2282 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2283 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2284 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2285 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2286 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2287
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2288 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2289 gtk_widget_instantiate_1 (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2290 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2291 Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2292 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2293 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2294 Lisp_Object widget = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2295 char *nm = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2296 GtkWidget *w = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2297 struct gcpro gcpro1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2298
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2299 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2300
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2301 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2302 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2303 LISP_STRING_TO_EXTERNAL (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm, Qnative);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2304 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2305
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2306 ii->data = xnew_and_zero (struct gtk_subwindow_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2307
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2308 /* Create a clipping widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2309 IMAGE_INSTANCE_GTK_CLIPWIDGET (ii) = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2310 IMAGE_INSTANCE_GTK_ALREADY_PUT(ii) = FALSE;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2311
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2312 /* Create the actual widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2313 GCPRO1 (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2314 widget = call5 (Qgtk_widget_instantiate_internal,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2315 image_instance, instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2316 pointer_fg, pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2317 domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2318
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2319 if (!NILP (widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2320 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2321 CHECK_GTK_OBJECT (widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2322 w = GTK_WIDGET (XGTK_OBJECT (widget)->object);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2323 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2324 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2325 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2326 stderr_out ("Lisp-level creation of widget failed... falling back\n");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2327 w = gtk_label_new ("Widget Creation Failed...");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2328 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2329
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2330 UNGCPRO;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2331
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2332 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void *) w;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2333
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2334 /* #### HACK!!!! We should make this do the right thing if we
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2335 ** really need a clip widget!
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2336 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2337 IMAGE_INSTANCE_GTK_CLIPWIDGET (ii) = w;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2338
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2339 return (Qt);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2340 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2341
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2342 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2343 gtk_widget_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2344 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2345 int dest_mask, Lisp_Object domain)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2346 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2347 call_with_suspended_errors ((lisp_fn_t) gtk_widget_instantiate_1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2348 Qnil, Qimage,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2349 ERROR_ME_WARN, 5,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2350 image_instance, instantiator,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2351 pointer_fg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2352 pointer_bg,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2353 domain);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2354 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2355
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2356 /* get properties of a control */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2357 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2358 gtk_widget_property (Lisp_Object image_instance, Lisp_Object prop)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2359 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2360 /* Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2361
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2362 /* get the text from a control */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2363 if (EQ (prop, Q_text))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2364 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2365 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2366 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2367 return Qunbound;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2368 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2369
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2370 #define FAKE_GTK_WIDGET_INSTANTIATOR(x) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2371 static void \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2372 gtk_##x##_instantiate (Lisp_Object image_instance, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2373 Lisp_Object instantiator, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2374 Lisp_Object pointer_fg, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2375 Lisp_Object pointer_bg, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2376 int dest_mask, Lisp_Object domain) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2377 { \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2378 gtk_widget_instantiate (image_instance, instantiator, pointer_fg, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2379 pointer_bg, dest_mask, domain); \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2380 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2381
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2382 FAKE_GTK_WIDGET_INSTANTIATOR(native_layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2383 FAKE_GTK_WIDGET_INSTANTIATOR(button);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2384 FAKE_GTK_WIDGET_INSTANTIATOR(progress_gauge);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2385 FAKE_GTK_WIDGET_INSTANTIATOR(edit_field);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2386 FAKE_GTK_WIDGET_INSTANTIATOR(combo_box);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2387 FAKE_GTK_WIDGET_INSTANTIATOR(tab_control);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2388 FAKE_GTK_WIDGET_INSTANTIATOR(label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2389
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2390 /* Update a button's clicked state. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2391 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2392 gtk_button_redisplay (Lisp_Object image_instance)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2393 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2394 /* This function can GC if IN_REDISPLAY is false. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2395 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2396 GtkWidget *w = IMAGE_INSTANCE_GTK_CLIPWIDGET (p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2397
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2398 if (GTK_WIDGET_TYPE (w) == gtk_button_get_type ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2399 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2400 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2401 else if (GTK_WIDGET_TYPE (w) == gtk_check_button_get_type ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2402 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2403 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2404 else if (GTK_WIDGET_TYPE (w) == gtk_radio_button_get_type ())
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2405 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2406 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2407 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2408 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2409 /* Unknown button type... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2410 abort();
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2411 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2412 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2413
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2414 /* get properties of a button */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2415 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2416 gtk_button_property (Lisp_Object image_instance, Lisp_Object prop)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2417 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2418 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2419
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2420 /* check the state of a button */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2421 if (EQ (prop, Q_selected))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2422 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2423 if (GTK_WIDGET_HAS_FOCUS (IMAGE_INSTANCE_SUBWINDOW_ID (ii)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2424 return Qt;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2425 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2426 return Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2427 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2428 return Qunbound;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2429 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2430
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2431 /* set the properties of a progress gauge */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2432 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2433 gtk_progress_gauge_redisplay (Lisp_Object image_instance)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2434 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2435 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2436
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2437 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2438 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2439 gfloat f;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2440 Lisp_Object val;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2441
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2442 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2443 f = XFLOATINT (val);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2444
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2445 gtk_progress_set_value (GTK_PROGRESS (IMAGE_INSTANCE_SUBWINDOW_ID (ii)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2446 f);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2447 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2448 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2449
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2450 /* Set the properties of a tab control */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2451 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2452 gtk_tab_control_redisplay (Lisp_Object image_instance)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2453 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2454 /* #### Convert this to GTK baby! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2455 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2456
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2457 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2458 IMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (ii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2459 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2460 /* If only the order has changed then simply select the first
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2461 one of the pending set. This stops horrendous rebuilding -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2462 and hence flicker - of the tabs each time you click on
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2463 one. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2464 if (tab_control_order_only_changed (image_instance))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2465 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2466 Lisp_Object rest, selected =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2467 gui_item_list_find_selected
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2468 (NILP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)) ?
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2469 XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)) :
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2470 XCDR (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2471
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2472 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2473 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2474 if (gui_item_equal_sans_selected (XCAR (rest), selected, 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2475 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2476 Lisp_Object old_selected =gui_item_list_find_selected
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2477 (XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2478
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2479 /* Need to focus on the widget... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2480 stderr_out ("Hey, change the tab-focus you boob...\n");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2481
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2482 /* Pick up the new selected item. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2483 XGUI_ITEM (old_selected)->selected =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2484 XGUI_ITEM (XCAR (rest))->selected;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2485 XGUI_ITEM (XCAR (rest))->selected =
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2486 XGUI_ITEM (selected)->selected;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2487 /* We're not actually changing the items anymore. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2488 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2489 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2490 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2491 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2492 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2493 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2494 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2495 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2496 /* More than just the order has changed... let's get busy! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2497 GtkNotebook *nb = GTK_NOTEBOOK (IMAGE_INSTANCE_GTK_CLIPWIDGET (ii));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2498 guint num_pages = g_list_length (nb->children);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2499 Lisp_Object rest;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2500
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2501 if (num_pages >= 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2502 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2503 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2504 for (i = num_pages; i >= 0; --i)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2505 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2506 gtk_notebook_remove_page (nb, i);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2507 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2508 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2509
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2510 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2511 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2512 Lisp_Gui_Item *pgui = XGUI_ITEM (XCAR (rest));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2513 char *c_name = NULL;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2514
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2515 if (!STRINGP (pgui->name))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2516 pgui->name = Feval (pgui->name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2517
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2518 CHECK_STRING (pgui->name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2519
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2520 TO_EXTERNAL_FORMAT (LISP_STRING, pgui->name,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2521 C_STRING_ALLOCA, c_name,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2522 Qctext);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2523
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2524 gtk_notebook_append_page (nb,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2525 gtk_vbox_new (FALSE, 3),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2526 gtk_label_new (c_name));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2527 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2528
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2529 /* Show all the new widgets we just added... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2530 gtk_widget_show_all (GTK_WIDGET (nb));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2531 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2532 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2533
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2534 /* Possibly update the face. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2535 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2536 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (ii)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2537 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2538 XFRAME (IMAGE_INSTANCE_FRAME (ii))->faces_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2539 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2540 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2541 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2542 update_tab_widget_face (wv, ii,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2543 IMAGE_INSTANCE_FRAME (ii));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2544 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2545 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2546 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2547 #endif /* HAVE_WIDGETS */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2548
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2549
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2550 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2551 /* initialization */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2552 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2553 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2554 syms_of_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2555 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2556 #ifdef HAVE_WIDGETS
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2557 DEFSYMBOL (Qgtk_widget_instantiate_internal);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2558 DEFSYMBOL (Qgtk_widget_property_internal);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2559 DEFSYMBOL (Qgtk_widget_redisplay_internal);
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
2560 DEFSYMBOL (Qgtk_widget_set_style);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2561 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2562 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2563
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2564 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2565 console_type_create_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2566 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2567 /* image methods */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2568 CONSOLE_HAS_METHOD (gtk, print_image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2569 CONSOLE_HAS_METHOD (gtk, finalize_image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2570 CONSOLE_HAS_METHOD (gtk, image_instance_equal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2571 CONSOLE_HAS_METHOD (gtk, image_instance_hash);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2572 CONSOLE_HAS_METHOD (gtk, colorize_image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2573 CONSOLE_HAS_METHOD (gtk, init_image_instance_from_eimage);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2574 CONSOLE_HAS_METHOD (gtk, locate_pixmap_file);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2575 CONSOLE_HAS_METHOD (gtk, unmap_subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2576 CONSOLE_HAS_METHOD (gtk, map_subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2577 CONSOLE_HAS_METHOD (gtk, redisplay_widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2578 CONSOLE_HAS_METHOD (gtk, redisplay_subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2579 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2580
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2581 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2582 image_instantiator_format_create_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2583 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2584 IIFORMAT_VALID_CONSOLE (gtk, nothing);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2585 IIFORMAT_VALID_CONSOLE (gtk, string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2586 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2587 IIFORMAT_VALID_CONSOLE (gtk, layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2588 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2589 IIFORMAT_VALID_CONSOLE (gtk, formatted_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2590 IIFORMAT_VALID_CONSOLE (gtk, inherit);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2591 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2592 INITIALIZE_DEVICE_IIFORMAT (gtk, xpm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2593 IIFORMAT_HAS_DEVMETHOD (gtk, xpm, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2594 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2595 #ifdef HAVE_JPEG
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2596 IIFORMAT_VALID_CONSOLE (gtk, jpeg);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2597 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2598 #ifdef HAVE_TIFF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2599 IIFORMAT_VALID_CONSOLE (gtk, tiff);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2600 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2601 #ifdef HAVE_PNG
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2602 IIFORMAT_VALID_CONSOLE (gtk, png);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2603 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2604 #ifdef HAVE_GIF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2605 IIFORMAT_VALID_CONSOLE (gtk, gif);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2606 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2607
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2608 INITIALIZE_DEVICE_IIFORMAT (gtk, subwindow);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2609 IIFORMAT_HAS_DEVMETHOD (gtk, subwindow, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2610
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2611 #ifdef HAVE_WIDGETS
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2612 /* layout widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2613 INITIALIZE_DEVICE_IIFORMAT (gtk, native_layout);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2614 IIFORMAT_HAS_DEVMETHOD (gtk, native_layout, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2615
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2616 /* button widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2617 INITIALIZE_DEVICE_IIFORMAT (gtk, button);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2618 IIFORMAT_HAS_DEVMETHOD (gtk, button, property);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2619 IIFORMAT_HAS_DEVMETHOD (gtk, button, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2620 IIFORMAT_HAS_DEVMETHOD (gtk, button, redisplay);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2621 /* general widget methods. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2622 INITIALIZE_DEVICE_IIFORMAT (gtk, widget);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2623 IIFORMAT_HAS_DEVMETHOD (gtk, widget, property);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2624
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2625 /* progress gauge */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2626 INITIALIZE_DEVICE_IIFORMAT (gtk, progress_gauge);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2627 IIFORMAT_HAS_DEVMETHOD (gtk, progress_gauge, redisplay);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2628 IIFORMAT_HAS_DEVMETHOD (gtk, progress_gauge, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2629 /* text field */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2630 INITIALIZE_DEVICE_IIFORMAT (gtk, edit_field);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2631 IIFORMAT_HAS_DEVMETHOD (gtk, edit_field, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2632 INITIALIZE_DEVICE_IIFORMAT (gtk, combo_box);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2633 IIFORMAT_HAS_DEVMETHOD (gtk, combo_box, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2634 IIFORMAT_HAS_SHARED_DEVMETHOD (gtk, combo_box, redisplay, tab_control);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2635 /* tab control widget */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2636 INITIALIZE_DEVICE_IIFORMAT (gtk, tab_control);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2637 IIFORMAT_HAS_DEVMETHOD (gtk, tab_control, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2638 IIFORMAT_HAS_DEVMETHOD (gtk, tab_control, redisplay);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2639 /* label */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2640 INITIALIZE_DEVICE_IIFORMAT (gtk, label);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2641 IIFORMAT_HAS_DEVMETHOD (gtk, label, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2642 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2643
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2644 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (cursor_font, "cursor-font");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2645 IIFORMAT_VALID_CONSOLE (gtk, cursor_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2646
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2647 IIFORMAT_HAS_METHOD (cursor_font, validate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2648 IIFORMAT_HAS_METHOD (cursor_font, possible_dest_types);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2649 IIFORMAT_HAS_METHOD (cursor_font, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2650
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2651 IIFORMAT_VALID_KEYWORD (cursor_font, Q_data, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2652 IIFORMAT_VALID_KEYWORD (cursor_font, Q_foreground, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2653 IIFORMAT_VALID_KEYWORD (cursor_font, Q_background, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2654
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2655 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (font, "font");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2656 IIFORMAT_VALID_CONSOLE (gtk, font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2657
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2658 IIFORMAT_HAS_METHOD (font, validate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2659 IIFORMAT_HAS_METHOD (font, possible_dest_types);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2660 IIFORMAT_HAS_METHOD (font, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2661
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2662 IIFORMAT_VALID_KEYWORD (font, Q_data, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2663 IIFORMAT_VALID_KEYWORD (font, Q_foreground, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2664 IIFORMAT_VALID_KEYWORD (font, Q_background, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2665
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2666 #ifdef HAVE_XPM
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2667 INITIALIZE_DEVICE_IIFORMAT (gtk, xpm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2668 IIFORMAT_HAS_DEVMETHOD (gtk, xpm, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2669 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2670
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2671 #ifdef HAVE_XFACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2672 INITIALIZE_DEVICE_IIFORMAT (gtk, xface);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2673 IIFORMAT_HAS_DEVMETHOD (gtk, xface, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2674 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2675
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2676 INITIALIZE_DEVICE_IIFORMAT (gtk, xbm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2677 IIFORMAT_HAS_DEVMETHOD (gtk, xbm, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2678 IIFORMAT_VALID_CONSOLE (gtk, xbm);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2679
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2680 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (gtk_resource, "gtk-resource");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2681 IIFORMAT_VALID_CONSOLE (gtk, gtk_resource);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2682
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2683 IIFORMAT_HAS_METHOD (gtk_resource, validate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2684 IIFORMAT_HAS_METHOD (gtk_resource, normalize);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2685 IIFORMAT_HAS_METHOD (gtk_resource, possible_dest_types);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2686 IIFORMAT_HAS_METHOD (gtk_resource, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2687
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2688 IIFORMAT_VALID_KEYWORD (gtk_resource, Q_resource_type, check_valid_resource_symbol);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2689 IIFORMAT_VALID_KEYWORD (gtk_resource, Q_resource_id, check_valid_resource_id);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2690 IIFORMAT_VALID_KEYWORD (gtk_resource, Q_file, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2691
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2692 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT (autodetect, "autodetect");
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2693 IIFORMAT_VALID_CONSOLE (gtk, autodetect);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2694
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2695 IIFORMAT_HAS_METHOD (autodetect, validate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2696 IIFORMAT_HAS_METHOD (autodetect, normalize);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2697 IIFORMAT_HAS_METHOD (autodetect, possible_dest_types);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2698 IIFORMAT_HAS_METHOD (autodetect, instantiate);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2699
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2700 IIFORMAT_VALID_KEYWORD (autodetect, Q_data, check_valid_string);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2701 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2702
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2703 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2704 vars_of_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2705 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2706 #ifdef HAVE_XFACE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2707 Fprovide (Qxface);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2708 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2709
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2710 DEFVAR_LISP ("gtk-bitmap-file-path", &Vgtk_bitmap_file_path /*
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2711 A list of the directories in which X bitmap files may be found.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2712 If nil, this is initialized from the "*bitmapFilePath" resource.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2713 This is used by the `make-image-instance' function (however, note that if
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2714 the environment variable XBMLANGPATH is set, it is consulted first).
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2715 */ );
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2716 Vgtk_bitmap_file_path = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2717 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2718
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2719 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2720 complex_vars_of_glyphs_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2721 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2722 #define BUILD_GLYPH_INST(variable, name) \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2723 Fadd_spec_to_specifier \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2724 (GLYPH_IMAGE (XGLYPH (variable)), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2725 vector3 (Qxbm, Q_data, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2726 list3 (make_int (name##_width), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2727 make_int (name##_height), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2728 make_ext_string (name##_bits, \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2729 sizeof (name##_bits), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2730 Qbinary))), \
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2731 Qglobal, Qgtk, Qnil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2732
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2733 BUILD_GLYPH_INST (Vtruncation_glyph, truncator);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2734 BUILD_GLYPH_INST (Vcontinuation_glyph, continuer);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2735 BUILD_GLYPH_INST (Vxemacs_logo, xemacs);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2736 BUILD_GLYPH_INST (Vhscroll_glyph, hscroll);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2737
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2738 #undef BUILD_GLYPH_INST
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2739 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2740
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2741 /* X specific crap */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2742 #include <gdk/gdkx.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2743 /* #### Should remove all this X specific stuff when GTK/GDK matures a
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2744 bit more and provides an abstraction for it. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2745 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2746 gtk_colorize_image_instance (Lisp_Object image_instance,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2747 Lisp_Object foreground, Lisp_Object background)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2748 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2749 struct Lisp_Image_Instance *p;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2750
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2751 p = XIMAGE_INSTANCE (image_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2752
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2753 switch (IMAGE_INSTANCE_TYPE (p))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2754 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2755 case IMAGE_MONO_PIXMAP:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2756 IMAGE_INSTANCE_TYPE (p) = IMAGE_COLOR_PIXMAP;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2757 /* Make sure there aren't two pointers to the same mask, causing
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2758 it to get freed twice. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2759 IMAGE_INSTANCE_GTK_MASK (p) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2760 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2761
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2762 default:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2763 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2764 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2765
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2766 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2767 GdkWindow *draw = GET_GTK_WIDGET_WINDOW (DEVICE_GTK_APP_SHELL (XDEVICE (IMAGE_INSTANCE_DEVICE (p))));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2768 GdkPixmap *new_pxmp = gdk_pixmap_new (draw,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2769 IMAGE_INSTANCE_PIXMAP_WIDTH (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2770 IMAGE_INSTANCE_PIXMAP_HEIGHT (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2771 DEVICE_GTK_DEPTH (XDEVICE (IMAGE_INSTANCE_DEVICE (p))));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2772 GdkGCValues gcv;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2773 GdkGC *gc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2774
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2775 gcv.foreground = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (foreground));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2776 gcv.background = * COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (background));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2777 gc = gdk_gc_new_with_values (new_pxmp, &gcv, GDK_GC_BACKGROUND | GDK_GC_FOREGROUND);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2778
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2779 XCopyPlane (GDK_WINDOW_XDISPLAY (draw),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2780 GDK_WINDOW_XWINDOW (IMAGE_INSTANCE_GTK_PIXMAP (p)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2781 GDK_WINDOW_XWINDOW (new_pxmp),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2782 GDK_GC_XGC (gc), 0, 0,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2783 IMAGE_INSTANCE_PIXMAP_WIDTH (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2784 IMAGE_INSTANCE_PIXMAP_HEIGHT (p),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2785 0, 0, 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2786
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2787 gdk_gc_destroy (gc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2788 IMAGE_INSTANCE_GTK_PIXMAP (p) = new_pxmp;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2789 IMAGE_INSTANCE_PIXMAP_DEPTH (p) = DEVICE_GTK_DEPTH (XDEVICE (IMAGE_INSTANCE_DEVICE (p)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2790 IMAGE_INSTANCE_PIXMAP_FG (p) = foreground;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2791 IMAGE_INSTANCE_PIXMAP_BG (p) = background;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2792 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2793 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2794 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2795