Mercurial > hg > xemacs-beta
annotate lisp/glyphs.el @ 4522:fc7067b7f407
Backout last patch; forgot to specify file.
author | Stephen J. Turnbull <stephen@xemacs.org> |
---|---|
date | Wed, 29 Oct 2008 03:37:16 +0900 |
parents | 6a17ac5da3c4 |
children | 7191a7b120f1 |
rev | line source |
---|---|
428 | 1 ;;; glyphs.el --- Lisp interface to C glyphs |
2 | |
3 ;; Copyright (C) 1994, 1997 Free Software Foundation, Inc. | |
2607 | 4 ;; Copyright (C) 1995, 1996, 2000, 2005 Ben Wing. |
4226 | 5 ;; Copyright (C) 2007 Didier Verna |
428 | 6 |
7 ;; Author: Chuck Thompson <cthomp@cs.uiuc.edu>, Ben Wing <ben@xemacs.org> | |
8 ;; Maintainer: XEmacs Development Team | |
9 ;; Keywords: extensions, internal, dumped | |
10 | |
11 ;; This file is part of XEmacs. | |
12 | |
13 ;; XEmacs is free software; you can redistribute it and/or modify it | |
14 ;; under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; XEmacs is distributed in the hope that it will be useful, but | |
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 ;; General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with XEmacs; see the file COPYING. If not, write to the | |
25 ;; Free Software Foundation, 59 Temple Place - Suite 330, | |
26 ;; Boston, MA 02111-1307, USA. | |
27 | |
28 ;;; Synched up with: Not in FSF. | |
29 | |
442 | 30 ;;; Authorship: |
31 | |
32 ;; Prototype created 1995 by Chuck Thompson. | |
33 ;; Completely rewritten by Ben Wing, 1995. | |
34 ;; Various cleanups (esp. doc strings) by Ben Wing, May 2000. | |
35 | |
428 | 36 ;;; Commentary: |
37 | |
38 ;; This file is dumped with XEmacs. | |
39 | |
40 ;;; Code: | |
41 | |
442 | 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; image specifiers |
428 | 43 |
44 (defun make-image-specifier (spec-list) | |
45 "Return a new `image' specifier object with the specification list SPEC-LIST. | |
46 SPEC-LIST can be a list of specifications (each of which is a cons of a | |
47 locale and a list of instantiators), a single instantiator, or a list | |
48 of instantiators. See `make-specifier' for more information about | |
442 | 49 specifiers. |
50 | |
2607 | 51 The main purpose of this doc string is to describe the possible formats for |
52 image instantiators, as given as an argument to `make-glyph' or | |
53 `set-glyph-image'. | |
442 | 54 |
55 An image instantiator should be a string or a vector of the form | |
56 | |
57 [FORMAT :KEYWORD VALUE ...] | |
58 | |
59 i.e. a format symbol followed by zero or more alternating keyword-value | |
2607 | 60 pairs. The vector form of an image instantiator explicitly specifies the |
61 format of the image and other relevant properties. The string form | |
62 specifies only a filename or gives inline data of an unspecified format, | |
63 and XEmacs must guess the actual format. Once it has done this, it | |
64 internally converts the instantiator into the vector format. This is | |
65 described in more detail below. | |
442 | 66 |
2607 | 67 Following is a list of the possible values for FORMAT. After each |
68 description, the allowable keywords for the format are listed in brackets, | |
69 followed by the possible image instance types that can be generated from | |
70 this format. (Image instance types will be discussed below.) | |
71 | |
72 `nothing' | |
442 | 73 Don't display anything; no keywords are valid for this. |
2607 | 74 [] (nothing) |
75 `string' | |
76 Display this image as a text string. Support for instantiating as | |
77 `mono-pixmap' and `color-pixmap' should probably be added. | |
78 [:data] (text) | |
79 `formatted-string' | |
80 Display this image as a text string, with replaceable fields. | |
81 Not currently implemented -- it's treated like `string'. | |
82 [:data] (text) | |
83 `gif' | |
84 A GIF87 or GIF89 image; only if GIF support was compiled into this | |
85 XEmacs. NOTE: Only the first frame of animated gifs will be displayed. | |
86 [:data, :file] (color-pixmap, pointer) | |
87 `jpeg' | |
88 A JPEG image; only if JPEG support was compiled into this XEmacs. | |
89 [:data, :file] (color-pixmap, pointer) | |
90 `png' | |
91 A PNG image; only if PNG support was compiled into this XEmacs. | |
92 [:data, :file] (color-pixmap, pointer) | |
93 `tiff' | |
94 A TIFF image; only if TIFF support was compiled into this XEmacs. | |
95 [:data, :file] (color-pixmap, pointer) | |
96 `bmp' | |
97 A MS Windows BMP image; only if MS Windows support was compiled into | |
98 this XEmacs. | |
99 [:data, :file] (color-pixmap, pointer) | |
100 `xbm' | |
101 An X bitmap; exists if any window-system support was compiled into this | |
102 XEmacs. | |
103 [:data, :file, :foreground, :background, :mask-data, :mask-file, | |
104 :hotspot-x, :hotspot-y] (mono-pixmap, color-pixmap, pointer) | |
105 `xpm' | |
442 | 106 An XPM pixmap; only if XPM support was compiled into this XEmacs. |
2607 | 107 [:data, :file, :color-symbols] (mono-pixmap, color-pixmap, pointer) |
108 `xface' | |
442 | 109 An X-Face bitmap, used to encode people's faces in e-mail messages; |
2607 | 110 only if X-Face support was compiled into this XEmacs. |
111 [:data, :file, :foreground, :background, :mask-data, :mask-file, | |
112 :hotspot-x, :hotspot-y] (mono-pixmap, color-pixmap, pointer) | |
113 `cursor-font' | |
114 X and GTK only. One of the standard cursor-font names, such as \"watch\" | |
115 or \"right_ptr\" under X. Under X, this is, more specifically, any | |
442 | 116 of the standard cursor names from appendix B of the Xlib manual |
117 [also known as the file <X11/cursorfont.h>] minus the XC_ prefix. | |
118 On other window systems, the valid names will be specific to the | |
2607 | 119 type of window system. |
120 [:data, :foreground, :background] (pointer) | |
121 `mswindows-resource' | |
442 | 122 An MS Windows pointer resource. Specifies a resource to retrieve |
123 directly from the system (an OEM resource) or from a file, particularly | |
124 an executable file. If the resource is to be retrieved from a file, use | |
125 :file and optionally :resource-id. Otherwise use :resource-id. Always | |
126 specify :resource-type to specify the type (cursor, bitmap or icon) of | |
2607 | 127 the resource. Possible values for :resource-id are listed below. |
128 [:file, :resource-type, :resource-id] (pointer, color-pixmap) | |
129 `font' | |
442 | 130 A glyph from a font; i.e. the name of a font, and glyph index into it |
131 of the form \"FONT fontname index [[mask-font] mask-index]\". | |
2607 | 132 Currently can only be instantiated as `pointer', although this should |
442 | 133 probably be fixed. |
2607 | 134 [:data, :foreground, :background] (pointer) |
135 `subwindow' | |
136 An embedded windowing system window. | |
137 [:pixel-width, :pixel-height] (subwindow) | |
138 `button' | |
442 | 139 A button widget; either a push button, radio button or toggle button. |
2607 | 140 [WIDGET-KEYWORDS, GUI-KEYWORDS, :image] (widget) |
141 `combo-box' | |
442 | 142 A drop list of selectable items in a widget, for editing text. |
2607 | 143 [GUI-KEYWORDS, :width, :height, :pixel-width, :face, :items] (widget) |
144 `edit-field' | |
145 A text editing widget. | |
146 [WIDGET-KEYWORDS, GUI-KEYWORDS] (widget) | |
147 `label' | |
148 A static, text-only, widget; for displaying text. | |
149 [WIDGET-KEYWORDS, :descriptor] (widget) | |
150 `layout' | |
442 | 151 A widget for controlling the positioning of children underneath it. |
152 Through the use of nested layouts, a widget hierarchy can be created | |
153 which can have the appearance of any standard dialog box or similar | |
154 arrangement; all of this is counted as one \"glyph\" and could appear | |
2607 | 155 in many of the places that expect a single glyph. |
156 [WIDGET-KEYWORDS, GUI-KEYWORDS, :orientation, :justify, :vertically-justify, | |
157 :horizontally-justify, :border, :margin-width, :items] (widget) | |
158 `native-layout' | |
442 | 159 The native version of a layout widget. #### Document me better! |
2607 | 160 [WIDGET-KEYWORDS, GUI-KEYWORDS] (widget) |
161 `progress-gauge' | |
162 A sliding widget, for showing progress. | |
163 [WIDGET-KEYWORDS, GUI-KEYWORDS, :value] (widget) | |
164 `tab-control' | |
165 A tab widget; a series of user selectable tabs. | |
166 [WIDGET-KEYWORDS, GUI-KEYWORDS, :orientation, :items] (widget) | |
167 `tree-view' | |
168 A folding widget. | |
169 [WIDGET-KEYWORDS, GUI-KEYWORDS, :items] (widget) | |
170 `scrollbar' | |
171 A scrollbar widget. | |
172 [GUI-KEYWORDS, :pixel-width, :face, :items] (widget) | |
173 `autodetect' | |
442 | 174 XEmacs tries to guess what format the data is in. If X support |
175 exists, the data string will be checked to see if it names a filename. | |
176 If so, and this filename contains XBM or XPM data, the appropriate | |
177 sort of pixmap or pointer will be created. [This includes picking up | |
178 any specified hotspot or associated mask file.] Otherwise, if `pointer' | |
179 is one of the allowable image-instance types and the string names a | |
180 valid cursor-font name, the image will be created as a pointer. | |
181 Otherwise, the image will be displayed as text. If no X support | |
2607 | 182 exists, the image will always be displayed as text. |
183 [:data] (mono-pixmap, color-pixmap, pointer, text) | |
184 `inherit' | |
185 Inherit from the background-pixmap property of a face. | |
186 [:face] (mono-pixmap) | |
442 | 187 |
188 The valid keywords are: | |
189 | |
190 :data | |
191 Inline data. For most formats above, this should be a string. For | |
192 XBM images, this should be a list of three elements: width, height, and | |
193 a string of bit data. This keyword is valid for all of the bitmap/pixmap | |
194 formats, as well as `string', `formatted-string', `font', `cursor-font', | |
195 and `autodetect'. | |
196 :file | |
197 Data is contained in a file. The value is the name of this file. | |
198 If both :data and :file are specified, the image is created from | |
199 what is specified in :data and the string in :file becomes the | |
200 value of the `image-instance-file-name' function when applied to | |
201 the resulting image-instance. This keyword is valid for all of the | |
202 bitmap/pixmap formats as well as `mswindows-resource'. | |
203 :foreground | |
204 :background | |
205 For `xbm', `xface', `cursor-font', `widget' and `font'. These keywords | |
206 allow you to explicitly specify foreground and background colors. | |
207 The argument should be anything acceptable to `make-color-instance'. | |
208 This will cause what would be a `mono-pixmap' to instead be colorized | |
209 as a two-color color-pixmap, and specifies the foreground and/or | |
210 background colors for a pointer instead of black and white. | |
211 :mask-data | |
212 For `xbm' and `xface'. This specifies a mask to be used with the | |
213 bitmap. The format is a list of width, height, and bits, like for | |
214 :data. | |
215 :mask-file | |
216 For `xbm' and `xface'. This specifies a file containing the mask data. | |
217 If neither a mask file nor inline mask data is given for an XBM image, | |
218 and the XBM image comes from a file, XEmacs will look for a mask file | |
219 with the same name as the image file but with \"Mask\" or \"msk\" | |
220 appended. For example, if you specify the XBM file \"left_ptr\" | |
221 [usually located in \"/usr/include/X11/bitmaps\"], the associated | |
222 mask file \"left_ptrmsk\" will automatically be picked up. | |
223 :hotspot-x | |
224 :hotspot-y | |
225 For `xbm' and `xface'. These keywords specify a hotspot if the image | |
226 is instantiated as a `pointer'. Note that if the XBM image file | |
227 specifies a hotspot, it will automatically be picked up if no | |
228 explicit hotspot is given. | |
229 :color-symbols | |
230 Only for `xpm'. This specifies an alist that maps strings | |
231 that specify symbolic color names to the actual color to be used | |
232 for that symbolic color (in the form of a string or a color-specifier | |
233 object). If this is not specified, the contents of `xpm-color-symbols' | |
234 are used to generate the alist. | |
235 :resource-id | |
236 Only for `mswindows-resource'. This must be either an integer (which | |
237 directly specifies a resource number) or a string. Valid strings are | |
238 | |
239 -- For bitmaps: | |
240 | |
241 \"close\", \"uparrow\", \"dnarrow\", \"rgarrow\", \"lfarrow\", | |
242 \"reduce\", \"zoom\", \"restore\", \"reduced\", \"zoomd\", | |
243 \"restored\", \"uparrowd\", \"dnarrowd\", \"rgarrowd\", \"lfarrowd\", | |
244 \"mnarrow\", \"combo\", \"uparrowi\", \"dnarrowi\", \"rgarrowi\", | |
245 \"lfarrowi\", \"size\", \"btsize\", \"check\", \"checkboxes\", and | |
246 \"btncorners\". | |
247 | |
2607 | 248 -- For pointers: |
442 | 249 |
250 \"normal\", \"ibeam\", \"wait\", \"cross\", \"up\", \"sizenwse\", | |
251 \"sizenesw\", \"sizewe\", \"sizens\", \"sizeall\", and \"no\". | |
252 | |
253 -- For icons: | |
254 | |
255 \"sample\", \"hand\", \"ques\", \"bang\", \"note\", and \"winlogo\". | |
256 :resource-type | |
2607 | 257 Only for `mswindows-resource'. This must be a symbol, either `cursor' |
258 (i.e. pointer), `icon', or `bitmap', specifying the type of resource to | |
259 be retrieved. | |
442 | 260 :face |
261 Only for `inherit'. This specifies the face to inherit from. | |
262 For widgets this also specifies the face to use for display. It defaults | |
263 to gui-element-face. | |
2607 | 264 :pixel-width, :pixel-height |
265 Width and height of element, in pixels. For `subwindow', the values | |
266 must be integers. For widgets, the values can be integers or | |
267 expressions that evaluate to integers. | |
442 | 268 |
2607 | 269 \[WIDGET-KEYWORDS] stands for the standard keywords accepted by widgets: |
442 | 270 These are `:selected', `:active', `:suffix', `:keys', `:style', |
271 `:filter', `:config', `:included', `:key-sequence', `:accelerator', | |
2607 | 272 `:label', `:callback', `:initial-focus', and `:descriptor'. |
273 #### Document me. | |
274 | |
275 \[GUI-KEYWORDS] stands for keywords accepted by many widgets. | |
276 These are `:width', `:height', `:pixel-width', `:pixel-height', and `:face'. | |
277 #### Document me. | |
442 | 278 |
279 If instead of a vector, the instantiator is a string, it will be | |
280 converted into a vector by looking it up according to the specs in the | |
281 `console-type-image-conversion-list' (q.v.) for the console type of | |
282 the domain (usually a window; sometimes a frame or device) over which | |
283 the image is being instantiated. | |
284 | |
285 If the instantiator specifies data from a file, the data will be read | |
286 in at the time that the instantiator is added to the image (which may | |
287 be well before when the image is actually displayed), and the | |
288 instantiator will be converted into one of the inline-data forms, with | |
289 the filename retained using a :file keyword. This implies that the | |
290 file must exist when the instantiator is added to the image, but does | |
291 not need to exist at any other time (e.g. it may safely be a temporary | |
292 file). | |
2607 | 293 |
294 NOTE: In practice, you rarely, if ever, need to actually | |
295 create an image specifier! (The function `make-image-specifier' exists | |
296 mainly for completeness.) Pretty much the only use for image specifiers is | |
297 to control how glyphs are displayed, and the image specifier associated | |
298 with a glyph (the `image' property of a glyph) is created automatically | |
299 when a glyph is created (see `make-glyph') and need not \(and cannot, for | |
300 that matter) ever be changed. In fact, the design decision to create a | |
301 separate image specifier type, rather than make glyphs themselves be | |
302 specifiers, is debatable -- the other properties of glyphs are rarely used | |
303 and could conceivably have been incorporated into the glyph's instantiator. | |
304 The rarely used glyph types (buffer, pointer, icon) could also have been | |
305 incorporated into the instantiator. | |
306 | |
307 An image specifier is used for images (pixmaps, widgets and the like). It | |
308 is used to describe the actual image in a glyph. It is instantiated \(see | |
309 `specifier-instance') as an image-instance. Note that \"image\" as used in | |
310 XEmacs does not actually refer to what the term \"image\" normally means (a | |
311 picture, e.g. in .GIF or .JPG format, and called a \"pixmap\" in XEmacs), | |
312 but includes all types of graphical elements, including pixmaps, widgets | |
313 \(buttons, sliders, text fields, etc.) and even strings of text. | |
314 | |
315 There is an important distinction to be made between image instantiators | |
316 and image instances, and \"image instantiator formats\" and \"image | |
317 instance types\", analogous to the distinction between source and | |
318 destination. An image instantiator describes the source data for an image. | |
319 An image instance encapsulates the resulting window-system object used to | |
320 display the image. Image instantiator formats are the formats of the | |
321 source: This includes familiar and less-familiar graphics formats such as | |
322 `gif', `jpeg', `png' and `xpm'; widget types such as `button', `edit-field' | |
323 and `combo-box'; and other beasts such as `string' (plain text, which could | |
324 potentially behave like text when placed in a buffer, such as wrapping), | |
325 `font' (a single character from a particular font, specified by the index | |
326 into the font), etc. Image instance types are the (destination) types of | |
327 the resulting image instance. Different image instance types correspond to | |
328 fundamentally different appearance and behaviors for the resulting image, | |
329 specifically: | |
330 | |
331 -- `color-pixmap' (a color image); | |
332 -- `mono-pixmap' (a \"monochrome\" image, technically a two-color image | |
333 that comes in two unspecified shades \"foreground\" and \"background\", | |
334 determined from the face [see `make-face'] of the glyph or surrounding | |
335 text); | |
336 -- `text' (a string of text appearing somewhere in a buffer's text or | |
337 margins, which has an unspecified foreground, background, and font | |
338 derived from the surrounding text or other external property and which | |
339 behaves in many respects like an image but can wrap across the end of a | |
340 line to the beginning of the next); | |
341 -- `pointer' (the mouse pointer for a window; this is a combination of a | |
342 rectangular pixmap image, a monochrome mask that specifies the | |
343 transparency of the image [i.e. in which places the underlying screen | |
344 image can show through, and how much of it], and a \"hotspot\" that | |
345 indicates which pixel in the pointer's image is considered the actual | |
346 pointer location -- for example, this will be located near the tip of | |
347 an arrow, in the middle of a crosshairs, somewhere along an i-beam, etc.); | |
348 -- `widget' (a window-system object or \"widget\" that interacts with the | |
349 user, such as a button, edit-field or combo-box); | |
350 -- `subwindow' (a rectangular area that another program can draw into); | |
351 -- `nothing' (no display). | |
352 | |
353 There is not a one-to-one mapping between source (image instantiator) | |
354 formats and destination (image instance) types. For example, the source | |
355 format `xpm' can generate the image instance types `color-pixmap', | |
356 `mono-pixmap', or `pointer', and the image instance type `color-pixmap' can | |
357 be generated by any of `gif', `jpeg', `png', `tiff', `xpm', `xbm' and | |
358 `xface'. | |
359 | |
360 In general, the user or programmer specifies the image instantiator format, | |
361 while the appropriate image instance type is determined automatically by | |
362 XEmacs from the image instantiator format, from the data in the | |
363 instantiator and from the particular situation the image (and the glyph | |
364 that holds it) is being used in. (However, it's possible to explicitly | |
365 create image instances and control their types; see `make-image-instance'.) | |
366 For example, a glyph used to specify the shape of a mouse pointer can only | |
367 result in `pointer'-type image instances, and a glyph used for an icon can | |
368 only result in `color-pixmap' image instances. A glyph used in a buffer | |
369 can potentially result in any image instance type except for `pointer', but | |
370 particular instantiator formats have only a limited set of image instance | |
371 types they will support. Here is an example of how the image instance type | |
372 for an `xpm' instantiator (which can potentially support `color-pixmap', | |
373 `mono-pixmap', or `pointer') is determined: | |
374 | |
375 1. If the glyph is being used for a mouse pointer (hence its `glyph-type' | |
376 is `pointer'), it can be instantiated only a `pointer'-type image instance. | |
377 2. If the glyph is being used for an icon (hence its `glyph-type' is `icon'), | |
378 it can be instantiated only a `color-pixmap'-type image instance. | |
379 3. Otherwise, the glyph is being used somewhere inside a frame (`glyph-type' | |
380 of `buffer') and any image instance type except `pointer' can be | |
381 supported. In this case, this means `color-pixmap' or `mono-pixmap'. | |
382 Which one will result depends on the particular data being processed, | |
383 since XPM images can specify whether they are color or mono. | |
384 | |
385 Note again that \"mono\" does *NOT* simply mean \"an image with two | |
386 colors\". The latter image has two prespecified colors, e.g. red and blue | |
387 or black and white, and will always appear with those colors, no matter | |
388 what the context. A mono image has two *unspecified* colors, symbolically | |
389 named \"foreground\" and \"background\", and the actual values for those | |
390 colors depends on context. A mono pixmap displayed among text will take | |
391 its foreground and background from that of the text and hence blend in | |
392 nicely; a two-color color pixmap won't do that. | |
393 | |
394 Note also that `color-pixmap' image instances can be generated from the | |
395 supported pixmap formats that are inherently mono (i.e. `xbm' and `xface') | |
396 by specifying :foreground and :background values. | |
397 | |
398 A table of the various image instantiator formats and the possible | |
399 destination (image instance) types that can be generated from them is as | |
400 follows: | |
401 | |
402 | |
403 color-pixmap mono-pixmap text pointer widget subwindow noth. | |
404 ------------------------------------------------------------------------------- | |
405 nothing + | |
406 string + | |
407 formatted-string + | |
408 xbm + + + | |
409 xpm + + + | |
410 xface + + + | |
411 gif + + | |
412 jpeg + + | |
413 png + + | |
414 tiff + + | |
415 bmp + + | |
416 cursor-font + | |
417 mswindows-resource + + | |
418 font + | |
419 subwindow + | |
420 button + | |
421 combo-box + | |
422 edit-field + | |
423 label + | |
424 layout + | |
425 native-layout + | |
426 progress-gauge + | |
427 tab-control + | |
428 tree-view + | |
429 scrollbar + | |
430 autodetect + + + + | |
431 inherit + | |
432 | |
433 See `make-image-instance' for a more detailed discussion of image | |
434 instance types." | |
428 | 435 (make-specifier-and-init 'image spec-list)) |
436 | |
437 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; glyphs | |
438 | |
439 (defconst built-in-glyph-specifiers | |
440 '(image contrib-p baseline) | |
442 | 441 "A list of the built-in glyph properties that are specifiers.") |
428 | 442 |
443 (defun glyph-property (glyph property &optional locale) | |
444 "Return GLYPH's value of PROPERTY in LOCALE. | |
445 | |
446 If LOCALE is omitted, the GLYPH's actual value for PROPERTY will be | |
447 returned. For built-in properties, this will be a specifier object | |
448 of a type appropriate to the property (e.g. a font or color | |
449 specifier). For other properties, this could be anything. | |
450 | |
451 If LOCALE is supplied, then instead of returning the actual value, | |
452 the specification(s) for the given locale or locale type will | |
453 be returned. This will only work if the actual value of | |
454 PROPERTY is a specifier (this will always be the case for built-in | |
455 properties, but not or not may apply to user-defined properties). | |
456 If the actual value of PROPERTY is not a specifier, this value | |
457 will simply be returned regardless of LOCALE. | |
458 | |
459 The return value will be a list of instantiators (e.g. strings | |
460 specifying a font or color name), or a list of specifications, each | |
461 of which is a cons of a locale and a list of instantiators. | |
462 Specifically, if LOCALE is a particular locale (a buffer, window, | |
2607 | 463 frame, device, or `global'), a list of instantiators for that locale |
428 | 464 will be returned. Otherwise, if LOCALE is a locale type (one of |
2607 | 465 the symbols `buffer', `window', `frame', `device', `device-class', or |
466 `device-type'), the specifications for all locales of that type will | |
467 be returned. Finally, if LOCALE is `all', the specifications for all | |
428 | 468 locales of all types will be returned. |
469 | |
470 The specifications in a specifier determine what the value of | |
471 PROPERTY will be in a particular \"domain\" or set of circumstances, | |
472 which is typically a particular Emacs window along with the buffer | |
473 it contains and the frame and device it lies within. The value | |
474 is derived from the instantiator associated with the most specific | |
2607 | 475 locale (in the order buffer, window, frame, device, and `global') |
428 | 476 that matches the domain in question. In other words, given a domain |
477 (i.e. an Emacs window, usually), the specifier for PROPERTY will first | |
478 be searched for a specification whose locale is the buffer contained | |
479 within that window; then for a specification whose locale is the window | |
480 itself; then for a specification whose locale is the frame that the | |
481 window is contained within; etc. The first instantiator that is | |
482 valid for the domain (usually this means that the instantiator is | |
483 recognized by the device [i.e. the X server or TTY device] that the | |
484 domain is on. The function `glyph-property-instance' actually does | |
485 all this, and is used to determine how to display the glyph. | |
486 | |
487 See `set-glyph-property' for the built-in property-names." | |
488 (check-argument-type 'glyphp glyph) | |
489 (let ((value (get glyph property))) | |
490 (if (and locale | |
491 (or (memq property built-in-glyph-specifiers) | |
492 (specifierp value))) | |
493 (setq value (specifier-specs value locale))) | |
494 value)) | |
495 | |
496 (defun convert-glyph-property-into-specifier (glyph property) | |
497 "Convert PROPERTY on GLYPH into a specifier, if it's not already." | |
498 (check-argument-type 'glyphp glyph) | |
499 (let ((specifier (get glyph property))) | |
500 ;; if a user-property does not have a specifier but a | |
501 ;; locale was specified, put a specifier there. | |
502 ;; If there was already a value there, convert it to a | |
2607 | 503 ;; specifier with the value as its `global' instantiator. |
428 | 504 (if (not (specifierp specifier)) |
505 (let ((new-specifier (make-specifier 'generic))) | |
506 (if (or (not (null specifier)) | |
507 ;; make sure the nil returned from `get' wasn't | |
508 ;; actually the value of the property | |
509 (null (get glyph property t))) | |
510 (add-spec-to-specifier new-specifier specifier)) | |
511 (setq specifier new-specifier) | |
512 (put glyph property specifier))))) | |
513 | |
514 (defun glyph-property-instance (glyph property | |
515 &optional domain default no-fallback) | |
516 "Return the instance of GLYPH's PROPERTY in the specified DOMAIN. | |
517 | |
518 Under most circumstances, DOMAIN will be a particular window, | |
519 and the returned instance describes how the specified property | |
520 actually is displayed for that window and the particular buffer | |
521 in it. Note that this may not be the same as how the property | |
522 appears when the buffer is displayed in a different window or | |
523 frame, or how the property appears in the same window if you | |
524 switch to another buffer in that window; and in those cases, | |
525 the returned instance would be different. | |
526 | |
527 DOMAIN defaults to the selected window if omitted. | |
528 | |
529 DOMAIN can be a frame or device, instead of a window. The value | |
530 returned for a such a domain is used in special circumstances | |
531 when a more specific domain does not apply; for example, a frame | |
532 value might be used for coloring a toolbar, which is conceptually | |
533 attached to a frame rather than a particular window. The value | |
534 is also useful in determining what the value would be for a | |
535 particular window within the frame or device, if it is not | |
536 overridden by a more specific specification. | |
537 | |
538 If PROPERTY does not name a built-in property, its value will | |
539 simply be returned unless it is a specifier object, in which case | |
540 it will be instanced using `specifier-instance'. | |
541 | |
542 Optional arguments DEFAULT and NO-FALLBACK are the same as in | |
543 `specifier-instance'." | |
544 (check-argument-type 'glyphp glyph) | |
545 (let ((value (get glyph property))) | |
546 (if (specifierp value) | |
547 (setq value (specifier-instance value domain default no-fallback))) | |
548 value)) | |
549 | |
550 (defun set-glyph-property (glyph property value &optional locale tag-set | |
551 how-to-add) | |
552 "Change a property of a GLYPH. | |
553 | |
554 NOTE: If you want to remove a property from a glyph, use | |
555 `remove-glyph-property' rather than attempting to set a value of nil | |
556 for the property. | |
557 | |
558 For built-in properties, the actual value of the property is a | |
559 specifier and you cannot change this; but you can change the | |
560 specifications within the specifier, and that is what this function | |
561 will do. For user-defined properties, you can use this function | |
562 to either change the actual value of the property or, if this value | |
563 is a specifier, change the specifications within it. | |
564 | |
565 If PROPERTY is a built-in property, the specifications to be added to | |
566 this property can be supplied in many different ways: | |
567 | |
568 -- If VALUE is a simple instantiator (e.g. a string naming a font or | |
569 color) or a list of instantiators, then the instantiator(s) will | |
570 be added as a specification of the property for the given LOCALE | |
2607 | 571 (which defaults to `global' if omitted). |
428 | 572 -- If VALUE is a list of specifications (each of which is a cons of |
573 a locale and a list of instantiators), then LOCALE must be nil | |
574 (it does not make sense to explicitly specify a locale in this | |
575 case), and specifications will be added as given. | |
576 -- If VALUE is a specifier (as would be returned by `glyph-property' | |
577 if no LOCALE argument is given), then some or all of the | |
578 specifications in the specifier will be added to the property. | |
579 In this case, the function is really equivalent to | |
580 `copy-specifier' and LOCALE has the same semantics (if it is | |
581 a particular locale, the specification for the locale will be | |
582 copied; if a locale type, specifications for all locales of | |
2607 | 583 that type will be copied; if nil or `all', then all |
428 | 584 specifications will be copied). |
585 | |
2607 | 586 HOW-TO-ADD should be either nil or one of the symbols `prepend', |
587 `append', `remove-tag-set-prepend', `remove-tag-set-append', `remove-locale', | |
3061 | 588 `remove-locale-type', or `remove-all'. See `copy-specifier' and |
428 | 589 `add-spec-to-specifier' for a description of what each of |
590 these means. Most of the time, you do not need to worry about | |
591 this argument; the default behavior usually is fine. | |
592 | |
593 In general, it is OK to pass an instance object (e.g. as returned | |
594 by `glyph-property-instance') as an instantiator in place of | |
595 an actual instantiator. In such a case, the instantiator used | |
596 to create that instance object will be used (for example, if | |
2607 | 597 you set a font-instance object as the value of the `font' |
428 | 598 property, then the font name used to create that object will |
599 be used instead). If some cases, however, doing this | |
600 conversion does not make sense, and this will be noted in | |
601 the documentation for particular types of instance objects. | |
602 | |
603 If PROPERTY is not a built-in property, then this function will | |
604 simply set its value if LOCALE is nil. However, if LOCALE is | |
605 given, then this function will attempt to add VALUE as the | |
606 instantiator for the given LOCALE, using `add-spec-to-specifier'. | |
607 If the value of the property is not a specifier, it will | |
2607 | 608 automatically be converted into a `generic' specifier. |
428 | 609 |
610 | |
611 The following symbols have predefined meanings: | |
612 | |
613 image The image used to display the glyph. | |
614 | |
615 baseline Percent above baseline that glyph is to be | |
616 displayed. | |
617 | |
618 contrib-p Whether the glyph contributes to the | |
619 height of the line it's on. | |
620 | |
621 face Face of this glyph (*not* a specifier)." | |
622 (check-argument-type 'glyphp glyph) | |
623 (if (memq property built-in-glyph-specifiers) | |
624 (set-specifier (get glyph property) value locale tag-set how-to-add) | |
625 | |
626 ;; This section adds user defined properties. | |
627 (if (not locale) | |
628 (put glyph property value) | |
629 (convert-glyph-property-into-specifier glyph property) | |
630 (add-spec-to-specifier (get glyph property) value locale tag-set | |
631 how-to-add))) | |
632 value) | |
633 | |
634 (defun remove-glyph-property (glyph property &optional locale tag-set exact-p) | |
635 "Remove a property from a glyph. | |
636 For built-in properties, this is analogous to `remove-specifier'. | |
637 See `remove-specifier' for the meaning of the LOCALE, TAG-SET, and EXACT-P | |
638 arguments." | |
639 (or locale (setq locale 'all)) | |
640 (if (memq property built-in-glyph-specifiers) | |
641 (remove-specifier (glyph-property glyph property) locale tag-set exact-p) | |
642 (if (eq locale 'all) | |
643 (remprop glyph property) | |
644 (convert-glyph-property-into-specifier glyph property) | |
645 (remove-specifier (glyph-property glyph property) locale tag-set | |
646 exact-p)))) | |
647 | |
648 (defun glyph-face (glyph) | |
649 "Return the face of GLYPH." | |
650 (glyph-property glyph 'face)) | |
651 | |
652 (defun set-glyph-face (glyph face) | |
653 "Change the face of GLYPH to FACE." | |
654 ; (interactive (glyph-interactive "face")) | |
655 (set-glyph-property glyph 'face face)) | |
656 | |
657 (defun glyph-image (glyph &optional locale) | |
658 "Return the image of GLYPH in LOCALE, or nil if it is unspecified. | |
659 | |
660 LOCALE may be a locale (the instantiators for that particular locale | |
661 will be returned), a locale type (the specifications for all locales | |
2607 | 662 of that type will be returned), `all' (all specifications will be |
428 | 663 returned), or nil (the actual specifier object will be returned). |
664 | |
665 See `glyph-property' for more information." | |
666 (glyph-property glyph 'image locale)) | |
667 | |
668 (defun glyph-image-instance (glyph &optional domain default no-fallback) | |
669 "Return the instance of GLYPH's image in DOMAIN. | |
670 | |
671 Normally DOMAIN will be a window or nil (meaning the selected window), | |
672 and an instance object describing how the image appears in that | |
673 particular window and buffer will be returned. | |
674 | |
675 See `glyph-property-instance' for more information." | |
676 (glyph-property-instance glyph 'image domain default no-fallback)) | |
677 | |
442 | 678 (defun glyph-image-property (glyph prop &optional domain default no-fallback) |
679 "Return property PROP of the instance of GLYPH's image in DOMAIN. | |
680 | |
681 Normally DOMAIN will be a window or nil (meaning the selected window). | |
682 The value returned is dependent on the image instance type." | |
683 (image-instance-property | |
684 (glyph-image-instance glyph domain default no-fallback) prop)) | |
685 | |
428 | 686 (defun set-glyph-image (glyph spec &optional locale tag-set how-to-add) |
687 "Change the image of GLYPH in LOCALE. | |
688 | |
689 SPEC should be an instantiator (a string or vector; see | |
442 | 690 `make-image-specifier' for a description of possible values here), |
428 | 691 a list of (possibly tagged) instantiators, an alist of specifications |
692 (each mapping a locale to an instantiator list), or an image specifier | |
693 object. | |
694 | |
695 If SPEC is an alist, LOCALE must be omitted. If SPEC is a | |
2607 | 696 specifier object, LOCALE can be a locale, a locale type, `all', |
428 | 697 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE |
698 specifies the locale under which the specified instantiator(s) | |
3061 | 699 will be added, and defaults to `global'. |
428 | 700 |
701 See `set-glyph-property' for more information." | |
702 ; (interactive (glyph-interactive "image")) | |
703 (set-glyph-property glyph 'image spec locale tag-set how-to-add)) | |
704 | |
705 (defun glyph-contrib-p (glyph &optional locale) | |
706 "Return whether GLYPH contributes to its line height. | |
707 | |
708 LOCALE may be a locale (the instantiators for that particular locale | |
709 will be returned), a locale type (the specifications for all locales | |
2607 | 710 of that type will be returned), `all' (all specifications will be |
428 | 711 returned), or nil (the actual specifier object will be returned). |
712 | |
713 See `glyph-property' for more information." | |
714 (glyph-property glyph 'contrib-p locale)) | |
715 | |
716 (defun glyph-contrib-p-instance (glyph &optional domain default no-fallback) | |
2607 | 717 "Return the instance of GLYPH's `contrib-p' property in DOMAIN. |
428 | 718 |
719 Normally DOMAIN will be a window or nil (meaning the selected window), | |
2607 | 720 and an instance object describing what the `contrib-p' property is in |
428 | 721 that particular window and buffer will be returned. |
722 | |
723 See `glyph-property-instance' for more information." | |
724 (glyph-property-instance glyph 'contrib-p domain default no-fallback)) | |
725 | |
726 (defun set-glyph-contrib-p (glyph spec &optional locale tag-set how-to-add) | |
727 "Change the contrib-p property of GLYPH in LOCALE. | |
728 | |
729 SPEC should be an instantiator (t or nil), a list of (possibly | |
730 tagged) instantiators, an alist of specifications (each mapping a | |
731 locale to an instantiator list), or a boolean specifier object. | |
732 | |
733 If SPEC is an alist, LOCALE must be omitted. If SPEC is a | |
2607 | 734 specifier object, LOCALE can be a locale, a locale type, `all', |
428 | 735 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE |
736 specifies the locale under which the specified instantiator(s) | |
3061 | 737 will be added, and defaults to `global'. |
428 | 738 |
739 See `set-glyph-property' for more information." | |
740 ; (interactive (glyph-interactive "contrib-p")) | |
741 (set-glyph-property glyph 'contrib-p spec locale tag-set how-to-add)) | |
742 | |
743 (defun glyph-baseline (glyph &optional locale) | |
744 "Return the baseline of GLYPH in LOCALE, or nil if it is unspecified. | |
745 | |
746 LOCALE may be a locale (the instantiators for that particular locale | |
747 will be returned), a locale type (the specifications for all locales | |
2607 | 748 of that type will be returned), `all' (all specifications will be |
428 | 749 returned), or nil (the actual specifier object will be returned). |
750 | |
751 See `glyph-property' for more information." | |
752 (glyph-property glyph 'baseline locale)) | |
753 | |
754 (defun glyph-baseline-instance (glyph &optional domain default no-fallback) | |
755 "Return the instance of GLYPH's baseline in DOMAIN. | |
756 | |
757 Normally DOMAIN will be a window or nil (meaning the selected window), | |
758 and an integer or nil (specifying the baseline in that particular | |
759 window and buffer) will be returned. | |
760 | |
761 See `glyph-property-instance' for more information." | |
762 (glyph-property-instance glyph 'baseline domain default no-fallback)) | |
763 | |
764 (defun set-glyph-baseline (glyph spec &optional locale tag-set how-to-add) | |
765 "Change the baseline of GLYPH to SPEC in LOCALE. | |
766 | |
767 SPEC should be an instantiator (an integer [a percentage above the | |
768 baseline of the line the glyph is on] or nil), a list of (possibly | |
769 tagged) instantiators, an alist of specifications (each mapping a | |
770 locale to an instantiator list), or a generic specifier object. | |
771 | |
772 If SPEC is an alist, LOCALE must be omitted. If SPEC is a | |
2607 | 773 specifier object, LOCALE can be a locale, a locale type, `all', |
428 | 774 or nil; see `copy-specifier' for its semantics. Otherwise LOCALE |
775 specifies the locale under which the specified instantiator(s) | |
3061 | 776 will be added, and defaults to `global'. |
428 | 777 |
778 See `set-glyph-property' for more information." | |
779 ; (interactive (glyph-interactive "baseline")) | |
780 (set-glyph-property glyph 'baseline spec locale tag-set how-to-add)) | |
781 | |
782 (defun make-glyph (&optional spec-list type) | |
442 | 783 "Create a new glyph of type TYPE. |
784 | |
785 A glyph in XEmacs does NOT refer to a single unit of textual display (the | |
786 XEmacs term for this is \"rune\"), but rather is an object encapsulating | |
787 a graphical element, such as an image or widget (an element such as a | |
788 button or text field; \"widget\" is the term for this under X Windows, | |
789 and it's called a \"control\" under MS Windows). This graphical element | |
790 could appear in a buffer, a margin, a gutter, or a toolbar, or as a mouse | |
791 pointer or an icon, for example. | |
792 | |
793 Creating a glyph using `make-glyph' does not specify *where* the glyph | |
794 will be used, but it does specify *what* the glyph will look like. In | |
795 particular, SPEC-LIST is used to specify this, and it's used to | |
796 initialize the glyph's `image' property, which is an image | |
797 specifier. (Note that \"image\" as used in the context of a glyph's | |
798 `image' property or in the terms \"image specifier\", \"image | |
799 instantiator\", or \"image instance\" does not refer to what people | |
800 normally think of as an image (which in XEmacs is called a | |
801 \"pixmap\"), but to any graphical element -- a pixmap, a widget, or | |
802 even a block of text, when used in the places that call for a glyph.) | |
2607 | 803 |
804 SPEC-LIST is typically an image instantiator, describing the source for the | |
805 image data. This is either a vector of the form [FORMAT :KEYWORD DATA ...], | |
806 for example | |
807 | |
808 [jpeg :file \"/user/john/images/myimage.jpg\"] | |
809 | |
810 or | |
811 | |
812 [xbm :data \"/* XPM */\nstatic char * copy[] = {\n...\"] | |
813 | |
814 or it is a string, either giving a file name or directly specifying inline | |
815 data. See `make-image-specifier' for a detailed description of valid image | |
816 instantiators. If the instantiator is a string, XEmacs will convert it | |
817 into vector form by trying to guess whether a file name or inline data is | |
818 intended, and what kind of data is inline or in the file. Usually it does | |
819 a pretty good job. See `console-type-image-conversion-list' for details of | |
820 how this works. | |
821 | |
822 If the instantiator specifies data from a file, the data will be read in | |
823 when `make-glyph' is called and substituted inline into the instantiator, | |
824 using the :data keyword. This means that the file must exist when the | |
825 glyph is created, but does not need to exist afterwards (e.g. it may safely | |
826 be a temporary file). | |
827 | |
828 When errors occur in the process of reading image data from a file | |
829 \(e.g. the file does not exist or the data is of the wrong format or | |
830 corrupted), no Lisp error will currently be signalled. Instead, the | |
831 instantiator is skipped and warnings will be issued at level `debug'. \(A | |
832 glyph with no instantiators in it cannot be displayed.) Normally, such | |
833 warnings are ignored entirely, but you can change this by setting | |
834 `log-warning-minimum-level'. This is useful if you're trying to debug why | |
835 particular instantiators are not being processed. (#### We should probably | |
836 provide a way of getting errors in such circumstances, or even make this | |
837 the default behavior.) | |
838 | |
839 Technically, SPEC-LIST can also be a list of image instantiators (each one | |
840 in turn is tried until an image is successfully produced), a cons of a | |
841 locale (frame, buffer, etc.) and an instantiator, a list of such conses, | |
842 or any other form accepted by `canonicalize-spec-list'. | |
428 | 843 |
442 | 844 If you're not familiar with specifiers, you should be in order to |
845 understand how glyphs work. The clearest introduction to specifiers | |
846 is in the Lispref manual, available under Info. (Choose | |
847 Help->Info->Info Contents on the menubar or type \\[info].) You can | |
848 also see `make-specifier' for a capsule summary. What's important to | |
849 keep in mind is that a specifier lets you set a different value for | |
850 any particular buffer, window, frame, device, or console. This allows | |
851 for a great deal of flexibility; in particular, only one global glyph | |
852 needs to exist for a particular purpose (e.g. the icon used to represent | |
853 an iconified frame, the mouse pointer used over particular areas of a | |
854 frame, etc.), and in these cases you do not create your own glyph, but | |
855 rather modify the existing one. | |
856 | |
857 As well as using SPEC-LIST to initialize the glyph, you can set | |
858 specifications using `set-glyph-image'. Note that, due to a possibly | |
859 questionable historical design decision, a glyph itself is not | |
860 actually a specifier, but rather is an object containing an image | |
861 specifier (as well as other, seldom-used properties). Therefore, you | |
862 cannot set or access specifications for the glyph's image by directly | |
863 using `set-specifier', `specifier-instance' or the like on the glyph; | |
864 instead use them on `(glyph-image GLYPH)' or use the convenience | |
865 functions `set-glyph-image', `glyph-image-instance', and | |
866 `glyph-image'. | |
867 | |
868 Once you have created a glyph, you specify where it will be used as follows: | |
869 | |
870 -- To insert a glyph into a buffer, create an extent in the buffer and then | |
871 use `set-extent-begin-glyph' or `set-extent-end-glyph' to set a glyph | |
872 to be displayed at the corresponding edge of the extent. (It is common | |
873 to create zero-width extents for this purpose.) | |
874 | |
875 -- To insert a glyph into the left or right margin of a buffer, first | |
876 make sure the margin is visible by setting a value for the specifiers | |
877 `left-margin-width' or `right-margin-width'. (Not strictly necessary | |
878 when using margin glyphs with layout policy `whitespace'.) Then follow | |
879 the same procedure above for inserting a glyph in a buffer, and then | |
880 set a non-default layout policy for the glyph using | |
881 `set-extent-begin-glyph-layout' or `set-extent-end-glyph-layout'. | |
882 Alternatively, use the high-level annotations API (see | |
883 `make-annotation'). (In point of fact, you can also use the annotations | |
884 API for glyphs in a buffer, by setting a layout policy of `text'.) | |
885 | |
886 -- To insert a glyph into the modeline, just put the glyph directly as | |
887 one of the modeline elements. (Unfortunately you can't currently | |
888 put a begin glyph or end glyph on one of the modeline extents -- | |
889 they're ignored.) | |
428 | 890 |
442 | 891 -- To insert a glyph into a toolbar, specify it as part of a toolbar |
892 instantiator (typically set on the specifier `default-toolbar'). | |
893 See `default-toolbar' for more information. (Note that it is standard | |
894 practice to use a symbol in place of the glyph list in the toolbar | |
895 instantiator; the symbol is evalled to get the glyph list. This | |
896 facilitates both creating the toolbar instantiator and modifying | |
897 individual glyphs in a toolbar later on. For example, you can | |
898 change the way that the Mail toolbar button looks by modifying the | |
899 value of the variable `toolbar-mail-icon' (in general, `toolbar-*-icon') | |
900 and then calling `(set-specifier-dirty-flag default-toolbar)'. | |
901 (#### Unfortunately this doesn't quite work the way it should; the | |
2607 | 902 change will appear in new frames, but not existing ones.) |
442 | 903 |
904 -- To insert a glyph into a gutter, create or modify a gutter instantiator | |
905 (typically set on the specifier `default-gutter'). Gutter instantiators | |
906 consist of strings or lists of strings, so to insert a glyph, create an | |
907 extent over the string, and use `set-extent-begin-glyph' or | |
908 `set-extent-end-glyph' to set a glyph to be displayed at the corresponding | |
909 edge of the extent, just like for glyphs in a buffer. | |
910 | |
911 -- To use a glyph as the icon for a frame, you do not actually create a new | |
912 glyph; rather, you change the specifications for the existing glyph | |
913 `frame-icon-glyph'. (Remember that, because of the specifier nature of | |
914 glyphs, you can set different values for any particular buffer or frame.) | |
915 | |
916 -- To use a glyph as the mouse pointer, in general you do not create a | |
917 new glyph, but rather you change the specifications of various existing | |
918 glyphs, such as `text-pointer-glyph' for the pointer used over text, | |
919 `modeline-pointer-glyph' for the pointer used over the modeline, etc. | |
920 Do an apropos over `*-pointer-glyph' to find all of them. (Note also | |
921 that you can temporarily set the mouse pointer to some specific shape | |
922 by using `set-frame-pointer', which takes an image instance, as obtained | |
923 from calling `glyph-image-instance' on a glyph of type `pointer' -- | |
924 either one of the above-mentioned variables or one you created yourself. | |
925 (See below for what it means to create a glyph of type `pointer'.) | |
926 This pointer will last only until the next mouse motion event is | |
927 processed or certain other things happen, such as creating or deleting | |
928 a window. (In fact, the above-mentioned pointer glyph variables are | |
929 implemented as part of the default handler for mouse motion events. | |
930 If you want to customize this behavior, take a look at `mode-motion-hook', | |
931 or `mouse-motion-handler' if you really want to get low-level.) | |
932 | |
933 -- To use a glyph to control the shape of miscellaneous redisplay effects | |
934 such as the truncation and continuation markers, set the appropriate | |
935 existing glyph variables, as for icons and pointers above. See | |
936 `continuation-glyph', `control-arrow-glyph', `hscroll-glyph', | |
937 `invisible-text-glyph', `octal-escape-glyph', and `truncation-glyph'. | |
938 See also `overlay-arrow-string', an odd redisplay leftover which can | |
939 be set to a glyph you created, and will cause the glyph to be displayed | |
940 on top of the text position specified in the marker stored in | |
941 `overlay-arrow-position'. | |
942 | |
943 -- To use a glyph in a display table (i.e. to control the appearance of | |
944 any individual character), create the appropriate character glyphs | |
945 and then set a specification for the specifier `current-display-table', | |
946 which controls the appearance of characters. You can also set an | |
947 overriding display table for use with text displayed in a particular | |
948 face; see `set-face-display-table' and `make-display-table'. | |
949 | |
950 -- To use a glyph as the background pixmap of a face: Note that the | |
951 background pixmap of a face is actually an image specifier -- probably | |
952 the only place in XEmacs where an image specifier occurs outside of | |
953 a glyph. Similarly to how the glyph's image specifier works, you | |
954 don't create your own image specifier, but rather add specifications | |
955 to the existing one (using `set-face-background-pixmap'). Note that | |
956 the image instance that is generated in order to actually display the | |
957 background pixmap is of type `mono-pixmap', meaning that it's a two-color | |
958 image and the foreground and background of the image get filled in with | |
959 the corresponding colors from the face. | |
960 | |
961 It is extremely rare that you will ever have to specify a value for TYPE, | |
962 which should be one of `buffer' (used for glyphs in an extent, the modeline, | |
963 the toolbar, or elsewhere in a buffer), `pointer' (used for the mouse-pointer), | |
964 or `icon' (used for a frame's icon), and defaults to `buffer'. The only cases | |
965 where it needs to be specified is when creating icon or pointer glyphs, and | |
966 in both cases the necessary glyphs have already been created at startup and | |
967 are accessed through the appropriate variables, e.g. `text-pointer-glyph' | |
968 (or in general, `*-pointer-glyph') and `frame-icon-glyph'." | |
428 | 969 (let ((glyph (make-glyph-internal type))) |
970 (and spec-list (set-glyph-image glyph spec-list)) | |
971 glyph)) | |
972 | |
973 (defun buffer-glyph-p (object) | |
974 "Return t if OBJECT is a glyph of type `buffer'." | |
975 (and (glyphp object) (eq 'buffer (glyph-type object)))) | |
976 | |
977 (defun pointer-glyph-p (object) | |
978 "Return t if OBJECT is a glyph of type `pointer'." | |
979 (and (glyphp object) (eq 'pointer (glyph-type object)))) | |
980 | |
981 (defun icon-glyph-p (object) | |
982 "Return t if OBJECT is a glyph of type `icon'." | |
983 (and (glyphp object) (eq 'icon (glyph-type object)))) | |
984 | |
985 (defun make-pointer-glyph (&optional spec-list) | |
986 "Return a new `pointer-glyph' object with the specification list SPEC-LIST. | |
987 This is equivalent to calling `make-glyph', specifying a type of `pointer'. | |
442 | 988 See `make-glyph' for more information. |
428 | 989 |
442 | 990 It is extremely unlikely that you will ever need to create a pointer glyph. |
991 Instead, you probably want to be calling `set-glyph-image' on an existing | |
992 glyph, e.g. `text-pointer-glyph'." | |
428 | 993 (make-glyph spec-list 'pointer)) |
994 | |
995 (defun make-icon-glyph (&optional spec-list) | |
996 "Return a new `icon-glyph' object with the specification list SPEC-LIST. | |
997 This is equivalent to calling `make-glyph', specifying a type of `icon'. | |
442 | 998 See `make-glyph' for more information. |
428 | 999 |
442 | 1000 It is extremely unlikely that you will ever need to create a icon glyph. |
1001 Instead, you probably want to be calling `set-glyph-image' on | |
1002 `frame-icon-glyph'." | |
428 | 1003 (make-glyph spec-list 'icon)) |
1004 | |
1005 (defun nothing-image-instance-p (object) | |
1006 "Return t if OBJECT is an image instance of type `nothing'." | |
1007 (and (image-instance-p object) (eq 'nothing (image-instance-type object)))) | |
1008 | |
1009 (defun text-image-instance-p (object) | |
1010 "Return t if OBJECT is an image instance of type `text'." | |
1011 (and (image-instance-p object) (eq 'text (image-instance-type object)))) | |
1012 | |
1013 (defun mono-pixmap-image-instance-p (object) | |
1014 "Return t if OBJECT is an image instance of type `mono-pixmap'." | |
1015 (and (image-instance-p object) (eq 'mono-pixmap | |
1016 (image-instance-type object)))) | |
1017 | |
1018 (defun color-pixmap-image-instance-p (object) | |
1019 "Return t if OBJECT is an image instance of type `color-pixmap'." | |
1020 (and (image-instance-p object) (eq 'color-pixmap | |
1021 (image-instance-type object)))) | |
1022 | |
1023 (defun pointer-image-instance-p (object) | |
1024 "Return t if OBJECT is an image instance of type `pointer'." | |
1025 (and (image-instance-p object) (eq 'pointer (image-instance-type object)))) | |
1026 | |
442 | 1027 (defun widget-image-instance-p (object) |
1028 "Return t if OBJECT is an image instance of type `widget'." | |
1029 (and (image-instance-p object) (eq 'widget (image-instance-type object)))) | |
1030 | |
428 | 1031 (defun subwindow-image-instance-p (object) |
442 | 1032 "Return t if OBJECT is an image instance of type `subwindow'." |
428 | 1033 (and (image-instance-p object) (eq 'subwindow (image-instance-type object)))) |
1034 | |
1035 ;;;;;;;;;; the built-in glyphs | |
1036 | |
1037 (defvar text-pointer-glyph (make-pointer-glyph) | |
1038 "*The shape of the mouse-pointer when over text. | |
1039 This is a glyph; use `set-glyph-image' to change it.") | |
1040 (set-glyph-face text-pointer-glyph 'pointer) | |
1041 | |
1042 (defvar nontext-pointer-glyph (make-pointer-glyph) | |
1043 "*The shape of the mouse-pointer when over a buffer, but not over text. | |
1044 This is a glyph; use `set-glyph-image' to change it. | |
1045 If unspecified in a particular domain, `text-pointer-glyph' is used.") | |
1046 (set-glyph-face nontext-pointer-glyph 'pointer) | |
1047 | |
1048 (defvar modeline-pointer-glyph (make-pointer-glyph) | |
1049 "*The shape of the mouse-pointer when over the modeline. | |
1050 This is a glyph; use `set-glyph-image' to change it. | |
1051 If unspecified in a particular domain, `nontext-pointer-glyph' is used.") | |
1052 (set-glyph-face modeline-pointer-glyph 'pointer) | |
1053 | |
1054 (defvar selection-pointer-glyph (make-pointer-glyph) | |
1055 "*The shape of the mouse-pointer when over a selectable text region. | |
1056 This is a glyph; use `set-glyph-image' to change it. | |
1057 If unspecified in a particular domain, `text-pointer-glyph' is used.") | |
1058 (set-glyph-face selection-pointer-glyph 'pointer) | |
1059 | |
1060 (defvar busy-pointer-glyph (make-pointer-glyph) | |
1061 "*The shape of the mouse-pointer when XEmacs is busy. | |
1062 This is a glyph; use `set-glyph-image' to change it. | |
1063 If unspecified in a particular domain, the pointer is not changed | |
1064 when XEmacs is busy.") | |
1065 (set-glyph-face busy-pointer-glyph 'pointer) | |
1066 | |
1067 (defvar toolbar-pointer-glyph (make-pointer-glyph) | |
1068 "*The shape of the mouse-pointer when over a toolbar. | |
1069 This is a glyph; use `set-glyph-image' to change it. | |
1070 If unspecified in a particular domain, `nontext-pointer-glyph' is used.") | |
1071 (set-glyph-face toolbar-pointer-glyph 'pointer) | |
1072 | |
1073 (defvar divider-pointer-glyph (make-pointer-glyph) | |
1074 "*The shape of the mouse-pointer when over a window divider. | |
1075 This is a glyph; use `set-glyph-image' to change it. | |
1076 If unspecified in a particular domain, `nontext-pointer-glyph' is used.") | |
1077 (set-glyph-face divider-pointer-glyph 'pointer) | |
1078 | |
1079 ;; The following three are in C. | |
1080 (if (featurep 'menubar) | |
1081 (set-glyph-face menubar-pointer-glyph 'pointer)) | |
1082 (if (featurep 'scrollbar) | |
1083 (set-glyph-face scrollbar-pointer-glyph 'pointer)) | |
1084 (set-glyph-face gc-pointer-glyph 'pointer) | |
1085 | |
1086 ;; Now add the magic access/set behavior. | |
1087 | |
1088 (defun dontusethis-set-value-glyph-handler (sym args fun harg handler) | |
1089 (error "Use `set-glyph-image' to set `%s'" sym)) | |
1090 (defun dontusethis-make-unbound-glyph-handler (sym args fun harg handler) | |
1091 (error "Can't `makunbound' `%s'" sym)) | |
1092 (defun dontusethis-make-local-glyph-handler (sym args fun harg handler) | |
1093 (error "Use `set-glyph-image' to make local values for `%s'" sym)) | |
1094 | |
1095 (defun define-constant-glyph (sym) | |
1096 (dontusethis-set-symbol-value-handler | |
1097 sym 'set-value | |
1098 'dontusethis-set-value-glyph-handler) | |
1099 (dontusethis-set-symbol-value-handler | |
1100 sym 'make-unbound | |
1101 'dontusethis-make-unbound-glyph-handler) | |
1102 (dontusethis-set-symbol-value-handler | |
1103 sym 'make-local | |
1104 'dontusethis-make-local-glyph-handler) | |
1105 ;; Make frame properties magically work with glyph variables. | |
1106 (put sym 'const-glyph-variable t)) | |
1107 | |
1108 (define-constant-glyph 'text-pointer-glyph) | |
1109 (define-constant-glyph 'nontext-pointer-glyph) | |
1110 (define-constant-glyph 'modeline-pointer-glyph) | |
1111 (define-constant-glyph 'selection-pointer-glyph) | |
1112 (define-constant-glyph 'busy-pointer-glyph) | |
1113 (define-constant-glyph 'gc-pointer-glyph) | |
1114 (define-constant-glyph 'divider-pointer-glyph) | |
1115 (define-constant-glyph 'toolbar-pointer-glyph) | |
1116 (define-constant-glyph 'menubar-pointer-glyph) | |
1117 (define-constant-glyph 'scrollbar-pointer-glyph) | |
1118 | |
1119 (define-constant-glyph 'octal-escape-glyph) | |
1120 (define-constant-glyph 'control-arrow-glyph) | |
1121 (define-constant-glyph 'invisible-text-glyph) | |
1122 (define-constant-glyph 'hscroll-glyph) | |
1123 (define-constant-glyph 'truncation-glyph) | |
1124 (define-constant-glyph 'continuation-glyph) | |
1125 | |
1126 (define-constant-glyph 'frame-icon-glyph) | |
1127 | |
1128 ;; backwards compatibility garbage | |
1129 | |
1130 (defun dontusethis-old-pointer-shape-handler (sym args fun harg handler) | |
1131 (let ((value (car args))) | |
1132 (if (null value) | |
1133 (remove-specifier harg 'global) | |
1134 (set-glyph-image (symbol-value harg) value)))) | |
1135 | |
1136 ;; It might or might not be garbage, but it's rude. Make these | |
3061 | 1137 ;; `compatible' instead of `obsolete'. -slb |
428 | 1138 (defun define-obsolete-pointer-glyph (old new) |
1139 (define-compatible-variable-alias old new) | |
1140 (dontusethis-set-symbol-value-handler | |
1141 old 'set-value 'dontusethis-old-pointer-shape-handler new)) | |
1142 | |
1143 ;;; (defvar x-pointer-shape nil) | |
1144 (define-obsolete-pointer-glyph 'x-pointer-shape 'text-pointer-glyph) | |
1145 | |
1146 ;;; (defvar x-nontext-pointer-shape nil) | |
1147 (define-obsolete-pointer-glyph 'x-nontext-pointer-shape 'nontext-pointer-glyph) | |
1148 | |
1149 ;;; (defvar x-mode-pointer-shape nil) | |
1150 (define-obsolete-pointer-glyph 'x-mode-pointer-shape 'modeline-pointer-glyph) | |
1151 | |
1152 ;;; (defvar x-selection-pointer-shape nil) | |
1153 (define-obsolete-pointer-glyph 'x-selection-pointer-shape | |
1154 'selection-pointer-glyph) | |
1155 | |
1156 ;;; (defvar x-busy-pointer-shape nil) | |
1157 (define-obsolete-pointer-glyph 'x-busy-pointer-shape 'busy-pointer-glyph) | |
1158 | |
1159 ;;; (defvar x-gc-pointer-shape nil) | |
1160 (define-obsolete-pointer-glyph 'x-gc-pointer-shape 'gc-pointer-glyph) | |
1161 | |
1162 ;;; (defvar x-toolbar-pointer-shape nil) | |
1163 (define-obsolete-pointer-glyph 'x-toolbar-pointer-shape 'toolbar-pointer-glyph) | |
1164 | |
1165 ;; for subwindows | |
1166 (defalias 'subwindow-xid 'image-instance-subwindow-id) | |
1167 (defalias 'subwindow-width 'image-instance-width) | |
1168 (defalias 'subwindow-height 'image-instance-height) | |
1169 ;;;;;;;;;; initialization | |
1170 | |
1171 (defun init-glyphs () | |
1172 ;; initialize default image types | |
1173 (if (featurep 'x) | |
1174 (set-console-type-image-conversion-list 'x | |
1175 `(,@(if (featurep 'xpm) '(("\\.xpm\\'" [xpm :file nil] 2))) | |
1176 ("\\.xbm\\'" [xbm :file nil] 2) | |
1177 ,@(if (featurep 'xpm) '(("\\`/\\* XPM \\*/" [xpm :data nil] 2))) | |
1178 ,@(if (featurep 'xface) '(("\\`X-Face:" [xface :data nil] 2))) | |
1179 ,@(if (featurep 'gif) '(("\\.gif\\'" [gif :file nil] 2) | |
1180 ("\\`GIF8[79]" [gif :data nil] 2))) | |
1181 ,@(if (featurep 'jpeg) '(("\\.jpe?g\\'" [jpeg :file nil] 2))) | |
1182 ;; all of the JFIF-format JPEG's that I've seen begin with | |
1183 ;; the following. I have no idea if this is standard. | |
1184 ,@(if (featurep 'jpeg) '(("\\`\377\330\377\340\000\020JFIF" | |
1185 [jpeg :data nil] 2))) | |
1186 ,@(if (featurep 'png) '(("\\.png\\'" [png :file nil] 2))) | |
1187 ,@(if (featurep 'png) '(("\\`\211PNG" [png :data nil] 2))) | |
4363
6a17ac5da3c4
Accept strings as glyph instantiators, fix control-arrow-glyph, etc.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4226
diff
changeset
|
1188 ("" [string :data nil] 2) |
446 | 1189 ("" [nothing])))) |
428 | 1190 ;; #### this should really be formatted-string, not string but we |
1191 ;; don't have it implemented yet | |
1192 (if (featurep 'tty) | |
1193 (progn | |
1194 (set-console-type-image-conversion-list | |
1195 'tty | |
4226 | 1196 '(("\\.xpm\\'" [string :data nil] 2) |
1197 ("\\.xbm\\'" [string :data nil] 2) | |
1198 ;; #define could also mean a bitmap as well as a version 1 XPM. Who | |
1199 ;; cares. | |
1200 ("^#define" [string :data "[xpm]"]) | |
428 | 1201 ("\\`/\\* XPM \\*/" [string :data "[xpm]"]) |
4226 | 1202 ("\\`X-Face:" [string :data "[xface]"]) |
1203 ("\\.gif\\'" [string :data nil] 2) | |
1204 ("\\`GIF8[79]" [string :data "[gif]"]) | |
1205 ("\\.jpe?g\\'" [string :data nil] 2) | |
428 | 1206 ("\\`\377\330\340\000\020JFIF" [string :data "[jpeg]"]) |
4226 | 1207 ;; all of the JFIF-format JPEG's that I've seen begin with |
1208 ;; the following. I have no idea if this is standard. | |
1209 ("\\`\377\330\377\340\000\020JFIF" [string :data "[jpeg]"]) | |
1210 ("\\.png\\'" [string :data nil] 2) | |
1211 ("\\`\211PNG" [string :data "[png]"]) | |
4363
6a17ac5da3c4
Accept strings as glyph instantiators, fix control-arrow-glyph, etc.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4226
diff
changeset
|
1212 ("" [string :data nil] 2) |
428 | 1213 ;; this last one is here for pointers and icons and such -- |
1214 ;; strings are not allowed so they will be ignored. | |
1215 ("" [nothing]))) | |
1216 | |
1217 ;; finish initializing truncation glyph -- created internally | |
1218 ;; because it has a built-in bitmap | |
1219 (set-glyph-image truncation-glyph "$" 'global 'tty) | |
1220 | |
1221 ;; finish initializing continuation glyph -- created internally | |
1222 ;; because it has a built-in bitmap | |
1223 (set-glyph-image continuation-glyph "\\" 'global 'tty) | |
1224 | |
1225 ;; finish initializing hscroll glyph -- created internally | |
1226 ;; because it has a built-in bitmap | |
1227 (set-glyph-image hscroll-glyph "$" 'global 'tty))) | |
1228 | |
4226 | 1229 ;; For streams, we don't want images at all -- dvl |
1230 (set-console-type-image-conversion-list 'stream '(("" [nothing]))) | |
1231 | |
1232 | |
428 | 1233 (set-glyph-image octal-escape-glyph "\\") |
1234 (set-glyph-image control-arrow-glyph "^") | |
1235 (set-glyph-image invisible-text-glyph " ...") | |
1236 ;; (set-glyph-image hscroll-glyph "$") | |
1237 | |
1238 (let ((face (make-face 'border-glyph | |
1239 "Truncation and continuation glyphs face"))) | |
1240 (set-glyph-face continuation-glyph face) | |
1241 (set-glyph-face truncation-glyph face) | |
1242 (set-glyph-face hscroll-glyph face)) | |
1243 | |
1244 ;; finish initializing xemacs logo -- created internally because it | |
1245 ;; has a built-in bitmap | |
1246 (if (featurep 'xpm) | |
1247 (set-glyph-image xemacs-logo | |
1248 (concat "../etc/" | |
1249 (if emacs-beta-version | |
1250 "xemacs-beta.xpm" | |
1251 "xemacs.xpm")) | |
1252 'global 'x)) | |
1253 (cond ((featurep 'xpm) | |
1254 (set-glyph-image frame-icon-glyph | |
1255 (concat "../etc/" "xemacs-icon.xpm") | |
1256 'global 'x)) | |
1257 ((featurep 'x) | |
1258 (set-glyph-image frame-icon-glyph | |
1259 (concat "../etc/" "xemacs-icon2.xbm") | |
1260 'global 'x))) | |
1261 | |
1262 (if (featurep 'tty) | |
1263 (set-glyph-image xemacs-logo | |
1264 "XEmacs <insert spiffy graphic logo here>" | |
1265 'global 'tty)) | |
1266 ) | |
1267 | |
1268 (init-glyphs) | |
1269 | |
1270 ;;; glyphs.el ends here. |