428
|
1 @c -*-texinfo-*-
|
|
2 @c This is part of the XEmacs Lisp Reference Manual.
|
|
3 @c Copyright (C) 1995, 1996 Ben Wing.
|
|
4 @c See the file lispref.texi for copying conditions.
|
|
5 @setfilename ../../info/glyphs.info
|
|
6 @node Glyphs, Annotations, Faces and Window-System Objects, top
|
|
7 @chapter Glyphs
|
|
8 @cindex glyphs
|
|
9
|
442
|
10 A @dfn{glyph} is an object that is used for pixmaps, widgets and
|
|
11 images of all sorts, as well as for things that ``act'' like pixmaps,
|
|
12 such as non-textual strings (@dfn{annotations}) displayed in a buffer or
|
|
13 in the margins. It is used in begin-glyphs and end-glyphs attached to
|
|
14 extents, marginal and textual annotations, overlay arrows
|
|
15 (@code{overlay-arrow-*} variables), toolbar buttons, mouse pointers,
|
|
16 frame icons, truncation and continuation markers, and the
|
|
17 like. (Basically, any place there is an image or something that acts
|
|
18 like an image, there will be a glyph object representing it.)
|
428
|
19
|
|
20 The actual image that is displayed (as opposed to its position or
|
|
21 clipping) is defined by an @dfn{image specifier} object contained
|
|
22 within the glyph. The separation between an image specifier object
|
|
23 and a glyph object is made because the glyph includes other properties
|
|
24 than just the actual image: e.g. the face it is displayed in (for text
|
|
25 images), the alignment of the image (when it is in a buffer), etc.
|
|
26
|
|
27 @defun glyphp object
|
|
28 This function returns @code{t} if @var{object} is a glyph.
|
|
29 @end defun
|
|
30
|
|
31 @menu
|
|
32 * Glyph Functions:: Functions for working with glyphs.
|
|
33 * Images:: Graphical images displayed in a frame.
|
|
34 * Glyph Types:: Each glyph has a particular type.
|
|
35 * Mouse Pointer:: Controlling the mouse pointer.
|
|
36 * Redisplay Glyphs:: Glyphs controlling various redisplay functions.
|
2028
|
37 * Native GUI Widgets:: Complex active images treated as a single glyph.
|
428
|
38 * Subwindows:: Inserting an externally-controlled subwindow
|
|
39 into a buffer.
|
707
|
40 * Glyph Examples:: Examples of how to work with glyphs.
|
428
|
41 @end menu
|
|
42
|
|
43 @node Glyph Functions
|
|
44 @section Glyph Functions
|
|
45
|
|
46 @menu
|
|
47 * Creating Glyphs:: Creating new glyphs.
|
|
48 * Glyph Properties:: Accessing and modifying a glyph's properties.
|
|
49 * Glyph Convenience Functions::
|
|
50 Convenience functions for accessing particular
|
|
51 properties of a glyph.
|
|
52 * Glyph Dimensions:: Determining the height, width, etc. of a glyph.
|
|
53 @end menu
|
|
54
|
|
55 @node Creating Glyphs
|
|
56 @subsection Creating Glyphs
|
|
57
|
|
58 @defun make-glyph &optional spec-list type
|
|
59 This function creates a new glyph object of type @var{type}.
|
|
60
|
|
61 @var{spec-list} is used to initialize the glyph's image. It is
|
|
62 typically an image instantiator (a string or a vector; @ref{Image
|
|
63 Specifiers}), but can also be a list of such instantiators (each one in
|
|
64 turn is tried until an image is successfully produced), a cons of a
|
|
65 locale (frame, buffer, etc.) and an instantiator, a list of such conses,
|
|
66 or any other form accepted by @code{canonicalize-spec-list}.
|
|
67 @xref{Specifiers}, for more information about specifiers.
|
|
68
|
|
69 @var{type} specifies the type of the glyph, which specifies in which
|
|
70 contexts the glyph can be used, and controls the allowable image types
|
|
71 into which the glyph's image can be instantiated. @var{type} should be
|
|
72 one of @code{buffer} (used for glyphs in an extent, the modeline, the
|
|
73 toolbar, or elsewhere in a buffer), @code{pointer} (used for the
|
|
74 mouse-pointer), or @code{icon} (used for a frame's icon), and defaults
|
|
75 to @code{buffer}. @xref{Glyph Types}.
|
442
|
76
|
|
77 A glyph in XEmacs does @strong{NOT} refer to a single unit of textual
|
|
78 display (the XEmacs term for this is @dfn{rune}), but rather is an
|
|
79 object encapsulating a graphical element, such as an image or widget (an
|
|
80 element such as a button or text field; @dfn{widget} is the term for
|
|
81 this under X Windows, and it's called a @dfn{control} under MS Windows).
|
|
82 This graphical element could appear in a buffer, a margin, a gutter, or
|
|
83 a toolbar, or as a mouse pointer or an icon, for example.
|
|
84
|
|
85 Creating a glyph using @code{make-glyph} does not specify @emph{where}
|
|
86 the glyph will be used, but it does specify @emph{what} the glyph will
|
444
|
87 look like. In particular, @var{spec-list} is used to specify this, and it's
|
442
|
88 used to initialize the glyph's @code{image} property, which is an image
|
|
89 specifier. (Note that @dfn{image} as used in the context of a glyph's
|
|
90 @code{image} property or in the terms @dfn{image specifier}, @dfn{image
|
|
91 instantiator}, or @dfn{image instance} does not refer to what people
|
|
92 normally think of as an image (which in XEmacs is called a
|
|
93 @dfn{pixmap}), but to any graphical element---a pixmap, a widget, or
|
|
94 even a block of text, when used in the places that call for a glyph.)
|
444
|
95 The format of the @var{spec-list} is typically an image instantiator (a string
|
442
|
96 or a vector; @ref{Image Specifiers}), but can also be a list of such
|
|
97 instantiators (each one in turn is tried until an image is successfully
|
|
98 produced), a cons of a locale (frame, buffer, etc.) and an
|
|
99 instantiator, a list of such conses, or any other form accepted by
|
|
100 @code{canonicalize-spec-list}. @xref{Specifiers}, for more information
|
|
101 about specifiers.
|
|
102
|
|
103 If you're not familiar with specifiers, you should be in order to
|
|
104 understand how glyphs work. The clearest introduction to specifiers
|
|
105 is in the Lispref manual, available under Info. (Choose
|
|
106 Help->Info->Info Contents on the menubar or type C-h i.) You can
|
|
107 also see @code{make-specifier} for a capsule summary. What's important to
|
|
108 keep in mind is that a specifier lets you set a different value for
|
|
109 any particular buffer, window, frame, device, or console. This allows
|
|
110 for a great deal of flexibility; in particular, only one global glyph
|
|
111 needs to exist for a particular purpose (e.g. the icon used to represent
|
|
112 an iconified frame, the mouse pointer used over particular areas of a
|
|
113 frame, etc.), and in these cases you do not create your own glyph, but
|
|
114 rather modify the existing one.
|
|
115
|
|
116 As well as using @var{spec-list} to initialize the glyph, you can set
|
|
117 specifications using @code{set-glyph-image}. Note that, due to a
|
|
118 possibly questionable historical design decision, a glyph itself is not
|
|
119 actually a specifier, but rather is an object containing an image
|
|
120 specifier (as well as other, seldom-used properties). Therefore, you
|
|
121 cannot set or access specifications for the glyph's image by directly
|
|
122 using @code{set-specifier}, @code{specifier-instance} or the like on the
|
|
123 glyph; instead use them on @code{(glyph-image @var{glyph})} or use the
|
|
124 convenience functions @code{set-glyph-image},
|
|
125 @code{glyph-image-instance}, and @code{glyph-image}.
|
|
126
|
|
127 Once you have created a glyph, you specify where it will be used as
|
|
128 follows:
|
|
129
|
|
130 @itemize @bullet
|
|
131 @item
|
|
132 To insert a glyph into a buffer, create an extent in the buffer and then
|
|
133 use @code{set-extent-begin-glyph} or @code{set-extent-end-glyph} to set
|
|
134 a glyph to be displayed at the corresponding edge of the extent. (It is
|
|
135 common to create zero-width extents for this purpose.)
|
|
136
|
|
137 @item
|
|
138 To insert a glyph into the left or right margin of a buffer, first
|
|
139 make sure the margin is visible by setting a value for the specifiers
|
|
140 @code{left-margin-width} or @code{right-margin-width}. (Not strictly necessary
|
|
141 when using margin glyphs with layout policy @code{whitespace}.) Then follow
|
|
142 the same procedure above for inserting a glyph in a buffer, and then
|
|
143 set a non-default layout policy for the glyph using
|
|
144 @code{set-extent-begin-glyph-layout} or @code{set-extent-end-glyph-layout}.
|
|
145 Alternatively, use the high-level annotations API (see
|
|
146 @code{make-annotation}). (In point of fact, you can also use the annotations
|
|
147 API for glyphs in a buffer, by setting a layout policy of @code{text}.)
|
|
148
|
|
149 @item
|
|
150 To insert a glyph into the modeline, just put the glyph directly as one
|
|
151 of the modeline elements. (Unfortunately you can't currently put a begin
|
|
152 glyph or end glyph on one of the modeline extents---they're ignored.)
|
|
153
|
|
154 @item
|
|
155 To insert a glyph into a toolbar, specify it as part of a toolbar
|
|
156 instantiator (typically set on the specifier @code{default-toolbar}).
|
|
157 See @code{default-toolbar} for more information. (Note that it is
|
|
158 standard practice to use a symbol in place of the glyph list in the
|
|
159 toolbar instantiator; the symbol is evalled to get the glyph list. This
|
|
160 facilitates both creating the toolbar instantiator and modifying
|
|
161 individual glyphs in a toolbar later on. For example, you can change
|
|
162 the way that the Mail toolbar button looks by modifying the value of the
|
|
163 variable @code{toolbar-mail-icon} (in general, @code{toolbar-*-icon})
|
|
164 and then calling @code{(set-specifier-dirty-flag default-toolbar)}.
|
|
165 (#### Unfortunately this doesn't quite work the way it should; the
|
|
166 change will appear in new frames, but not existing ones.
|
|
167
|
|
168 @item
|
|
169 To insert a glyph into a gutter, create or modify a gutter instantiator
|
|
170 (typically set on the specifier @code{default-gutter}). Gutter
|
|
171 instantiators consist of strings or lists of strings, so to insert a
|
|
172 glyph, create an extent over the string, and use
|
|
173 @code{set-extent-begin-glyph} or @code{set-extent-end-glyph} to set a
|
|
174 glyph to be displayed at the corresponding edge of the extent, just like
|
|
175 for glyphs in a buffer.
|
|
176
|
|
177 @item
|
|
178 To use a glyph as the icon for a frame, you do not actually create a new
|
|
179 glyph; rather, you change the specifications for the existing glyph
|
|
180 @code{frame-icon-glyph}. (Remember that, because of the specifier nature
|
|
181 of glyphs, you can set different values for any particular buffer or
|
|
182 frame.)
|
|
183
|
|
184 @item
|
|
185 To use a glyph as the mouse pointer, in general you do not create a new
|
|
186 glyph, but rather you change the specifications of various existing
|
|
187 glyphs, such as @code{text-pointer-glyph} for the pointer used over
|
|
188 text, @code{modeline-pointer-glyph} for the pointer used over the
|
|
189 modeline, etc. Do an apropos over @code{*-pointer-glyph} to find all of
|
|
190 them. (Note also that you can temporarily set the mouse pointer to some
|
|
191 specific shape by using @code{set-frame-pointer}, which takes an image
|
|
192 instance, as obtained from calling @code{glyph-image-instance} on a glyph
|
|
193 of type @code{pointer} -- either one of the above-mentioned variables or
|
|
194 one you created yourself. (See below for what it means to create a
|
|
195 glyph of type @code{pointer}.) This pointer will last only until the
|
|
196 next mouse motion event is processed or certain other things happen,
|
|
197 such as creating or deleting a window. (In fact, the above-mentioned
|
|
198 pointer glyph variables are implemented as part of the default handler
|
|
199 for mouse motion events. If you want to customize this behavior, take a
|
|
200 look at @code{mode-motion-hook}, or @code{mouse-motion-handler} if you
|
|
201 really want to get low-level.)
|
|
202
|
|
203 @item
|
|
204 To use a glyph to control the shape of miscellaneous redisplay effects
|
|
205 such as the truncation and continuation markers, set the appropriate
|
|
206 existing glyph variables, as for icons and pointers above. See
|
|
207 @code{continuation-glyph}, @code{control-arrow-glyph},
|
|
208 @code{hscroll-glyph}, @code{invisible-text-glyph},
|
|
209 @code{octal-escape-glyph}, and @code{truncation-glyph}. See also
|
|
210 @code{overlay-arrow-string}, an odd redisplay leftover which can be set
|
|
211 to a glyph you created, and will cause the glyph to be displayed on top
|
|
212 of the text position specified in the marker stored in
|
|
213 @code{overlay-arrow-position}.
|
|
214
|
|
215 @item
|
|
216 To use a glyph in a display table (i.e. to control the appearance of any
|
|
217 individual character), create the appropriate character glyphs and then
|
|
218 set a specification for the specifier @code{current-display-table},
|
|
219 which controls the appearance of characters. You can also set an
|
|
220 overriding display table for use with text displayed in a particular
|
|
221 face; see @code{set-face-display-table} and @code{make-display-table}.
|
|
222 #### Note: Display tables do not currently support general Mule
|
|
223 characters. They will be overhauled at some point to support this
|
|
224 and to provide other features required under Mule.
|
|
225
|
|
226 @item
|
|
227 To use a glyph as the background pixmap of a face: Note that the
|
|
228 background pixmap of a face is actually an image specifier -- probably
|
|
229 the only place in XEmacs where an image specifier occurs outside of a
|
1137
|
230 glyph. Similarly to how the glyph's image specifier works, you don't
|
442
|
231 create your own image specifier, but rather add specifications to the
|
1137
|
232 existing one (using @code{set-face-background-pixmap-file} or
|
|
233 @code{set-face-background-pixmap}). Note that the image instance that is
|
|
234 generated in order to actually display the background pixmap is of type
|
|
235 @code{mono-pixmap}, meaning that it's a two-color image and the
|
|
236 foreground and background of the image get filled in with the
|
|
237 corresponding colors from the face.
|
442
|
238 @end itemize
|
|
239
|
|
240 It is extremely rare that you will ever have to specify a value for
|
444
|
241 @var{type}, which should be one of @code{buffer} (used for glyphs in an
|
442
|
242 extent, the modeline, the toolbar, or elsewhere in a buffer),
|
|
243 @code{pointer} (used for the mouse-pointer), or @code{icon} (used for a
|
|
244 frame's icon), and defaults to @code{buffer}. The only cases where it
|
|
245 needs to be specified is when creating icon or pointer glyphs, and in
|
|
246 both cases the necessary glyphs have already been created at startup and
|
|
247 are accessed through the appropriate variables,
|
|
248 e.g. @code{text-pointer-glyph} (or in general, @code{*-pointer-glyph})
|
|
249 and @code{frame-icon-glyph}. @xref{Glyph Types}.
|
428
|
250 @end defun
|
|
251
|
|
252 @defun make-glyph-internal &optional type
|
|
253 This function creates a new, uninitialized glyph of type @var{type}.
|
|
254 @end defun
|
|
255
|
|
256 @defun make-pointer-glyph &optional spec-list
|
442
|
257
|
|
258 Return a new @code{pointer-glyph} object with the specification list
|
|
259 @var{spec-list}. This function is equivalent to calling
|
|
260 @code{make-glyph} with a @var{type} of @code{pointer}.
|
|
261
|
|
262 It is extremely unlikely that you will ever need to create a pointer
|
|
263 glyph. Instead, you probably want to be calling @code{set-glyph-image}
|
|
264 on an existing glyph, e.g. @code{text-pointer-glyph}.
|
428
|
265 @end defun
|
|
266
|
|
267 @defun make-icon-glyph &optional spec-list
|
442
|
268
|
|
269 Return a new @code{pointer-glyph} object with the specification list
|
|
270 @var{spec-list}. This function is equivalent to calling
|
|
271 @code{make-glyph} with a @var{type} of @code{icon}.
|
|
272
|
|
273 It is extremely unlikely that you will ever need to create a pointer
|
|
274 glyph. Instead, you probably want to be calling @code{set-glyph-image}
|
|
275 on an existing glyph, e.g. @code{text-pointer-glyph}.
|
428
|
276 @end defun
|
|
277
|
|
278 @node Glyph Properties
|
|
279 @subsection Glyph Properties
|
|
280
|
|
281 Each glyph has a list of properties, which control all of the aspects of
|
|
282 the glyph's appearance. The following symbols have predefined meanings:
|
|
283
|
|
284 @table @code
|
|
285 @item image
|
|
286 The image used to display the glyph.
|
|
287
|
|
288 @item baseline
|
|
289 Percent above baseline that glyph is to be displayed. Only for glyphs
|
|
290 displayed inside of a buffer.
|
|
291
|
|
292 @item contrib-p
|
|
293 Whether the glyph contributes to the height of the line it's on.
|
|
294 Only for glyphs displayed inside of a buffer.
|
|
295
|
|
296 @item face
|
|
297 Face of this glyph (@emph{not} a specifier).
|
|
298 @end table
|
|
299
|
|
300 @defun set-glyph-property glyph property value &optional locale tag-set how-to-add
|
|
301 This function changes a property of a @var{glyph}.
|
|
302
|
|
303 For built-in properties, the actual value of the property is a specifier
|
|
304 and you cannot change this; but you can change the specifications within
|
|
305 the specifier, and that is what this function will do. For user-defined
|
|
306 properties, you can use this function to either change the actual value
|
|
307 of the property or, if this value is a specifier, change the
|
|
308 specifications within it.
|
|
309
|
|
310 If @var{property} is a built-in property, the specifications to be added
|
|
311 to this property can be supplied in many different ways:
|
|
312
|
|
313 @itemize @bullet
|
|
314 @item
|
|
315 If @var{value} is a simple instantiator (e.g. a string naming a pixmap
|
|
316 filename) or a list of instantiators, then the instantiator(s) will be
|
|
317 added as a specification of the property for the given @var{locale}
|
|
318 (which defaults to @code{global} if omitted).
|
|
319
|
|
320 @item
|
|
321 If @var{value} is a list of specifications (each of which is a cons of a
|
|
322 locale and a list of instantiators), then @var{locale} must be
|
|
323 @code{nil} (it does not make sense to explicitly specify a locale in
|
|
324 this case), and specifications will be added as given.
|
|
325
|
|
326 @item
|
|
327 If @var{value} is a specifier (as would be returned by
|
|
328 @code{glyph-property} if no @var{locale} argument is given), then some
|
|
329 or all of the specifications in the specifier will be added to the
|
|
330 property. In this case, the function is really equivalent to
|
|
331 @code{copy-specifier} and @var{locale} has the same semantics (if it is
|
|
332 a particular locale, the specification for the locale will be copied; if
|
|
333 a locale type, specifications for all locales of that type will be
|
|
334 copied; if @code{nil} or @code{all}, then all specifications will be
|
|
335 copied).
|
|
336 @end itemize
|
|
337
|
|
338 @var{how-to-add} should be either @code{nil} or one of the symbols
|
|
339 @code{prepend}, @code{append}, @code{remove-tag-set-prepend},
|
|
340 @code{remove-tag-set-append}, @code{remove-locale},
|
|
341 @code{remove-locale-type}, or @code{remove-all}. See
|
|
342 @code{copy-specifier} and @code{add-spec-to-specifier} for a description
|
|
343 of what each of these means. Most of the time, you do not need to worry
|
|
344 about this argument; the default behavior usually is fine.
|
|
345
|
|
346 In general, it is OK to pass an instance object (e.g. as returned by
|
|
347 @code{glyph-property-instance}) as an instantiator in place of an actual
|
|
348 instantiator. In such a case, the instantiator used to create that
|
|
349 instance object will be used (for example, if you set a font-instance
|
|
350 object as the value of the @code{font} property, then the font name used
|
2028
|
351 to create that object will be used instead). In some cases, however,
|
428
|
352 doing this conversion does not make sense, and this will be noted in the
|
|
353 documentation for particular types of instance objects.
|
|
354
|
|
355 If @var{property} is not a built-in property, then this function will
|
|
356 simply set its value if @var{locale} is @code{nil}. However, if
|
|
357 @var{locale} is given, then this function will attempt to add
|
|
358 @var{value} as the instantiator for the given @var{locale}, using
|
|
359 @code{add-spec-to-specifier}. If the value of the property is not a
|
|
360 specifier, it will automatically be converted into a @code{generic}
|
|
361 specifier.
|
|
362 @end defun
|
|
363
|
|
364 @defun glyph-property glyph property &optional locale
|
|
365 This function returns @var{glyph}'s value of the given @var{property}.
|
|
366
|
|
367 If @var{locale} is omitted, the @var{glyph}'s actual value for
|
|
368 @var{property} will be returned. For built-in properties, this will be
|
|
369 a specifier object of a type appropriate to the property (e.g. a font or
|
|
370 color specifier). For other properties, this could be anything.
|
|
371
|
|
372 If @var{locale} is supplied, then instead of returning the actual value,
|
|
373 the specification(s) for the given locale or locale type will be
|
|
374 returned. This will only work if the actual value of @var{property} is
|
|
375 a specifier (this will always be the case for built-in properties, but
|
|
376 may or may not apply to user-defined properties). If the actual value
|
|
377 of @var{property} is not a specifier, this value will simply be returned
|
|
378 regardless of @var{locale}.
|
|
379
|
|
380 The return value will be a list of instantiators (e.g. vectors
|
|
381 specifying pixmap data), or a list of specifications, each of which is a
|
|
382 cons of a locale and a list of instantiators. Specifically, if
|
|
383 @var{locale} is a particular locale (a buffer, window, frame, device, or
|
|
384 @code{global}), a list of instantiators for that locale will be
|
|
385 returned. Otherwise, if @var{locale} is a locale type (one of the
|
|
386 symbols @code{buffer}, @code{window}, @code{frame}, or @code{device}),
|
|
387 the specifications for all locales of that type will be returned.
|
|
388 Finally, if @var{locale} is @code{all}, the specifications for all
|
|
389 locales of all types will be returned.
|
|
390
|
|
391 The specifications in a specifier determine what the value of
|
|
392 @var{property} will be in a particular @dfn{domain} or set of
|
|
393 circumstances, which is typically a particular Emacs window along with
|
|
394 the buffer it contains and the frame and device it lies within. The
|
|
395 value is derived from the instantiator associated with the most specific
|
|
396 locale (in the order buffer, window, frame, device, and @code{global})
|
|
397 that matches the domain in question. In other words, given a domain
|
|
398 (i.e. an Emacs window, usually), the specifier for @var{property} will
|
|
399 first be searched for a specification whose locale is the buffer
|
|
400 contained within that window; then for a specification whose locale is
|
|
401 the window itself; then for a specification whose locale is the frame
|
|
402 that the window is contained within; etc. The first instantiator that
|
|
403 is valid for the domain (usually this means that the instantiator is
|
|
404 recognized by the device [i.e. the X server or TTY device] that the
|
|
405 domain is on). The function @code{glyph-property-instance} actually does
|
|
406 all this, and is used to determine how to display the glyph.
|
|
407 @end defun
|
|
408
|
|
409 @defun glyph-property-instance glyph property &optional domain default no-fallback
|
|
410 This function returns the instance of @var{glyph}'s @var{property} in the
|
|
411 specified @var{domain}.
|
|
412
|
|
413 Under most circumstances, @var{domain} will be a particular window, and
|
|
414 the returned instance describes how the specified property actually is
|
|
415 displayed for that window and the particular buffer in it. Note that
|
|
416 this may not be the same as how the property appears when the buffer is
|
|
417 displayed in a different window or frame, or how the property appears in
|
|
418 the same window if you switch to another buffer in that window; and in
|
|
419 those cases, the returned instance would be different.
|
|
420
|
|
421 The returned instance is an image-instance object, and you can query it
|
|
422 using the appropriate image instance functions. For example, you could use
|
|
423 @code{image-instance-depth} to find out the depth (number of color
|
|
424 planes) of a pixmap displayed in a particular window. The results might
|
|
425 be different from the results you would get for another window (perhaps
|
|
426 the user specified a different image for the frame that window is on; or
|
|
427 perhaps the same image was specified but the window is on a different X
|
|
428 server, and that X server has different color capabilities from this
|
|
429 one).
|
|
430
|
|
431 @var{domain} defaults to the selected window if omitted.
|
|
432
|
|
433 @var{domain} can be a frame or device, instead of a window. The value
|
|
434 returned for such a domain is used in special circumstances when a
|
|
435 more specific domain does not apply; for example, a frame value might be
|
|
436 used for coloring a toolbar, which is conceptually attached to a frame
|
|
437 rather than a particular window. The value is also useful in
|
|
438 determining what the value would be for a particular window within the
|
|
439 frame or device, if it is not overridden by a more specific
|
|
440 specification.
|
|
441
|
|
442 If @var{property} does not name a built-in property, its value will
|
|
443 simply be returned unless it is a specifier object, in which case it
|
|
444 will be instanced using @code{specifier-instance}.
|
|
445
|
|
446 Optional arguments @var{default} and @var{no-fallback} are the same as
|
|
447 in @code{specifier-instance}. @xref{Specifiers}.
|
|
448 @end defun
|
|
449
|
|
450 @defun remove-glyph-property glyph property &optional locale tag-set exact-p
|
|
451 This function removes a property from a glyph. For built-in properties,
|
|
452 this is analogous to @code{remove-specifier}. @xref{Specifiers,
|
|
453 remove-specifier-p}, for the meaning of the @var{locale}, @var{tag-set},
|
|
454 and @var{exact-p} arguments.
|
|
455 @end defun
|
|
456
|
|
457 @node Glyph Convenience Functions
|
|
458 @subsection Glyph Convenience Functions
|
|
459
|
|
460 The following functions are provided for working with specific
|
|
461 properties of a glyph. Note that these are exactly like calling
|
|
462 the general functions described above and passing in the
|
|
463 appropriate value for @var{property}.
|
|
464
|
|
465 Remember that if you want to determine the ``value'' of a
|
|
466 specific glyph property, you probably want to use the @code{*-instance}
|
|
467 functions. For example, to determine whether a glyph contributes
|
|
468 to its line height, use @code{glyph-contrib-p-instance}, not
|
|
469 @code{glyph-contrib-p}. (The latter will return a boolean specifier
|
|
470 or a list of specifications, and you probably aren't concerned with
|
|
471 these.)
|
|
472
|
|
473 @defun glyph-image glyph &optional locale
|
|
474 This function is equivalent to calling @code{glyph-property} with
|
|
475 a property of @code{image}. The return value will be an image
|
|
476 specifier if @var{locale} is @code{nil} or omitted; otherwise,
|
|
477 it will be a specification or list of specifications.
|
|
478 @end defun
|
|
479
|
|
480 @defun set-glyph-image glyph spec &optional locale tag-set how-to-add
|
|
481 This function is equivalent to calling @code{set-glyph-property} with
|
|
482 a property of @code{image}.
|
|
483 @end defun
|
|
484
|
|
485 @defun glyph-image-instance glyph &optional domain default no-fallback
|
|
486 This function returns the instance of @var{glyph}'s image in the given
|
|
487 @var{domain}, and is equivalent to calling
|
|
488 @code{glyph-property-instance} with a property of @code{image}. The
|
|
489 return value will be an image instance.
|
|
490
|
|
491 Normally @var{domain} will be a window or @code{nil} (meaning the
|
|
492 selected window), and an instance object describing how the image
|
|
493 appears in that particular window and buffer will be returned.
|
|
494 @end defun
|
|
495
|
|
496 @defun glyph-contrib-p glyph &optional locale
|
|
497 This function is equivalent to calling @code{glyph-property} with
|
|
498 a property of @code{contrib-p}. The return value will be a boolean
|
|
499 specifier if @var{locale} is @code{nil} or omitted; otherwise,
|
|
500 it will be a specification or list of specifications.
|
|
501 @end defun
|
|
502
|
|
503 @defun set-glyph-contrib-p glyph spec &optional locale tag-set how-to-add
|
|
504 This function is equivalent to calling @code{set-glyph-property} with
|
|
505 a property of @code{contrib-p}.
|
|
506 @end defun
|
|
507
|
|
508 @defun glyph-contrib-p-instance glyph &optional domain default no-fallback
|
|
509 This function returns whether the glyph contributes to its line height
|
|
510 in the given @var{domain}, and is equivalent to calling
|
|
511 @code{glyph-property-instance} with a property of @code{contrib-p}. The
|
|
512 return value will be either @code{nil} or @code{t}. (Normally @var{domain}
|
|
513 will be a window or @code{nil}, meaning the selected window.)
|
|
514 @end defun
|
|
515
|
|
516 @defun glyph-baseline glyph &optional locale
|
|
517 This function is equivalent to calling @code{glyph-property} with a
|
|
518 property of @code{baseline}. The return value will be a specifier if
|
|
519 @var{locale} is @code{nil} or omitted; otherwise, it will be a
|
|
520 specification or list of specifications.
|
|
521 @end defun
|
|
522
|
|
523 @defun set-glyph-baseline glyph spec &optional locale tag-set how-to-add
|
|
524 This function is equivalent to calling @code{set-glyph-property} with
|
|
525 a property of @code{baseline}.
|
|
526 @end defun
|
|
527
|
|
528 @defun glyph-baseline-instance glyph &optional domain default no-fallback
|
|
529 This function returns the instance of @var{glyph}'s baseline value in
|
|
530 the given @var{domain}, and is equivalent to calling
|
|
531 @code{glyph-property-instance} with a property of @code{baseline}. The
|
|
532 return value will be an integer or @code{nil}.
|
|
533
|
|
534 Normally @var{domain} will be a window or @code{nil} (meaning the
|
|
535 selected window), and an instance object describing the baseline value
|
|
536 appears in that particular window and buffer will be returned.
|
|
537 @end defun
|
|
538
|
|
539 @defun glyph-face glyph
|
|
540 This function returns the face of @var{glyph}. (Remember, this is
|
|
541 not a specifier, but a simple property.)
|
|
542 @end defun
|
|
543
|
|
544 @defun set-glyph-face glyph face
|
|
545 This function changes the face of @var{glyph} to @var{face}.
|
|
546 @end defun
|
|
547
|
|
548 @node Glyph Dimensions
|
|
549 @subsection Glyph Dimensions
|
|
550
|
|
551 @defun glyph-width glyph &optional window
|
|
552 This function returns the width of @var{glyph} on @var{window}. This
|
|
553 may not be exact as it does not take into account all of the context
|
|
554 that redisplay will.
|
|
555 @end defun
|
|
556
|
|
557 @defun glyph-ascent glyph &optional window
|
|
558 This function returns the ascent value of @var{glyph} on @var{window}.
|
|
559 This may not be exact as it does not take into account all of the
|
|
560 context that redisplay will.
|
|
561 @end defun
|
|
562
|
|
563 @defun glyph-descent glyph &optional window
|
|
564 This function returns the descent value of @var{glyph} on @var{window}.
|
|
565 This may not be exact as it does not take into account all of the
|
|
566 context that redisplay will.
|
|
567 @end defun
|
|
568
|
|
569 @defun glyph-height glyph &optional window
|
|
570 This function returns the height of @var{glyph} on @var{window}. (This
|
|
571 is equivalent to the sum of the ascent and descent values.) This may
|
|
572 not be exact as it does not take into account all of the context that
|
|
573 redisplay will.
|
|
574 @end defun
|
|
575
|
|
576 @node Images
|
|
577 @section Images
|
|
578
|
|
579 @menu
|
|
580 * Image Specifiers:: Specifying how an image will appear.
|
|
581 * Image Instantiator Conversion::
|
|
582 Conversion is applied to image instantiators
|
|
583 at the time they are added to an
|
|
584 image specifier or at the time they
|
|
585 are passed to @code{make-image-instance}.
|
|
586 * Image Instances:: What an image specifier gets instanced as.
|
|
587 @end menu
|
|
588
|
|
589 @node Image Specifiers
|
|
590 @subsection Image Specifiers
|
|
591 @cindex image specifiers
|
|
592
|
|
593 An image specifier is used to describe the actual image of a glyph.
|
|
594 It works like other specifiers (@pxref{Specifiers}), in that it contains
|
|
595 a number of specifications describing how the image should appear in a
|
|
596 variety of circumstances. These specifications are called @dfn{image
|
|
597 instantiators}. When XEmacs wants to display the image, it instantiates
|
|
598 the image into an @dfn{image instance}. Image instances are their own
|
|
599 primitive object type (similar to font instances and color instances),
|
|
600 describing how the image appears in a particular domain. (On the other
|
|
601 hand, image instantiators, which are just descriptions of how the image
|
|
602 should appear, are represented using strings or vectors.)
|
|
603
|
|
604 @defun image-specifier-p object
|
|
605 This function returns non-@code{nil} if @var{object} is an image specifier.
|
|
606 Usually, an image specifier results from calling @code{glyph-image} on
|
|
607 a glyph.
|
|
608 @end defun
|
|
609
|
|
610 @defun make-image-specifier spec-list
|
442
|
611 This function creates a new image specifier object and initializes it
|
|
612 according to @var{spec-list}. @xref{Specifiers}.
|
|
613
|
|
614 Note that, in practice, you rarely, if ever, need to actually create an
|
|
615 image specifier! (This function exists mainly for completeness.) Pretty
|
|
616 much the only use for image specifiers is to control how glyphs are
|
|
617 displayed, and the image specifier associated with a glyph (the
|
|
618 @code{image} property of a glyph) is created automatically when a glyph
|
|
619 is created and need not (and cannot, for that matter) ever be changed
|
|
620 (@pxref{Glyphs}). In fact, the design decision to create a separate
|
|
621 image specifier type, rather than make glyphs themselves be specifiers,
|
|
622 is debatable---the other properties of glyphs are rarely used and could
|
|
623 conceivably have been incorporated into the glyph's instantiator. The
|
|
624 rarely used glyph types (buffer, pointer, icon) could also have been
|
|
625 incorporated into the instantiator.
|
428
|
626 @end defun
|
|
627
|
|
628 Image instantiators come in many formats: @code{xbm}, @code{xpm},
|
|
629 @code{gif}, @code{jpeg}, etc. This describes the format of the data
|
|
630 describing the image. The resulting image instances also come in many
|
440
|
631 types---@code{mono-pixmap}, @code{color-pixmap}, @code{text},
|
428
|
632 @code{pointer}, etc. This refers to the behavior of the image and the
|
|
633 sorts of places it can appear. (For example, a color-pixmap image has
|
|
634 fixed colors specified for it, while a mono-pixmap image comes in two
|
|
635 unspecified shades ``foreground'' and ``background'' that are determined
|
|
636 from the face of the glyph or surrounding text; a text image appears as
|
|
637 a string of text and has an unspecified foreground, background, and
|
|
638 font; a pointer image behaves like a mono-pixmap image but can only be
|
|
639 used as a mouse pointer [mono-pixmap images cannot be used as mouse
|
|
640 pointers]; etc.) It is important to keep the distinction between image
|
|
641 instantiator format and image instance type in mind. Typically, a given
|
|
642 image instantiator format can result in many different image instance
|
|
643 types (for example, @code{xpm} can be instanced as @code{color-pixmap},
|
|
644 @code{mono-pixmap}, or @code{pointer}; whereas @code{cursor-font} can be
|
|
645 instanced only as @code{pointer}), and a particular image instance type
|
|
646 can be generated by many different image instantiator formats (e.g.
|
|
647 @code{color-pixmap} can be generated by @code{xpm}, @code{gif},
|
|
648 @code{jpeg}, etc.).
|
|
649
|
|
650 @xref{Image Instances}, for a more detailed discussion of image
|
|
651 instance types.
|
|
652
|
|
653 An image instantiator should be a string or a vector of the form
|
|
654
|
|
655 @example
|
|
656 @code{[@var{format} @var{:keyword} @var{value} ...]}
|
|
657 @end example
|
|
658
|
|
659 i.e. a format symbol followed by zero or more alternating keyword-value
|
|
660 pairs. The @dfn{format} field should be a symbol, one of
|
|
661
|
|
662 @table @code
|
|
663 @item nothing
|
442
|
664 Don't display anything; no keywords are valid for this. Can only be
|
|
665 instanced as @code{nothing}.
|
428
|
666 @item string
|
442
|
667 Display this image as a text string. Can only be instanced
|
428
|
668 as @code{text}, although support for instancing as @code{mono-pixmap}
|
442
|
669 should be added.
|
428
|
670 @item formatted-string
|
442
|
671 Display this image as a text string with replaceable fields,
|
|
672 similar to a modeline format string; not currently implemented.
|
428
|
673 @item xbm
|
442
|
674 An X bitmap; only if X support was compiled into this XEmacs. Can be
|
428
|
675 instanced as @code{mono-pixmap}, @code{color-pixmap}, or
|
442
|
676 @code{pointer}.
|
428
|
677 @item xpm
|
442
|
678 An XPM pixmap; only if XPM support was compiled into this XEmacs. Can
|
428
|
679 be instanced as @code{color-pixmap}, @code{mono-pixmap}, or
|
|
680 @code{pointer}. XPM is an add-on library for X that was designed to
|
|
681 rectify the shortcomings of the XBM format. Most implementations of X
|
|
682 include the XPM library as a standard part. If your vendor does not, it
|
|
683 is highly recommended that you download it and install it. You can get
|
442
|
684 it from the standard XEmacs FTP site, among other places.
|
428
|
685 @item xface
|
442
|
686 An X-Face bitmap, used to encode people's faces in e-mail messages;
|
428
|
687 only if X-Face support was compiled into this XEmacs. Can be instanced
|
442
|
688 as @code{mono-pixmap}, @code{color-pixmap}, or @code{pointer}.
|
428
|
689 @item gif
|
442
|
690 A GIF87 or GIF89 image; only if GIF support was compiled into this
|
428
|
691 XEmacs. Can be instanced as @code{color-pixmap}. Note that XEmacs
|
|
692 includes GIF decoding functions as a standard part of it, so if you have
|
|
693 X support, you will normally have GIF support, unless you explicitly
|
442
|
694 disable it at configure time.
|
428
|
695 @item jpeg
|
442
|
696 A JPEG-format image; only if JPEG support was compiled into this
|
428
|
697 XEmacs. Can be instanced as @code{color-pixmap}. If you have the JPEG
|
|
698 libraries present on your system when XEmacs is built, XEmacs will
|
|
699 automatically detect this and use them, unless you explicitly disable it
|
442
|
700 at configure time.
|
428
|
701 @item png
|
442
|
702 A PNG/GIF24 image; only if PNG support was compiled into this XEmacs.
|
|
703 Can be instanced as @code{color-pixmap}.
|
428
|
704 @item tiff
|
442
|
705 A TIFF-format image; only if TIFF support was compiled into this XEmacs.
|
428
|
706 @item cursor-font
|
442
|
707 One of the standard cursor-font names, such as @samp{watch} or
|
428
|
708 @samp{right_ptr} under X. Under X, this is, more specifically, any of
|
|
709 the standard cursor names from appendix B of the Xlib manual [also known
|
|
710 as the file @file{<X11/cursorfont.h>}] minus the @samp{XC_} prefix. On
|
|
711 other window systems, the valid names will be specific to the type of
|
442
|
712 window system. Can only be instanced as @code{pointer}.
|
428
|
713 @item font
|
442
|
714 A glyph from a font; i.e. the name of a font, and glyph index into it
|
428
|
715 of the form @samp{@var{font} fontname index [[mask-font] mask-index]}.
|
|
716 Only if X support was compiled into this XEmacs. Currently can only be
|
442
|
717 instanced as @code{pointer}, although this should probably be fixed.
|
|
718 @item mswindows-resource
|
|
719 An MS Windows pointer resource. Specifies a resource to retrieve
|
|
720 directly from the system (an OEM resource) or from a file, particularly
|
|
721 an executable file. If the resource is to be retrieved from a file, use
|
|
722 :file and optionally :resource-id. Otherwise use :resource-id. Always
|
|
723 specify :resource-type to specify the type (cursor, bitmap or icon) of
|
|
724 the resource. Possible values for :resource-id are listed below. Can
|
|
725 be instanced as @code{pointer} or @code{color-pixmap}.
|
428
|
726 @item subwindow
|
442
|
727 An embedded windowing system window. Can only be instanced as
|
|
728 @code{subwindow}.
|
|
729 @item button
|
|
730 A button widget; either a push button, radio button or toggle button.
|
|
731 Can only be instanced as @code{widget}.
|
|
732 @item combo-box
|
|
733 A drop list of selectable items in a widget, for editing text.
|
|
734 Can only be instanced as @code{widget}.
|
|
735 @item edit-field
|
|
736 A text editing widget. Can only be instanced as @code{widget}.
|
|
737 @item label
|
|
738 A static, text-only, widget; for displaying text. Can only be instanced
|
|
739 as @code{widget}.
|
|
740 @item layout
|
|
741 A widget for controlling the positioning of children underneath it.
|
|
742 Through the use of nested layouts, a widget hierarchy can be created
|
|
743 which can have the appearance of any standard dialog box or similar
|
|
744 arrangement; all of this is counted as one @dfn{glyph} and could appear
|
|
745 in many of the places that expect a single glyph. Can only be instanced
|
|
746 as @code{widget}.
|
|
747 @item native-layout
|
|
748 @c #### Document me better!
|
|
749 The native version of a layout widget.
|
|
750 Can only be instanced as @code{widget}.
|
|
751 @item progress-gauge
|
|
752 A sliding widget, for showing progress. Can only be instanced as
|
|
753 @code{widget}.
|
|
754 @item tab-control
|
|
755 A tab widget; a series of user selectable tabs. Can only be instanced
|
|
756 as @code{widget}.
|
|
757 @item tree-view
|
|
758 A folding widget. Can only be instanced as @code{widget}.
|
|
759 @item scrollbar
|
|
760 A scrollbar widget. Can only be instanced as @code{widget}.
|
428
|
761 @item autodetect
|
442
|
762 XEmacs tries to guess what format the data is in. If X support exists,
|
428
|
763 the data string will be checked to see if it names a filename. If so,
|
|
764 and this filename contains XBM or XPM data, the appropriate sort of
|
|
765 pixmap or pointer will be created. [This includes picking up any
|
|
766 specified hotspot or associated mask file.] Otherwise, if @code{pointer}
|
|
767 is one of the allowable image-instance types and the string names a
|
|
768 valid cursor-font name, the image will be created as a pointer.
|
|
769 Otherwise, the image will be displayed as text. If no X support exists,
|
442
|
770 the image will always be displayed as text.
|
|
771 @item inherit
|
|
772 Inherit from the background-pixmap property of a face. Can only be
|
|
773 instanced as @code{mono-pixmap}.
|
428
|
774 @end table
|
|
775
|
|
776 The valid keywords are:
|
|
777
|
|
778 @table @code
|
|
779 @item :data
|
442
|
780 Inline data. For most formats above, this should be a string. For
|
428
|
781 XBM images, this should be a list of three elements: width, height, and
|
|
782 a string of bit data. This keyword is not valid for instantiator
|
442
|
783 format @code{nothing}.
|
428
|
784
|
|
785 @item :file
|
442
|
786 Data is contained in a file. The value is the name of this file. If
|
428
|
787 both @code{:data} and @code{:file} are specified, the image is created
|
|
788 from what is specified in @code{:data} and the string in @code{:file}
|
|
789 becomes the value of the @code{image-instance-file-name} function when
|
|
790 applied to the resulting image-instance. This keyword is not valid for
|
|
791 instantiator formats @code{nothing}, @code{string},
|
|
792 @code{formatted-string}, @code{cursor-font}, @code{font}, and
|
442
|
793 @code{autodetect}.
|
428
|
794
|
|
795 @item :foreground
|
|
796 @itemx :background
|
442
|
797 For @code{xbm}, @code{xface}, @code{cursor-font}, and @code{font}.
|
428
|
798 These keywords allow you to explicitly specify foreground and background
|
|
799 colors. The argument should be anything acceptable to
|
|
800 @code{make-color-instance}. This will cause what would be a
|
|
801 @code{mono-pixmap} to instead be colorized as a two-color color-pixmap,
|
|
802 and specifies the foreground and/or background colors for a pointer
|
442
|
803 instead of black and white.
|
428
|
804
|
|
805 @item :mask-data
|
442
|
806 For @code{xbm} and @code{xface}. This specifies a mask to be used with the
|
428
|
807 bitmap. The format is a list of width, height, and bits, like for
|
442
|
808 @code{:data}.
|
428
|
809
|
|
810 @item :mask-file
|
442
|
811 For @code{xbm} and @code{xface}. This specifies a file containing the
|
428
|
812 mask data. If neither a mask file nor inline mask data is given for an
|
|
813 XBM image, and the XBM image comes from a file, XEmacs will look for a
|
|
814 mask file with the same name as the image file but with @samp{Mask} or
|
|
815 @samp{msk} appended. For example, if you specify the XBM file
|
|
816 @file{left_ptr} [usually located in @file{/usr/include/X11/bitmaps}],
|
|
817 the associated mask file @file{left_ptrmsk} will automatically be picked
|
442
|
818 up.
|
428
|
819
|
|
820 @item :hotspot-x
|
|
821 @itemx :hotspot-y
|
442
|
822 For @code{xbm} and @code{xface}. These keywords specify a hotspot if
|
428
|
823 the image is instantiated as a @code{pointer}. Note that if the XBM
|
|
824 image file specifies a hotspot, it will automatically be picked up if no
|
442
|
825 explicit hotspot is given.
|
428
|
826
|
|
827 @item :color-symbols
|
442
|
828 Only for @code{xpm}. This specifies an alist that maps strings that
|
428
|
829 specify symbolic color names to the actual color to be used for that
|
|
830 symbolic color (in the form of a string or a color-specifier object).
|
|
831 If this is not specified, the contents of @code{xpm-color-symbols} are
|
442
|
832 used to generate the alist.
|
|
833 @item :resource-id
|
|
834 Only for @code{mswindows-resource}. This must be either an integer
|
|
835 (which directly specifies a resource number) or a string. Valid strings
|
|
836 are
|
|
837
|
|
838 For bitmaps:
|
|
839
|
|
840 "close", "uparrow", "dnarrow", "rgarrow", "lfarrow",
|
|
841 "reduce", "zoom", "restore", "reduced", "zoomd",
|
|
842 "restored", "uparrowd", "dnarrowd", "rgarrowd", "lfarrowd",
|
|
843 "mnarrow", "combo", "uparrowi", "dnarrowi", "rgarrowi",
|
|
844 "lfarrowi", "size", "btsize", "check", "checkboxes", and
|
|
845 "btncorners".
|
|
846
|
|
847 For cursors:
|
|
848
|
|
849 "normal", "ibeam", "wait", "cross", "up", "sizenwse",
|
|
850 "sizenesw", "sizewe", "sizens", "sizeall", and "no".
|
|
851
|
|
852 For icons:
|
|
853
|
|
854 "sample", "hand", "ques", "bang", "note", and "winlogo".
|
|
855 @item :resource-type
|
|
856 Only for @code{mswindows-resource}. This must be a symbol, either
|
|
857 @code{cursor}, @code{icon}, or @code{bitmap}, specifying the type of
|
|
858 resource to be retrieved.
|
|
859 @item :face
|
|
860 Only for @code{inherit}. This specifies the face to inherit from. For
|
|
861 widgets this also specifies the face to use for display. It defaults to
|
|
862 gui-element-face.
|
428
|
863 @end table
|
|
864
|
442
|
865 Keywords accepted as menu item specs are also accepted by widgets.
|
|
866 These are @code{:selected}, @code{:active}, @code{:suffix},
|
|
867 @code{:keys}, @code{:style}, @code{:filter}, @code{:config},
|
|
868 @code{:included}, @code{:key-sequence}, @code{:accelerator},
|
|
869 @code{:label} and @code{:callback}.
|
|
870
|
428
|
871 If instead of a vector, the instantiator is a string, it will be
|
|
872 converted into a vector by looking it up according to the specs in the
|
|
873 @code{console-type-image-conversion-list} for the console type of
|
|
874 the domain (usually a window; sometimes a frame or device) over which
|
|
875 the image is being instantiated.
|
|
876
|
|
877 If the instantiator specifies data from a file, the data will be read in
|
|
878 at the time that the instantiator is added to the image specifier (which
|
|
879 may be well before the image is actually displayed), and the
|
|
880 instantiator will be converted into one of the inline-data forms, with
|
|
881 the filename retained using a @code{:file} keyword. This implies that
|
|
882 the file must exist when the instantiator is added to the image, but
|
|
883 does not need to exist at any other time (e.g. it may safely be a
|
|
884 temporary file).
|
|
885
|
444
|
886 @defun valid-image-instantiator-format-p format &optional locale
|
428
|
887 This function returns non-@code{nil} if @var{format} is a valid image
|
444
|
888 instantiator format.
|
|
889
|
|
890 If @var{locale} is non-@code{nil} then the format is checked in that locale.
|
|
891 If @var{locale} is @code{nil} the current console is used.
|
|
892
|
|
893 Note that the return value for many formats listed above depends on
|
|
894 whether XEmacs was compiled with support for that format.
|
428
|
895 @end defun
|
|
896
|
|
897 @defun image-instantiator-format-list
|
|
898 This function return a list of valid image-instantiator formats.
|
|
899 @end defun
|
|
900
|
|
901 @defvar xpm-color-symbols
|
|
902 This variable holds definitions of logical color-names used when reading
|
|
903 XPM files. Elements of this list should be of the form
|
|
904 @code{(@var{color-name} @var{form-to-evaluate})}. The @var{color-name}
|
|
905 should be a string, which is the name of the color to define; the
|
|
906 @var{form-to-evaluate} should evaluate to a color specifier object, or a
|
|
907 string to be passed to @code{make-color-instance} (@pxref{Colors}). If
|
|
908 a loaded XPM file references a symbolic color called @var{color-name},
|
|
909 it will display as the computed color instead.
|
|
910
|
|
911 The default value of this variable defines the logical color names
|
|
912 @samp{"foreground"} and @samp{"background"} to be the colors of the
|
|
913 @code{default} face.
|
|
914 @end defvar
|
|
915
|
|
916 @defvar x-bitmap-file-path
|
444
|
917 A list of the directories in which X bitmap files may be found. If @code{nil},
|
428
|
918 this is initialized from the @samp{"*bitmapFilePath"} resource. This is
|
|
919 used by the @code{make-image-instance} function (however, note that if
|
|
920 the environment variable @samp{XBMLANGPATH} is set, it is consulted
|
|
921 first).
|
|
922 @end defvar
|
|
923
|
|
924 @node Image Instantiator Conversion
|
|
925 @subsection Image Instantiator Conversion
|
|
926 @cindex image instantiator conversion
|
|
927 @cindex conversion of image instantiators
|
|
928
|
|
929 @defun set-console-type-image-conversion-list console-type list
|
|
930 This function sets the image-conversion-list for consoles of the given
|
|
931 @var{console-type}. The image-conversion-list specifies how image
|
|
932 instantiators that are strings should be interpreted. Each element of
|
|
933 the list should be a list of two elements (a regular expression string
|
|
934 and a vector) or a list of three elements (the preceding two plus an
|
|
935 integer index into the vector). The string is converted to the vector
|
|
936 associated with the first matching regular expression. If a vector
|
|
937 index is specified, the string itself is substituted into that position
|
|
938 in the vector.
|
|
939
|
|
940 Note: The conversion above is applied when the image instantiator is
|
|
941 added to an image specifier, not when the specifier is actually
|
|
942 instantiated. Therefore, changing the image-conversion-list only affects
|
|
943 newly-added instantiators. Existing instantiators in glyphs and image
|
|
944 specifiers will not be affected.
|
|
945 @end defun
|
|
946
|
|
947 @defun console-type-image-conversion-list console-type
|
|
948 This function returns the image-conversion-list for consoles of the given
|
|
949 @var{console-type}.
|
|
950 @end defun
|
|
951
|
|
952 @node Image Instances
|
|
953 @subsection Image Instances
|
|
954 @cindex image instances
|
|
955
|
|
956 Image-instance objects encapsulate the way a particular image (pixmap,
|
|
957 etc.) is displayed on a particular device.
|
|
958
|
|
959 In most circumstances, you do not need to directly create image
|
|
960 instances; use a glyph instead. However, it may occasionally be useful
|
|
961 to explicitly create image instances, if you want more control over the
|
|
962 instantiation process.
|
|
963
|
|
964 @defun image-instance-p object
|
|
965 This function returns non-@code{nil} if @var{object} is an image instance.
|
|
966 @end defun
|
|
967
|
|
968 @menu
|
|
969 * Image Instance Types:: Each image instances has a particular type.
|
|
970 * Image Instance Functions:: Functions for working with image instances.
|
|
971 @end menu
|
|
972
|
|
973 @node Image Instance Types
|
|
974 @subsubsection Image Instance Types
|
|
975 @cindex image instance types
|
|
976
|
|
977 Image instances come in a number of different types. The type
|
|
978 of an image instance specifies the nature of the image: Whether
|
|
979 it is a text string, a mono pixmap, a color pixmap, etc.
|
|
980
|
|
981 The valid image instance types are
|
|
982
|
|
983 @table @code
|
|
984 @item nothing
|
|
985 Nothing is displayed.
|
|
986
|
|
987 @item text
|
|
988 Displayed as text. The foreground and background colors and the
|
|
989 font of the text are specified independent of the pixmap. Typically
|
|
990 these attributes will come from the face of the surrounding text,
|
|
991 unless a face is specified for the glyph in which the image appears.
|
|
992
|
|
993 @item mono-pixmap
|
|
994 Displayed as a mono pixmap (a pixmap with only two colors where the
|
|
995 foreground and background can be specified independent of the pixmap;
|
|
996 typically the pixmap assumes the foreground and background colors of
|
|
997 the text around it, unless a face is specified for the glyph in which
|
|
998 the image appears).
|
|
999 @item color-pixmap
|
|
1000
|
|
1001 Displayed as a color pixmap.
|
|
1002
|
|
1003 @item pointer
|
|
1004 Used as the mouse pointer for a window.
|
|
1005
|
|
1006 @item subwindow
|
|
1007 A child window that is treated as an image. This allows (e.g.)
|
|
1008 another program to be responsible for drawing into the window.
|
|
1009 Not currently implemented.
|
|
1010 @end table
|
|
1011
|
|
1012 @defun valid-image-instance-type-p type
|
|
1013 This function returns non-@code{nil} if @var{type} is a valid image
|
|
1014 instance type.
|
|
1015 @end defun
|
|
1016
|
|
1017 @defun image-instance-type-list
|
|
1018 This function returns a list of the valid image instance types.
|
|
1019 @end defun
|
|
1020
|
|
1021 @defun image-instance-type image-instance
|
|
1022 This function returns the type of the given image instance. The return
|
|
1023 value will be one of @code{nothing}, @code{text}, @code{mono-pixmap},
|
|
1024 @code{color-pixmap}, @code{pointer}, or @code{subwindow}.
|
|
1025 @end defun
|
|
1026
|
|
1027 @defun text-image-instance-p object
|
|
1028 This function returns non-@code{nil} if @var{object} is an image
|
|
1029 instance of type @code{text}.
|
|
1030 @end defun
|
|
1031
|
|
1032 @defun mono-pixmap-image-instance-p object
|
|
1033 This function returns non-@code{nil} if @var{object} is an image
|
|
1034 instance of type @code{mono-pixmap}.
|
|
1035 @end defun
|
|
1036
|
|
1037 @defun color-pixmap-image-instance-p object
|
|
1038 This function returns non-@code{nil} if @var{object} is an image
|
|
1039 instance of type @code{color-pixmap}.
|
|
1040 @end defun
|
|
1041
|
|
1042 @defun pointer-image-instance-p object
|
|
1043 This function returns non-@code{nil} if @var{object} is an image
|
|
1044 instance of type @code{pointer}.
|
|
1045 @end defun
|
|
1046
|
|
1047 @defun subwindow-image-instance-p object
|
|
1048 This function returns non-@code{nil} if @var{object} is an image
|
|
1049 instance of type @code{subwindow}.
|
|
1050 @end defun
|
|
1051
|
|
1052 @defun nothing-image-instance-p object
|
|
1053 This function returns non-@code{nil} if @var{object} is an image
|
|
1054 instance of type @code{nothing}.
|
|
1055 @end defun
|
|
1056
|
442
|
1057 @defun widget-image-instance-p object
|
444
|
1058 Return @code{t} if @var{object} is an image instance of type @code{widget}.
|
442
|
1059 @end defun
|
|
1060
|
428
|
1061 @node Image Instance Functions
|
|
1062 @subsubsection Image Instance Functions
|
|
1063
|
444
|
1064 @defun make-image-instance data &optional domain dest-types noerror
|
428
|
1065 This function creates a new image-instance object.
|
|
1066
|
|
1067 @var{data} is an image instantiator, which describes the image
|
|
1068 (@pxref{Image Specifiers}).
|
|
1069
|
|
1070 @var{dest-types} should be a list of allowed image instance types that
|
|
1071 can be generated. The @var{dest-types} list is unordered. If multiple
|
|
1072 destination types are possible for a given instantiator, the ``most
|
|
1073 natural'' type for the instantiator's format is chosen. (For XBM, the
|
|
1074 most natural types are @code{mono-pixmap}, followed by
|
|
1075 @code{color-pixmap}, followed by @code{pointer}. For the other normal
|
|
1076 image formats, the most natural types are @code{color-pixmap}, followed
|
|
1077 by @code{mono-pixmap}, followed by @code{pointer}. For the string and
|
|
1078 formatted-string formats, the most natural types are @code{text},
|
|
1079 followed by @code{mono-pixmap} (not currently implemented), followed by
|
442
|
1080 @code{color-pixmap} (not currently implemented). For MS Windows
|
|
1081 resources, the most natural type for pointer resources is
|
|
1082 @code{pointer}, and for the others it's @code{color-pixmap}. The other
|
|
1083 formats can only be instantiated as one type. (If you want to control
|
|
1084 more specifically the order of the types into which an image is
|
|
1085 instantiated, just call @code{make-image-instance} repeatedly until it
|
|
1086 succeeds, passing less and less preferred destination types each time.
|
428
|
1087
|
|
1088 If @var{dest-types} is omitted, all possible types are allowed.
|
|
1089
|
442
|
1090 @var{domain} specifies the domain to which the image instance will be
|
|
1091 attached. This domain is termed the @dfn{governing domain}. The type
|
|
1092 of the governing domain depends on the image instantiator
|
|
1093 format. (Although, more correctly, it should probably depend on the
|
|
1094 image instance type.) For example, pixmap image instances are specific
|
|
1095 to a device, but widget image instances are specific to a particular
|
|
1096 XEmacs window because in order to display such a widget when two windows
|
|
1097 onto the same buffer want to display the widget, two separate underlying
|
|
1098 widgets must be created. (That's because a widget is actually a child
|
|
1099 window-system window, and all window-system windows have a unique
|
|
1100 existence on the screen.) This means that the governing domain for a
|
|
1101 pixmap image instance will be some device (most likely, the only
|
|
1102 existing device), whereas the governing domain for a widget image
|
|
1103 instance will be some XEmacs window.
|
|
1104
|
|
1105 If you specify an overly general @var{domain} (e.g. a frame when a
|
|
1106 window was wanted), an error is signaled. If you specify an overly
|
|
1107 specific @var{domain} (e.g. a window when a device was wanted), the
|
|
1108 corresponding general domain is fetched and used instead. For
|
|
1109 @code{make-image-instance}, it makes no difference whether you specify
|
|
1110 an overly specific domain or the properly general domain derived from
|
|
1111 it. However, it does matter when creating an image instance by
|
|
1112 instantiating a specifier or glyph (e.g. with
|
|
1113 @code{glyph-image-instance}), because the more specific domain causes
|
|
1114 spec lookup to start there and proceed to more general domains. (It
|
|
1115 would also matter when creating an image instance with an instantiator
|
|
1116 format of @code{inherit}, but we currently disallow this. #### We should
|
|
1117 fix this.)
|
|
1118 n
|
|
1119 If omitted, @var{domain} defaults to the selected window.
|
|
1120
|
444
|
1121 @var{noerror} controls what happens when the image cannot be generated.
|
|
1122 If @code{nil}, an error message is generated. If @code{t}, no messages
|
|
1123 are generated and this function returns @code{nil}. If anything else, a
|
|
1124 warning message is generated and this function returns @code{nil}.
|
428
|
1125 @end defun
|
|
1126
|
|
1127 @defun colorize-image-instance image-instance foreground background
|
|
1128 This function makes the image instance be displayed in the given
|
|
1129 colors. Image instances come in two varieties: bitmaps, which are 1
|
|
1130 bit deep which are rendered in the prevailing foreground and background
|
|
1131 colors; and pixmaps, which are of arbitrary depth (including 1) and
|
|
1132 which have the colors explicitly specified. This function converts a
|
|
1133 bitmap to a pixmap. If the image instance was a pixmap already,
|
|
1134 nothing is done (and @code{nil} is returned). Otherwise @code{t} is
|
|
1135 returned.
|
|
1136 @end defun
|
|
1137
|
|
1138 @defun image-instance-name image-instance
|
|
1139 This function returns the name of the given image instance.
|
|
1140 @end defun
|
|
1141
|
442
|
1142 @defun image-instance-domain image-instance
|
|
1143
|
|
1144 Return the governing domain of the given @var{image-instance}. The
|
|
1145 governing domain of an image instance is the domain that the image
|
|
1146 instance is specific to. It is @emph{NOT} necessarily the domain that
|
|
1147 was given to the call to @code{specifier-instance} that resulted in the
|
|
1148 creation of this image instance. See @code{make-image-instance} for
|
|
1149 more information on governing domains.
|
|
1150 @end defun
|
|
1151
|
|
1152
|
428
|
1153 @defun image-instance-string image-instance
|
|
1154 This function returns the string of the given image instance. This will
|
|
1155 only be non-@code{nil} for text image instances.
|
|
1156 @end defun
|
|
1157
|
|
1158 @defun image-instance-file-name image-instance
|
|
1159 This function returns the file name from which @var{image-instance} was
|
|
1160 read, if known.
|
|
1161 @end defun
|
|
1162
|
|
1163 @defun image-instance-mask-file-name image-instance
|
|
1164 This function returns the file name from which @var{image-instance}'s
|
|
1165 mask was read, if known.
|
|
1166 @end defun
|
|
1167
|
|
1168 @defun image-instance-depth image-instance
|
|
1169 This function returns the depth of the image instance. This is 0 for a
|
|
1170 mono pixmap, or a positive integer for a color pixmap.
|
|
1171 @end defun
|
|
1172
|
|
1173 @defun image-instance-height image-instance
|
|
1174 This function returns the height of the image instance, in pixels.
|
|
1175 @end defun
|
|
1176
|
|
1177 @defun image-instance-width image-instance
|
|
1178 This function returns the width of the image instance, in pixels.
|
|
1179 @end defun
|
|
1180
|
|
1181 @defun image-instance-hotspot-x image-instance
|
|
1182 This function returns the X coordinate of the image instance's hotspot,
|
|
1183 if known. This is a point relative to the origin of the pixmap. When
|
|
1184 an image is used as a mouse pointer, the hotspot is the point on the
|
|
1185 image that sits over the location that the pointer points to. This is,
|
|
1186 for example, the tip of the arrow or the center of the crosshairs.
|
|
1187
|
|
1188 This will always be @code{nil} for a non-pointer image instance.
|
|
1189 @end defun
|
|
1190
|
|
1191 @defun image-instance-hotspot-y image-instance
|
|
1192 This function returns the Y coordinate of the image instance's hotspot,
|
|
1193 if known.
|
|
1194 @end defun
|
|
1195
|
|
1196 @defun image-instance-foreground image-instance
|
|
1197 This function returns the foreground color of @var{image-instance}, if
|
|
1198 applicable. This will be a color instance or @code{nil}. (It will only
|
|
1199 be non-@code{nil} for colorized mono pixmaps and for pointers.)
|
|
1200 @end defun
|
|
1201
|
|
1202 @defun image-instance-background image-instance
|
|
1203 This function returns the background color of @var{image-instance}, if
|
|
1204 applicable. This will be a color instance or @code{nil}. (It will only
|
|
1205 be non-@code{nil} for colorized mono pixmaps and for pointers.)
|
|
1206 @end defun
|
|
1207
|
|
1208 @node Glyph Types
|
|
1209 @section Glyph Types
|
|
1210
|
|
1211 Each glyph has a particular type, which controls how the glyph's image
|
|
1212 is generated. Each glyph type has a corresponding list of allowable
|
|
1213 image instance types that can be generated. When you call
|
|
1214 @code{glyph-image-instance} to retrieve the image instance of a glyph,
|
|
1215 XEmacs does the equivalent of calling @code{make-image-instance} and
|
|
1216 passing in @var{dest-types} the list of allowable image instance types
|
|
1217 for the glyph's type.
|
|
1218
|
|
1219 @itemize @bullet
|
|
1220 @item
|
|
1221 @code{buffer} glyphs can be used as the begin-glyph or end-glyph of an
|
|
1222 extent, in the modeline, and in the toolbar. Their image can be
|
|
1223 instantiated as @code{nothing}, @code{mono-pixmap}, @code{color-pixmap},
|
|
1224 @code{text}, and @code{subwindow}.
|
|
1225
|
|
1226 @item
|
|
1227 @code{pointer} glyphs can be used to specify the mouse pointer. Their
|
|
1228 image can be instantiated as @code{pointer}.
|
|
1229
|
|
1230 @item
|
|
1231 @code{icon} glyphs can be used to specify the icon used when a frame is
|
|
1232 iconified. Their image can be instantiated as @code{mono-pixmap} and
|
|
1233 @code{color-pixmap}.
|
|
1234 @end itemize
|
|
1235
|
|
1236 @defun glyph-type glyph
|
|
1237 This function returns the type of the given glyph. The return value
|
|
1238 will be a symbol, one of @code{buffer}, @code{pointer}, or @code{icon}.
|
|
1239 @end defun
|
|
1240
|
|
1241 @defun valid-glyph-type-p glyph-type
|
|
1242 Given a @var{glyph-type}, this function returns non-@code{nil} if it is
|
|
1243 valid.
|
|
1244 @end defun
|
|
1245
|
|
1246 @defun glyph-type-list
|
|
1247 This function returns a list of valid glyph types.
|
|
1248 @end defun
|
|
1249
|
|
1250 @defun buffer-glyph-p object
|
|
1251 This function returns non-@code{nil} if @var{object} is a glyph of type
|
|
1252 @code{buffer}.
|
|
1253 @end defun
|
|
1254
|
|
1255 @defun icon-glyph-p object
|
|
1256 This function returns non-@code{nil} if @var{object} is a glyph of type
|
|
1257 @code{icon}.
|
|
1258 @end defun
|
|
1259
|
|
1260 @defun pointer-glyph-p object
|
|
1261 This function returns non-@code{nil} if @var{object} is a glyph of type
|
|
1262 @code{pointer}.
|
|
1263 @end defun
|
|
1264
|
|
1265 @node Mouse Pointer
|
|
1266 @section Mouse Pointer
|
|
1267 @cindex mouse cursor
|
|
1268 @cindex cursor (mouse)
|
|
1269 @cindex pointer (mouse)
|
|
1270 @cindex mouse pointer
|
|
1271
|
|
1272 The shape of the mouse pointer when over a particular section of a frame
|
|
1273 is controlled using various glyph variables. Since the image of a glyph
|
|
1274 is a specifier, it can be controlled on a per-buffer, per-frame, per-window,
|
|
1275 or per-device basis.
|
|
1276
|
|
1277 You should use @code{set-glyph-image} to set the following variables,
|
|
1278 @emph{not} @code{setq}.
|
|
1279
|
|
1280 @defvr Glyph text-pointer-glyph
|
|
1281 This variable specifies the shape of the mouse pointer when over text.
|
|
1282 @end defvr
|
|
1283
|
|
1284 @defvr Glyph nontext-pointer-glyph
|
|
1285 This variable specifies the shape of the mouse pointer when over a
|
|
1286 buffer, but not over text. If unspecified in a particular domain,
|
|
1287 @code{text-pointer-glyph} is used.
|
|
1288 @end defvr
|
|
1289
|
|
1290 @defvr Glyph modeline-pointer-glyph
|
|
1291 This variable specifies the shape of the mouse pointer when over the modeline.
|
|
1292 If unspecified in a particular domain, @code{nontext-pointer-glyph} is used.
|
|
1293 @end defvr
|
|
1294
|
|
1295 @defvr Glyph selection-pointer-glyph
|
|
1296 This variable specifies the shape of the mouse pointer when over a
|
|
1297 selectable text region. If unspecified in a particular domain,
|
|
1298 @code{text-pointer-glyph} is used.
|
|
1299 @end defvr
|
|
1300
|
|
1301 @defvr Glyph gc-pointer-glyph
|
|
1302 This variable specifies the shape of the mouse pointer when a garbage
|
|
1303 collection is in progress. If the selected window is on a window system
|
|
1304 and this glyph specifies a value (i.e. a pointer image instance) in the
|
|
1305 domain of the selected window, the pointer will be changed as specified
|
|
1306 during garbage collection. Otherwise, a message will be printed in the
|
|
1307 echo area, as controlled by @code{gc-message}.
|
|
1308 @end defvr
|
|
1309
|
|
1310 @defvr Glyph busy-pointer-glyph
|
|
1311 This variable specifies the shape of the mouse pointer when XEmacs is busy.
|
|
1312 If unspecified in a particular domain, the pointer is not changed
|
|
1313 when XEmacs is busy.
|
|
1314 @end defvr
|
|
1315
|
|
1316 @defvr Glyph menubar-pointer-glyph
|
|
1317 This variable specifies the shape of the mouse pointer when over the
|
|
1318 menubar. If unspecified in a particular domain, the
|
|
1319 window-system-provided default pointer is used.
|
|
1320 @end defvr
|
|
1321
|
|
1322 @defvr Glyph scrollbar-pointer-glyph
|
|
1323 This variable specifies the shape of the mouse pointer when over a
|
|
1324 scrollbar. If unspecified in a particular domain, the
|
|
1325 window-system-provided default pointer is used.
|
|
1326 @end defvr
|
|
1327
|
|
1328 @defvr Glyph toolbar-pointer-glyph
|
|
1329 This variable specifies the shape of the mouse pointer when over a
|
|
1330 toolbar. If unspecified in a particular domain,
|
|
1331 @code{nontext-pointer-glyph} is used.
|
|
1332 @end defvr
|
|
1333
|
|
1334 Internally, these variables are implemented in
|
|
1335 @code{default-mouse-motion-handler}, and thus only take effect when the
|
|
1336 mouse moves. That function calls @code{set-frame-pointer}, which sets
|
|
1337 the current mouse pointer for a frame.
|
|
1338
|
|
1339 @defun set-frame-pointer frame image-instance
|
|
1340 This function sets the mouse pointer of @var{frame} to the given pointer
|
|
1341 image instance. You should not call this function directly.
|
|
1342 (If you do, the pointer will change again the next time the mouse moves.)
|
|
1343 @end defun
|
|
1344
|
|
1345 @node Redisplay Glyphs
|
|
1346 @section Redisplay Glyphs
|
|
1347
|
|
1348 @defvr Glyph truncation-glyph
|
|
1349 This variable specifies what is displayed at the end of truncated lines.
|
|
1350 @end defvr
|
|
1351
|
|
1352 @defvr Glyph continuation-glyph
|
|
1353 This variable specifies what is displayed at the end of wrapped lines.
|
|
1354 @end defvr
|
|
1355
|
|
1356 @defvr Glyph octal-escape-glyph
|
|
1357 This variable specifies what to prefix character codes displayed in octal
|
|
1358 with.
|
|
1359 @end defvr
|
|
1360
|
|
1361 @defvr Glyph hscroll-glyph
|
|
1362 This variable specifies what to display at the beginning of horizontally
|
|
1363 scrolled lines.
|
|
1364 @end defvr
|
|
1365
|
|
1366 @defvr Glyph invisible-text-glyph
|
|
1367 This variable specifies what to use to indicate the presence of
|
|
1368 invisible text. This is the glyph that is displayed when an ellipsis is
|
|
1369 called for, according to @code{selective-display-ellipses} or
|
|
1370 @code{buffer-invisibility-spec}). Normally this is three dots (``...'').
|
|
1371 @end defvr
|
|
1372
|
|
1373 @defvr Glyph control-arrow-glyph
|
|
1374 This variable specifies what to use as an arrow for control characters.
|
|
1375 @end defvr
|
|
1376
|
2028
|
1377 @node Native GUI Widgets
|
|
1378 @section Native GUI Widgets
|
|
1379 @cindex native widget
|
|
1380
|
|
1381 A ``native widget'' is a primitive GUI object defined either by the host
|
|
1382 GUI platform or an external toolkit, and accessed from Lisp as a
|
|
1383 ``glyph.''
|
|
1384
|
|
1385 @menu
|
|
1386 * Introduction to Widgets:: Native widgets provide tight integration of
|
|
1387 GUI features with the platform GUI.
|
|
1388 * Lisp API to Native Widgets:: Native widgets are glyphs.
|
|
1389 * Layouts:: Specifying composite widgets from Lisp.
|
|
1390 * Primitive Widgets:: Catalogue of available native widgets.
|
|
1391 @end menu
|
|
1392
|
|
1393 @node Introduction to Widgets
|
|
1394 @subsection Introduction to Native Widgets and Subwindow Glyphs
|
|
1395
|
|
1396 Traditionally Emacsen have hidden the GUI apparatus from the Lisp
|
|
1397 programmer, but in XEmacs 21.4 the ability to embed autonomous GUI
|
|
1398 objects, called @dfn{native widgets}, in text was added to Lisp. They
|
|
1399 are handled as @emph{glyphs}. Unlike traditional XEmacs
|
|
1400 glyphs such images and strings, native widgets are opaque to XEmacs, and
|
|
1401 must be able to redraw themselves because they are implemented as
|
|
1402 subwindows, not as graphics drawn by XEmacs into the text window.
|
|
1403
|
|
1404 Primitive widgets are coded in C using the underlying GUI toolkit, and
|
|
1405 thus are beyond the scope of the @emph{XEmacs Lisp Reference Manual}.
|
|
1406 However, composite widgets can be created in Lisp using ``layouts,''
|
|
1407 which are horizontal or vertical arrays of subwidgets. For example, the
|
|
1408 search dialog is formatted using layouts.
|
|
1409
|
|
1410 @node Lisp API to Native Widgets
|
|
1411 @subsection Lisp API to Native Widgets
|
|
1412
|
|
1413 Native widgets are manipulated as @emph{glyphs} (@pxref{Glyphs}). Thus
|
|
1414 they are created using @code{make-glyph}, with a format of one of the
|
|
1415 widget types and a @code{:data} property specific to the widget being
|
|
1416 instanced.
|
|
1417
|
|
1418 However, there is a technical difference between widgets and other kinds
|
|
1419 of glyphs that is theoretically important, which is that because widgets
|
|
1420 are active (that is, they can respond to user input events themselves),
|
|
1421 it is possible for the user to become aware that two appearances of the
|
|
1422 ``same'' glyph are actually separate instances. For example, if a user
|
|
1423 changes an image glyph from red to blue, and the buffer containing the
|
|
1424 glyph appears in more than one window, the user will perceive all the
|
|
1425 appearances to change from red to blue simultaneously. However, suppose
|
|
1426 the glyph is a button glyph (@emph{e.g.}, as used in the Customize
|
|
1427 buffer for the Set, Save, and Done buttons). Then if the Customize
|
|
1428 buffer appears in several windows at the same time, and the user clicks
|
|
1429 on the button, she will only perceive the button to be depressed in the
|
|
1430 window where she clicked the button.
|
|
1431
|
|
1432 It seems from this example that it is unlikely to be a problem in
|
|
1433 practice. When the user is faced with an active widget, it seems likely
|
|
1434 that attention will focus on the widget being manipulated, and having
|
|
1435 other instances of the widget respond simultaneously might be more
|
|
1436 disconcerting than the actual case.
|
|
1437
|
|
1438 @node Layouts
|
|
1439 @subsection Layouts
|
|
1440
|
|
1441 An XEmacs @dfn{layout} is a one-dimensional array of glyphs. It is a
|
|
1442 widget for controlling the positioning of children underneath it.
|
|
1443 Through the use of nested layouts, a widget hierarchy can be created
|
|
1444 which can have the appearance of any standard dialog box or similar
|
|
1445 arrangement; all of this is counted as one "glyph" and could appear in
|
|
1446 many of the places that expect a single glyph.
|
|
1447
|
|
1448 (There are also @dfn{native layouts}, but I don't know what these are or
|
|
1449 how they are used.)
|
|
1450
|
|
1451 A layout descriptor is an image instantiator, @emph{i.e.}, a vector of
|
|
1452 the form @samp{[FORMAT KEY-1 VALUE-1 KEY-2 VALUE-2 ...]} with format
|
|
1453 @code{layout}, and properties
|
|
1454
|
|
1455 @c #### need defaults for these
|
|
1456 @table @code
|
|
1457 @item :orientation
|
|
1458 Specifies the orientation of the contained array of glyphs. The value
|
|
1459 must be one of the symbols @code{horizontal} or @code{vertical}.
|
|
1460
|
|
1461 @item :horizontally-justify
|
|
1462 Specifies the horizontal justification of the items in the array. The
|
|
1463 value must be one of the symbols @code{:right}, @code{:center}, or
|
|
1464 @code{:left}.
|
|
1465
|
|
1466 @item :vertically-justify
|
|
1467 Specifies the vertical justification of the items in the array. The
|
|
1468 value must be one of the symbols @code{:center}, @code{:center}, or
|
|
1469 @code{:bottom}.
|
|
1470
|
|
1471 @item :justify
|
|
1472 Specifies justification. #### not understood.
|
|
1473
|
|
1474 @item :border
|
|
1475 A glyph to place in the border. The value must be an image
|
|
1476 instantiator.
|
|
1477
|
|
1478 @item :items
|
|
1479 The glyphs controlled by the layout. The value must be a list of image
|
|
1480 instantiators.
|
|
1481 @end table
|
|
1482
|
|
1483 Here is the specification of the search dialog widget created by
|
|
1484 @code{make-search-dialog} in the @file{dialog-items} library, which
|
|
1485 makes use of recursive layouts.
|
|
1486
|
|
1487 @example
|
|
1488 (make-glyph
|
|
1489 `[layout
|
|
1490 :orientation horizontal
|
|
1491 :vertically-justify top
|
|
1492 :horizontally-justify center
|
|
1493 :border [string :data "Search"]
|
|
1494 :items
|
|
1495 ([layout :orientation vertical
|
|
1496 :justify top ; implies left also
|
|
1497 :items
|
|
1498 ([string :data "Search for:"]
|
|
1499 [button :descriptor "Match Case"
|
|
1500 :style toggle
|
|
1501 :selected (not case-fold-search)
|
|
1502 :callback (setq case-fold-search
|
|
1503 (not case-fold-search))]
|
|
1504 [button :descriptor "Regular Expression"
|
|
1505 :style toggle
|
|
1506 :selected search-dialog-regexp
|
|
1507 :callback (setq search-dialog-regexp
|
|
1508 (not search-dialog-regexp))]
|
|
1509 [button :descriptor "Forwards"
|
|
1510 :style radio
|
|
1511 :selected search-dialog-direction
|
|
1512 :callback (setq search-dialog-direction t)]
|
|
1513 [button :descriptor "Backwards"
|
|
1514 :style radio
|
|
1515 :selected (not search-dialog-direction)
|
|
1516 :callback (setq search-dialog-direction nil)]
|
|
1517 )]
|
|
1518 [layout :orientation vertical
|
|
1519 :vertically-justify top
|
|
1520 :horizontally-justify right
|
|
1521 :items
|
|
1522 ([edit-field :width 15 :descriptor "" :active t
|
|
1523 :initial-focus t]
|
|
1524 [button :width 10 :descriptor "Find Next"
|
|
1525 :callback-ex
|
|
1526 (lambda (image-instance event)
|
|
1527 (search-dialog-callback ,parent
|
|
1528 image-instance
|
|
1529 event))]
|
|
1530 [button :width 10 :descriptor "Cancel"
|
|
1531 :callback-ex
|
|
1532 (lambda (image-instance event)
|
|
1533 (isearch-dehighlight)
|
|
1534 (delete-frame
|
|
1535 (event-channel event)))])])])
|
|
1536 @end example
|
|
1537
|
|
1538 @node Primitive Widgets
|
|
1539 @subsection Primitive Widgets
|
|
1540
|
|
1541 @c #### the following table should be replaced with a menu of nodes
|
|
1542 @table @code
|
|
1543 @item button
|
|
1544 A button widget; either a push button, radio button or toggle
|
|
1545 button.
|
|
1546
|
|
1547 @item combo-box
|
|
1548 A drop list of selectable items in a widget, for editing text.
|
|
1549
|
|
1550 @item edit-field
|
|
1551 A text editing widget.
|
|
1552
|
|
1553 @item label
|
|
1554 A static, text-only, widget; for displaying text.
|
|
1555
|
|
1556 @item progress-gauge
|
|
1557 A sliding widget, for showing progress.
|
|
1558
|
|
1559 @item tab-control
|
|
1560 A tab widget; a series of user selectable tabs.
|
|
1561
|
|
1562 @item tree-view
|
|
1563 A folding widget.
|
|
1564
|
|
1565 @item scrollbar
|
|
1566 A scrollbar widget. (#### Probably not the same as the scrollbar
|
|
1567 controlling an Emacs window.)
|
|
1568 @end table
|
|
1569
|
|
1570
|
428
|
1571 @node Subwindows
|
|
1572 @section Subwindows
|
|
1573
|
|
1574 Subwindows are not currently implemented.
|
|
1575
|
|
1576 @defun subwindowp object
|
|
1577 This function returns non-@code{nil} if @var{object} is a subwindow.
|
|
1578 @end defun
|
707
|
1579
|
|
1580 @node Glyph Examples
|
|
1581 @section Glyph Examples
|
|
1582
|
|
1583 For many applications, displaying graphics is a simple process: you
|
|
1584 create a glyph, and then you insert it into a buffer.
|
|
1585
|
|
1586 The easiest way to create a glyph is to use a file that contains a
|
|
1587 graphical image, such as a JPEG, TIFF, or PNG file:
|
|
1588
|
|
1589 @lisp
|
|
1590 ;; Create a glyph from a JPEG file:
|
|
1591 (setq foo (make-glyph [jpeg :file "/tmp/file1.jpg"]))
|
|
1592 @end lisp
|
|
1593
|
|
1594 @lisp
|
|
1595 ;; Create a glyph from a XPM file:
|
|
1596 (setq foo (make-glyph [xpm :file "/tmp/file2.xpm"]))
|
|
1597 @end lisp
|
|
1598
|
|
1599 @lisp
|
|
1600 ;; Create a glyph from a PNG file:
|
|
1601 (setq foo (make-glyph [png :file "/tmp/file3.png"]))
|
|
1602 @end lisp
|
|
1603
|
|
1604 @lisp
|
|
1605 ;; Create a glyph from a TIFF file:
|
|
1606 (setq foo (make-glyph [tiff :file "/tmp/file4.tiff"]))
|
|
1607 @end lisp
|
|
1608
|
|
1609 The parameters passed to @code{make-glyph} are called "Image
|
|
1610 Specifiers", and can handle more image types than those shown above.
|
|
1611 You can also put the raw image data into a string (e.g., if you put the
|
|
1612 contents of a JPEG file into a string), and use that to create a glyph.
|
|
1613 @xref{Image Specifiers}, for more information.
|
|
1614
|
|
1615 @quotation
|
|
1616 @strong{Caution}: In order for XEmacs to read a particular graphics file
|
|
1617 format, support for that format must have been compiled into XEmacs.
|
|
1618 It's possible, although somewhat unlikely, for XEmacs to have been
|
|
1619 compiled without support for any of the various graphics file formats.
|
|
1620 To see what graphics formats your particular version of XEmacs supports,
|
|
1621 use @kbd{M-x describe-installation}.
|
|
1622
|
|
1623 To programmatically query whether or not a particular file format is
|
|
1624 supported, you can use the @code{featurep} function, with one of:
|
|
1625 @code{gif}, @code{tiff}, @code{jpeg}, @code{xpm}, @code{xbm},
|
|
1626 @code{png}, or @code{xface}. For an up-to-date list, @ref{Image
|
|
1627 Specifiers}. Example:
|
|
1628
|
|
1629 @example
|
|
1630 ;; Returns `t' if TIFF is supported:
|
|
1631 (featurep 'tiff)
|
|
1632 @end example
|
|
1633
|
|
1634 Another example is:
|
|
1635
|
|
1636 @example
|
|
1637 ;; Returns a list of `t' or `nil', depending on whether or not the
|
|
1638 ;; corresponding feature is supported:
|
|
1639 (mapcar #'(lambda (format-symbol) (featurep format-symbol))
|
|
1640 '(gif tiff jpeg xpm png))
|
|
1641 @end example
|
|
1642
|
|
1643 @end quotation
|
|
1644
|
|
1645 Once you have a glyph, you can then insert it into a buffer. Example:
|
|
1646
|
|
1647 @lisp
|
|
1648 ;; Use this function to insert a glyph at the left edge of point in the
|
|
1649 ;; current buffer. Any existing glyph at this location is replaced.
|
|
1650 (defun insert-glyph (gl)
|
|
1651 "Insert a glyph at the left edge of point."
|
1137
|
1652 (let ( (prop 'myimage) ;; myimage is an arbitrary name, chosen
|
707
|
1653 ;; to (hopefully) not conflict with any
|
|
1654 ;; other properties. Change it if
|
|
1655 ;; necessary.
|
|
1656 extent )
|
|
1657 ;; First, check to see if one of our extents already exists at
|
|
1658 ;; point. For ease-of-programming, we are creating and using our
|
|
1659 ;; own extents (multiple extents are allowed to exist/overlap at the
|
|
1660 ;; same point, and it's quite possible for other applications to
|
|
1661 ;; embed extents in the current buffer without your knowledge).
|
|
1662 ;; Basically, if an extent, with the property stored in "prop",
|
|
1663 ;; exists at point, we assume that it is one of ours, and we re-use
|
|
1664 ;; it (this is why it is important for the property stored in "prop"
|
|
1665 ;; to be unique, and only used by us).
|
|
1666 (if (not (setq extent (extent-at (point) (current-buffer) prop)))
|
|
1667 (progn
|
|
1668 ;; If an extent does not already exist, create a zero-length
|
|
1669 ;; extent, and give it our special property.
|
|
1670 (setq extent (make-extent (point) (point) (current-buffer)))
|
|
1671 (set-extent-property extent prop t)
|
|
1672 ))
|
|
1673 ;; Display the glyph by storing it as the extent's "begin-glyph".
|
|
1674 (set-extent-property extent 'begin-glyph gl)
|
|
1675 ))
|
|
1676
|
|
1677 ;; You can then use this function like:
|
|
1678 (insert-glyph (make-glyph [jpeg :file "/tmp/file1.jpg"]))
|
|
1679 ;; This will insert the glyph at point.
|
|
1680
|
|
1681 ;; Here's an example of how to insert two glyphs side-by-side, at point
|
|
1682 ;; (using the above code):
|
|
1683 (progn
|
|
1684 (insert-glyph (make-glyph [jpeg :file "/tmp/file1.jpg"]))
|
|
1685 ;; Create a new extent at point. We can't simply call "insert-glyph",
|
|
1686 ;; as "insert-glyph" will simply replace the first glyph with the
|
|
1687 ;; second.
|
|
1688 (setq extent (make-extent (point) (point) (current-buffer)))
|
|
1689 ;; Here, we're only setting the 'myimage property in case we need
|
|
1690 ;; to later identify/locate/reuse this particular extent.
|
|
1691 (set-extent-property extent 'myimage t)
|
|
1692 (set-extent-property extent 'begin-glyph
|
|
1693 (make-glyph [jpeg :file "/tmp/file2.jpg"]))
|
|
1694 )
|
|
1695
|
|
1696 @end lisp
|
|
1697
|
|
1698 Here are the gory details:
|
|
1699
|
|
1700 @itemize @bullet
|
|
1701
|
|
1702 @item
|
|
1703 Glyphs are displayed by attaching them to extents (see @ref{Extents}),
|
|
1704 either to the beginning or the end of extents.
|
|
1705
|
|
1706 Note that extents can be used for many things, and not just for
|
|
1707 displaying images (although, in the above example, we are creating our
|
|
1708 own extent for the sole purpose of displaying an image). Also, note
|
|
1709 that multiple extents are allowed to exist at the same position, and
|
|
1710 they can overlap.
|
|
1711
|
|
1712 @item
|
|
1713 Glyphs are often displayed inside the text area (alongside text). This
|
|
1714 is the default.
|
|
1715
|
|
1716 Although glyphs can also be displayed in the margins, how to do this
|
|
1717 will not be described here. For more information on this, see
|
|
1718 @ref{Annotation Basics} (look for information on "layout types") and
|
|
1719 @ref{Extent Properties} (look for @code{begin-glyph-layout} and
|
|
1720 @code{end-glyph-layout}).
|
|
1721
|
|
1722 @item
|
|
1723 The easiest way to insert a glyph into text is to create a zero-length
|
|
1724 extent at the point where you want the glyph to appear.
|
|
1725
|
|
1726 Note that zero-length extents are attached to the character to the
|
|
1727 right of the extent; deleting this character will also delete the extent.
|
|
1728
|
|
1729 @item
|
|
1730 It's often a good idea to assign a unique property to the newly-created
|
|
1731 extent, in case you later want to locate it, and replace any existing
|
|
1732 glyph with a different one (or just delete the existing one). In the
|
|
1733 above example, we are using "myimage" as our (hopefully) unique property
|
|
1734 name.
|
|
1735
|
|
1736 If you need to locate all of the extents, you'll have to use functions
|
|
1737 like @code{extent-list} or @code{next-extent}, or provide additional
|
|
1738 parameters to the @code{extent-at} function. Assigning a unique
|
|
1739 property to the extent makes it easy to locate your extents; for
|
|
1740 example, @code{extent-list} can return only those extents with a
|
|
1741 particular property. @xref{Finding Extents}, and @ref{Mapping Over
|
|
1742 Extents}, for more information.
|
|
1743
|
|
1744 @item
|
|
1745 Glyphs are displayed by assigning then to the @code{begin-glyph} or
|
|
1746 @code{end-glyph} property of the extent. For zero-length extents, it
|
|
1747 doesn't really matter if you assign the glyph to the @code{begin-glyph}
|
|
1748 or @code{end-glyph} property, as they are both at the same location;
|
|
1749 however, for non-zero-length extents (extents that cover one or more
|
|
1750 characters of text), it does matter which one you use.
|
|
1751
|
|
1752 Assigning @code{nil} to the @code{begin-glyph} or @code{end-glyph}
|
|
1753 property will delete any existing glyph. In this case, you may also
|
|
1754 want to delete the extent, assuming that the extent is used for no other
|
|
1755 purpose.
|
|
1756
|
|
1757 @item
|
|
1758 If you happen to insert two glyphs, side-by-side, note that the example
|
|
1759 @code{insert-glyph} function will have trouble, if it's again used at
|
|
1760 the same point (it can only locate one of the two extents).
|
|
1761 @xref{Finding Extents}, and @ref{Mapping Over Extents}, for more
|
|
1762 information on locating extents in a buffer.
|
|
1763
|
|
1764 @item
|
|
1765 Among other things, glyphs provide a way of displaying graphics
|
|
1766 alongside text. Note, however, that glyphs only provide a way of
|
|
1767 displaying graphics; glyphs are not actually part of the text, and are
|
|
1768 only displayed alongside the text. If you save the text in the buffer,
|
|
1769 the graphics are not saved. The low-level glyph code does not provide a
|
|
1770 way of saving graphics with the text. If you need to save graphics and
|
|
1771 text, you have to write your own code to do this, and this topic is
|
|
1772 outside the scope of this discussion.
|
|
1773
|
|
1774 @end itemize
|