209
|
1 ;;; objects.el --- Lisp interface to C window-system objects
|
|
2
|
|
3 ;; Copyright (C) 1994, 1997 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Ben Wing
|
|
5
|
|
6 ;; Author: Chuck Thompson <cthomp@xemacs.org>
|
298
|
7 ;; Author: Ben Wing <ben@xemacs.org>
|
209
|
8 ;; Maintainer: XEmacs Development Team
|
|
9 ;; Keywords: faces, internal, dumped
|
|
10
|
|
11 ;; This file is part of XEmacs.
|
|
12
|
|
13 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
14 ;; under the terms of the GNU General Public License as published by
|
|
15 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;; any later version.
|
|
17
|
|
18 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;; General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
272
|
24 ;; along with XEmacs; see the file COPYING. If not, write to the
|
209
|
25 ;; Free Software Foundation, 59 Temple Place - Suite 330,
|
|
26 ;; Boston, MA 02111-1307, USA.
|
|
27
|
|
28 ;;; Synched up with: Not in FSF.
|
|
29
|
|
30 ;;; Commentary:
|
|
31
|
|
32 ;; This file is dumped with XEmacs.
|
|
33
|
|
34 ;;; Code:
|
|
35
|
|
36 (defun ws-object-property-1 (function object domain &optional matchspec)
|
|
37 (let ((instance (if matchspec
|
|
38 (specifier-matching-instance object matchspec domain)
|
|
39 (specifier-instance object domain))))
|
|
40 (and instance (funcall function instance))))
|
|
41
|
|
42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; font specifiers
|
|
43
|
|
44 (defun make-font-specifier (spec-list)
|
272
|
45 "Return a new `font' specifier object with the given specification list.
|
209
|
46 SPEC-LIST can be a list of specifications (each of which is a cons of a
|
|
47 locale and a list of instantiators), a single instantiator, or a list
|
|
48 of instantiators. See `make-specifier' for more information about
|
408
|
49 specifiers.
|
|
50
|
|
51 Valid instantiators for font specifiers are:
|
|
52
|
|
53 -- a string naming a font (e.g. under X this might be
|
|
54 \"-*-courier-medium-r-*-*-*-140-*-*-*-*-iso8859-*\" for a 14-point
|
|
55 upright medium-weight Courier font)
|
|
56 -- a font instance (use that instance directly if the device matches,
|
|
57 or use the string that generated it)
|
|
58 -- a vector of no elements (only on TTY's; this means to set no font
|
|
59 at all, thus using the \"natural\" font of the terminal's text)
|
|
60 -- a vector of one element (a face to inherit from)
|
|
61 "
|
209
|
62 (make-specifier-and-init 'font spec-list))
|
|
63
|
|
64 (defun font-name (font &optional domain charset)
|
|
65 "Return the name of the FONT in the specified DOMAIN, if any.
|
|
66 FONT should be a font specifier object and DOMAIN is normally a window
|
|
67 and defaults to the selected window if omitted. This is equivalent
|
|
68 to using `specifier-instance' and applying `font-instance-name' to
|
|
69 the result. See `make-specifier' for more information about specifiers."
|
|
70 (ws-object-property-1 'font-instance-name font domain charset))
|
|
71
|
|
72 (defun font-ascent (font &optional domain charset)
|
|
73 "Return the ascent of the FONT in the specified DOMAIN, if any.
|
|
74 FONT should be a font specifier object and DOMAIN is normally a window
|
|
75 and defaults to the selected window if omitted. This is equivalent
|
|
76 to using `specifier-instance' and applying `font-instance-ascent' to
|
|
77 the result. See `make-specifier' for more information about specifiers."
|
|
78 (ws-object-property-1 'font-instance-ascent font domain charset))
|
|
79
|
|
80 (defun font-descent (font &optional domain charset)
|
|
81 "Return the descent of the FONT in the specified DOMAIN, if any.
|
|
82 FONT should be a font specifier object and DOMAIN is normally a window
|
|
83 and defaults to the selected window if omitted. This is equivalent
|
|
84 to using `specifier-instance' and applying `font-instance-descent' to
|
|
85 the result. See `make-specifier' for more information about specifiers."
|
|
86 (ws-object-property-1 'font-instance-descent font domain charset))
|
|
87
|
|
88 (defun font-width (font &optional domain charset)
|
|
89 "Return the width of the FONT in the specified DOMAIN, if any.
|
|
90 FONT should be a font specifier object and DOMAIN is normally a window
|
|
91 and defaults to the selected window if omitted. This is equivalent
|
|
92 to using `specifier-instance' and applying `font-instance-width' to
|
|
93 the result. See `make-specifier' for more information about specifiers."
|
|
94 (ws-object-property-1 'font-instance-width font domain charset))
|
|
95
|
|
96 (defun font-height (font &optional domain charset)
|
|
97 "Return the height of the FONT in the specified DOMAIN, if any.
|
|
98 FONT should be a font specifier object and DOMAIN is normally a window
|
|
99 and defaults to the selected window if omitted. This is equivalent
|
|
100 to using `specifier-instance' and applying `font-instance-height' to
|
|
101 the result. See `make-specifier' for more information about specifiers."
|
|
102 (ws-object-property-1 'font-instance-height font domain charset))
|
|
103
|
|
104 (defun font-proportional-p (font &optional domain charset)
|
|
105 "Return whether FONT is proportional in the specified DOMAIN, if known.
|
|
106 FONT should be a font specifier object and DOMAIN is normally a window
|
|
107 and defaults to the selected window if omitted. This is equivalent
|
|
108 to using `specifier-instance' and applying `font-instance-proportional-p' to
|
|
109 the result. See `make-specifier' for more information about specifiers."
|
|
110 (ws-object-property-1 'font-instance-proportional-p font domain charset))
|
|
111
|
|
112 (defun font-properties (font &optional domain charset)
|
|
113 "Return the properties of the FONT in the specified DOMAIN, if any.
|
|
114 FONT should be a font specifier object and DOMAIN is normally a window
|
|
115 and defaults to the selected window if omitted. This is equivalent
|
|
116 to using `specifier-instance' and applying `font-instance-properties'
|
|
117 to the result. See `make-specifier' for more information about specifiers."
|
|
118 (ws-object-property-1 'font-instance-properties font domain charset))
|
|
119
|
|
120 (defun font-truename (font &optional domain charset)
|
|
121 "Return the truename of the FONT in the specified DOMAIN, if any.
|
|
122 FONT should be a font specifier object and DOMAIN is normally a window
|
|
123 and defaults to the selected window if omitted. This is equivalent
|
|
124 to using `specifier-instance' and applying `font-instance-truename'
|
|
125 to the result. See `make-specifier' for more information about specifiers."
|
|
126 (ws-object-property-1 'font-instance-truename font domain charset))
|
|
127
|
|
128 (defun font-instance-height (font-instance)
|
|
129 "Return the height in pixels of FONT-INSTANCE.
|
|
130 The returned value is the maximum height for all characters in the font,\n\
|
|
131 and is equivalent to the sum of the font instance's ascent and descent."
|
|
132 (+ (font-instance-ascent font-instance)
|
|
133 (font-instance-descent font-instance)))
|
|
134
|
|
135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; color specifiers
|
|
136
|
|
137 (defun make-color-specifier (spec-list)
|
272
|
138 "Return a new `color' specifier object with the given specification list.
|
209
|
139 SPEC-LIST can be a list of specifications (each of which is a cons of a
|
|
140 locale and a list of instantiators), a single instantiator, or a list
|
|
141 of instantiators. See `make-specifier' for a detailed description of
|
408
|
142 how specifiers work.
|
|
143
|
|
144 Valid instantiators for color specifiers are:
|
|
145
|
|
146 -- a string naming a color (e.g. under X this might be \"lightseagreen2\"
|
|
147 or \"#F534B2\")
|
|
148 -- a color instance (use that instance directly if the device matches,
|
|
149 or use the string that generated it)
|
|
150 -- a vector of no elements (only on TTY's; this means to set no color
|
|
151 at all, thus using the \"natural\" color of the terminal's text)
|
|
152 -- a vector of one or two elements: a face to inherit from, and
|
|
153 optionally a symbol naming which property of that face to inherit,
|
|
154 either `foreground' or `background' (if omitted, defaults to the same
|
|
155 property that this color specifier is used for; if this specifier is
|
|
156 not part of a face, the instantiator would not be valid)."
|
209
|
157 (make-specifier-and-init 'color spec-list))
|
|
158
|
|
159 (defun color-name (color &optional domain)
|
|
160 "Return the name of the COLOR in the specified DOMAIN, if any.
|
|
161 COLOR should be a color specifier object and DOMAIN is normally a window
|
|
162 and defaults to the selected window if omitted. This is equivalent
|
|
163 to using `specifier-instance' and applying `color-instance-name' to
|
|
164 the result. See `make-specifier' for more information about specifiers."
|
|
165 (ws-object-property-1 'color-instance-name color domain))
|
|
166
|
|
167 (defun color-rgb-components (color &optional domain)
|
|
168 "Return the RGB components of the COLOR in the specified DOMAIN, if any.
|
|
169 COLOR should be a color specifier object and DOMAIN is normally a window
|
|
170 and defaults to the selected window if omitted. This is equivalent
|
|
171 to using `specifier-instance' and applying `color-instance-rgb-components'
|
|
172 to the result. See `make-specifier' for more information about specifiers."
|
|
173 (ws-object-property-1 'color-instance-rgb-components color domain))
|
|
174
|
408
|
175 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-boolean specifiers
|
|
176
|
|
177 (defun make-face-boolean-specifier (spec-list)
|
|
178 "Return a new `face-boolean' specifier object with the given spec list.
|
|
179 SPEC-LIST can be a list of specifications (each of which is a cons of a
|
|
180 locale and a list of instantiators), a single instantiator, or a list
|
|
181 of instantiators. See `make-specifier' for a detailed description of
|
|
182 how specifiers work.
|
|
183
|
|
184 Valid instantiators for face-boolean specifiers are
|
|
185
|
|
186 -- t or nil
|
|
187 -- a vector of two or three elements: a face to inherit from,
|
|
188 optionally a symbol naming the property of that face to inherit from
|
|
189 (if omitted, defaults to the same property that this face-boolean
|
|
190 specifier is used for; if this specifier is not part of a face,
|
|
191 the instantiator would not be valid), and optionally a value which,
|
|
192 if non-nil, means to invert the sense of the inherited property."
|
|
193 (make-specifier-and-init 'color spec-list))
|
|
194
|
209
|
195 ;;; objects.el ends here.
|