annotate src/objects-gtk.c @ 867:804517e16990

[xemacs-hg @ 2002-06-05 09:54:39 by ben] Textual renaming: text/char names abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization. [a] distinguish between "charptr" when it refers to operations on the pointer itself and when it refers to operations on text; and [b] use consistent naming for everything referring to internal format, i.e. Itext == text in internal format Ibyte == a byte in such text Ichar == a char as represented in internal character format thus e.g. set_charptr_emchar -> set_itext_ichar The pre and post tags on either side of this change are: pre-internal-format-textual-renaming post-internal-format-textual-renaming See the Internals Manual for details of exactly how this was done, how to handle the change in your workspace, etc.
author ben
date Wed, 05 Jun 2002 09:58:45 +0000
parents a5954632b187
children 79c6ff3eef26
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.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5 Copyright (C) 1995, 1996 Ben Wing.
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33 #include "console-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
34 #include "objects-gtk.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
35
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36 #include "buffer.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 #include "device.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38 #include "insdel.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 /* sigh */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 #include <gdk/gdkx.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45 /* color instances */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 /* Replacement for XAllocColor() that tries to return the nearest
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49 available color if the colormap is full. Original was from FSFmacs,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 but rewritten by Jareth Hein <jareth@camelot-soft.com> 97/11/25
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 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
52 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
53 match - tries the next nearest...
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 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
56 worry about it.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 Return value is 1 for normal success, 2 for nearest color success,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 3 for Non-deallocable sucess. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 allocate_nearest_color (GdkColormap *colormap, GdkVisual *visual,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 GdkColor *color_def)
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 int rc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 rc = gdk_colormap_alloc_color (colormap, color_def, FALSE, TRUE);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 if (rc == TRUE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 return (1);
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 return (0);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74 int
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
75 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
76 Bytecount len, Error_Behavior errb)
462
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 GdkColormap *cmap;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79 GdkVisual *visual;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 int result;
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 cmap = DEVICE_GTK_COLORMAP(d);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 visual = DEVICE_GTK_VISUAL (d);
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 xzero (*color);
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 const Extbyte *extname;
665
fdefd0186b75 [xemacs-hg @ 2001-09-20 06:28:42 by ben]
ben
parents: 578
diff changeset
88 Bytecount extnamelen;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 TO_EXTERNAL_FORMAT (DATA, (name, len), ALLOCA, (extname, extnamelen), Qbinary);
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 result = gdk_color_parse (extname, 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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 if (result == FALSE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
97 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
98 Qcolor, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 return 0;
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 = allocate_nearest_color (cmap, visual, color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 if (!result)
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_signal_error (Qgui_error, "couldn't allocate color",
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
105 make_string (name, len), 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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 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
114 Lisp_Object device, Error_Behavior errb)
462
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 GdkColor color;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 int result;
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 result = gtk_parse_nearest_color (XDEVICE (device), &color,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 XSTRING_DATA (name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 XSTRING_LENGTH (name),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 errb);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 if (!result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 /* 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
128 or the finalize method may get fucked. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 c->data = xnew (struct gtk_color_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 if (result == 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 COLOR_INSTANCE_GTK_DEALLOC (c) = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 COLOR_INSTANCE_GTK_DEALLOC (c) = 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 COLOR_INSTANCE_GTK_COLOR (c) = gdk_color_copy (&color);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 gtk_print_color_instance (struct Lisp_Color_Instance *c,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 Lisp_Object printcharfun,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 int escapeflag)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
144 write_fmt_string (printcharfun, " %ld=(%X,%X,%X)",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
145 color->pixel, color->red, color->green, color->blue);
462
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 gtk_finalize_color_instance (struct Lisp_Color_Instance *c)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 if (c->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 if (DEVICE_LIVE_P (XDEVICE (c->device)))
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 if (COLOR_INSTANCE_GTK_DEALLOC (c))
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 gdk_colormap_free_colors (DEVICE_GTK_COLORMAP (XDEVICE (c->device)),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 COLOR_INSTANCE_GTK_COLOR (c), 1);
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 gdk_color_free (COLOR_INSTANCE_GTK_COLOR (c));
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 xfree (c->data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 c->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 /* 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
168 screen (have the same RGB values). I imagine that
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 "same RGB values" == "same cell in the colormap." Arguably we should
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 be comparing their names or pixel values instead. */
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 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 gtk_color_instance_equal (struct Lisp_Color_Instance *c1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 struct Lisp_Color_Instance *c2,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175 int depth)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 return (gdk_color_equal (COLOR_INSTANCE_GTK_COLOR (c1),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 COLOR_INSTANCE_GTK_COLOR (c2)));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 }
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 unsigned long
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 gtk_color_instance_hash (struct Lisp_Color_Instance *c, int depth)
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_hash (COLOR_INSTANCE_GTK_COLOR (c), NULL));
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 gtk_color_instance_rgb_components (struct Lisp_Color_Instance *c)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 return (list3 (make_int (color->red),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 make_int (color->green),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193 make_int (color->blue)));
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 int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 gtk_valid_color_name_p (struct device *d, Lisp_Object color)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 GdkColor c;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 const char *extname;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 TO_EXTERNAL_FORMAT (LISP_STRING, color, C_STRING_ALLOCA, extname, Qctext);
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 if (gdk_color_parse (extname, &c) != TRUE)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 return(0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 return (1);
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209
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 /* font instances */
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 gtk_initialize_font_instance (struct Lisp_Font_Instance *f, Lisp_Object name,
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
216 Lisp_Object device, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 GdkFont *gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 XFontStruct *xf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220 const char *extname;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 TO_EXTERNAL_FORMAT (LISP_STRING, f->name, C_STRING_ALLOCA, extname, Qctext);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 gf = gdk_font_load (extname);
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 if (!gf)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 {
563
183866b06e0b [xemacs-hg @ 2001-05-24 07:50:48 by ben]
ben
parents: 462
diff changeset
228 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
229 Qfont, errb);
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 xf = GDK_FONT_XFONT (gf);
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 /* 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
236 or the finalize method may get fucked. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 f->data = xnew (struct gtk_font_instance_data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 FONT_INSTANCE_GTK_TRUENAME (f) = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 FONT_INSTANCE_GTK_FONT (f) = gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 f->ascent = gf->ascent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 f->descent = gf->descent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242 f->height = gf->ascent + gf->descent;
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 /* Now lets figure out the width of the font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 unsigned int def_char = 'n'; /*xf->default_char;*/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248 unsigned int byte1, byte2;
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 once_more:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 byte1 = def_char >> 8;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252 byte2 = def_char & 0xFF;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 if (xf->per_char)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 /* Old versions of the R5 font server have garbage (>63k) as
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 def_char. 'n' might not be a valid character. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 if (byte1 < xf->min_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 byte1 > xf->max_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 byte2 < xf->min_char_or_byte2 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 byte2 > xf->max_char_or_byte2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 f->width = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 f->width = xf->per_char[(byte1 - xf->min_byte1) *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 (xf->max_char_or_byte2 -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 xf->min_char_or_byte2 + 1) +
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 (byte2 - xf->min_char_or_byte2)].width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270 f->width = xf->max_bounds.width;
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 /* 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
273 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
274 0 width too (unlikely) then just use the max width. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 if (f->width == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 if (def_char == xf->default_char)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 f->width = xf->max_bounds.width;
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 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 def_char = xf->default_char;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 goto once_more;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 }
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 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 /* If all characters don't exist then there could potentially be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 0-width characters lurking out there. Not setting this flag
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 trips an optimization that would make them appear to have width
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290 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
291 have the same width or if not all characters are defined.
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 /* #### This sucks. There is a measurable performance increase
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 when using proportional width fonts if this flag is not set.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 Unfortunately so many of the fucking X fonts are not fully
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 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
297 make it an assertion. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 (/* x_handle_non_fully_specified_fonts */ 0 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 !xf->all_chars_exist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 f->width = gdk_char_width (gf, 'n');
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303 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
304 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 gtk_mark_font_instance (struct Lisp_Font_Instance *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 mark_object (FONT_INSTANCE_GTK_TRUENAME (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 gtk_print_font_instance (struct Lisp_Font_Instance *f,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 Lisp_Object printcharfun,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 int escapeflag)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 {
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
319 write_fmt_string (printcharfun, " 0x%lx",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
320 (unsigned long) gdk_font_id (FONT_INSTANCE_GTK_FONT (f)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 }
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 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 gtk_finalize_font_instance (struct Lisp_Font_Instance *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 if (f->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328 if (DEVICE_LIVE_P (XDEVICE (f->device)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 gdk_font_unref (FONT_INSTANCE_GTK_FONT (f));
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 xfree (f->data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333 f->data = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 }
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 /* Forward declarations for X specific functions at the end of the file */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339 static Lisp_Object __gtk_list_fonts_internal (const char *pattern);
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 static Lisp_Object
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
342 gtk_font_instance_truename (struct Lisp_Font_Instance *f, Error_Behavior errb)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 if (NILP (FONT_INSTANCE_GTK_TRUENAME (f)))
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 FONT_INSTANCE_GTK_TRUENAME (f) = __get_gtk_font_truename (FONT_INSTANCE_GTK_FONT (f), 1);
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 if (NILP (FONT_INSTANCE_GTK_TRUENAME (f)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
350 /* Ok, just this once, return the font name as the truename.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351 (This is only used by Fequal() right now.) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352 return f->name;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
353 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355 return (FONT_INSTANCE_GTK_TRUENAME (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 gtk_font_instance_properties (struct Lisp_Font_Instance *f)
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 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 /* There seems to be no way to get this information under Gtk */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 }
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 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 gtk_list_fonts (Lisp_Object pattern, Lisp_Object device)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 const char *patternext;
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 TO_EXTERNAL_FORMAT (LISP_STRING, pattern, C_STRING_ALLOCA, patternext, Qbinary);
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 return (__gtk_list_fonts_internal (patternext));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 }
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 #ifdef MULE
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 int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
381 gtk_font_spec_matches_charset (struct device *d, Lisp_Object charset,
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
382 const Ibyte *nonreloc, Lisp_Object reloc,
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 Bytecount offset, Bytecount length)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 if (UNBOUNDP (charset))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387 /* Hack! Short font names don't have the registry in them,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388 so we just assume the user knows what they're doing in the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389 case of ASCII. For other charsets, you gotta give the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 long form; sorry buster.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
391 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392 if (EQ (charset, Vcharset_ascii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
394 const Ibyte *the_nonreloc = nonreloc;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396 Bytecount the_length = length;
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 if (!the_nonreloc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 the_nonreloc = XSTRING_DATA (reloc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 the_nonreloc += offset;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 if (!memchr (the_nonreloc, '*', the_length))
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 for (i = 0;; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
406 const Ibyte *new_nonreloc = (const Ibyte *)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 memchr (the_nonreloc, '-', the_length);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 if (!new_nonreloc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 new_nonreloc++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 the_length -= new_nonreloc - the_nonreloc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 the_nonreloc = new_nonreloc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 /* If it has less than 5 dashes, it's a short font.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 Of course, long fonts always have 14 dashes or so, but short
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 fonts never have more than 1 or 2 dashes, so this is some
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 sort of reasonable heuristic. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 if (i < 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 return (fast_string_match (XCHARSET_REGISTRY (charset),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425 nonreloc, reloc, offset, length, 1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 ERROR_ME, 0) >= 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 /* find a font spec that matches font spec FONT and also matches
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430 (the registry of) CHARSET. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431 static Lisp_Object gtk_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 #endif /* MULE */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437 /* initialization */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 /************************************************************************/
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 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441 syms_of_objects_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 {
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 console_type_create_objects_gtk (void)
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 /* object methods */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 CONSOLE_HAS_METHOD (gtk, initialize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 CONSOLE_HAS_METHOD (gtk, print_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 CONSOLE_HAS_METHOD (gtk, finalize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 CONSOLE_HAS_METHOD (gtk, color_instance_equal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 CONSOLE_HAS_METHOD (gtk, color_instance_hash);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 CONSOLE_HAS_METHOD (gtk, color_instance_rgb_components);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 CONSOLE_HAS_METHOD (gtk, valid_color_name_p);
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 CONSOLE_HAS_METHOD (gtk, initialize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 CONSOLE_HAS_METHOD (gtk, mark_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 CONSOLE_HAS_METHOD (gtk, print_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 CONSOLE_HAS_METHOD (gtk, finalize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462 CONSOLE_HAS_METHOD (gtk, font_instance_truename);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 CONSOLE_HAS_METHOD (gtk, font_instance_properties);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 CONSOLE_HAS_METHOD (gtk, list_fonts);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
466 CONSOLE_HAS_METHOD (gtk, find_charset_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 CONSOLE_HAS_METHOD (gtk, font_spec_matches_charset);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 }
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 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472 vars_of_objects_gtk (void)
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 }
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 /* #### BILL!!! Try to make this go away eventually */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 /* X Specific stuff */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 #include <X11/Xatom.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 /* Unbounded, for sufficiently small values of infinity... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 #define MAX_FONT_COUNT 5000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
483 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484 /* find a font spec that matches font spec FONT and also matches
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485 (the registry of) CHARSET. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 gtk_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset)
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 char **names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
490 int count = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
492 const char *patternext;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493 int i;
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 TO_EXTERNAL_FORMAT (LISP_STRING, font, C_STRING_ALLOCA, patternext, Qbinary);
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 names = XListFonts (GDK_DISPLAY (),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
498 patternext, MAX_FONT_COUNT, &count);
788
026c5bf9c134 [xemacs-hg @ 2002-03-21 07:29:57 by ben]
ben
parents: 665
diff changeset
499 /* #### This code seems awfully bogus -- mrb */
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 for (i = 0; i < count; i ++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
502 const Ibyte *intname;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503 Bytecount intlen;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505 TO_INTERNAL_FORMAT (C_STRING, names[i], ALLOCA, (intname, intlen),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506 Qctext);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 if (gtk_font_spec_matches_charset (XDEVICE (device), charset,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
508 intname, Qnil, 0, -1))
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 result = make_string ((char *) intname, intlen);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
512 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
513 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
514
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 XFreeFontNames (names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518 /* Check for a short font name. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
519 if (NILP (result)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
520 && gtk_font_spec_matches_charset (XDEVICE (device), charset, 0,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
521 font, 0, -1))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
522 return font;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
523
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
524 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
525 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
526 #endif /* MULE */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528 /* Unbounded, for sufficiently small values of infinity... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
529 #define MAX_FONT_COUNT 5000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
530
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532 valid_font_name_p (Display *dpy, char *name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534 /* Maybe this should be implemented by callign XLoadFont and trapping
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535 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
536 might be more correct.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538 int nnames = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539 char **names = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540 if (! name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541 return 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542 names = XListFonts (dpy, name, 1, &nnames);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 XFreeFontNames (names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
545 return (nnames != 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
546 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
547
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548 Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
549 __get_gtk_font_truename (GdkFont *gdk_font, int expandp)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
550 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551 Display *dpy = GDK_FONT_XDISPLAY (gdk_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
552 GSList *names = ((GdkFontPrivate *) gdk_font)->names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
553 Lisp_Object font_name = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
554
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
555 while (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
556 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557 if (names->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
559 if (valid_font_name_p (dpy, names->data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
561 if (!expandp)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
562 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
563 /* They want the wildcarded version */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
564 font_name = build_string (names->data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
567 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
568 /* Need to expand out */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
569 int nnames = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570 char **x_font_names = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
571
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
572 x_font_names = XListFonts (dpy, names->data, 1, &nnames);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
573 if (x_font_names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575 font_name = build_string (x_font_names[0]);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576 XFreeFontNames (x_font_names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582 names = names->next;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584 return (font_name);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
587 static Lisp_Object __gtk_list_fonts_internal (const char *pattern)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
588 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 char **names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590 int count = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 names = XListFonts (GDK_DISPLAY (), pattern, MAX_FONT_COUNT, &count);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594 while (count--)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595 result = Fcons (build_ext_string (names [count], Qbinary), result);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596 if (names)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 XFreeFontNames (names);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
598
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
599 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
600 }