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