comparison lisp/glyphs.el @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 3ecd8885ac67
children 1ccc32a20af4
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
1 ;;; glyphs.el --- Lisp interface to C glyphs 1 ;;; glyphs.el --- Lisp interface to C glyphs
2 2
3 ;; Copyright (C) 1994, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1994, 1997 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995, 1996 Ben Wing. 4 ;; Copyright (C) 1995, 1996, 2000 Ben Wing.
5 5
6 ;; Author: Chuck Thompson <cthomp@cs.uiuc.edu>, Ben Wing <ben@xemacs.org> 6 ;; Author: Chuck Thompson <cthomp@cs.uiuc.edu>, Ben Wing <ben@xemacs.org>
7 ;; Maintainer: XEmacs Development Team 7 ;; Maintainer: XEmacs Development Team
8 ;; Keywords: extensions, internal, dumped 8 ;; Keywords: extensions, internal, dumped
9 9
24 ;; Free Software Foundation, 59 Temple Place - Suite 330, 24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA. 25 ;; Boston, MA 02111-1307, USA.
26 26
27 ;;; Synched up with: Not in FSF. 27 ;;; Synched up with: Not in FSF.
28 28
29 ;;; Authorship:
30
31 ;; Prototype created 1995 by Chuck Thompson.
32 ;; Completely rewritten by Ben Wing, 1995.
33 ;; Various cleanups (esp. doc strings) by Ben Wing, May 2000.
34
29 ;;; Commentary: 35 ;;; Commentary:
30 36
31 ;; This file is dumped with XEmacs. 37 ;; This file is dumped with XEmacs.
32 38
33 ;;; Code: 39 ;;; Code:
34 40
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; font specifiers 41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; image specifiers
36 42
37 (defun make-image-specifier (spec-list) 43 (defun make-image-specifier (spec-list)
38 "Return a new `image' specifier object with the specification list SPEC-LIST. 44 "Return a new `image' specifier object with the specification list SPEC-LIST.
39 SPEC-LIST can be a list of specifications (each of which is a cons of a 45 SPEC-LIST can be a list of specifications (each of which is a cons of a
40 locale and a list of instantiators), a single instantiator, or a list 46 locale and a list of instantiators), a single instantiator, or a list
41 of instantiators. See `make-specifier' for more information about 47 of instantiators. See `make-specifier' for more information about
42 specifiers." 48 specifiers.
49
50 An image specifier is used for images (pixmaps, widgets and the like).
51 It is used to describe the actual image in a glyph. It is instanced
52 as an image-instance. Note that \"image\" as used in XEmacs does not
53 actually refer to what the term \"image\" normally means (a picture,
54 e.g. in .GIF or .JPG format, and called a \"pixmap\" in XEmacs), but
55 includes all types of graphical elements, including pixmaps, widgets
56 \(buttons, sliders, text fields, etc.) and even strings of text.
57
58 Note that, in practice, you rarely, if ever, need to actually create
59 an image specifier! (The function `make-image-specifier' exists mainly
60 for completeness.) Pretty much the only use for image specifiers is to
61 control how glyphs are displayed, and the image specifier associated
62 with a glyph (the `image' property of a glyph) is created
63 automatically when a glyph is created (see `make-glyph') and need not
64 \(and cannot, for that matter) ever be changed. In fact, the design
65 decision to create a separate image specifier type, rather than make
66 glyphs themselves be specifiers, is debatable -- the other properties
67 of glyphs are rarely used and could conceivably have been incorporated
68 into the glyph's instantiator. The rarely used glyph types (buffer,
69 pointer, icon) could also have been incorporated into the instantiator.
70
71 Image instantiators come in many formats: `xbm', `xpm', `gif', `jpeg',
72 etc. This describes the format of the data describing the image. The
73 resulting image instances also come in many types -- `mono-pixmap',
74 `color-pixmap', `text', `pointer', etc. This refers to the behavior of
75 the image and the sorts of places it can appear. (For example, a
76 color-pixmap image has fixed colors specified for it, while a
77 mono-pixmap image comes in two unspecified shades \"foreground\" and
78 \"background\" that are determined from the face of the glyph or
79 surrounding text; a text image appears as a string of text and has an
80 unspecified foreground, background, and font; a pointer image behaves
81 like a mono-pixmap image but can only be used as a mouse pointer
82 \[mono-pixmap images cannot be used as mouse pointers]; etc.) It is
83 important to keep the distinction between image instantiator format and
84 image instance type in mind. Typically, a given image instantiator
85 format can result in many different image instance types (for example,
86 `xpm' can be instanced as `color-pixmap', `mono-pixmap', or `pointer';
87 whereas `cursor-font' can be instanced only as `pointer'), and a
88 particular image instance type can be generated by many different
89 image instantiator formats (e.g. `color-pixmap' can be generated by `xpm',
90 `gif', `jpeg', etc.).
91
92 See `make-image-instance' for a more detailed discussion of image
93 instance types.
94
95 An image instantiator should be a string or a vector of the form
96
97 [FORMAT :KEYWORD VALUE ...]
98
99 i.e. a format symbol followed by zero or more alternating keyword-value
100 pairs. FORMAT should be one of
101
102 'nothing
103 Don't display anything; no keywords are valid for this.
104 Can only be instanced as `nothing'.
105 'string
106 Display this image as a text string. Can only be instanced
107 as `text', although support for instancing as `mono-pixmap'
108 and `color-pixmap' should be added.
109 'formatted-string
110 Display this image as a text string, with replaceable fields;
111 not currently implemented. (It is, instead, equivalent to `string'.)
112 'xbm
113 An X bitmap; only if X or MS Windows support was compiled into this
114 XEmacs. Can be instanced as `mono-pixmap', `color-pixmap', or `pointer'.
115 'xpm
116 An XPM pixmap; only if XPM support was compiled into this XEmacs.
117 Can be instanced as `color-pixmap', `mono-pixmap', or `pointer'.
118 'xface
119 An X-Face bitmap, used to encode people's faces in e-mail messages;
120 only if X-Face support was compiled into this XEmacs. Can be
121 instanced as `mono-pixmap', `color-pixmap', or `pointer'.
122 'gif
123 A GIF87 or GIF89 image; only if GIF support was compiled into this
124 XEmacs. NOTE: only the first frame of animated gifs will be displayed.
125 Can be instanced as `color-pixmap'.
126 'jpeg
127 A JPEG image; only if JPEG support was compiled into this XEmacs.
128 Can be instanced as `color-pixmap'.
129 'png
130 A PNG image; only if PNG support was compiled into this XEmacs.
131 Can be instanced as `color-pixmap'.
132 'tiff
133 A TIFF image; only if TIFF support was compiled into this XEmacs.
134 Can be instanced as `color-pixmap'.
135 'bmp
136 A MS Windows BMP image; only if MS Windows support was compiled into
137 this XEmacs. Can be instanced as `color-pixmap'.
138 'cursor-font
139 One of the standard cursor-font names, such as \"watch\" or
140 \"right_ptr\" under X. Under X, this is, more specifically, any
141 of the standard cursor names from appendix B of the Xlib manual
142 [also known as the file <X11/cursorfont.h>] minus the XC_ prefix.
143 On other window systems, the valid names will be specific to the
144 type of window system. Can only be instanced as `pointer'.
145 'mswindows-resource
146 An MS Windows pointer resource. Specifies a resource to retrieve
147 directly from the system (an OEM resource) or from a file, particularly
148 an executable file. If the resource is to be retrieved from a file, use
149 :file and optionally :resource-id. Otherwise use :resource-id. Always
150 specify :resource-type to specify the type (cursor, bitmap or icon) of
151 the resource. Possible values for :resource-id are listed below. Can
152 be instanced as `pointer' or `color-pixmap'.
153 'font
154 A glyph from a font; i.e. the name of a font, and glyph index into it
155 of the form \"FONT fontname index [[mask-font] mask-index]\".
156 Currently can only be instanced as `pointer', although this should
157 probably be fixed.
158 'subwindow
159 An embedded windowing system window. Can only be instanced as
160 `subwindow'.
161 'button
162 A button widget; either a push button, radio button or toggle button.
163 Can only be instanced as `widget'.
164 'combo-box
165 A drop list of selectable items in a widget, for editing text.
166 Can only be instanced as `widget'.
167 'edit-field
168 A text editing widget. Can only be instanced as `widget'.
169 'label
170 A static, text-only, widget; for displaying text. Can only be instanced
171 as `widget'.
172 'layout
173 A widget for controlling the positioning of children underneath it.
174 Through the use of nested layouts, a widget hierarchy can be created
175 which can have the appearance of any standard dialog box or similar
176 arrangement; all of this is counted as one \"glyph\" and could appear
177 in many of the places that expect a single glyph. Can only be instanced
178 as `widget'.
179 'native-layout
180 The native version of a layout widget. #### Document me better!
181 Can only be instanced as `widget'.
182 'progress-gauge
183 A sliding widget, for showing progress. Can only be instanced as
184 `widget'.
185 'tab-control
186 A tab widget; a series of user selectable tabs. Can only be instanced
187 as `widget'.
188 'tree-view
189 A folding widget. Can only be instanced as `widget'.
190 'scrollbar
191 A scrollbar widget. Can only be instanced as `widget'.
192 'autodetect
193 XEmacs tries to guess what format the data is in. If X support
194 exists, the data string will be checked to see if it names a filename.
195 If so, and this filename contains XBM or XPM data, the appropriate
196 sort of pixmap or pointer will be created. [This includes picking up
197 any specified hotspot or associated mask file.] Otherwise, if `pointer'
198 is one of the allowable image-instance types and the string names a
199 valid cursor-font name, the image will be created as a pointer.
200 Otherwise, the image will be displayed as text. If no X support
201 exists, the image will always be displayed as text. Can be instanced as
202 `mono-pixmap', `color-pixmap', `pointer', or `text'.
203 'inherit
204 Inherit from the background-pixmap property of a face. Can only be
205 instanced as `mono-pixmap'.
206
207 The valid keywords are:
208
209 :data
210 Inline data. For most formats above, this should be a string. For
211 XBM images, this should be a list of three elements: width, height, and
212 a string of bit data. This keyword is valid for all of the bitmap/pixmap
213 formats, as well as `string', `formatted-string', `font', `cursor-font',
214 and `autodetect'.
215 :file
216 Data is contained in a file. The value is the name of this file.
217 If both :data and :file are specified, the image is created from
218 what is specified in :data and the string in :file becomes the
219 value of the `image-instance-file-name' function when applied to
220 the resulting image-instance. This keyword is valid for all of the
221 bitmap/pixmap formats as well as `mswindows-resource'.
222 :foreground
223 :background
224 For `xbm', `xface', `cursor-font', `widget' and `font'. These keywords
225 allow you to explicitly specify foreground and background colors.
226 The argument should be anything acceptable to `make-color-instance'.
227 This will cause what would be a `mono-pixmap' to instead be colorized
228 as a two-color color-pixmap, and specifies the foreground and/or
229 background colors for a pointer instead of black and white.
230 :mask-data
231 For `xbm' and `xface'. This specifies a mask to be used with the
232 bitmap. The format is a list of width, height, and bits, like for
233 :data.
234 :mask-file
235 For `xbm' and `xface'. This specifies a file containing the mask data.
236 If neither a mask file nor inline mask data is given for an XBM image,
237 and the XBM image comes from a file, XEmacs will look for a mask file
238 with the same name as the image file but with \"Mask\" or \"msk\"
239 appended. For example, if you specify the XBM file \"left_ptr\"
240 [usually located in \"/usr/include/X11/bitmaps\"], the associated
241 mask file \"left_ptrmsk\" will automatically be picked up.
242 :hotspot-x
243 :hotspot-y
244 For `xbm' and `xface'. These keywords specify a hotspot if the image
245 is instantiated as a `pointer'. Note that if the XBM image file
246 specifies a hotspot, it will automatically be picked up if no
247 explicit hotspot is given.
248 :color-symbols
249 Only for `xpm'. This specifies an alist that maps strings
250 that specify symbolic color names to the actual color to be used
251 for that symbolic color (in the form of a string or a color-specifier
252 object). If this is not specified, the contents of `xpm-color-symbols'
253 are used to generate the alist.
254 :resource-id
255 Only for `mswindows-resource'. This must be either an integer (which
256 directly specifies a resource number) or a string. Valid strings are
257
258 -- For bitmaps:
259
260 \"close\", \"uparrow\", \"dnarrow\", \"rgarrow\", \"lfarrow\",
261 \"reduce\", \"zoom\", \"restore\", \"reduced\", \"zoomd\",
262 \"restored\", \"uparrowd\", \"dnarrowd\", \"rgarrowd\", \"lfarrowd\",
263 \"mnarrow\", \"combo\", \"uparrowi\", \"dnarrowi\", \"rgarrowi\",
264 \"lfarrowi\", \"size\", \"btsize\", \"check\", \"checkboxes\", and
265 \"btncorners\".
266
267 -- For cursors:
268
269 \"normal\", \"ibeam\", \"wait\", \"cross\", \"up\", \"sizenwse\",
270 \"sizenesw\", \"sizewe\", \"sizens\", \"sizeall\", and \"no\".
271
272 -- For icons:
273
274 \"sample\", \"hand\", \"ques\", \"bang\", \"note\", and \"winlogo\".
275 :resource-type
276 Only for `mswindows-resource'. This must be a symbol, either `cursor',
277 `icon', or `bitmap', specifying the type of resource to be retrieved.
278 :face
279 Only for `inherit'. This specifies the face to inherit from.
280 For widgets this also specifies the face to use for display. It defaults
281 to gui-element-face.
282
283 Keywords accepted as menu item specs are also accepted by widgets.
284 These are `:selected', `:active', `:suffix', `:keys', `:style',
285 `:filter', `:config', `:included', `:key-sequence', `:accelerator',
286 `:label' and `:callback'.
287
288 If instead of a vector, the instantiator is a string, it will be
289 converted into a vector by looking it up according to the specs in the
290 `console-type-image-conversion-list' (q.v.) for the console type of
291 the domain (usually a window; sometimes a frame or device) over which
292 the image is being instantiated.
293
294 If the instantiator specifies data from a file, the data will be read
295 in at the time that the instantiator is added to the image (which may
296 be well before when the image is actually displayed), and the
297 instantiator will be converted into one of the inline-data forms, with
298 the filename retained using a :file keyword. This implies that the
299 file must exist when the instantiator is added to the image, but does
300 not need to exist at any other time (e.g. it may safely be a temporary
301 file).
302 "
43 (make-specifier-and-init 'image spec-list)) 303 (make-specifier-and-init 'image spec-list))
44 304
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; glyphs 305 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; glyphs
46 306
47 (defconst built-in-glyph-specifiers 307 (defconst built-in-glyph-specifiers
48 '(image contrib-p baseline) 308 '(image contrib-p baseline)
49 "A list of the built-in face properties that are specifiers.") 309 "A list of the built-in glyph properties that are specifiers.")
50 310
51 (defun glyph-property (glyph property &optional locale) 311 (defun glyph-property (glyph property &optional locale)
52 "Return GLYPH's value of PROPERTY in LOCALE. 312 "Return GLYPH's value of PROPERTY in LOCALE.
53 313
54 If LOCALE is omitted, the GLYPH's actual value for PROPERTY will be 314 If LOCALE is omitted, the GLYPH's actual value for PROPERTY will be
281 particular window and buffer will be returned. 541 particular window and buffer will be returned.
282 542
283 See `glyph-property-instance' for more information." 543 See `glyph-property-instance' for more information."
284 (glyph-property-instance glyph 'image domain default no-fallback)) 544 (glyph-property-instance glyph 'image domain default no-fallback))
285 545
546 (defun glyph-image-property (glyph prop &optional domain default no-fallback)
547 "Return property PROP of the instance of GLYPH's image in DOMAIN.
548
549 Normally DOMAIN will be a window or nil (meaning the selected window).
550 The value returned is dependent on the image instance type."
551 (image-instance-property
552 (glyph-image-instance glyph domain default no-fallback) prop))
553
286 (defun set-glyph-image (glyph spec &optional locale tag-set how-to-add) 554 (defun set-glyph-image (glyph spec &optional locale tag-set how-to-add)
287 "Change the image of GLYPH in LOCALE. 555 "Change the image of GLYPH in LOCALE.
288 556
289 SPEC should be an instantiator (a string or vector; see 557 SPEC should be an instantiator (a string or vector; see
290 `image-specifier-p' for a description of possible values here), 558 `make-image-specifier' for a description of possible values here),
291 a list of (possibly tagged) instantiators, an alist of specifications 559 a list of (possibly tagged) instantiators, an alist of specifications
292 (each mapping a locale to an instantiator list), or an image specifier 560 (each mapping a locale to an instantiator list), or an image specifier
293 object. 561 object.
294 562
295 If SPEC is an alist, LOCALE must be omitted. If SPEC is a 563 If SPEC is an alist, LOCALE must be omitted. If SPEC is a
378 See `set-glyph-property' for more information." 646 See `set-glyph-property' for more information."
379 ; (interactive (glyph-interactive "baseline")) 647 ; (interactive (glyph-interactive "baseline"))
380 (set-glyph-property glyph 'baseline spec locale tag-set how-to-add)) 648 (set-glyph-property glyph 'baseline spec locale tag-set how-to-add))
381 649
382 (defun make-glyph (&optional spec-list type) 650 (defun make-glyph (&optional spec-list type)
383 "Return a new `glyph' object of type TYPE. 651 "Create a new glyph of type TYPE.
384 652
385 TYPE should be one of `buffer' (used for glyphs in an extent, the modeline, 653 A glyph in XEmacs does NOT refer to a single unit of textual display (the
654 XEmacs term for this is \"rune\"), but rather is an object encapsulating
655 a graphical element, such as an image or widget (an element such as a
656 button or text field; \"widget\" is the term for this under X Windows,
657 and it's called a \"control\" under MS Windows). This graphical element
658 could appear in a buffer, a margin, a gutter, or a toolbar, or as a mouse
659 pointer or an icon, for example.
660
661 Creating a glyph using `make-glyph' does not specify *where* the glyph
662 will be used, but it does specify *what* the glyph will look like. In
663 particular, SPEC-LIST is used to specify this, and it's used to
664 initialize the glyph's `image' property, which is an image
665 specifier. (Note that \"image\" as used in the context of a glyph's
666 `image' property or in the terms \"image specifier\", \"image
667 instantiator\", or \"image instance\" does not refer to what people
668 normally think of as an image (which in XEmacs is called a
669 \"pixmap\"), but to any graphical element -- a pixmap, a widget, or
670 even a block of text, when used in the places that call for a glyph.)
671 The format of the SPEC-LIST is typically an image instantiator (a
672 string or a vector; see `make-image-specifier' for a detailed description
673 of the valid image instantiators), but can also be a list of such
674 instantiators (each one in turn is tried until an image is
675 successfully produced), a cons of a locale (frame, buffer, etc.) and
676 an instantiator, a list of such conses, or any other form accepted by
677 `canonicalize-spec-list'.
678
679 If you're not familiar with specifiers, you should be in order to
680 understand how glyphs work. The clearest introduction to specifiers
681 is in the Lispref manual, available under Info. (Choose
682 Help->Info->Info Contents on the menubar or type \\[info].) You can
683 also see `make-specifier' for a capsule summary. What's important to
684 keep in mind is that a specifier lets you set a different value for
685 any particular buffer, window, frame, device, or console. This allows
686 for a great deal of flexibility; in particular, only one global glyph
687 needs to exist for a particular purpose (e.g. the icon used to represent
688 an iconified frame, the mouse pointer used over particular areas of a
689 frame, etc.), and in these cases you do not create your own glyph, but
690 rather modify the existing one.
691
692 As well as using SPEC-LIST to initialize the glyph, you can set
693 specifications using `set-glyph-image'. Note that, due to a possibly
694 questionable historical design decision, a glyph itself is not
695 actually a specifier, but rather is an object containing an image
696 specifier (as well as other, seldom-used properties). Therefore, you
697 cannot set or access specifications for the glyph's image by directly
698 using `set-specifier', `specifier-instance' or the like on the glyph;
699 instead use them on `(glyph-image GLYPH)' or use the convenience
700 functions `set-glyph-image', `glyph-image-instance', and
701 `glyph-image'.
702
703 Once you have created a glyph, you specify where it will be used as follows:
704
705 -- To insert a glyph into a buffer, create an extent in the buffer and then
706 use `set-extent-begin-glyph' or `set-extent-end-glyph' to set a glyph
707 to be displayed at the corresponding edge of the extent. (It is common
708 to create zero-width extents for this purpose.)
709
710 -- To insert a glyph into the left or right margin of a buffer, first
711 make sure the margin is visible by setting a value for the specifiers
712 `left-margin-width' or `right-margin-width'. (Not strictly necessary
713 when using margin glyphs with layout policy `whitespace'.) Then follow
714 the same procedure above for inserting a glyph in a buffer, and then
715 set a non-default layout policy for the glyph using
716 `set-extent-begin-glyph-layout' or `set-extent-end-glyph-layout'.
717 Alternatively, use the high-level annotations API (see
718 `make-annotation'). (In point of fact, you can also use the annotations
719 API for glyphs in a buffer, by setting a layout policy of `text'.)
720
721 -- To insert a glyph into the modeline, just put the glyph directly as
722 one of the modeline elements. (Unfortunately you can't currently
723 put a begin glyph or end glyph on one of the modeline extents --
724 they're ignored.)
725
726 -- To insert a glyph into a toolbar, specify it as part of a toolbar
727 instantiator (typically set on the specifier `default-toolbar').
728 See `default-toolbar' for more information. (Note that it is standard
729 practice to use a symbol in place of the glyph list in the toolbar
730 instantiator; the symbol is evalled to get the glyph list. This
731 facilitates both creating the toolbar instantiator and modifying
732 individual glyphs in a toolbar later on. For example, you can
733 change the way that the Mail toolbar button looks by modifying the
734 value of the variable `toolbar-mail-icon' (in general, `toolbar-*-icon')
735 and then calling `(set-specifier-dirty-flag default-toolbar)'.
736 (#### Unfortunately this doesn't quite work the way it should; the
737 change will appear in new frames, but not existing ones.
738
739 -- To insert a glyph into a gutter, create or modify a gutter instantiator
740 (typically set on the specifier `default-gutter'). Gutter instantiators
741 consist of strings or lists of strings, so to insert a glyph, create an
742 extent over the string, and use `set-extent-begin-glyph' or
743 `set-extent-end-glyph' to set a glyph to be displayed at the corresponding
744 edge of the extent, just like for glyphs in a buffer.
745
746 -- To use a glyph as the icon for a frame, you do not actually create a new
747 glyph; rather, you change the specifications for the existing glyph
748 `frame-icon-glyph'. (Remember that, because of the specifier nature of
749 glyphs, you can set different values for any particular buffer or frame.)
750
751 -- To use a glyph as the mouse pointer, in general you do not create a
752 new glyph, but rather you change the specifications of various existing
753 glyphs, such as `text-pointer-glyph' for the pointer used over text,
754 `modeline-pointer-glyph' for the pointer used over the modeline, etc.
755 Do an apropos over `*-pointer-glyph' to find all of them. (Note also
756 that you can temporarily set the mouse pointer to some specific shape
757 by using `set-frame-pointer', which takes an image instance, as obtained
758 from calling `glyph-image-instance' on a glyph of type `pointer' --
759 either one of the above-mentioned variables or one you created yourself.
760 (See below for what it means to create a glyph of type `pointer'.)
761 This pointer will last only until the next mouse motion event is
762 processed or certain other things happen, such as creating or deleting
763 a window. (In fact, the above-mentioned pointer glyph variables are
764 implemented as part of the default handler for mouse motion events.
765 If you want to customize this behavior, take a look at `mode-motion-hook',
766 or `mouse-motion-handler' if you really want to get low-level.)
767
768 -- To use a glyph to control the shape of miscellaneous redisplay effects
769 such as the truncation and continuation markers, set the appropriate
770 existing glyph variables, as for icons and pointers above. See
771 `continuation-glyph', `control-arrow-glyph', `hscroll-glyph',
772 `invisible-text-glyph', `octal-escape-glyph', and `truncation-glyph'.
773 See also `overlay-arrow-string', an odd redisplay leftover which can
774 be set to a glyph you created, and will cause the glyph to be displayed
775 on top of the text position specified in the marker stored in
776 `overlay-arrow-position'.
777
778 -- To use a glyph in a display table (i.e. to control the appearance of
779 any individual character), create the appropriate character glyphs
780 and then set a specification for the specifier `current-display-table',
781 which controls the appearance of characters. You can also set an
782 overriding display table for use with text displayed in a particular
783 face; see `set-face-display-table' and `make-display-table'.
784 #### Note: Display tables do not currently support general Mule
785 characters. They will be overhauled at some point to support this
786 and to provide other features required under Mule.
787
788 -- To use a glyph as the background pixmap of a face: Note that the
789 background pixmap of a face is actually an image specifier -- probably
790 the only place in XEmacs where an image specifier occurs outside of
791 a glyph. Similarly to how the glyph's image specifier works, you
792 don't create your own image specifier, but rather add specifications
793 to the existing one (using `set-face-background-pixmap'). Note that
794 the image instance that is generated in order to actually display the
795 background pixmap is of type `mono-pixmap', meaning that it's a two-color
796 image and the foreground and background of the image get filled in with
797 the corresponding colors from the face.
798
799 It is extremely rare that you will ever have to specify a value for TYPE,
800 which should be one of `buffer' (used for glyphs in an extent, the modeline,
386 the toolbar, or elsewhere in a buffer), `pointer' (used for the mouse-pointer), 801 the toolbar, or elsewhere in a buffer), `pointer' (used for the mouse-pointer),
387 or `icon' (used for a frame's icon), and defaults to `buffer'. 802 or `icon' (used for a frame's icon), and defaults to `buffer'. The only cases
388 803 where it needs to be specified is when creating icon or pointer glyphs, and
389 SPEC-LIST is used to initialize the glyph's image. It is typically an 804 in both cases the necessary glyphs have already been created at startup and
390 image instantiator (a string or a vector; see `image-specifier-p' for 805 are accessed through the appropriate variables, e.g. `text-pointer-glyph'
391 a detailed description of the valid image instantiators), but can also 806 (or in general, `*-pointer-glyph') and `frame-icon-glyph'."
392 be a list of such instantiators (each one in turn is tried until an
393 image is successfully produced), a cons of a locale (frame, buffer, etc.)
394 and an instantiator, a list of such conses, or any other form accepted
395 by `canonicalize-spec-list'. See `make-specifier' for more information
396 about specifiers."
397 (let ((glyph (make-glyph-internal type))) 807 (let ((glyph (make-glyph-internal type)))
398 (and spec-list (set-glyph-image glyph spec-list)) 808 (and spec-list (set-glyph-image glyph spec-list))
399 glyph)) 809 glyph))
400 810
401 (defun buffer-glyph-p (object) 811 (defun buffer-glyph-p (object)
410 "Return t if OBJECT is a glyph of type `icon'." 820 "Return t if OBJECT is a glyph of type `icon'."
411 (and (glyphp object) (eq 'icon (glyph-type object)))) 821 (and (glyphp object) (eq 'icon (glyph-type object))))
412 822
413 (defun make-pointer-glyph (&optional spec-list) 823 (defun make-pointer-glyph (&optional spec-list)
414 "Return a new `pointer-glyph' object with the specification list SPEC-LIST. 824 "Return a new `pointer-glyph' object with the specification list SPEC-LIST.
415
416 This is equivalent to calling `make-glyph', specifying a type of `pointer'. 825 This is equivalent to calling `make-glyph', specifying a type of `pointer'.
417 826 See `make-glyph' for more information.
418 SPEC-LIST is used to initialize the glyph's image. It is typically an 827
419 image instantiator (a string or a vector; see `image-specifier-p' for 828 It is extremely unlikely that you will ever need to create a pointer glyph.
420 a detailed description of the valid image instantiators), but can also 829 Instead, you probably want to be calling `set-glyph-image' on an existing
421 be a list of such instantiators (each one in turn is tried until an 830 glyph, e.g. `text-pointer-glyph'."
422 image is successfully produced), a cons of a locale (frame, buffer, etc.)
423 and an instantiator, a list of such conses, or any other form accepted
424 by `canonicalize-spec-list'. See `make-specifier' for more information
425 about specifiers.
426
427 You can also create a glyph with an empty SPEC-LIST and add image
428 instantiators afterwards using `set-glyph-image'."
429 (make-glyph spec-list 'pointer)) 831 (make-glyph spec-list 'pointer))
430 832
431 (defun make-icon-glyph (&optional spec-list) 833 (defun make-icon-glyph (&optional spec-list)
432 "Return a new `icon-glyph' object with the specification list SPEC-LIST. 834 "Return a new `icon-glyph' object with the specification list SPEC-LIST.
433
434 This is equivalent to calling `make-glyph', specifying a type of `icon'. 835 This is equivalent to calling `make-glyph', specifying a type of `icon'.
435 836 See `make-glyph' for more information.
436 SPEC-LIST is used to initialize the glyph's image. It is typically an 837
437 image instantiator (a string or a vector; see `image-specifier-p' for 838 It is extremely unlikely that you will ever need to create a icon glyph.
438 a detailed description of the valid image instantiators), but can also 839 Instead, you probably want to be calling `set-glyph-image' on
439 be a list of such instantiators (each one in turn is tried until an 840 `frame-icon-glyph'."
440 image is successfully produced), a cons of a locale (frame, buffer, etc.)
441 and an instantiator, a list of such conses, or any other form accepted
442 by `canonicalize-spec-list'. See `make-specifier' for more information
443 about specifiers.
444
445 You can also create a glyph with an empty SPEC-LIST and add image
446 instantiators afterwards using `set-glyph-image'."
447 (make-glyph spec-list 'icon)) 841 (make-glyph spec-list 'icon))
448 842
449 (defun nothing-image-instance-p (object) 843 (defun nothing-image-instance-p (object)
450 "Return t if OBJECT is an image instance of type `nothing'." 844 "Return t if OBJECT is an image instance of type `nothing'."
451 (and (image-instance-p object) (eq 'nothing (image-instance-type object)))) 845 (and (image-instance-p object) (eq 'nothing (image-instance-type object))))
466 860
467 (defun pointer-image-instance-p (object) 861 (defun pointer-image-instance-p (object)
468 "Return t if OBJECT is an image instance of type `pointer'." 862 "Return t if OBJECT is an image instance of type `pointer'."
469 (and (image-instance-p object) (eq 'pointer (image-instance-type object)))) 863 (and (image-instance-p object) (eq 'pointer (image-instance-type object))))
470 864
865 (defun widget-image-instance-p (object)
866 "Return t if OBJECT is an image instance of type `widget'."
867 (and (image-instance-p object) (eq 'widget (image-instance-type object))))
868
471 (defun subwindow-image-instance-p (object) 869 (defun subwindow-image-instance-p (object)
472 "Return t if OBJECT is an image instance of type `subwindow'. 870 "Return t if OBJECT is an image instance of type `subwindow'."
473 Subwindows are not implemented in this version of XEmacs."
474 (and (image-instance-p object) (eq 'subwindow (image-instance-type object)))) 871 (and (image-instance-p object) (eq 'subwindow (image-instance-type object))))
475 872
476 ;;;;;;;;;; the built-in glyphs 873 ;;;;;;;;;; the built-in glyphs
477 874
478 (defvar text-pointer-glyph (make-pointer-glyph) 875 (defvar text-pointer-glyph (make-pointer-glyph)