annotate src/objects-gtk.c @ 5118:e0db3c197671 ben-lisp-object

merge up to latest default branch, doesn't compile yet
author Ben Wing <ben@xemacs.org>
date Sat, 26 Dec 2009 21:18:49 -0600
parents 3ef0aaf3dc34
children b3ce27ca7647 304aebb79cd3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 /* X-specific Lisp objects.
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.
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
5 Copyright (C) 1995, 1996, 2002 Ben Wing.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 Copyright (C) 1995 Sun Microsystems, Inc.
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 /* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 /* Gtk version by William Perry */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
33 #include "buffer.h"
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
34 #include "charset.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
35 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
36 #include "insdel.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
38 #include "console-gtk-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
39 #include "objects-gtk-impl.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 /* sigh */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 #include <gdk/gdkx.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
44 /* XListFonts doesn't allocate memory unconditionally based on this. (For
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
45 XFree86 in 2005, at least. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
46 #define MAX_FONT_COUNT INT_MAX
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
47
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
48 #ifdef DEBUG_XEMACS
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
49 Fixnum debug_x_objects;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
50 #endif /* DEBUG_XEMACS */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
51
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 /* color instances */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 /* Replacement for XAllocColor() that tries to return the nearest
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 available color if the colormap is full. Original was from FSFmacs,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 but rewritten by Jareth Hein <jareth@camelot-soft.com> 97/11/25
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 Modified by Lee Kindness <lkindness@csl.co.uk> 31/08/99 to handle previous
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 total failure which was due to a read/write colorcell being the nearest
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 match - tries the next nearest...
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64 Gdk takes care of all this behind the scenes, so we don't need to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 worry about it.
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 Return value is 1 for normal success, 2 for nearest color success,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 3 for Non-deallocable sucess. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
70 allocate_nearest_color (GdkColormap *colormap, GdkVisual *UNUSED (visual),
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 GdkColor *color_def)
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 int rc;
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 rc = gdk_colormap_alloc_color (colormap, color_def, FALSE, TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 if (rc == TRUE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 return (1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 return (0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 int
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
84 gtk_parse_nearest_color (struct device *d, GdkColor *color, Ibyte *name,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
85 Bytecount len, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 GdkColormap *cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88 GdkVisual *visual;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 int result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 cmap = DEVICE_GTK_COLORMAP(d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 visual = DEVICE_GTK_VISUAL (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 xzero (*color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 const Extbyte *extname;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 578
diff changeset
97 Bytecount extnamelen;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 TO_EXTERNAL_FORMAT (DATA, (name, len), ALLOCA, (extname, extnamelen), Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 result = gdk_color_parse (extname, color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 if (result == FALSE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
106 maybe_invalid_argument ("unrecognized color", make_string (name, len),
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
107 Qcolor, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110 result = allocate_nearest_color (cmap, visual, color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111 if (!result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
113 maybe_signal_error (Qgui_error, "couldn't allocate color",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
114 make_string (name, len), Qcolor, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 return 0;
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 }
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 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 gtk_initialize_color_instance (struct Lisp_Color_Instance *c, Lisp_Object name,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
123 Lisp_Object device, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 GdkColor color;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 int result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 result = gtk_parse_nearest_color (XDEVICE (device), &color,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 XSTRING_DATA (name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 XSTRING_LENGTH (name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 errb);
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 if (!result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 /* Don't allocate the data until we're sure that we will succeed,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 or the finalize method may get fucked. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 c->data = xnew (struct gtk_color_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 if (result == 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 COLOR_INSTANCE_GTK_DEALLOC (c) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 COLOR_INSTANCE_GTK_DEALLOC (c) = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 COLOR_INSTANCE_GTK_COLOR (c) = gdk_color_copy (&color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 gtk_print_color_instance (struct Lisp_Color_Instance *c,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
150 int UNUSED (escapeflag))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152 GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
153 write_fmt_string (printcharfun, " %ld=(%X,%X,%X)",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
154 color->pixel, color->red, color->green, color->blue);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 gtk_finalize_color_instance (struct Lisp_Color_Instance *c)
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 if (c->data)
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 if (DEVICE_LIVE_P (XDEVICE (c->device)))
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 if (COLOR_INSTANCE_GTK_DEALLOC (c))
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 gdk_colormap_free_colors (DEVICE_GTK_COLORMAP (XDEVICE (c->device)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 COLOR_INSTANCE_GTK_COLOR (c), 1);
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 gdk_color_free (COLOR_INSTANCE_GTK_COLOR (c));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 }
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1701
diff changeset
171 xfree (c->data, void *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 c->data = 0;
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 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 /* Color instances are equal if they resolve to the same color on the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 screen (have the same RGB values). I imagine that
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 "same RGB values" == "same cell in the colormap." Arguably we should
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 be comparing their names or pixel values instead. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 gtk_color_instance_equal (struct Lisp_Color_Instance *c1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 struct Lisp_Color_Instance *c2,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
184 int UNUSED (depth))
462
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 return (gdk_color_equal (COLOR_INSTANCE_GTK_COLOR (c1),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 COLOR_INSTANCE_GTK_COLOR (c2)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2286
diff changeset
190 static Hashcode
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
191 gtk_color_instance_hash (struct Lisp_Color_Instance *c, int UNUSED (depth))
462
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 return (gdk_color_hash (COLOR_INSTANCE_GTK_COLOR (c), NULL));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194 }
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 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 gtk_color_instance_rgb_components (struct Lisp_Color_Instance *c)
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 GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 return (list3 (make_int (color->red),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 make_int (color->green),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 make_int (color->blue)));
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 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
206 gtk_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208 GdkColor c;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 const char *extname;
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 TO_EXTERNAL_FORMAT (LISP_STRING, color, C_STRING_ALLOCA, extname, Qctext);
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 if (gdk_color_parse (extname, &c) != TRUE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 return(0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 return (1);
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
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
218 static Lisp_Object
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
219 gtk_color_list (void)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
220 {
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
221 /* #### BILL!!!
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
222 Is this correct? */
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
223 return call0 (intern ("x-color-list-internal"));
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
224 }
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
225
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 /* font instances */
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
232 gtk_initialize_font_instance (struct Lisp_Font_Instance *f,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
233 Lisp_Object UNUSED (name),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
234 Lisp_Object UNUSED (device), Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 GdkFont *gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 XFontStruct *xf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 const char *extname;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 TO_EXTERNAL_FORMAT (LISP_STRING, f->name, C_STRING_ALLOCA, extname, Qctext);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242 gf = gdk_font_load (extname);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 if (!gf)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
246 maybe_signal_error (Qgui_error, "couldn't load font", f->name,
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
247 Qfont, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
251 xf = (XFontStruct*) GDK_FONT_XFONT (gf);
462
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 /* Don't allocate the data until we're sure that we will succeed,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 or the finalize method may get fucked. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 f->data = xnew (struct gtk_font_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 FONT_INSTANCE_GTK_FONT (f) = gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 f->ascent = gf->ascent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 f->descent = gf->descent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 f->height = gf->ascent + gf->descent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 /* Now lets figure out the width of the font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 unsigned int def_char = 'n'; /*xf->default_char;*/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 unsigned int byte1, byte2;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 once_more:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 byte1 = def_char >> 8;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 byte2 = def_char & 0xFF;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 if (xf->per_char)
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 /* Old versions of the R5 font server have garbage (>63k) as
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 def_char. 'n' might not be a valid character. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 if (byte1 < xf->min_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 byte1 > xf->max_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 byte2 < xf->min_char_or_byte2 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 byte2 > xf->max_char_or_byte2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 f->width = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 f->width = xf->per_char[(byte1 - xf->min_byte1) *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 (xf->max_char_or_byte2 -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 xf->min_char_or_byte2 + 1) +
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 (byte2 - xf->min_char_or_byte2)].width;
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 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 f->width = xf->max_bounds.width;
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 /* Some fonts have a default char whose width is 0. This is no good.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 If that's the case, first try 'n' as the default char, and if n has
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 0 width too (unlikely) then just use the max width. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292 if (f->width == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 if (def_char == xf->default_char)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 f->width = xf->max_bounds.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 def_char = xf->default_char;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 goto once_more;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 }
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 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 /* If all characters don't exist then there could potentially be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 0-width characters lurking out there. Not setting this flag
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 trips an optimization that would make them appear to have width
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 to redisplay. This is bad. So we set it if not all characters
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 have the same width or if not all characters are defined.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 /* #### This sucks. There is a measurable performance increase
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 when using proportional width fonts if this flag is not set.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 Unfortunately so many of the fucking X fonts are not fully
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 defined that we could almost just get rid of this damn flag and
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 make it an assertion. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 (/* x_handle_non_fully_specified_fonts */ 0 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 !xf->all_chars_exist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 f->width = gdk_char_width (gf, 'n');
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 f->proportional_p = (gdk_char_width (gf, '|') != gdk_char_width (gf, 'W')) ? 1 : 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 gtk_print_font_instance (struct Lisp_Font_Instance *f,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
328 int UNUSED (escapeflag))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 {
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
330 write_fmt_string (printcharfun, " 0x%lx",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
331 (unsigned long) gdk_font_id (FONT_INSTANCE_GTK_FONT (f)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 }
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 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 gtk_finalize_font_instance (struct Lisp_Font_Instance *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 if (f->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 if (DEVICE_LIVE_P (XDEVICE (f->device)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 gdk_font_unref (FONT_INSTANCE_GTK_FONT (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 }
1726
a8d8f419b459 [xemacs-hg @ 2003-09-30 15:26:34 by james]
james
parents: 1701
diff changeset
343 xfree (f->data, void *);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 f->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345 }
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 /* Forward declarations for X specific functions at the end of the file */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349 Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp);
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
350 static Lisp_Object __gtk_font_list_internal (const char *pattern);
462
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 Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
353 gtk_font_instance_truename (struct Lisp_Font_Instance *f,
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
354 Error_Behavior UNUSED (errb))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
356 if (NILP (FONT_INSTANCE_TRUENAME (f)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
358 FONT_INSTANCE_TRUENAME (f) = __get_gtk_font_truename (FONT_INSTANCE_GTK_FONT (f), 1);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
360 if (NILP (FONT_INSTANCE_TRUENAME (f)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
361 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362 /* Ok, just this once, return the font name as the truename.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 (This is only used by Fequal() right now.) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 return f->name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 }
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
367 return (FONT_INSTANCE_TRUENAME (f));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
368 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 static Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
371 gtk_font_instance_properties (struct Lisp_Font_Instance *UNUSED (f))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 /* There seems to be no way to get this information under Gtk */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 }
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 static Lisp_Object
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
381 gtk_font_list (Lisp_Object pattern, Lisp_Object UNUSED (device),
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
382 Lisp_Object UNUSED (maxnumber))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 const char *patternext;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 TO_EXTERNAL_FORMAT (LISP_STRING, pattern, C_STRING_ALLOCA, patternext, Qbinary);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
388 return (__gtk_font_list_internal (patternext));
462
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
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
391 /* Include the charset support, shared, for the moment, with X11. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
392 #define THIS_IS_GTK
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
393 #include "objects-xlike-inc.c"
462
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
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 /* initialization */
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 syms_of_objects_gtk (void)
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 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 console_type_create_objects_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 /* object methods */
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 CONSOLE_HAS_METHOD (gtk, initialize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 CONSOLE_HAS_METHOD (gtk, print_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 CONSOLE_HAS_METHOD (gtk, finalize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 CONSOLE_HAS_METHOD (gtk, color_instance_equal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 CONSOLE_HAS_METHOD (gtk, color_instance_hash);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 CONSOLE_HAS_METHOD (gtk, color_instance_rgb_components);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 CONSOLE_HAS_METHOD (gtk, valid_color_name_p);
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
417 CONSOLE_HAS_METHOD (gtk, color_list);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 CONSOLE_HAS_METHOD (gtk, initialize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 CONSOLE_HAS_METHOD (gtk, print_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 CONSOLE_HAS_METHOD (gtk, finalize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 CONSOLE_HAS_METHOD (gtk, font_instance_truename);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 CONSOLE_HAS_METHOD (gtk, font_instance_properties);
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
424 CONSOLE_HAS_METHOD (gtk, font_list);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 CONSOLE_HAS_METHOD (gtk, find_charset_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 CONSOLE_HAS_METHOD (gtk, font_spec_matches_charset);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 }
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 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 vars_of_objects_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 {
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
434 #ifdef DEBUG_XEMACS
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
435 DEFVAR_INT ("debug-x-objects", &debug_x_objects /*
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
436 If non-zero, display debug information about X objects
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
437 */ );
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
438 debug_x_objects = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
439 #endif
462
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 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 valid_font_name_p (Display *dpy, char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 /* Maybe this should be implemented by callign XLoadFont and trapping
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 the error. That would be a lot of work, and wasteful as hell, but
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 might be more correct.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 int nnames = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 char **names = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 if (! name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 names = XListFonts (dpy, name, 1, &nnames);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 XFreeFontNames (names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 return (nnames != 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457 }
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 Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 __get_gtk_font_truename (GdkFont *gdk_font, int expandp)
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 Display *dpy = GDK_FONT_XDISPLAY (gdk_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 GSList *names = ((GdkFontPrivate *) gdk_font)->names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 Lisp_Object font_name = Qnil;
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 while (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 if (names->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
470 if (valid_font_name_p (dpy, (char*) names->data))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
471 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472 if (!expandp)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 /* They want the wildcarded version */
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
475 font_name = build_string ((char*) names->data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 /* Need to expand out */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 int nnames = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 char **x_font_names = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
483 x_font_names = XListFonts (dpy, (char*) names->data, 1, &nnames);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484 if (x_font_names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 font_name = build_string (x_font_names[0]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 XFreeFontNames (x_font_names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
488 }
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 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
492 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493 names = names->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
494 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
495 return (font_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
496 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
497
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
498 static Lisp_Object __gtk_font_list_internal (const char *pattern)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
499 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 char **names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 int count = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
502 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504 names = XListFonts (GDK_DISPLAY (), pattern, MAX_FONT_COUNT, &count);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505 while (count--)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506 result = Fcons (build_ext_string (names [count], Qbinary), result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
508 XFreeFontNames (names);
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 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 }