annotate src/fontcolor-gtk.c @ 5524:e05d98bf9644

Style and indentation corrections, behavior.el. 2011-06-19 Aidan Kehoe <kehoea@parhasard.net> * behavior.el (enable-behavior): * behavior.el (disable-behavior): Remove a couple of redundant lambdas here, and remove a cond clause that was never tripped (because nil is a list.) * behavior.el (behavior-menu-filter): Correct some indentation here.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 19 Jun 2011 19:15:52 +0100
parents 4dee0387b9de
children 56144c8593a8
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5191
diff changeset
10 XEmacs is free software: you can redistribute it and/or modify it
462
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5191
diff changeset
12 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5191
diff changeset
13 option) any later version.
462
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
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5191
diff changeset
21 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
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 /* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26 /* Gtk version by William Perry */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
31 #include "buffer.h"
3676
3ef0aaf3dc34 [xemacs-hg @ 2006-11-12 13:40:04 by aidan]
aidan
parents: 3659
diff changeset
32 #include "charset.h"
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
33 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
34 #include "insdel.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
35
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
36 #include "console-gtk-impl.h"
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
37 #include "fontcolor-gtk-impl.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39 /* sigh */
4908
b3ce27ca7647 various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents: 3676
diff changeset
40 #include "sysgdkx.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
42 /* 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
43 XFree86 in 2005, at least. */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
44 #define MAX_FONT_COUNT INT_MAX
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
45
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
46 #ifdef DEBUG_XEMACS
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
47 Fixnum debug_x_objects;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
48 #endif /* DEBUG_XEMACS */
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
49
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 /* color instances */
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 /* Replacement for XAllocColor() that tries to return the nearest
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 available color if the colormap is full. Original was from FSFmacs,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 but rewritten by Jareth Hein <jareth@camelot-soft.com> 97/11/25
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 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
59 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
60 match - tries the next nearest...
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 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
63 worry about it.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 Return value is 1 for normal success, 2 for nearest color success,
5384
3889ef128488 Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents: 5191
diff changeset
66 3 for Non-deallocable success. */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
68 allocate_nearest_color (GdkColormap *colormap, GdkVisual *UNUSED (visual),
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 GdkColor *color_def)
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 int rc;
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 rc = gdk_colormap_alloc_color (colormap, color_def, FALSE, TRUE);
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 (rc == TRUE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76 return (1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 return (0);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81 int
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
82 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
83 Bytecount len, Error_Behavior errb)
462
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 GdkColormap *cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86 GdkVisual *visual;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 int result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 cmap = DEVICE_GTK_COLORMAP(d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 visual = DEVICE_GTK_VISUAL (d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92 xzero (*color);
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 const Extbyte *extname;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 578
diff changeset
95 Bytecount extnamelen;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 TO_EXTERNAL_FORMAT (DATA, (name, len), ALLOCA, (extname, extnamelen), Qbinary);
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 result = gdk_color_parse (extname, color);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 if (result == FALSE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
104 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
105 Qcolor, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 result = allocate_nearest_color (cmap, visual, color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 if (!result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
111 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
112 make_string (name, len), Qcolor, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 return result;
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 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
121 Lisp_Object device, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 GdkColor color;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 int result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 result = gtk_parse_nearest_color (XDEVICE (device), &color,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 XSTRING_DATA (name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 XSTRING_LENGTH (name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 errb);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 if (!result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 /* 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
135 or the finalize method may get fucked. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 c->data = xnew (struct gtk_color_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 if (result == 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 COLOR_INSTANCE_GTK_DEALLOC (c) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 COLOR_INSTANCE_GTK_DEALLOC (c) = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 COLOR_INSTANCE_GTK_COLOR (c) = gdk_color_copy (&color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 return 1;
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 gtk_print_color_instance (struct Lisp_Color_Instance *c,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
148 int UNUSED (escapeflag))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
151 write_fmt_string (printcharfun, " %ld=(%X,%X,%X)",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
152 color->pixel, color->red, color->green, color->blue);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 gtk_finalize_color_instance (struct Lisp_Color_Instance *c)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 if (c->data)
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 (DEVICE_LIVE_P (XDEVICE (c->device)))
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 (COLOR_INSTANCE_GTK_DEALLOC (c))
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 gdk_colormap_free_colors (DEVICE_GTK_COLORMAP (XDEVICE (c->device)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 COLOR_INSTANCE_GTK_COLOR (c), 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 gdk_color_free (COLOR_INSTANCE_GTK_COLOR (c));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 }
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
169 xfree (c->data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 c->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 }
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 /* 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
175 screen (have the same RGB values). I imagine that
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 "same RGB values" == "same cell in the colormap." Arguably we should
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 be comparing their names or pixel values instead. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 gtk_color_instance_equal (struct Lisp_Color_Instance *c1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 struct Lisp_Color_Instance *c2,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
182 int UNUSED (depth))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 return (gdk_color_equal (COLOR_INSTANCE_GTK_COLOR (c1),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 COLOR_INSTANCE_GTK_COLOR (c2)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187
2515
de9952d2ed18 [xemacs-hg @ 2005-01-26 10:22:19 by ben]
ben
parents: 2286
diff changeset
188 static Hashcode
5191
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
189 gtk_color_instance_hash (struct Lisp_Color_Instance *c, int UNUSED (depth),
71ee43b8a74d Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents: 5176
diff changeset
190 Boolint UNUSED (equalp))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 return (gdk_color_hash (COLOR_INSTANCE_GTK_COLOR (c), NULL));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 }
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 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 gtk_color_instance_rgb_components (struct Lisp_Color_Instance *c)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 return (list3 (make_int (color->red),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 make_int (color->green),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 make_int (color->blue)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 }
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 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
205 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
206 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 GdkColor c;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208 const char *extname;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
210 extname = LISP_STRING_TO_EXTERNAL (color, Qctext);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212 if (gdk_color_parse (extname, &c) != TRUE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213 return(0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 return (1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
217 static Lisp_Object
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
218 gtk_color_list (void)
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
219 {
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
220 /* #### BILL!!!
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
221 Is this correct? */
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
222 return call0 (intern ("x-color-list-internal"));
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
223 }
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
224
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225
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 /* font instances */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 /************************************************************************/
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 static int
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
231 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
232 Lisp_Object UNUSED (name),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
233 Lisp_Object UNUSED (device), Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
234 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 GdkFont *gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 XFontStruct *xf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 const char *extname;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
239 extname = LISP_STRING_TO_EXTERNAL (f->name, Qctext);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 gf = gdk_font_load (extname);
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 if (!gf)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
245 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
246 Qfont, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 return 0;
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
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
250 xf = (XFontStruct*) GDK_FONT_XFONT (gf);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252 /* 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
253 or the finalize method may get fucked. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 f->data = xnew (struct gtk_font_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 FONT_INSTANCE_GTK_FONT (f) = gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 f->ascent = gf->ascent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 f->descent = gf->descent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 f->height = gf->ascent + gf->descent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 /* Now lets figure out the width of the font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 unsigned int def_char = 'n'; /*xf->default_char;*/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 unsigned int byte1, byte2;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 once_more:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 byte1 = def_char >> 8;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 byte2 = def_char & 0xFF;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270 if (xf->per_char)
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 /* Old versions of the R5 font server have garbage (>63k) as
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273 def_char. 'n' might not be a valid character. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 if (byte1 < xf->min_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 byte1 > xf->max_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 byte2 < xf->min_char_or_byte2 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 byte2 > xf->max_char_or_byte2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 f->width = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 f->width = xf->per_char[(byte1 - xf->min_byte1) *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 (xf->max_char_or_byte2 -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 xf->min_char_or_byte2 + 1) +
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 (byte2 - xf->min_char_or_byte2)].width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 f->width = xf->max_bounds.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 /* 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
289 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
290 0 width too (unlikely) then just use the max width. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 if (f->width == 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 if (def_char == xf->default_char)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 f->width = xf->max_bounds.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 def_char = xf->default_char;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 goto once_more;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 }
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 /* If all characters don't exist then there could potentially be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 0-width characters lurking out there. Not setting this flag
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 trips an optimization that would make them appear to have width
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 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
307 have the same width or if not all characters are defined.
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 /* #### This sucks. There is a measurable performance increase
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 when using proportional width fonts if this flag is not set.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 Unfortunately so many of the fucking X fonts are not fully
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 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
313 make it an assertion. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 (/* x_handle_non_fully_specified_fonts */ 0 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 !xf->all_chars_exist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 f->width = gdk_char_width (gf, 'n');
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 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
320 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 }
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 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 gtk_print_font_instance (struct Lisp_Font_Instance *f,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 Lisp_Object printcharfun,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
327 int UNUSED (escapeflag))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 {
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
329 write_fmt_string (printcharfun, " 0x%lx",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
330 (unsigned long) gdk_font_id (FONT_INSTANCE_GTK_FONT (f)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331 }
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 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 gtk_finalize_font_instance (struct Lisp_Font_Instance *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336 if (f->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 if (DEVICE_LIVE_P (XDEVICE (f->device)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 gdk_font_unref (FONT_INSTANCE_GTK_FONT (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 }
4976
16112448d484 Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
342 xfree (f->data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 f->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 }
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 /* Forward declarations for X specific functions at the end of the file */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
348 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
349 static Lisp_Object __gtk_font_list_internal (const char *pattern);
462
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 static Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
352 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
353 Error_Behavior UNUSED (errb))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
355 if (NILP (FONT_INSTANCE_TRUENAME (f)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
357 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
358
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
359 if (NILP (FONT_INSTANCE_TRUENAME (f)))
462
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 /* Ok, just this once, return the font name as the truename.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362 (This is only used by Fequal() right now.) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 return f->name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365 }
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
366 return (FONT_INSTANCE_TRUENAME (f));
462
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 static Lisp_Object
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2054
diff changeset
370 gtk_font_instance_properties (struct Lisp_Font_Instance *UNUSED (f))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375 /* There seems to be no way to get this information under Gtk */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377 }
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 static Lisp_Object
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
380 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
381 Lisp_Object UNUSED (maxnumber))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 const char *patternext;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384
4981
4aebb0131297 Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents: 4962
diff changeset
385 patternext = LISP_STRING_TO_EXTERNAL (pattern, Qbinary);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
387 return (__gtk_font_list_internal (patternext));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
390 /* 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
391 #define THIS_IS_GTK
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
392 #include "fontcolor-xlike-inc.c"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393
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 /* initialization */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397 /************************************************************************/
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 void
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
400 syms_of_fontcolor_gtk (void)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 {
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 void
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
405 console_type_create_fontcolor_gtk (void)
462
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 /* object methods */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 CONSOLE_HAS_METHOD (gtk, initialize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 CONSOLE_HAS_METHOD (gtk, print_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 CONSOLE_HAS_METHOD (gtk, finalize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 CONSOLE_HAS_METHOD (gtk, color_instance_equal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 CONSOLE_HAS_METHOD (gtk, color_instance_hash);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 CONSOLE_HAS_METHOD (gtk, color_instance_rgb_components);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 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
416 CONSOLE_HAS_METHOD (gtk, color_list);
462
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 CONSOLE_HAS_METHOD (gtk, initialize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 CONSOLE_HAS_METHOD (gtk, print_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 CONSOLE_HAS_METHOD (gtk, finalize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 CONSOLE_HAS_METHOD (gtk, font_instance_truename);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 CONSOLE_HAS_METHOD (gtk, font_instance_properties);
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
423 CONSOLE_HAS_METHOD (gtk, font_list);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425 CONSOLE_HAS_METHOD (gtk, find_charset_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 CONSOLE_HAS_METHOD (gtk, font_spec_matches_charset);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 }
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 void
5176
8b2f75cecb89 rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents: 4982
diff changeset
431 vars_of_fontcolor_gtk (void)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 {
3659
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
433 #ifdef DEBUG_XEMACS
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
434 DEFVAR_INT ("debug-x-objects", &debug_x_objects /*
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
435 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
436 */ );
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
437 debug_x_objects = 0;
98af8a976fc3 [xemacs-hg @ 2006-11-05 22:31:31 by aidan]
aidan
parents: 3169
diff changeset
438 #endif
462
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 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 valid_font_name_p (Display *dpy, char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 /* Maybe this should be implemented by callign XLoadFont and trapping
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 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
446 might be more correct.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 int nnames = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 char **names = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 if (! name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 names = XListFonts (dpy, name, 1, &nnames);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 XFreeFontNames (names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 return (nnames != 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 }
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 Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 __get_gtk_font_truename (GdkFont *gdk_font, int expandp)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 Display *dpy = GDK_FONT_XDISPLAY (gdk_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462 GSList *names = ((GdkFontPrivate *) gdk_font)->names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 Lisp_Object font_name = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 while (names)
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 if (names->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 {
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
469 if (valid_font_name_p (dpy, (char*) names->data))
462
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 if (!expandp)
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 /* They want the wildcarded version */
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 3676
diff changeset
474 font_name = build_cistring ((char*) names->data);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 /* Need to expand out */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 int nnames = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 char **x_font_names = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481
2054
91d4c8c65a0f [xemacs-hg @ 2004-05-02 04:06:51 by malcolmp]
malcolmp
parents: 1726
diff changeset
482 x_font_names = XListFonts (dpy, (char*) names->data, 1, &nnames);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
483 if (x_font_names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484 {
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 3676
diff changeset
485 font_name = build_cistring (x_font_names[0]);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 XFreeFontNames (x_font_names);
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 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489 break;
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 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
492 names = names->next;
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 return (font_name);
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
2527
491f8cf78a9c [xemacs-hg @ 2005-01-28 02:58:38 by ben]
ben
parents: 2515
diff changeset
497 static Lisp_Object __gtk_font_list_internal (const char *pattern)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
498 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
499 char **names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 int count = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
502
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503 names = XListFonts (GDK_DISPLAY (), pattern, MAX_FONT_COUNT, &count);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504 while (count--)
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 3676
diff changeset
505 result = Fcons (build_extstring (names [count], Qbinary), result);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 XFreeFontNames (names);
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 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
510 }