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