annotate src/objects.c @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children 859a2309aef8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Generic Objects and Functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "device.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "elhash.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include "faces.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include "frame.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #include "objects.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "specifier.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "window.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 /* Objects that are substituted when an instantiation fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 If we leave in the Qunbound value, we will probably get crashes. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 /* Authors: Ben Wing, Chuck Thompson */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 finalose (void *ptr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 Lisp_Object obj;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 XSETOBJ (obj, Lisp_Record, ptr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 signal_simple_error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ("Can't dump an emacs containing window system objects", obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 /****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 * Color-Instance Object *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 Lisp_Object Qcolor_instancep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 static Lisp_Object mark_color_instance (Lisp_Object, void (*) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 static void print_color_instance (Lisp_Object, Lisp_Object, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 static void finalize_color_instance (void *, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 static int color_instance_equal (Lisp_Object, Lisp_Object, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 static unsigned long color_instance_hash (Lisp_Object obj, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 DEFINE_LRECORD_IMPLEMENTATION ("color-instance", color_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 mark_color_instance, print_color_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 finalize_color_instance, color_instance_equal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 color_instance_hash,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 struct Lisp_Color_Instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 mark_color_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ((markobj) (c->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 if (!NILP (c->device)) /* Vthe_null_color_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 MAYBE_DEVMETH (XDEVICE (c->device), mark_color_instance, (c, markobj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 return (c->device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 print_color_instance (Lisp_Object obj, Lisp_Object printcharfun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 char buf[100];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 error ("printing unreadable object #<color-instance 0x%x>",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 c->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 write_c_string ("#<color-instance ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 print_internal (c->name, printcharfun, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 write_c_string (" on ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 print_internal (c->device, printcharfun, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 if (!NILP (c->device)) /* Vthe_null_color_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (c, printcharfun, escapeflag));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 sprintf (buf, " 0x%x>", c->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 finalize_color_instance (void *header, int for_disksave)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 struct Lisp_Color_Instance *c = (struct Lisp_Color_Instance *) header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 if (!NILP (c->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 if (for_disksave) finalose (c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 MAYBE_DEVMETH (XDEVICE (c->device), finalize_color_instance, (c));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 color_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 struct Lisp_Color_Instance *c1 = XCOLOR_INSTANCE (o1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 struct Lisp_Color_Instance *c2 = XCOLOR_INSTANCE (o2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 struct device *d1 = DEVICEP (c1->device) ? XDEVICE (c1->device) : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 struct device *d2 = DEVICEP (c2->device) ? XDEVICE (c2->device) : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 if (d1 != d2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 if (!d1 || !HAS_DEVMETH_P (d1, color_instance_equal))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 return EQ (o1, o2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 return DEVMETH (d1, color_instance_equal, (c1, c2, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 color_instance_hash (Lisp_Object obj, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 struct Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 struct device *d = DEVICEP (c->device) ? XDEVICE (c->device) : 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 return HASH2 ((unsigned long) d,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 !d ? LISP_HASH (obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 LISP_HASH (obj)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 DEFUN ("make-color-instance", Fmake_color_instance, Smake_color_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 1, 3, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 Creates a new `color-instance' object of the specified color.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 DEVICE specifies the device this object applies to and defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 selected device. An error is signalled if the color is unknown or cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 be allocated; however, if NOERROR is non-nil, nil is simply returned in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 this case. (And if NOERROR is other than t, a warning may be issued.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 The returned object is a normal, first-class lisp object. The way you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 `deallocate' the color is the way you deallocate any other lisp object:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 you drop all pointers to it and allow it to be garbage collected. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 these objects are GCed, the underlying window-system data (e.g. X object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 is deallocated as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (name, device, no_error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 Lisp_Object name, device, no_error;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 struct Lisp_Color_Instance *c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 int retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 CHECK_STRING (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 XSETDEVICE (device, decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 c = alloc_lcrecord (sizeof (struct Lisp_Color_Instance),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 lrecord_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 c->name = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 c->device = device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 c->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (c, name, device,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 decode_error_behavior_flag (no_error)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 if (!retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 XSETCOLOR_INSTANCE (val, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 DEFUN ("color-instance-p", Fcolor_instance_p, Scolor_instance_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 Return non-nil if OBJECT is a color instance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 return (COLOR_INSTANCEP (object) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 DEFUN ("color-instance-name", Fcolor_instance_name, Scolor_instance_name,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 Return the name used to allocate COLOR-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (color_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 Lisp_Object color_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 CHECK_COLOR_INSTANCE (color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 return (XCOLOR_INSTANCE (color_instance)->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 DEFUN ("color-instance-rgb-components", Fcolor_instance_rgb_components,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 Scolor_instance_rgb_components, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 Return a three element list containing the red, green, and blue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 color components of COLOR-INSTANCE, or nil if unknown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (color_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 Lisp_Object color_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 struct Lisp_Color_Instance *c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 CHECK_COLOR_INSTANCE (color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 c = XCOLOR_INSTANCE (color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 if (NILP (c->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 return MAYBE_LISP_DEVMETH (XDEVICE (c->device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 color_instance_rgb_components,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (c));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 DEFUN ("valid-color-name-p", Fvalid_color_name_p, Svalid_color_name_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 1, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 Return true if COLOR names a valid color for the current device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 Valid color names for X are listed in the file /usr/lib/X11/rgb.txt, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 whatever the equivalent is on your system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 Valid color names for TTY are those which have an ISO 6429 (ANSI) sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 In addition to being a color this may be one of a number of attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 such as `blink'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (color, device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 Lisp_Object color, device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 struct device *d = decode_device (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 CHECK_STRING (color);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 return MAYBE_INT_DEVMETH (d, valid_color_name_p, (d, color)) ? Qt : Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 /***************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 * Font-Instance Object *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ***************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 Lisp_Object Qfont_instancep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 static Lisp_Object mark_font_instance (Lisp_Object, void (*) (Lisp_Object));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 static void print_font_instance (Lisp_Object, Lisp_Object, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 static void finalize_font_instance (void *, int);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 static int font_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 static unsigned long font_instance_hash (Lisp_Object obj, int depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 DEFINE_LRECORD_IMPLEMENTATION ("font-instance", font_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 mark_font_instance, print_font_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 finalize_font_instance, font_instance_equal,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 font_instance_hash, struct Lisp_Font_Instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 static Lisp_Object font_instance_truename_internal (Lisp_Object xfont,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 Error_behavior errb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 mark_font_instance (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 struct Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ((markobj) (f->name));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 if (!NILP (f->device)) /* Vthe_null_font_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 MAYBE_DEVMETH (XDEVICE (f->device), mark_font_instance, (f, markobj));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 return f->device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 print_font_instance (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 char buf[200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 struct Lisp_Font_Instance *f = XFONT_INSTANCE (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 if (print_readably)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 error ("printing unreadable object #<font-instance 0x%x>", f->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 write_c_string ("#<font-instance ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 print_internal (f->name, printcharfun, 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 write_c_string (" on ", printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 print_internal (f->device, printcharfun, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 MAYBE_DEVMETH (XDEVICE (f->device), print_font_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (f, printcharfun, escapeflag));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 sprintf (buf, " 0x%x>", f->header.uid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 write_c_string (buf, printcharfun);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 finalize_font_instance (void *header, int for_disksave)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 struct Lisp_Font_Instance *f = (struct Lisp_Font_Instance *) header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 if (!NILP (f->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 if (for_disksave) finalose (f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 MAYBE_DEVMETH (XDEVICE (f->device), finalize_font_instance, (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 /* Fonts are equal if they resolve to the same name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 Since we call `font-truename' to do this, and since font-truename is lazy,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 this means the `equal' could cause XListFonts to be run the first time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 font_instance_equal (Lisp_Object o1, Lisp_Object o2, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 /* #### should this be moved into a device method? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 return (internal_equal (font_instance_truename_internal (o1, ERROR_ME_NOT),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 font_instance_truename_internal (o2, ERROR_ME_NOT),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 depth + 1));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 static unsigned long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 font_instance_hash (Lisp_Object obj, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 return internal_hash (font_instance_truename_internal (obj, ERROR_ME_NOT),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 depth + 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 DEFUN ("make-font-instance", Fmake_font_instance, Smake_font_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 1, 3, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 Creates a new `font-instance' object of the specified name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 DEVICE specifies the device this object applies to and defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 selected device. An error is signalled if the font is unknown or cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 be allocated; however, if NOERROR is non-nil, nil is simply returned in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 this case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 The returned object is a normal, first-class lisp object. The way you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 `deallocate' the font is the way you deallocate any other lisp object:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 you drop all pointers to it and allow it to be garbage collected. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 these objects are GCed, the underlying X data is deallocated as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (name, device, no_error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 Lisp_Object name, device, no_error;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 struct Lisp_Font_Instance *f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 Lisp_Object val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 int retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 Error_behavior errb = decode_error_behavior_flag (no_error);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 if (ERRB_EQ (errb, ERROR_ME))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 CHECK_STRING (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 else if (!STRINGP (name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 XSETDEVICE (device, decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 f = alloc_lcrecord (sizeof (struct Lisp_Font_Instance),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 lrecord_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 f->name = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 f->device = device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 f->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 /* Stick some default values here ... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 f->ascent = f->height = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 f->descent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 f->width = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 f->proportional_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_font_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (f, name, device, errb));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 if (!retval)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 XSETFONT_INSTANCE (val, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 return val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 DEFUN ("font-instance-p", Ffont_instance_p, Sfont_instance_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 Return non-nil if OBJECT is a font instance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 return (FONT_INSTANCEP (object) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 DEFUN ("font-instance-name", Ffont_instance_name, Sfont_instance_name, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 Return the name used to allocate FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (font_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 Lisp_Object font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 return (XFONT_INSTANCE (font_instance)->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 DEFUN ("font-instance-ascent", Ffont_instance_ascent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 Sfont_instance_ascent, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 Return the ascent in pixels of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 The returned value is the maximum ascent for all characters in the font,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 where a character's ascent is the number of pixels above (and including)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 the baseline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (font_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 Lisp_Object font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 return make_int (XFONT_INSTANCE (font_instance)->ascent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 DEFUN ("font-instance-descent", Ffont_instance_descent,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 Sfont_instance_descent, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 Return the descent in pixels of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 The returned value is the maximum descent for all characters in the font,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 where a character's descent is the number of pixels below the baseline.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (Many characters to do not have any descent. Typical characters with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 descent are lowercase p and lowercase g.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (font_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 Lisp_Object font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 return make_int (XFONT_INSTANCE (font_instance)->descent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 DEFUN ("font-instance-width", Ffont_instance_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 Sfont_instance_width, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 Return the width in pixels of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 The returned value is the average width for all characters in the font.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (font_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 Lisp_Object font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 return make_int (XFONT_INSTANCE (font_instance)->width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 DEFUN ("font-instance-proportional-p", Ffont_instance_proportional_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 Sfont_instance_proportional_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 Return whether FONT-INSTANCE is proportional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 This means that different characters in the font have different widths.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (font_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 Lisp_Object font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 return (XFONT_INSTANCE (font_instance)->proportional_p ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 font_instance_truename_internal (Lisp_Object font_instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 Error_behavior errb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 struct Lisp_Font_Instance *f = XFONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 return DEVMETH_OR_GIVEN (XDEVICE (f->device), font_instance_truename,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (f, errb), f->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 DEFUN ("font-instance-truename", Ffont_instance_truename,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 Sfont_instance_truename, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 Return the canonical name of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 Font names are patterns which may match any number of fonts, of which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 the first found is used. This returns an unambiguous name for that font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (but not necessarily its only unambiguous name).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (font_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 Lisp_Object font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 return font_instance_truename_internal (font_instance, ERROR_ME);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 DEFUN ("font-instance-properties", Ffont_instance_properties,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 Sfont_instance_properties, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 Return the properties (an alist or nil) of FONT-INSTANCE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (font_instance)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 Lisp_Object font_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 struct Lisp_Font_Instance *f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 CHECK_FONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 f = XFONT_INSTANCE (font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 return MAYBE_LISP_DEVMETH (XDEVICE (f->device),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 font_instance_properties, (f));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 DEFUN ("list-fonts", Flist_fonts, Slist_fonts, 1, 2, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 Return a list of font names matching the given pattern.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 DEVICE specifies which device to search for names, and defaults to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 currently selected device.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (pattern, device)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 Lisp_Object pattern, device;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 CHECK_STRING (pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 XSETDEVICE (device, decode_device (device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 return MAYBE_LISP_DEVMETH (XDEVICE (device), list_fonts, (pattern, device));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 /****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 Color Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ***************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 DEFINE_SPECIFIER_TYPE (color);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 /* Qcolor defined in general.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 color_create (Lisp_Object obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 COLOR_SPECIFIER_FACE (color) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 COLOR_SPECIFIER_FACE_PROPERTY (color) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 color_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ((markobj) (COLOR_SPECIFIER_FACE (color)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ((markobj) (COLOR_SPECIFIER_FACE_PROPERTY (color)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 /* No equal or hash methods; ignore the face the color is based off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 of for `equal' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 color_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 Lisp_Object domain, Lisp_Object instantiator,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 Lisp_Object depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 /* When called, we're inside of call_with_suspended_errors(),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 so we can freely error. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 Lisp_Object device = DFW_DEVICE (domain);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 struct device *d = XDEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 Lisp_Object instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 if (COLOR_INSTANCEP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 /* If we are on the same device then we're done. Otherwise change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 the instantiator to the name used to generate the pixel and let the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 STRINGP case deal with it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 if (NILP (device) /* Vthe_null_color_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 || EQ (device, XCOLOR_INSTANCE (instantiator)->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 return instantiator;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 instantiator = Fcolor_instance_name (instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 if (STRINGP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 /* First, look to see if we can retrieve a cached value. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 instance = Fgethash (instantiator, d->color_instance_cache, Qunbound);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 /* Otherwise, make a new one. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 if (UNBOUNDP (instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 /* make sure we cache the failures, too. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 instance = Fmake_color_instance (instantiator, device, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 Fputhash (instantiator, instance, d->color_instance_cache);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 return (NILP (instance) ? Qunbound : instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 else if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 switch (XVECTOR (instantiator)->size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 if (DEVICE_TTY_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 return Vthe_null_color_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 signal_simple_error ("Color instantiator [] only valid on TTY's",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 case 1:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 signal_simple_error ("Color specifier not attached to a face",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 return (FACE_PROPERTY_INSTANCE_1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (Fget_face (vector_data (XVECTOR (instantiator))[0]),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 COLOR_SPECIFIER_FACE_PROPERTY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (XCOLOR_SPECIFIER (specifier)), domain,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ERROR_ME, 0, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 case 2:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 return (FACE_PROPERTY_INSTANCE_1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (Fget_face (vector_data (XVECTOR (instantiator))[0]),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 vector_data (XVECTOR (instantiator))[1], domain,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ERROR_ME, 0, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 else if (NILP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 if (DEVICE_TTY_P (d))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 return Vthe_null_color_instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 signal_simple_error ("Color instantiator [] only valid on TTY's",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 abort (); /* The spec validation routines are screwed up. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 color_validate (Lisp_Object instantiator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 if (COLOR_INSTANCEP (instantiator) || STRINGP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 if (XVECTOR (instantiator)->size > 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 signal_simple_error ("Inheritance vector must be of size 0 - 2",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 else if (XVECTOR (instantiator)->size > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 Lisp_Object face = vector_data (XVECTOR (instantiator))[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 Fget_face (face);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 if (XVECTOR (instantiator)->size == 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 Lisp_Object field = vector_data (XVECTOR (instantiator))[1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 if (!EQ (field, Qforeground) && !EQ (field, Qbackground))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 signal_simple_error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ("Inheritance field must be `foreground' or `background'",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 field);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 signal_simple_error ("Invalid color instantiator", instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 color_after_change (Lisp_Object specifier, Lisp_Object locale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 Lisp_Object face = COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 Lisp_Object property =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 if (!NILP (face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 face_property_was_changed (face, property, locale);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 set_color_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 struct Lisp_Specifier *color = XCOLOR_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 COLOR_SPECIFIER_FACE (color) = face;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 COLOR_SPECIFIER_FACE_PROPERTY (color) = property;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 DEFUN ("color-specifier-p", Fcolor_specifier_p, Scolor_specifier_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 Return non-nil if OBJECT is a color specifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 Valid instantiators for color specifiers are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 -- a string naming a color (e.g. under X this might be \"lightseagreen2\"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 or \"#F534B2\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 -- a color instance (use that instance directly if the device matches,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 or use the string that generated it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 -- a vector of no elements (only on TTY's; this means to set no color
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 at all, thus using the \"natural\" color of the terminal's text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 -- a vector of one or two elements: a face to inherit from, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 optionally a symbol naming which property of that face to inherit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 either `foreground' or `background' (if omitted, defaults to the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 property that this color specifier is used for; if this specifier is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 not part of a face, the instantiator would not be valid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 return (COLOR_SPECIFIERP (object) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 /****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 Font Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ***************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 DEFINE_SPECIFIER_TYPE (font);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 /* Qfont defined in general.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 font_create (Lisp_Object obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 FONT_SPECIFIER_FACE (font) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 FONT_SPECIFIER_FACE_PROPERTY (font) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 font_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ((markobj) (FONT_SPECIFIER_FACE (font)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ((markobj) (FONT_SPECIFIER_FACE_PROPERTY (font)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 /* No equal or hash methods; ignore the face the font is based off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 of for `equal' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 font_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 Lisp_Object domain, Lisp_Object instantiator,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 Lisp_Object depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 /* When called, we're inside of call_with_suspended_errors(),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 so we can freely error. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 Lisp_Object device = DFW_DEVICE (domain);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 struct device *d = XDEVICE (device);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 Lisp_Object instance;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 if (FONT_INSTANCEP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 if (NILP (device) /* Vthe_null_color_instance */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 || EQ (device, XFONT_INSTANCE (instantiator)->device))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 return instantiator;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 instantiator = Ffont_instance_name (instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 }
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
726
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
727 if (STRINGP (instantiator))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 /* First, look to see if we can retrieve a cached value. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 instance = Fgethash (instantiator, d->font_instance_cache, Qunbound);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 /* Otherwise, make a new one. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 if (UNBOUNDP (instance))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 /* make sure we cache the failures, too. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 instance = Fmake_font_instance (instantiator, device, Qt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 Fputhash (instantiator, instance, d->font_instance_cache);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 return (NILP (instance) ? Qunbound : instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 else if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 assert (XVECTOR (instantiator)->size == 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 return (face_property_matching_instance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (Fget_face (vector_data (XVECTOR (instantiator))[0]), Qfont,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 matchspec, domain, ERROR_ME, 0, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 else if (NILP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 abort (); /* Eh? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 font_validate (Lisp_Object instantiator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 if (FONT_INSTANCEP (instantiator) || STRINGP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 if (vector_length (XVECTOR (instantiator)) != 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 signal_simple_error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 ("Vector length must be one for font inheritance", instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 Fget_face (vector_data (XVECTOR (instantiator))[0]);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 signal_simple_error ("Must be string, vector, or font-instance",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 font_after_change (Lisp_Object specifier, Lisp_Object locale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 Lisp_Object face = FONT_SPECIFIER_FACE (XFONT_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 Lisp_Object property =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 FONT_SPECIFIER_FACE_PROPERTY (XFONT_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 if (!NILP (face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 face_property_was_changed (face, property, locale);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 set_font_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 struct Lisp_Specifier *font = XFONT_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 FONT_SPECIFIER_FACE (font) = face;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 FONT_SPECIFIER_FACE_PROPERTY (font) = property;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 DEFUN ("font-specifier-p", Ffont_specifier_p, Sfont_specifier_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 Return non-nil if OBJECT is a font specifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 Valid instantiators for font specifiers are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 -- a string naming a font (e.g. under X this might be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 \"-*-courier-medium-r-*-*-*-140-*-*-*-*-iso8859-*\" for a 14-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 upright medium-weight Courier font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 -- a font instance (use that instance directly if the device matches,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 or use the string that generated it)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 -- a vector of no elements (only on TTY's; this means to set no font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 at all, thus using the \"natural\" font of the terminal's text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 -- a vector of one element (a face to inherit from)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 return (FONT_SPECIFIERP (object) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 /*****************************************************************************
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 Face Boolean Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ****************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 DEFINE_SPECIFIER_TYPE (face_boolean);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 Lisp_Object Qface_boolean;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 face_boolean_create (Lisp_Object obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 face_boolean_mark (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 ((markobj) (FACE_BOOLEAN_SPECIFIER_FACE (face_boolean)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 ((markobj) (FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean)));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 /* No equal or hash methods; ignore the face the face-boolean is based off
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 of for `equal' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 face_boolean_instantiate (Lisp_Object specifier, Lisp_Object matchspec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 Lisp_Object domain, Lisp_Object instantiator,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 Lisp_Object depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 /* When called, we're inside of call_with_suspended_errors(),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 so we can freely error. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 if (NILP (instantiator) || EQ (instantiator, Qt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 return instantiator;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 else if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 Lisp_Object retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 Lisp_Object prop;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 assert (XVECTOR (instantiator)->size >= 1 &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 XVECTOR (instantiator)->size <= 3);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 if (XVECTOR (instantiator)->size > 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 prop = vector_data (XVECTOR (instantiator))[1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 if (NILP (FACE_BOOLEAN_SPECIFIER_FACE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (XFACE_BOOLEAN_SPECIFIER (specifier))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 signal_simple_error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 ("Face-boolean specifier not attached to a face", instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 prop = FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (XFACE_BOOLEAN_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 retval = (FACE_PROPERTY_INSTANCE_1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (Fget_face (vector_data (XVECTOR (instantiator))[0]),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 prop, domain, ERROR_ME, 0, depth));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 if (XVECTOR (instantiator)->size == 3 &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 !NILP (vector_data (XVECTOR (instantiator))[2]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 retval = (NILP (retval) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 return retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 abort (); /* Eh? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 return Qunbound;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 face_boolean_validate (Lisp_Object instantiator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 if (NILP (instantiator) || EQ (instantiator, Qt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 else if (VECTORP (instantiator) &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (XVECTOR (instantiator)->size >= 1 &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 XVECTOR (instantiator)->size <= 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 Lisp_Object face = vector_data (XVECTOR (instantiator))[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 Fget_face (face);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 if (XVECTOR (instantiator)->size > 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 Lisp_Object field = vector_data (XVECTOR (instantiator))[1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 if (!EQ (field, Qunderline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 && !EQ (field, Qstrikethru)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 && !EQ (field, Qhighlight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 && !EQ (field, Qdim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 && !EQ (field, Qblinking)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 && !EQ (field, Qreverse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 signal_simple_error ("Invalid face-boolean inheritance field",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 field);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 else if (VECTORP (instantiator))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 signal_simple_error ("Wrong length for face-boolean inheritance spec",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 signal_simple_error ("Face-boolean instantiator must be nil, t, or vector",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 instantiator);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 face_boolean_after_change (Lisp_Object specifier, Lisp_Object locale)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 Lisp_Object face =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 FACE_BOOLEAN_SPECIFIER_FACE (XFACE_BOOLEAN_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 Lisp_Object property =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (XFACE_BOOLEAN_SPECIFIER (specifier));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 if (!NILP (face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 face_property_was_changed (face, property, locale);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 Lisp_Object property)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 struct Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = face;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = property;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 DEFUN ("face-boolean-specifier-p", Fface_boolean_specifier_p,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 Sface_boolean_specifier_p, 1, 1, 0 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 Return non-nil if OBJECT is a face-boolean specifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 Valid instantiators for face-boolean specifiers are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 -- t or nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 -- a vector of two or three elements: a face to inherit from,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 optionally a symbol naming the property of that face to inherit from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (if omitted, defaults to the same property that this face-boolean
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 specifier is used for; if this specifier is not part of a face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 the instantiator would not be valid), and optionally a value which,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 if non-nil, means to invert the sense of the inherited property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 */ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 Lisp_Object object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 return (FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 /* initialization */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 /************************************************************************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 syms_of_objects (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 defsubr (&Scolor_specifier_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 defsubr (&Sfont_specifier_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 defsubr (&Sface_boolean_specifier_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 defsymbol (&Qcolor_instancep, "color-instance-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 defsubr (&Smake_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 defsubr (&Scolor_instance_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 defsubr (&Scolor_instance_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 defsubr (&Scolor_instance_rgb_components);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 defsubr (&Svalid_color_name_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 defsymbol (&Qfont_instancep, "font-instance-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 defsubr (&Smake_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 defsubr (&Sfont_instance_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 defsubr (&Sfont_instance_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 defsubr (&Sfont_instance_ascent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 defsubr (&Sfont_instance_descent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 defsubr (&Sfont_instance_width);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 defsubr (&Sfont_instance_proportional_p);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 defsubr (&Sfont_instance_truename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 defsubr (&Sfont_instance_properties);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 defsubr (&Slist_fonts);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 /* Qcolor, Qfont defined in general.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 defsymbol (&Qface_boolean, "face-boolean");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 specifier_type_create_objects (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 "face-boolean-specifier-p");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 SPECIFIER_HAS_METHOD (color, instantiate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 SPECIFIER_HAS_METHOD (font, instantiate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 SPECIFIER_HAS_METHOD (face_boolean, instantiate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 SPECIFIER_HAS_METHOD (color, validate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 SPECIFIER_HAS_METHOD (font, validate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 SPECIFIER_HAS_METHOD (face_boolean, validate);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 SPECIFIER_HAS_METHOD (color, create);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 SPECIFIER_HAS_METHOD (font, create);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 SPECIFIER_HAS_METHOD (face_boolean, create);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 SPECIFIER_HAS_METHOD (color, mark);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 SPECIFIER_HAS_METHOD (font, mark);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 SPECIFIER_HAS_METHOD (face_boolean, mark);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 SPECIFIER_HAS_METHOD (color, after_change);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 SPECIFIER_HAS_METHOD (font, after_change);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 SPECIFIER_HAS_METHOD (face_boolean, after_change);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 vars_of_objects (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 staticpro (&Vthe_null_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 struct Lisp_Color_Instance *c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 c = alloc_lcrecord (sizeof (struct Lisp_Color_Instance),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 lrecord_color_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 c->name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 c->device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 c->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 XSETCOLOR_INSTANCE (Vthe_null_color_instance, c);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 staticpro (&Vthe_null_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 struct Lisp_Font_Instance *f;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 f = alloc_lcrecord (sizeof (struct Lisp_Font_Instance),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 lrecord_font_instance);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 f->name = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 f->device = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 f->data = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 f->ascent = f->height = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 f->descent = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 f->width = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 f->proportional_p = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 XSETFONT_INSTANCE (Vthe_null_font_instance, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 }