annotate src/objects-gtk.c @ 872:79c6ff3eef26

[xemacs-hg @ 2002-06-20 21:18:01 by ben] font changes etc.; some 21.4 changes mule/mule-msw-init-late.el: Specify charset->windows-registry conversion. mule/mule-x-init.el: Delete extra mule font additions here. Put them in faces.c. cl-macs.el: Document better. font-lock.el: Move Lisp function regexp to lisp-mode.el. lisp-mode.el: Various indentation fixes: Handle flet functions better. Handle argument lists in defuns and flets. Handle quoted lists, e.g. property lists -- don't indent like function calls. Distinguish between lambdas and other lists. lisp-mode.el: Handle this form. faces.el, font-menu.el, font.el, gtk-faces.el, msw-faces.el, msw-font-menu.el, x-faces.el, x-init.el: Major overhaul of face-handling code: -- Fix lots of bogus code in msw-faces.el, msw-font-menu.el, font-menu.el that was "truenaming" font specs -- i.e. in the process of frobbing a particular field in a general user-specified font spec with wildcarded fields, sticking in particular values for all the remaining wildcarded fields. This bug was rampant everywhere except in x-faces.el (the oldest and only correctly written code). This also means that we need to work with font names at all times and not font instances, because a font instance is essentially a truenamed font. -- Total rewrite of extremely junky code in msw-faces.el. Work with names as well as font instances, and return names; stop truenaming when canonicalizing and frobbing; fix handling of the combined style field, i.e. weight/slant (also fixed in font.el). -- Totally rewrite the frobbing functions in faces.el. This time, we frob all the instantiators rather than just computing a single instance value and working backwards. That way, e.g., `bold' will work for all charsets that have bold available, rather than only for whatever charset was part of the computed font instance (another example of the truename virus). Also fix up code to look at the fallbacks (all of them) when no global value present, so we don't need to put something in the global value. Intelligently handle a request to frob a buffer locale, rather than signalling an error. When frobbing instantiators, try hard to figure out what device type is associated with them, and frob each according to its own proper device type. Correctly handle inheritance vectors given as instantiators. Preserve existing tags when putting back frobbed instantiators. Extract out general specifier-frobbing code into specifier.el. Document everything cleanly. Do lots of other things better, etc. -- Don't duplicatively set a global specification for the default font -- it's already in the fallback and we no longer need a default global specification present. Delete various code in x-faces.el and msw-faces.el that duplicated the lists of fonts in faces.c. -- init-global-faces was not being called at all under MS Windows! Major bogosity. That caused device-specific values to get stuck into all the fonts, making it very hard to change them -- setting global specs caused nothing to happen. -- Correct weight names in font.el. -- Lots more font fixups in objects*.c. Printer.el: Warning fix. specifier.el: Add more args to map-specifier. Add various "heuristic" specifier functions to aid in creation of specifier-munging code such as in faces.el. subr.el: New functions. lwlib.c: Fix warning. config.inc.samp: Clean up, add args to control fastcall (not yet supported! the changes needed are in another ws of mine), profile support, vc6 support, union-type. xemacs.dsp, xemacs.mak: Semi-major overhaul. Fix bug where dump-id was always getting recomputed, forcing a redump even when nothing changed. Add support for fastcall. Support edit-and-continue (on by default) with vc6. Use incremental linking when doing a debug compilation. Add support for profiling. Consolidate the various debug flags. Partial support for "batch-compiling" -- compiling many files on a single invocation of the compiler. Doesn't seem to help that much for me, so it's not finished or enabled by default. Remove HAVE_MSW_C_DIRED, we always do. Correct some sloppy use of directories. s/cygwin32.h: Allow pdump to work under Cygwin (mmap is broken, so need to undefine HAVE_MMAP). s/win32-common.h, s/windowsnt.h: Support for fastcall. Add WIN32_ANY for identifying all Win32 variants (Cygwin, native, MinGW). Both of these are properly used in another ws. alloc.c, balloon-x.c, buffer.c, bytecode.c, callint.c, cm.c, cmdloop.c, cmds.c, console-gtk.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-stream.h, console-tty.c, console-tty.h, console-x.c, console-x.h, console.c, console.h, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, device.h, devslots.h, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, editfns.c, emacs.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.c, extents.c, extents.h, faces.c, fileio.c, fns.c, frame-gtk.c, frame-msw.c, frame-tty.c, frame-x.c, frame.c, frame.h, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gui-gtk.c, gui-msw.c, gui-x.c, gui.c, gutter.c, input-method-xlib.c, intl-encap-win32.c, intl-win32.c, keymap.c, lisp.h, macros.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, menubar.h, minibuf.c, mule-charset.c, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-msw.h, objects-tty.c, objects-tty.h, objects-x.c, objects-x.h, objects.c, objects.h, postgresql.c, print.c, process.h, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, select-gtk.c, select-msw.c, select-x.c, select.c, signal.c, sound.c, specifier.c, symbols.c, syntax.c, sysdep.c, syssignal.h, syswindows.h, toolbar-common.c, toolbar-gtk.c, toolbar-msw.c, toolbar-x.c, toolbar.c, unicode.c, window.c, window.h: The following are the major changes made: (1) Separation of various header files into an external and an internal version, similar to the existing separation of process.h and procimpl.h. Eventually this should be done for all Lisp objects. The external version has the same name as currently; the internal adds -impl. The external file has XFOO() macros for objects, but the structure is opaque and defined only in the internal file. It's now reasonable to move all prototypes in lisp.h into the appropriate external file, and this should be done. Currently, separation has been done on extents.h, objects*.h, console.h, device.h, frame.h, and window.h. For c/d/f/w, the most basic properties are available in the external header file, with the macros resolving to functions. In the internal header file, the macros are redefined to directly access the structure. Also, the global MARK_FOO_CHANGED macros have been made into functions so that they can be accessed without needing to include lots of -impl headers -- they are used in almost exclusively in non-time-critical functions, and take up enough time that the function overhead will be negligible. Similarly, the function overhead from making the basic properties mentioned above into functions is negligible, and code that does heavy accessing of c/d/f/w structures inevitably ends up needing the internal header files, anyway. (2) More face changes. -- Major rewrite of objects-msw.c. Now handles wildcard specs properly, rather than "truenaming" (or even worse, signalling an error, which previously happened with some of the fallbacks if you tried to use them in make-font-instance!). -- Split charset matching of fonts into two stages -- one to find a font specifically designed for a particular charset (by examining its registry), the second to find a Unicode font that can support the charset. This needs to proceed as two complete, separate instantiations in order to work properly (otherwise many of the fonts in the HELLO page look wrong). This should also make it easy to support iso10646 (Unicode) fonts under X. -- All default values for fonts are now completely specified in the fallbacks. Stuff from mule-x-init.el has all been moved here, merged with the existing specs, and totally rethought so you get sensible results. (HELLO now looks much better!). -- Generalize the "default X/GTK device" stuff into a per-device-type "default device". -- Add mswindows-{set-}charset-registry. In time, charset<->code-page conversion functions will be removed. -- Wrap protective code around calls to compute device specifier tags, and do this computation before calling the face initialization code because the latter may need these tags to be correctly updated. (3) Other changes. EmacsFrame.c, glyphs-msw.c, eval.c, gui-x.c, intl-encap-win32.c, search.c, signal.c, toolbar-msw.c, unicode.c: Warning fixes. config.h.in: #undefs meant to be frobbed by configure *MUST* go inside of #ifndef WIN32_NO_CONFIGURE, and everything else *MUST* go outside! eval.c: Let detailed backtraces be detailed. specifier.c: Don't override user's print-string-length/print-length settings. glyphs.c: New function image-instance-instantiator. config.h.in, sysdep.c: Changes for fastcall. sysdep.c, nt.c: Fix up a previous botched patch that tried to add support for both EEXIST and EACCES. IF THE BOTCHED PATCH WENT INTO 21.4, THIS FIXUP NEEDS TO GO IN, TOO. search.c: Fix *evil* crash due to incorrect synching of syntax-cache code with 21.1. THIS SHOULD GO INTO 21.4.
author ben
date Thu, 20 Jun 2002 21:19:10 +0000
parents 804517e16990
children c1a972caf831
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 /* X-specific Lisp objects.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4 Copyright (C) 1995 Tinker Systems.
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
5 Copyright (C) 1995, 1996, 2002 Ben Wing.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 Copyright (C) 1995 Sun Microsystems, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10 XEmacs is free software; you can redistribute it and/or modify it
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
11 under the terms of the GNU General Public License as published by the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
12 Free Software Foundation; either version 2, or (at your option) any
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
13 later version.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
18 for more details.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21 along with XEmacs; see the file COPYING. If not, write to
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25 /* Synched up with: Not in FSF. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 /* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28 /* Gtk version by William Perry */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 #include <config.h>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 #include "lisp.h"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
33 #include "buffer.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
34 #include "device-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
35 #include "insdel.h"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
37 #include "console-gtk-impl.h"
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
38 #include "objects-gtk-impl.h"
462
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_FONT (f) = gf;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239 f->ascent = gf->ascent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 f->descent = gf->descent;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 f->height = gf->ascent + gf->descent;
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 /* Now lets figure out the width of the font */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 unsigned int def_char = 'n'; /*xf->default_char;*/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 unsigned int byte1, byte2;
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 once_more:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250 byte1 = def_char >> 8;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 byte2 = def_char & 0xFF;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253 if (xf->per_char)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 /* Old versions of the R5 font server have garbage (>63k) as
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 def_char. 'n' might not be a valid character. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 if (byte1 < xf->min_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 byte1 > xf->max_byte1 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259 byte2 < xf->min_char_or_byte2 ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 byte2 > xf->max_char_or_byte2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 f->width = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 f->width = xf->per_char[(byte1 - xf->min_byte1) *
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 (xf->max_char_or_byte2 -
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 xf->min_char_or_byte2 + 1) +
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266 (byte2 - xf->min_char_or_byte2)].width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 f->width = xf->max_bounds.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 /* 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
272 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
273 0 width too (unlikely) then just use the max width. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 if (f->width == 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276 if (def_char == xf->default_char)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 f->width = xf->max_bounds.width;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 else
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 def_char = xf->default_char;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 goto once_more;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 }
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 /* If all characters don't exist then there could potentially be
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 0-width characters lurking out there. Not setting this flag
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 trips an optimization that would make them appear to have width
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 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
290 have the same width or if not all characters are defined.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291 */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292 /* #### This sucks. There is a measurable performance increase
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293 when using proportional width fonts if this flag is not set.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 Unfortunately so many of the fucking X fonts are not fully
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 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
296 make it an assertion. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width ||
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 (/* x_handle_non_fully_specified_fonts */ 0 &&
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 !xf->all_chars_exist));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 #if 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 f->width = gdk_char_width (gf, 'n');
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 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
303 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 gtk_print_font_instance (struct Lisp_Font_Instance *f,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 Lisp_Object printcharfun,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310 int escapeflag)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 {
800
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
312 write_fmt_string (printcharfun, " 0x%lx",
a5954632b187 [xemacs-hg @ 2002-03-31 08:27:14 by ben]
ben
parents: 788
diff changeset
313 (unsigned long) gdk_font_id (FONT_INSTANCE_GTK_FONT (f)));
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 static void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 gtk_finalize_font_instance (struct Lisp_Font_Instance *f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 if (f->data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321 if (DEVICE_LIVE_P (XDEVICE (f->device)))
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 gdk_font_unref (FONT_INSTANCE_GTK_FONT (f));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 xfree (f->data);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 f->data = 0;
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 }
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 /* Forward declarations for X specific functions at the end of the file */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331 Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 static Lisp_Object __gtk_list_fonts_internal (const char *pattern);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 static Lisp_Object
578
190b164ddcac [xemacs-hg @ 2001-05-25 11:26:50 by ben]
ben
parents: 563
diff changeset
335 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
336 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
337 if (NILP (FONT_INSTANCE_TRUENAME (f)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
339 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
340
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
341 if (NILP (FONT_INSTANCE_TRUENAME (f)))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343 /* Ok, just this once, return the font name as the truename.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 (This is only used by Fequal() right now.) */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345 return f->name;
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 }
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
348 return (FONT_INSTANCE_TRUENAME (f));
462
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352 gtk_font_instance_properties (struct Lisp_Font_Instance *f)
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 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356 /* #### BILL!!! */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 /* There seems to be no way to get this information under Gtk */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358 return result;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 }
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 static Lisp_Object
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362 gtk_list_fonts (Lisp_Object pattern, Lisp_Object device)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 const char *patternext;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 TO_EXTERNAL_FORMAT (LISP_STRING, pattern, C_STRING_ALLOCA, patternext, Qbinary);
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 return (__gtk_list_fonts_internal (patternext));
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371 #ifdef MULE
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 static int
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374 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
375 const Ibyte *nonreloc, Lisp_Object reloc,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
376 Bytecount offset, Bytecount length,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
377 int stage)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 {
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
379 if (stage)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
380 return 0;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
381
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382 if (UNBOUNDP (charset))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 /* Hack! Short font names don't have the registry in them,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 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
386 case of ASCII. For other charsets, you gotta give the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387 long form; sorry buster.
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 if (EQ (charset, Vcharset_ascii))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
391 const Ibyte *the_nonreloc = nonreloc;
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393 Bytecount the_length = length;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395 if (!the_nonreloc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396 the_nonreloc = XSTRING_DATA (reloc);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
398 the_nonreloc += offset;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 if (!memchr (the_nonreloc, '*', the_length))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 for (i = 0;; i++)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 {
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 800
diff changeset
403 const Ibyte *new_nonreloc = (const Ibyte *)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404 memchr (the_nonreloc, '-', the_length);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 if (!new_nonreloc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 break;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 new_nonreloc++;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 the_length -= new_nonreloc - the_nonreloc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 the_nonreloc = new_nonreloc;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 /* If it has less than 5 dashes, it's a short font.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 Of course, long fonts always have 14 dashes or so, but short
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 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
415 sort of reasonable heuristic. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 if (i < 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 return 1;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421 return (fast_string_match (XCHARSET_REGISTRY (charset),
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 nonreloc, reloc, offset, length, 1,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 ERROR_ME, 0) >= 0);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 /* find a font spec that matches font spec FONT and also matches
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 (the registry of) CHARSET. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 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
429
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430 #endif /* MULE */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431
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 /************************************************************************/
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434 /* initialization */
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 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 syms_of_objects_gtk (void)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443 console_type_create_objects_gtk (void)
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 /* object methods */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 CONSOLE_HAS_METHOD (gtk, initialize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 CONSOLE_HAS_METHOD (gtk, print_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 CONSOLE_HAS_METHOD (gtk, finalize_color_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 CONSOLE_HAS_METHOD (gtk, color_instance_equal);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 CONSOLE_HAS_METHOD (gtk, color_instance_hash);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 CONSOLE_HAS_METHOD (gtk, color_instance_rgb_components);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453 CONSOLE_HAS_METHOD (gtk, valid_color_name_p);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 CONSOLE_HAS_METHOD (gtk, initialize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 CONSOLE_HAS_METHOD (gtk, print_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457 CONSOLE_HAS_METHOD (gtk, finalize_font_instance);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 CONSOLE_HAS_METHOD (gtk, font_instance_truename);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 CONSOLE_HAS_METHOD (gtk, font_instance_properties);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 CONSOLE_HAS_METHOD (gtk, list_fonts);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462 CONSOLE_HAS_METHOD (gtk, find_charset_font);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 CONSOLE_HAS_METHOD (gtk, font_spec_matches_charset);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 #endif
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 }
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
466
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 void
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 vars_of_objects_gtk (void)
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
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472 /* #### BILL!!! Try to make this go away eventually */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 /* X Specific stuff */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 #include <X11/Xatom.h>
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 /* Unbounded, for sufficiently small values of infinity... */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 #define MAX_FONT_COUNT 5000
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 #ifdef MULE
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 /* find a font spec that matches font spec FONT and also matches
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 (the registry of) CHARSET. */
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482 static Lisp_Object
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
483 gtk_find_charset_font (Lisp_Object device, Lisp_Object font,
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
484 Lisp_Object charset, int stage)
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485 {
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 char **names;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 int count = 0;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
488 Lisp_Object result = Qnil;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489 const char *patternext;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
490 int i;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
492 if (stage)
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
493 return Qnil;
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
494
462
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,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
508 intname, Qnil, 0, -1, 0))
462
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,
872
79c6ff3eef26 [xemacs-hg @ 2002-06-20 21:18:01 by ben]
ben
parents: 867
diff changeset
521 font, 0, -1, 0))
462
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 }