comparison lisp/glyphs.el @ 2607:f8db302d6298

[xemacs-hg @ 2005-02-22 23:38:49 by ben] Update glyph documentation glyphs.el: Update documentation of `make-glyph' and `make-image-specifier' to more clearly document image instantiators and describe how errors are handled in make-glyph. Also fix symbol references in doc strings to use `symbol' format, not 'symbol.
author ben
date Tue, 22 Feb 2005 23:38:50 +0000
parents 1ccc32a20af4
children fd1acd2f457a
comparison
equal deleted inserted replaced
2606:76568bec0cdb 2607:f8db302d6298
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, 2000 Ben Wing. 4 ;; Copyright (C) 1995, 1996, 2000, 2005 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
45 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
46 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
47 of instantiators. See `make-specifier' for more information about 47 of instantiators. See `make-specifier' for more information about
48 specifiers. 48 specifiers.
49 49
50 An image specifier is used for images (pixmaps, widgets and the like). 50 The main purpose of this doc string is to describe the possible formats for
51 It is used to describe the actual image in a glyph. It is instanced 51 image instantiators, as given as an argument to `make-glyph' or
52 as an image-instance. Note that \"image\" as used in XEmacs does not 52 `set-glyph-image'.
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 53
95 An image instantiator should be a string or a vector of the form 54 An image instantiator should be a string or a vector of the form
96 55
97 [FORMAT :KEYWORD VALUE ...] 56 [FORMAT :KEYWORD VALUE ...]
98 57
99 i.e. a format symbol followed by zero or more alternating keyword-value 58 i.e. a format symbol followed by zero or more alternating keyword-value
100 pairs. FORMAT should be one of 59 pairs. The vector form of an image instantiator explicitly specifies the
101 60 format of the image and other relevant properties. The string form
102 'nothing 61 specifies only a filename or gives inline data of an unspecified format,
62 and XEmacs must guess the actual format. Once it has done this, it
63 internally converts the instantiator into the vector format. This is
64 described in more detail below.
65
66 Following is a list of the possible values for FORMAT. After each
67 description, the allowable keywords for the format are listed in brackets,
68 followed by the possible image instance types that can be generated from
69 this format. (Image instance types will be discussed below.)
70
71 `nothing'
103 Don't display anything; no keywords are valid for this. 72 Don't display anything; no keywords are valid for this.
104 Can only be instanced as `nothing'. 73 [] (nothing)
105 'string 74 `string'
106 Display this image as a text string. Can only be instanced 75 Display this image as a text string. Support for instantiating as
107 as `text', although support for instancing as `mono-pixmap' 76 `mono-pixmap' and `color-pixmap' should probably be added.
108 and `color-pixmap' should be added. 77 [:data] (text)
109 'formatted-string 78 `formatted-string'
110 Display this image as a text string, with replaceable fields; 79 Display this image as a text string, with replaceable fields.
111 not currently implemented. (It is, instead, equivalent to `string'.) 80 Not currently implemented -- it's treated like `string'.
112 'xbm 81 [:data] (text)
113 An X bitmap; only if X or MS Windows support was compiled into this 82 `gif'
114 XEmacs. Can be instanced as `mono-pixmap', `color-pixmap', or `pointer'. 83 A GIF87 or GIF89 image; only if GIF support was compiled into this
115 'xpm 84 XEmacs. NOTE: Only the first frame of animated gifs will be displayed.
85 [:data, :file] (color-pixmap, pointer)
86 `jpeg'
87 A JPEG image; only if JPEG support was compiled into this XEmacs.
88 [:data, :file] (color-pixmap, pointer)
89 `png'
90 A PNG image; only if PNG support was compiled into this XEmacs.
91 [:data, :file] (color-pixmap, pointer)
92 `tiff'
93 A TIFF image; only if TIFF support was compiled into this XEmacs.
94 [:data, :file] (color-pixmap, pointer)
95 `bmp'
96 A MS Windows BMP image; only if MS Windows support was compiled into
97 this XEmacs.
98 [:data, :file] (color-pixmap, pointer)
99 `xbm'
100 An X bitmap; exists if any window-system support was compiled into this
101 XEmacs.
102 [:data, :file, :foreground, :background, :mask-data, :mask-file,
103 :hotspot-x, :hotspot-y] (mono-pixmap, color-pixmap, pointer)
104 `xpm'
116 An XPM pixmap; only if XPM support was compiled into this XEmacs. 105 An XPM pixmap; only if XPM support was compiled into this XEmacs.
117 Can be instanced as `color-pixmap', `mono-pixmap', or `pointer'. 106 [:data, :file, :color-symbols] (mono-pixmap, color-pixmap, pointer)
118 'xface 107 `xface'
119 An X-Face bitmap, used to encode people's faces in e-mail messages; 108 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 109 only if X-Face support was compiled into this XEmacs.
121 instanced as `mono-pixmap', `color-pixmap', or `pointer'. 110 [:data, :file, :foreground, :background, :mask-data, :mask-file,
122 'gif 111 :hotspot-x, :hotspot-y] (mono-pixmap, color-pixmap, pointer)
123 A GIF87 or GIF89 image; only if GIF support was compiled into this 112 `cursor-font'
124 XEmacs. NOTE: only the first frame of animated gifs will be displayed. 113 X and GTK only. One of the standard cursor-font names, such as \"watch\"
125 Can be instanced as `color-pixmap'. 114 or \"right_ptr\" under X. Under X, this is, more specifically, any
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 115 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. 116 [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 117 On other window systems, the valid names will be specific to the
144 type of window system. Can only be instanced as `pointer'. 118 type of window system.
145 'mswindows-resource 119 [:data, :foreground, :background] (pointer)
120 `mswindows-resource'
146 An MS Windows pointer resource. Specifies a resource to retrieve 121 An MS Windows pointer resource. Specifies a resource to retrieve
147 directly from the system (an OEM resource) or from a file, particularly 122 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 123 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 124 :file and optionally :resource-id. Otherwise use :resource-id. Always
150 specify :resource-type to specify the type (cursor, bitmap or icon) of 125 specify :resource-type to specify the type (cursor, bitmap or icon) of
151 the resource. Possible values for :resource-id are listed below. Can 126 the resource. Possible values for :resource-id are listed below.
152 be instanced as `pointer' or `color-pixmap'. 127 [:file, :resource-type, :resource-id] (pointer, color-pixmap)
153 'font 128 `font'
154 A glyph from a font; i.e. the name of a font, and glyph index into it 129 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]\". 130 of the form \"FONT fontname index [[mask-font] mask-index]\".
156 Currently can only be instanced as `pointer', although this should 131 Currently can only be instantiated as `pointer', although this should
157 probably be fixed. 132 probably be fixed.
158 'subwindow 133 [:data, :foreground, :background] (pointer)
159 An embedded windowing system window. Can only be instanced as 134 `subwindow'
160 `subwindow'. 135 An embedded windowing system window.
161 'button 136 [:pixel-width, :pixel-height] (subwindow)
137 `button'
162 A button widget; either a push button, radio button or toggle button. 138 A button widget; either a push button, radio button or toggle button.
163 Can only be instanced as `widget'. 139 [WIDGET-KEYWORDS, GUI-KEYWORDS, :image] (widget)
164 'combo-box 140 `combo-box'
165 A drop list of selectable items in a widget, for editing text. 141 A drop list of selectable items in a widget, for editing text.
166 Can only be instanced as `widget'. 142 [GUI-KEYWORDS, :width, :height, :pixel-width, :face, :items] (widget)
167 'edit-field 143 `edit-field'
168 A text editing widget. Can only be instanced as `widget'. 144 A text editing widget.
169 'label 145 [WIDGET-KEYWORDS, GUI-KEYWORDS] (widget)
170 A static, text-only, widget; for displaying text. Can only be instanced 146 `label'
171 as `widget'. 147 A static, text-only, widget; for displaying text.
172 'layout 148 [WIDGET-KEYWORDS, :descriptor] (widget)
149 `layout'
173 A widget for controlling the positioning of children underneath it. 150 A widget for controlling the positioning of children underneath it.
174 Through the use of nested layouts, a widget hierarchy can be created 151 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 152 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 153 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 154 in many of the places that expect a single glyph.
178 as `widget'. 155 [WIDGET-KEYWORDS, GUI-KEYWORDS, :orientation, :justify, :vertically-justify,
179 'native-layout 156 :horizontally-justify, :border, :margin-width, :items] (widget)
157 `native-layout'
180 The native version of a layout widget. #### Document me better! 158 The native version of a layout widget. #### Document me better!
181 Can only be instanced as `widget'. 159 [WIDGET-KEYWORDS, GUI-KEYWORDS] (widget)
182 'progress-gauge 160 `progress-gauge'
183 A sliding widget, for showing progress. Can only be instanced as 161 A sliding widget, for showing progress.
184 `widget'. 162 [WIDGET-KEYWORDS, GUI-KEYWORDS, :value] (widget)
185 'tab-control 163 `tab-control'
186 A tab widget; a series of user selectable tabs. Can only be instanced 164 A tab widget; a series of user selectable tabs.
187 as `widget'. 165 [WIDGET-KEYWORDS, GUI-KEYWORDS, :orientation, :items] (widget)
188 'tree-view 166 `tree-view'
189 A folding widget. Can only be instanced as `widget'. 167 A folding widget.
190 'scrollbar 168 [WIDGET-KEYWORDS, GUI-KEYWORDS, :items] (widget)
191 A scrollbar widget. Can only be instanced as `widget'. 169 `scrollbar'
192 'autodetect 170 A scrollbar widget.
171 [GUI-KEYWORDS, :pixel-width, :face, :items] (widget)
172 `autodetect'
193 XEmacs tries to guess what format the data is in. If X support 173 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. 174 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 175 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 176 sort of pixmap or pointer will be created. [This includes picking up
197 any specified hotspot or associated mask file.] Otherwise, if `pointer' 177 any specified hotspot or associated mask file.] Otherwise, if `pointer'
198 is one of the allowable image-instance types and the string names a 178 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. 179 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 180 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 181 exists, the image will always be displayed as text.
202 `mono-pixmap', `color-pixmap', `pointer', or `text'. 182 [:data] (mono-pixmap, color-pixmap, pointer, text)
203 'inherit 183 `inherit'
204 Inherit from the background-pixmap property of a face. Can only be 184 Inherit from the background-pixmap property of a face.
205 instanced as `mono-pixmap'. 185 [:face] (mono-pixmap)
206 186
207 The valid keywords are: 187 The valid keywords are:
208 188
209 :data 189 :data
210 Inline data. For most formats above, this should be a string. For 190 Inline data. For most formats above, this should be a string. For
262 \"restored\", \"uparrowd\", \"dnarrowd\", \"rgarrowd\", \"lfarrowd\", 242 \"restored\", \"uparrowd\", \"dnarrowd\", \"rgarrowd\", \"lfarrowd\",
263 \"mnarrow\", \"combo\", \"uparrowi\", \"dnarrowi\", \"rgarrowi\", 243 \"mnarrow\", \"combo\", \"uparrowi\", \"dnarrowi\", \"rgarrowi\",
264 \"lfarrowi\", \"size\", \"btsize\", \"check\", \"checkboxes\", and 244 \"lfarrowi\", \"size\", \"btsize\", \"check\", \"checkboxes\", and
265 \"btncorners\". 245 \"btncorners\".
266 246
267 -- For cursors: 247 -- For pointers:
268 248
269 \"normal\", \"ibeam\", \"wait\", \"cross\", \"up\", \"sizenwse\", 249 \"normal\", \"ibeam\", \"wait\", \"cross\", \"up\", \"sizenwse\",
270 \"sizenesw\", \"sizewe\", \"sizens\", \"sizeall\", and \"no\". 250 \"sizenesw\", \"sizewe\", \"sizens\", \"sizeall\", and \"no\".
271 251
272 -- For icons: 252 -- For icons:
273 253
274 \"sample\", \"hand\", \"ques\", \"bang\", \"note\", and \"winlogo\". 254 \"sample\", \"hand\", \"ques\", \"bang\", \"note\", and \"winlogo\".
275 :resource-type 255 :resource-type
276 Only for `mswindows-resource'. This must be a symbol, either `cursor', 256 Only for `mswindows-resource'. This must be a symbol, either `cursor'
277 `icon', or `bitmap', specifying the type of resource to be retrieved. 257 (i.e. pointer), `icon', or `bitmap', specifying the type of resource to
258 be retrieved.
278 :face 259 :face
279 Only for `inherit'. This specifies the face to inherit from. 260 Only for `inherit'. This specifies the face to inherit from.
280 For widgets this also specifies the face to use for display. It defaults 261 For widgets this also specifies the face to use for display. It defaults
281 to gui-element-face. 262 to gui-element-face.
282 263 :pixel-width, :pixel-height
283 Keywords accepted as menu item specs are also accepted by widgets. 264 Width and height of element, in pixels. For `subwindow', the values
265 must be integers. For widgets, the values can be integers or
266 expressions that evaluate to integers.
267
268 \[WIDGET-KEYWORDS] stands for the standard keywords accepted by widgets:
284 These are `:selected', `:active', `:suffix', `:keys', `:style', 269 These are `:selected', `:active', `:suffix', `:keys', `:style',
285 `:filter', `:config', `:included', `:key-sequence', `:accelerator', 270 `:filter', `:config', `:included', `:key-sequence', `:accelerator',
286 `:label' and `:callback'. 271 `:label', `:callback', `:initial-focus', and `:descriptor'.
272 #### Document me.
273
274 \[GUI-KEYWORDS] stands for keywords accepted by many widgets.
275 These are `:width', `:height', `:pixel-width', `:pixel-height', and `:face'.
276 #### Document me.
287 277
288 If instead of a vector, the instantiator is a string, it will be 278 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 279 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 280 `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 281 the domain (usually a window; sometimes a frame or device) over which
297 instantiator will be converted into one of the inline-data forms, with 287 instantiator will be converted into one of the inline-data forms, with
298 the filename retained using a :file keyword. This implies that the 288 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 289 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 290 not need to exist at any other time (e.g. it may safely be a temporary
301 file). 291 file).
302 " 292
293 NOTE: In practice, you rarely, if ever, need to actually
294 create an image specifier! (The function `make-image-specifier' exists
295 mainly for completeness.) Pretty much the only use for image specifiers is
296 to control how glyphs are displayed, and the image specifier associated
297 with a glyph (the `image' property of a glyph) is created automatically
298 when a glyph is created (see `make-glyph') and need not \(and cannot, for
299 that matter) ever be changed. In fact, the design decision to create a
300 separate image specifier type, rather than make glyphs themselves be
301 specifiers, is debatable -- the other properties of glyphs are rarely used
302 and could conceivably have been incorporated into the glyph's instantiator.
303 The rarely used glyph types (buffer, pointer, icon) could also have been
304 incorporated into the instantiator.
305
306 An image specifier is used for images (pixmaps, widgets and the like). It
307 is used to describe the actual image in a glyph. It is instantiated \(see
308 `specifier-instance') as an image-instance. Note that \"image\" as used in
309 XEmacs does not actually refer to what the term \"image\" normally means (a
310 picture, e.g. in .GIF or .JPG format, and called a \"pixmap\" in XEmacs),
311 but includes all types of graphical elements, including pixmaps, widgets
312 \(buttons, sliders, text fields, etc.) and even strings of text.
313
314 There is an important distinction to be made between image instantiators
315 and image instances, and \"image instantiator formats\" and \"image
316 instance types\", analogous to the distinction between source and
317 destination. An image instantiator describes the source data for an image.
318 An image instance encapsulates the resulting window-system object used to
319 display the image. Image instantiator formats are the formats of the
320 source: This includes familiar and less-familiar graphics formats such as
321 `gif', `jpeg', `png' and `xpm'; widget types such as `button', `edit-field'
322 and `combo-box'; and other beasts such as `string' (plain text, which could
323 potentially behave like text when placed in a buffer, such as wrapping),
324 `font' (a single character from a particular font, specified by the index
325 into the font), etc. Image instance types are the (destination) types of
326 the resulting image instance. Different image instance types correspond to
327 fundamentally different appearance and behaviors for the resulting image,
328 specifically:
329
330 -- `color-pixmap' (a color image);
331 -- `mono-pixmap' (a \"monochrome\" image, technically a two-color image
332 that comes in two unspecified shades \"foreground\" and \"background\",
333 determined from the face [see `make-face'] of the glyph or surrounding
334 text);
335 -- `text' (a string of text appearing somewhere in a buffer's text or
336 margins, which has an unspecified foreground, background, and font
337 derived from the surrounding text or other external property and which
338 behaves in many respects like an image but can wrap across the end of a
339 line to the beginning of the next);
340 -- `pointer' (the mouse pointer for a window; this is a combination of a
341 rectangular pixmap image, a monochrome mask that specifies the
342 transparency of the image [i.e. in which places the underlying screen
343 image can show through, and how much of it], and a \"hotspot\" that
344 indicates which pixel in the pointer's image is considered the actual
345 pointer location -- for example, this will be located near the tip of
346 an arrow, in the middle of a crosshairs, somewhere along an i-beam, etc.);
347 -- `widget' (a window-system object or \"widget\" that interacts with the
348 user, such as a button, edit-field or combo-box);
349 -- `subwindow' (a rectangular area that another program can draw into);
350 -- `nothing' (no display).
351
352 There is not a one-to-one mapping between source (image instantiator)
353 formats and destination (image instance) types. For example, the source
354 format `xpm' can generate the image instance types `color-pixmap',
355 `mono-pixmap', or `pointer', and the image instance type `color-pixmap' can
356 be generated by any of `gif', `jpeg', `png', `tiff', `xpm', `xbm' and
357 `xface'.
358
359 In general, the user or programmer specifies the image instantiator format,
360 while the appropriate image instance type is determined automatically by
361 XEmacs from the image instantiator format, from the data in the
362 instantiator and from the particular situation the image (and the glyph
363 that holds it) is being used in. (However, it's possible to explicitly
364 create image instances and control their types; see `make-image-instance'.)
365 For example, a glyph used to specify the shape of a mouse pointer can only
366 result in `pointer'-type image instances, and a glyph used for an icon can
367 only result in `color-pixmap' image instances. A glyph used in a buffer
368 can potentially result in any image instance type except for `pointer', but
369 particular instantiator formats have only a limited set of image instance
370 types they will support. Here is an example of how the image instance type
371 for an `xpm' instantiator (which can potentially support `color-pixmap',
372 `mono-pixmap', or `pointer') is determined:
373
374 1. If the glyph is being used for a mouse pointer (hence its `glyph-type'
375 is `pointer'), it can be instantiated only a `pointer'-type image instance.
376 2. If the glyph is being used for an icon (hence its `glyph-type' is `icon'),
377 it can be instantiated only a `color-pixmap'-type image instance.
378 3. Otherwise, the glyph is being used somewhere inside a frame (`glyph-type'
379 of `buffer') and any image instance type except `pointer' can be
380 supported. In this case, this means `color-pixmap' or `mono-pixmap'.
381 Which one will result depends on the particular data being processed,
382 since XPM images can specify whether they are color or mono.
383
384 Note again that \"mono\" does *NOT* simply mean \"an image with two
385 colors\". The latter image has two prespecified colors, e.g. red and blue
386 or black and white, and will always appear with those colors, no matter
387 what the context. A mono image has two *unspecified* colors, symbolically
388 named \"foreground\" and \"background\", and the actual values for those
389 colors depends on context. A mono pixmap displayed among text will take
390 its foreground and background from that of the text and hence blend in
391 nicely; a two-color color pixmap won't do that.
392
393 Note also that `color-pixmap' image instances can be generated from the
394 supported pixmap formats that are inherently mono (i.e. `xbm' and `xface')
395 by specifying :foreground and :background values.
396
397 A table of the various image instantiator formats and the possible
398 destination (image instance) types that can be generated from them is as
399 follows:
400
401
402 color-pixmap mono-pixmap text pointer widget subwindow noth.
403 -------------------------------------------------------------------------------
404 nothing +
405 string +
406 formatted-string +
407 xbm + + +
408 xpm + + +
409 xface + + +
410 gif + +
411 jpeg + +
412 png + +
413 tiff + +
414 bmp + +
415 cursor-font +
416 mswindows-resource + +
417 font +
418 subwindow +
419 button +
420 combo-box +
421 edit-field +
422 label +
423 layout +
424 native-layout +
425 progress-gauge +
426 tab-control +
427 tree-view +
428 scrollbar +
429 autodetect + + + +
430 inherit +
431
432 See `make-image-instance' for a more detailed discussion of image
433 instance types."
303 (make-specifier-and-init 'image spec-list)) 434 (make-specifier-and-init 'image spec-list))
304 435
305 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; glyphs 436 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; glyphs
306 437
307 (defconst built-in-glyph-specifiers 438 (defconst built-in-glyph-specifiers
326 457
327 The return value will be a list of instantiators (e.g. strings 458 The return value will be a list of instantiators (e.g. strings
328 specifying a font or color name), or a list of specifications, each 459 specifying a font or color name), or a list of specifications, each
329 of which is a cons of a locale and a list of instantiators. 460 of which is a cons of a locale and a list of instantiators.
330 Specifically, if LOCALE is a particular locale (a buffer, window, 461 Specifically, if LOCALE is a particular locale (a buffer, window,
331 frame, device, or 'global), a list of instantiators for that locale 462 frame, device, or `global'), a list of instantiators for that locale
332 will be returned. Otherwise, if LOCALE is a locale type (one of 463 will be returned. Otherwise, if LOCALE is a locale type (one of
333 the symbols 'buffer, 'window, 'frame, 'device, 'device-class, or 464 the symbols `buffer', `window', `frame', `device', `device-class', or
334 'device-type), the specifications for all locales of that type will 465 `device-type'), the specifications for all locales of that type will
335 be returned. Finally, if LOCALE is 'all, the specifications for all 466 be returned. Finally, if LOCALE is `all', the specifications for all
336 locales of all types will be returned. 467 locales of all types will be returned.
337 468
338 The specifications in a specifier determine what the value of 469 The specifications in a specifier determine what the value of
339 PROPERTY will be in a particular \"domain\" or set of circumstances, 470 PROPERTY will be in a particular \"domain\" or set of circumstances,
340 which is typically a particular Emacs window along with the buffer 471 which is typically a particular Emacs window along with the buffer
341 it contains and the frame and device it lies within. The value 472 it contains and the frame and device it lies within. The value
342 is derived from the instantiator associated with the most specific 473 is derived from the instantiator associated with the most specific
343 locale (in the order buffer, window, frame, device, and 'global) 474 locale (in the order buffer, window, frame, device, and `global')
344 that matches the domain in question. In other words, given a domain 475 that matches the domain in question. In other words, given a domain
345 (i.e. an Emacs window, usually), the specifier for PROPERTY will first 476 (i.e. an Emacs window, usually), the specifier for PROPERTY will first
346 be searched for a specification whose locale is the buffer contained 477 be searched for a specification whose locale is the buffer contained
347 within that window; then for a specification whose locale is the window 478 within that window; then for a specification whose locale is the window
348 itself; then for a specification whose locale is the frame that the 479 itself; then for a specification whose locale is the frame that the
366 (check-argument-type 'glyphp glyph) 497 (check-argument-type 'glyphp glyph)
367 (let ((specifier (get glyph property))) 498 (let ((specifier (get glyph property)))
368 ;; if a user-property does not have a specifier but a 499 ;; if a user-property does not have a specifier but a
369 ;; locale was specified, put a specifier there. 500 ;; locale was specified, put a specifier there.
370 ;; If there was already a value there, convert it to a 501 ;; If there was already a value there, convert it to a
371 ;; specifier with the value as its 'global instantiator. 502 ;; specifier with the value as its `global' instantiator.
372 (if (not (specifierp specifier)) 503 (if (not (specifierp specifier))
373 (let ((new-specifier (make-specifier 'generic))) 504 (let ((new-specifier (make-specifier 'generic)))
374 (if (or (not (null specifier)) 505 (if (or (not (null specifier))
375 ;; make sure the nil returned from `get' wasn't 506 ;; make sure the nil returned from `get' wasn't
376 ;; actually the value of the property 507 ;; actually the value of the property
434 this property can be supplied in many different ways: 565 this property can be supplied in many different ways:
435 566
436 -- If VALUE is a simple instantiator (e.g. a string naming a font or 567 -- If VALUE is a simple instantiator (e.g. a string naming a font or
437 color) or a list of instantiators, then the instantiator(s) will 568 color) or a list of instantiators, then the instantiator(s) will
438 be added as a specification of the property for the given LOCALE 569 be added as a specification of the property for the given LOCALE
439 (which defaults to 'global if omitted). 570 (which defaults to `global' if omitted).
440 -- If VALUE is a list of specifications (each of which is a cons of 571 -- If VALUE is a list of specifications (each of which is a cons of
441 a locale and a list of instantiators), then LOCALE must be nil 572 a locale and a list of instantiators), then LOCALE must be nil
442 (it does not make sense to explicitly specify a locale in this 573 (it does not make sense to explicitly specify a locale in this
443 case), and specifications will be added as given. 574 case), and specifications will be added as given.
444 -- If VALUE is a specifier (as would be returned by `glyph-property' 575 -- If VALUE is a specifier (as would be returned by `glyph-property'
446 specifications in the specifier will be added to the property. 577 specifications in the specifier will be added to the property.
447 In this case, the function is really equivalent to 578 In this case, the function is really equivalent to
448 `copy-specifier' and LOCALE has the same semantics (if it is 579 `copy-specifier' and LOCALE has the same semantics (if it is
449 a particular locale, the specification for the locale will be 580 a particular locale, the specification for the locale will be
450 copied; if a locale type, specifications for all locales of 581 copied; if a locale type, specifications for all locales of
451 that type will be copied; if nil or 'all, then all 582 that type will be copied; if nil or `all', then all
452 specifications will be copied). 583 specifications will be copied).
453 584
454 HOW-TO-ADD should be either nil or one of the symbols 'prepend, 585 HOW-TO-ADD should be either nil or one of the symbols `prepend',
455 'append, 'remove-tag-set-prepend, 'remove-tag-set-append, 'remove-locale, 586 `append', `remove-tag-set-prepend', `remove-tag-set-append', `remove-locale',
456 'remove-locale-type, or 'remove-all. See `copy-specifier' and 587 `remove-locale-type', or `remove-all.' See `copy-specifier' and
457 `add-spec-to-specifier' for a description of what each of 588 `add-spec-to-specifier' for a description of what each of
458 these means. Most of the time, you do not need to worry about 589 these means. Most of the time, you do not need to worry about
459 this argument; the default behavior usually is fine. 590 this argument; the default behavior usually is fine.
460 591
461 In general, it is OK to pass an instance object (e.g. as returned 592 In general, it is OK to pass an instance object (e.g. as returned
462 by `glyph-property-instance') as an instantiator in place of 593 by `glyph-property-instance') as an instantiator in place of
463 an actual instantiator. In such a case, the instantiator used 594 an actual instantiator. In such a case, the instantiator used
464 to create that instance object will be used (for example, if 595 to create that instance object will be used (for example, if
465 you set a font-instance object as the value of the 'font 596 you set a font-instance object as the value of the `font'
466 property, then the font name used to create that object will 597 property, then the font name used to create that object will
467 be used instead). If some cases, however, doing this 598 be used instead). If some cases, however, doing this
468 conversion does not make sense, and this will be noted in 599 conversion does not make sense, and this will be noted in
469 the documentation for particular types of instance objects. 600 the documentation for particular types of instance objects.
470 601
471 If PROPERTY is not a built-in property, then this function will 602 If PROPERTY is not a built-in property, then this function will
472 simply set its value if LOCALE is nil. However, if LOCALE is 603 simply set its value if LOCALE is nil. However, if LOCALE is
473 given, then this function will attempt to add VALUE as the 604 given, then this function will attempt to add VALUE as the
474 instantiator for the given LOCALE, using `add-spec-to-specifier'. 605 instantiator for the given LOCALE, using `add-spec-to-specifier'.
475 If the value of the property is not a specifier, it will 606 If the value of the property is not a specifier, it will
476 automatically be converted into a 'generic specifier. 607 automatically be converted into a `generic' specifier.
477 608
478 609
479 The following symbols have predefined meanings: 610 The following symbols have predefined meanings:
480 611
481 image The image used to display the glyph. 612 image The image used to display the glyph.
525 (defun glyph-image (glyph &optional locale) 656 (defun glyph-image (glyph &optional locale)
526 "Return the image of GLYPH in LOCALE, or nil if it is unspecified. 657 "Return the image of GLYPH in LOCALE, or nil if it is unspecified.
527 658
528 LOCALE may be a locale (the instantiators for that particular locale 659 LOCALE may be a locale (the instantiators for that particular locale
529 will be returned), a locale type (the specifications for all locales 660 will be returned), a locale type (the specifications for all locales
530 of that type will be returned), 'all (all specifications will be 661 of that type will be returned), `all' (all specifications will be
531 returned), or nil (the actual specifier object will be returned). 662 returned), or nil (the actual specifier object will be returned).
532 663
533 See `glyph-property' for more information." 664 See `glyph-property' for more information."
534 (glyph-property glyph 'image locale)) 665 (glyph-property glyph 'image locale))
535 666
559 a list of (possibly tagged) instantiators, an alist of specifications 690 a list of (possibly tagged) instantiators, an alist of specifications
560 (each mapping a locale to an instantiator list), or an image specifier 691 (each mapping a locale to an instantiator list), or an image specifier
561 object. 692 object.
562 693
563 If SPEC is an alist, LOCALE must be omitted. If SPEC is a 694 If SPEC is an alist, LOCALE must be omitted. If SPEC is a
564 specifier object, LOCALE can be a locale, a locale type, 'all, 695 specifier object, LOCALE can be a locale, a locale type, `all',
565 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE 696 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE
566 specifies the locale under which the specified instantiator(s) 697 specifies the locale under which the specified instantiator(s)
567 will be added, and defaults to 'global. 698 will be added, and defaults to `global.'
568 699
569 See `set-glyph-property' for more information." 700 See `set-glyph-property' for more information."
570 ; (interactive (glyph-interactive "image")) 701 ; (interactive (glyph-interactive "image"))
571 (set-glyph-property glyph 'image spec locale tag-set how-to-add)) 702 (set-glyph-property glyph 'image spec locale tag-set how-to-add))
572 703
573 (defun glyph-contrib-p (glyph &optional locale) 704 (defun glyph-contrib-p (glyph &optional locale)
574 "Return whether GLYPH contributes to its line height. 705 "Return whether GLYPH contributes to its line height.
575 706
576 LOCALE may be a locale (the instantiators for that particular locale 707 LOCALE may be a locale (the instantiators for that particular locale
577 will be returned), a locale type (the specifications for all locales 708 will be returned), a locale type (the specifications for all locales
578 of that type will be returned), 'all (all specifications will be 709 of that type will be returned), `all' (all specifications will be
579 returned), or nil (the actual specifier object will be returned). 710 returned), or nil (the actual specifier object will be returned).
580 711
581 See `glyph-property' for more information." 712 See `glyph-property' for more information."
582 (glyph-property glyph 'contrib-p locale)) 713 (glyph-property glyph 'contrib-p locale))
583 714
584 (defun glyph-contrib-p-instance (glyph &optional domain default no-fallback) 715 (defun glyph-contrib-p-instance (glyph &optional domain default no-fallback)
585 "Return the instance of GLYPH's 'contrib-p property in DOMAIN. 716 "Return the instance of GLYPH's `contrib-p' property in DOMAIN.
586 717
587 Normally DOMAIN will be a window or nil (meaning the selected window), 718 Normally DOMAIN will be a window or nil (meaning the selected window),
588 and an instance object describing what the 'contrib-p property is in 719 and an instance object describing what the `contrib-p' property is in
589 that particular window and buffer will be returned. 720 that particular window and buffer will be returned.
590 721
591 See `glyph-property-instance' for more information." 722 See `glyph-property-instance' for more information."
592 (glyph-property-instance glyph 'contrib-p domain default no-fallback)) 723 (glyph-property-instance glyph 'contrib-p domain default no-fallback))
593 724
597 SPEC should be an instantiator (t or nil), a list of (possibly 728 SPEC should be an instantiator (t or nil), a list of (possibly
598 tagged) instantiators, an alist of specifications (each mapping a 729 tagged) instantiators, an alist of specifications (each mapping a
599 locale to an instantiator list), or a boolean specifier object. 730 locale to an instantiator list), or a boolean specifier object.
600 731
601 If SPEC is an alist, LOCALE must be omitted. If SPEC is a 732 If SPEC is an alist, LOCALE must be omitted. If SPEC is a
602 specifier object, LOCALE can be a locale, a locale type, 'all, 733 specifier object, LOCALE can be a locale, a locale type, `all',
603 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE 734 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE
604 specifies the locale under which the specified instantiator(s) 735 specifies the locale under which the specified instantiator(s)
605 will be added, and defaults to 'global. 736 will be added, and defaults to `global.'
606 737
607 See `set-glyph-property' for more information." 738 See `set-glyph-property' for more information."
608 ; (interactive (glyph-interactive "contrib-p")) 739 ; (interactive (glyph-interactive "contrib-p"))
609 (set-glyph-property glyph 'contrib-p spec locale tag-set how-to-add)) 740 (set-glyph-property glyph 'contrib-p spec locale tag-set how-to-add))
610 741
611 (defun glyph-baseline (glyph &optional locale) 742 (defun glyph-baseline (glyph &optional locale)
612 "Return the baseline of GLYPH in LOCALE, or nil if it is unspecified. 743 "Return the baseline of GLYPH in LOCALE, or nil if it is unspecified.
613 744
614 LOCALE may be a locale (the instantiators for that particular locale 745 LOCALE may be a locale (the instantiators for that particular locale
615 will be returned), a locale type (the specifications for all locales 746 will be returned), a locale type (the specifications for all locales
616 of that type will be returned), 'all (all specifications will be 747 of that type will be returned), `all' (all specifications will be
617 returned), or nil (the actual specifier object will be returned). 748 returned), or nil (the actual specifier object will be returned).
618 749
619 See `glyph-property' for more information." 750 See `glyph-property' for more information."
620 (glyph-property glyph 'baseline locale)) 751 (glyph-property glyph 'baseline locale))
621 752
636 baseline of the line the glyph is on] or nil), a list of (possibly 767 baseline of the line the glyph is on] or nil), a list of (possibly
637 tagged) instantiators, an alist of specifications (each mapping a 768 tagged) instantiators, an alist of specifications (each mapping a
638 locale to an instantiator list), or a generic specifier object. 769 locale to an instantiator list), or a generic specifier object.
639 770
640 If SPEC is an alist, LOCALE must be omitted. If SPEC is a 771 If SPEC is an alist, LOCALE must be omitted. If SPEC is a
641 specifier object, LOCALE can be a locale, a locale type, 'all, 772 specifier object, LOCALE can be a locale, a locale type, `all',
642 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE 773 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE
643 specifies the locale under which the specified instantiator(s) 774 specifies the locale under which the specified instantiator(s)
644 will be added, and defaults to 'global. 775 will be added, and defaults to `global.'
645 776
646 See `set-glyph-property' for more information." 777 See `set-glyph-property' for more information."
647 ; (interactive (glyph-interactive "baseline")) 778 ; (interactive (glyph-interactive "baseline"))
648 (set-glyph-property glyph 'baseline spec locale tag-set how-to-add)) 779 (set-glyph-property glyph 'baseline spec locale tag-set how-to-add))
649 780
666 `image' property or in the terms \"image specifier\", \"image 797 `image' property or in the terms \"image specifier\", \"image
667 instantiator\", or \"image instance\" does not refer to what people 798 instantiator\", or \"image instance\" does not refer to what people
668 normally think of as an image (which in XEmacs is called a 799 normally think of as an image (which in XEmacs is called a
669 \"pixmap\"), but to any graphical element -- a pixmap, a widget, or 800 \"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.) 801 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 802
672 string or a vector; see `make-image-specifier' for a detailed description 803 SPEC-LIST is typically an image instantiator, describing the source for the
673 of the valid image instantiators), but can also be a list of such 804 image data. This is either a vector of the form [FORMAT :KEYWORD DATA ...],
674 instantiators (each one in turn is tried until an image is 805 for example
675 successfully produced), a cons of a locale (frame, buffer, etc.) and 806
676 an instantiator, a list of such conses, or any other form accepted by 807 [jpeg :file \"/user/john/images/myimage.jpg\"]
677 `canonicalize-spec-list'. 808
809 or
810
811 [xbm :data \"/* XPM */\nstatic char * copy[] = {\n...\"]
812
813 or it is a string, either giving a file name or directly specifying inline
814 data. See `make-image-specifier' for a detailed description of valid image
815 instantiators. If the instantiator is a string, XEmacs will convert it
816 into vector form by trying to guess whether a file name or inline data is
817 intended, and what kind of data is inline or in the file. Usually it does
818 a pretty good job. See `console-type-image-conversion-list' for details of
819 how this works.
820
821 If the instantiator specifies data from a file, the data will be read in
822 when `make-glyph' is called and substituted inline into the instantiator,
823 using the :data keyword. This means that the file must exist when the
824 glyph is created, but does not need to exist afterwards (e.g. it may safely
825 be a temporary file).
826
827 When errors occur in the process of reading image data from a file
828 \(e.g. the file does not exist or the data is of the wrong format or
829 corrupted), no Lisp error will currently be signalled. Instead, the
830 instantiator is skipped and warnings will be issued at level `debug'. \(A
831 glyph with no instantiators in it cannot be displayed.) Normally, such
832 warnings are ignored entirely, but you can change this by setting
833 `log-warning-minimum-level'. This is useful if you're trying to debug why
834 particular instantiators are not being processed. (#### We should probably
835 provide a way of getting errors in such circumstances, or even make this
836 the default behavior.)
837
838 Technically, SPEC-LIST can also be a list of image instantiators (each one
839 in turn is tried until an image is successfully produced), a cons of a
840 locale (frame, buffer, etc.) and an instantiator, a list of such conses,
841 or any other form accepted by `canonicalize-spec-list'.
678 842
679 If you're not familiar with specifiers, you should be in order to 843 If you're not familiar with specifiers, you should be in order to
680 understand how glyphs work. The clearest introduction to specifiers 844 understand how glyphs work. The clearest introduction to specifiers
681 is in the Lispref manual, available under Info. (Choose 845 is in the Lispref manual, available under Info. (Choose
682 Help->Info->Info Contents on the menubar or type \\[info].) You can 846 Help->Info->Info Contents on the menubar or type \\[info].) You can
732 individual glyphs in a toolbar later on. For example, you can 896 individual glyphs in a toolbar later on. For example, you can
733 change the way that the Mail toolbar button looks by modifying the 897 change the way that the Mail toolbar button looks by modifying the
734 value of the variable `toolbar-mail-icon' (in general, `toolbar-*-icon') 898 value of the variable `toolbar-mail-icon' (in general, `toolbar-*-icon')
735 and then calling `(set-specifier-dirty-flag default-toolbar)'. 899 and then calling `(set-specifier-dirty-flag default-toolbar)'.
736 (#### Unfortunately this doesn't quite work the way it should; the 900 (#### Unfortunately this doesn't quite work the way it should; the
737 change will appear in new frames, but not existing ones. 901 change will appear in new frames, but not existing ones.)
738 902
739 -- To insert a glyph into a gutter, create or modify a gutter instantiator 903 -- To insert a glyph into a gutter, create or modify a gutter instantiator
740 (typically set on the specifier `default-gutter'). Gutter instantiators 904 (typically set on the specifier `default-gutter'). Gutter instantiators
741 consist of strings or lists of strings, so to insert a glyph, create an 905 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 906 extent over the string, and use `set-extent-begin-glyph' or
779 any individual character), create the appropriate character glyphs 943 any individual character), create the appropriate character glyphs
780 and then set a specification for the specifier `current-display-table', 944 and then set a specification for the specifier `current-display-table',
781 which controls the appearance of characters. You can also set an 945 which controls the appearance of characters. You can also set an
782 overriding display table for use with text displayed in a particular 946 overriding display table for use with text displayed in a particular
783 face; see `set-face-display-table' and `make-display-table'. 947 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 948
788 -- To use a glyph as the background pixmap of a face: Note that the 949 -- 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 950 background pixmap of a face is actually an image specifier -- probably
790 the only place in XEmacs where an image specifier occurs outside of 951 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 952 a glyph. Similarly to how the glyph's image specifier works, you
970 (if (null value) 1131 (if (null value)
971 (remove-specifier harg 'global) 1132 (remove-specifier harg 'global)
972 (set-glyph-image (symbol-value harg) value)))) 1133 (set-glyph-image (symbol-value harg) value))))
973 1134
974 ;; It might or might not be garbage, but it's rude. Make these 1135 ;; It might or might not be garbage, but it's rude. Make these
975 ;; 'compatible instead of 'obsolete. -slb 1136 ;; `compatible' instead of `obsolete.' -slb
976 (defun define-obsolete-pointer-glyph (old new) 1137 (defun define-obsolete-pointer-glyph (old new)
977 (define-compatible-variable-alias old new) 1138 (define-compatible-variable-alias old new)
978 (dontusethis-set-symbol-value-handler 1139 (dontusethis-set-symbol-value-handler
979 old 'set-value 'dontusethis-old-pointer-shape-handler new)) 1140 old 'set-value 'dontusethis-old-pointer-shape-handler new))
980 1141