Initial git import
[sxemacs] / info / lispref / toolbar.texi
1 @c -*-texinfo-*-
2 @c This is part of the SXEmacs Lisp Reference Manual.
3 @c Copyright (C) 1995, 1996 Ben Wing.
4 @c Copyright (C) 2005 Sebastian Freundt <hroptatyr@sxemacs.org>
5 @c See the file lispref.texi for copying conditions.
6 @setfilename ../../info/toolbar.info
7
8 @node Toolbar, Gutter, Dialog Boxes, top
9 @chapter Toolbar
10 @cindex toolbar
11
12 @menu
13 * Toolbar Intro::               An introduction.
14 * Creating Toolbar::            How to create a toolbar.
15 * Toolbar Descriptor Format::   Accessing and modifying a toolbar's
16                                   properties.
17 * Specifying the Toolbar::      Setting a toolbar's contents.
18 * Other Toolbar Variables::     Controlling the size of toolbars.
19 @end menu
20
21
22 @node Toolbar Intro
23 @section Toolbar Intro
24
25 A @dfn{toolbar} is a bar of icons displayed along one edge of a frame.
26 You can view a toolbar as a series of menu shortcuts---the most
27 common menu options can be accessed with a single click rather than
28 a series of clicks and/or drags to select the option from a menu.
29 Consistent with this, a help string (called the @dfn{help-echo})
30 describing what an icon in the toolbar (called a @dfn{toolbar button})
31 does, is displayed in the minibuffer when the mouse is over the
32 button.
33
34 In SXEmacs, a toolbar can be displayed along any of the four edges
35 of the frame, and two or more different edges can be displaying
36 toolbars simultaneously.  The contents, thickness, and visibility of
37 the toolbars can be controlled separately, and the values can
38 be per-buffer, per-frame, etc., using specifiers (@pxref{Specifiers}).
39
40 Normally, there is one toolbar displayed in a frame.  Usually, this is
41 the standard toolbar, but certain modes will override this and
42 substitute their own toolbar.  In some cases (e.g. the VM package), a
43 package will supply its own toolbar along a different edge from the
44 standard toolbar, so that both can be visible at once.  This standard
45 toolbar is usually positioned along the top of the frame, but this can
46 be changed using @code{set-default-toolbar-position}.
47
48 Note that, for each of the toolbar properties (contents, thickness,
49 and visibility), there is a separate specifier for each of the four
50 toolbar positions (top, bottom, left, and right), and an additional
51 specifier for the ``default'' toolbar, i.e. the toolbar whose
52 position is controlled by @code{set-default-toolbar-position}.  The
53 way this works is that @code{set-default-toolbar-position} arranges
54 things so that the appropriate position-specific specifiers for the
55 default position inherit from the corresponding default specifiers.
56 That way, if the position-specific specifier does not give a value
57 (which it usually doesn't), then the value from the default
58 specifier applies.  If you want to control the default toolbar, you
59 just change the default specifiers, and everything works.  A package
60 such as VM that wants to put its own toolbar in a different location
61 from the default just sets the position-specific specifiers, and if
62 the user sets the default toolbar to the same position, it will just
63 not be visible.
64
65
66 @node Creating Toolbar
67 @section Creating Toolbar
68
69 @defun make-toolbar-specifier spec-list
70
71 Return a new @code{toolbar} specifier object with the given
72 specification list.  @var{spec-list} can be a list of specifications
73 (each of which is a cons of a locale and a list of instantiators), a
74 single instantiator, or a list of instantiators.  @xref{Specifiers}, for
75 more information about specifiers.
76
77 Toolbar specifiers are used to specify the format of a toolbar.  The
78 values of the variables @code{default-toolbar}, @code{top-toolbar},
79 @code{left-toolbar}, @code{right-toolbar}, and @code{bottom-toolbar} are
80 always toolbar specifiers.
81
82 Valid toolbar instantiators are called "toolbar descriptors"
83 and are lists of vectors.  See @code{default-toolbar} for a description
84 of the exact format.
85 @end defun
86
87
88 @node Toolbar Descriptor Format
89 @section Toolbar Descriptor Format
90
91 The contents of a toolbar are specified using a @dfn{toolbar descriptor}.
92 The format of a toolbar descriptor is a list of @dfn{toolbar button
93 descriptors}.  Each toolbar button descriptor is a vector in one of the
94 following formats:
95
96 @itemize @bullet
97 @item
98 @code{[@var{glyph-list} @var{function} @var{enabled-p} @var{help}]}
99 @item
100 @code{[:style @var{2d-or-3d}]}
101 @item
102 @code{[:style @var{2d-or-3d} :size @var{width-or-height}]}
103 @item
104 @code{[:size @var{width-or-height} :style @var{2d-or-3d}]}
105 @end itemize
106
107 Optionally, one of the toolbar button descriptors may be @code{nil}
108 instead of a vector; this signifies the division between the toolbar
109 buttons that are to be displayed flush-left, and the buttons to be
110 displayed flush-right.
111
112 The first vector format above specifies a normal toolbar button;
113 the others specify blank areas in the toolbar.
114
115 For the first vector format:
116
117 @itemize @bullet
118 @item
119 @var{glyph-list} should be a list of one to six glyphs (as created by
120 @code{make-glyph}) or a symbol whose value is such a list.  The first
121 glyph, which must be provided, is the glyph used to display the toolbar
122 button when it is in the ``up'' (not pressed) state.  The optional
123 second glyph is for displaying the button when it is in the ``down''
124 (pressed) state.  The optional third glyph is for when the button is
125 disabled.  The last three glyphs are for displaying the button in the
126 ``up'', ``down'', and ``disabled'' states, respectively, but are used
127 when the user has called for captioned toolbar buttons (using
128 @code{toolbar-buttons-captioned-p}).  The function
129 @code{toolbar-make-button-list} is useful in creating these glyph lists.
130
131 @item
132 Even if you do not provide separate down-state and disabled-state
133 glyphs, the user will still get visual feedback to indicate which
134 state the button is in.  Buttons in the up-state are displayed
135 with a shadowed border that gives a raised appearance to the
136 button.  Buttons in the down-state are displayed with shadows that
137 give a recessed appearance.  Buttons in the disabled state are
138 displayed with no shadows, giving a 2-d effect.
139
140 @item
141 If some of the toolbar glyphs are not provided, they inherit as follows:
142
143 @example
144      UP:                up
145      DOWN:              down -> up
146      DISABLED:          disabled -> up
147      CAP-UP:            cap-up -> up
148      CAP-DOWN:          cap-down -> cap-up -> down -> up
149      CAP-DISABLED:      cap-disabled -> cap-up -> disabled -> up
150 @end example
151
152 @item
153 The second element @var{function} is a function to be called when the
154 toolbar button is activated (i.e. when the mouse is released over the
155 toolbar button, if the press occurred in the toolbar).  It can be any
156 form accepted by @code{call-interactively}, since this is how it is
157 invoked.
158
159 @item
160 The third element @var{enabled-p} specifies whether the toolbar button
161 is enabled (disabled buttons do nothing when they are activated, and are
162 displayed differently; see above).  It should be either a boolean or a
163 form that evaluates to a boolean.
164
165 @item
166 The fourth element @var{help}, if non-@code{nil}, should be a string.
167 This string is displayed in the echo area when the mouse passes over the
168 toolbar button.
169 @end itemize
170
171 For the other vector formats (specifying blank areas of the toolbar):
172
173 @itemize @bullet
174 @item
175 @var{2d-or-3d} should be one of the symbols @code{2d} or @code{3d},
176 indicating whether the area is displayed with shadows (giving it a
177 raised, 3-d appearance) or without shadows (giving it a flat
178 appearance).
179
180 @item
181 @var{width-or-height} specifies the length, in pixels, of the blank
182 area.  If omitted, it defaults to a device-specific value (8 pixels for
183 X devices).
184 @end itemize
185
186 @defun toolbar-make-button-list up &optional down disabled cap-up cap-down cap-disabled
187 This function calls @code{make-glyph} on each arg and returns a list of
188 the results.  This is useful for setting the first argument of a toolbar
189 button descriptor (typically, the result of this function is assigned
190 to a symbol, which is specified as the first argument of the toolbar
191 button descriptor).
192 @end defun
193
194 @defun check-toolbar-button-syntax button &optional noerror
195 Verify the syntax of entry @var{button} in a toolbar description list.
196 If you want to verify the syntax of a toolbar description list as a
197 whole, use @code{check-valid-instantiator} with a specifier type of
198 @code{toolbar}.
199 @end defun
200
201
202 @node Specifying the Toolbar
203 @section Specifying the Toolbar
204
205 In order to specify the contents of a toolbar, set one of the specifier
206 variables @code{default-toolbar}, @code{top-toolbar},
207 @code{bottom-toolbar}, @code{left-toolbar}, or @code{right-toolbar}.
208 These are specifiers, which means you set them with @code{set-specifier}
209 and query them with @code{specifier-specs} or @code{specifier-instance}.
210 You will get an error if you try to set them using @code{setq}.  The
211 valid instantiators for these specifiers are toolbar descriptors, as
212 described above.  @xref{Specifiers}, for more information.
213
214 Most of the time, you will set @code{default-toolbar}, which allows
215 the user to choose where the toolbar should go.
216
217 @defvr Specifier default-toolbar
218 The position of this toolbar is specified in the function
219 @code{default-toolbar-position}.  If the corresponding
220 position-specific toolbar (e.g. @code{top-toolbar} if
221 @code{default-toolbar-position} is @code{top}) does not specify a
222 toolbar in a particular domain, then the value of @code{default-toolbar}
223 in that domain, of any, will be used instead.
224 @end defvr
225
226 Note that the toolbar at any particular position will not be displayed
227 unless its thickness (width or height, depending on orientation) is
228 non-zero and its visibility status is true.  The thickness is controlled
229 by the specifiers @code{top-toolbar-height},
230 @code{bottom-toolbar-height}, @code{left-toolbar-width}, and
231 @code{right-toolbar-width}, and the visibility status is controlled by
232 the specifiers @code{top-toolbar-visible-p},
233 @code{bottom-toolbar-visible-p}, @code{left-toolbar-visible-p}, and
234 @code{right-toolbar-visible-p} (@pxref{Other Toolbar Variables}).
235
236 @defun set-default-toolbar-position position
237 This function sets the position that the @code{default-toolbar} will be
238 displayed at.  Valid positions are the symbols @code{top},
239 @code{bottom}, @code{left} and @code{right}.  What this actually does is
240 set the fallback specifier for the position-specific specifier
241 corresponding to the given position to @code{default-toolbar}, and set
242 the fallbacks for the other position-specific specifiers to @code{nil}.
243 It also does the same thing for the position-specific thickness and
244 visibility specifiers, which inherit from one of
245 @code{default-toolbar-height} or @code{default-toolbar-width}, and from
246 @code{default-toolbar-visible-p}, respectively (@pxref{Other Toolbar
247 Variables}).
248 @end defun
249
250 @defun default-toolbar-position
251 This function returns the position that the @code{default-toolbar} will
252 be displayed at.
253 @end defun
254
255 You can also explicitly set a toolbar at a particular position.  When
256 redisplay determines what to display at a particular position in a
257 particular domain (i.e. window), it first consults the position-specific
258 toolbar.  If that does not yield a toolbar descriptor, the
259 @code{default-toolbar} is consulted if @code{default-toolbar-position}
260 indicates this position.
261
262 @defvr Specifier top-toolbar
263 Specifier for the toolbar at the top of the frame.
264 @end defvr
265
266 @defvr Specifier bottom-toolbar
267 Specifier for the toolbar at the bottom of the frame.
268 @end defvr
269
270 @defvr Specifier left-toolbar
271 Specifier for the toolbar at the left edge of the frame.
272 @end defvr
273
274 @defvr Specifier right-toolbar
275 Specifier for the toolbar at the right edge of the frame.
276 @end defvr
277
278 @defun toolbar-specifier-p object
279 This function returns non-@code{nil} if @var{object} is a toolbar specifier.
280 Toolbar specifiers are the actual objects contained in the toolbar
281 variables described above, and their valid instantiators are
282 toolbar descriptors (@pxref{Toolbar Descriptor Format}).
283 @end defun
284
285
286 @node Other Toolbar Variables
287 @section Other Toolbar Variables
288
289 The variables to control the toolbar thickness, visibility status, and
290 captioned status are all specifiers.  @xref{Specifiers}.
291
292 @defvr Specifier default-toolbar-height
293 This specifies the height of the default toolbar, if it's oriented
294 horizontally.  The position of the default toolbar is specified by the
295 function @code{set-default-toolbar-position}.  If the corresponding
296 position-specific toolbar thickness specifier
297 (e.g. @code{top-toolbar-height} if @code{default-toolbar-position} is
298 @code{top}) does not specify a thickness in a particular domain (a
299 window or a frame), then the value of @code{default-toolbar-height} or
300 @code{default-toolbar-width} (depending on the toolbar orientation) in
301 that domain, if any, will be used instead.
302 @end defvr
303
304 @defvr Specifier default-toolbar-width
305 This specifies the width of the default toolbar, if it's oriented
306 vertically.  This behaves like @code{default-toolbar-height}.
307 @end defvr
308
309 Note that @code{default-toolbar-height} is only used when
310 @code{default-toolbar-position} is @code{top} or @code{bottom}, and
311 @code{default-toolbar-width} is only used when
312 @code{default-toolbar-position} is @code{left} or @code{right}.
313
314 @defvr Specifier top-toolbar-height
315 This specifies the height of the top toolbar.
316 @end defvr
317
318 @defvr Specifier bottom-toolbar-height
319 This specifies the height of the bottom toolbar.
320 @end defvr
321
322 @defvr Specifier left-toolbar-width
323 This specifies the width of the left toolbar.
324 @end defvr
325
326 @defvr Specifier right-toolbar-width
327 This specifies the width of the right toolbar.
328 @end defvr
329
330 Note that all of the position-specific toolbar thickness specifiers
331 have a fallback value of zero when they do not correspond to the
332 default toolbar.  Therefore, you will have to set a non-zero thickness
333 value if you want a position-specific toolbar to be displayed.
334
335 @defvr Specifier default-toolbar-visible-p
336 This specifies whether the default toolbar is visible.  The position of
337 the default toolbar is specified by the function
338 @code{set-default-toolbar-position}.  If the corresponding position-specific
339 toolbar visibility specifier (e.g. @code{top-toolbar-visible-p} if
340 @code{default-toolbar-position} is @code{top}) does not specify a
341 visible-p value in a particular domain (a window or a frame), then the
342 value of @code{default-toolbar-visible-p} in that domain, if any, will
343 be used instead.
344 @end defvr
345
346 @defvr Specifier top-toolbar-visible-p
347 This specifies whether the top toolbar is visible.
348 @end defvr
349
350 @defvr Specifier bottom-toolbar-visible-p
351 This specifies whether the bottom toolbar is visible.
352 @end defvr
353
354 @defvr Specifier left-toolbar-visible-p
355 This specifies whether the left toolbar is visible.
356 @end defvr
357
358 @defvr Specifier right-toolbar-visible-p
359 This specifies whether the right toolbar is visible.
360 @end defvr
361
362 @code{default-toolbar-visible-p} and all of the position-specific
363 toolbar visibility specifiers have a fallback value of true.
364
365 Internally, toolbar thickness and visibility specifiers are instantiated
366 in both window and frame domains, for different purposes.  The value in
367 the domain of a frame's selected window specifies the actual toolbar
368 thickness or visibility that you will see in that frame.  The value in
369 the domain of a frame itself specifies the toolbar thickness or
370 visibility that is used in frame geometry calculations.
371
372 Thus, for example, if you set the frame width to 80 characters and the
373 left toolbar width for that frame to 68 pixels, then the frame will be
374 sized to fit 80 characters plus a 68-pixel left toolbar.  If you then
375 set the left toolbar width to 0 for a particular buffer (or if that
376 buffer does not specify a left toolbar or has a @code{nil} value specified for
377 @code{left-toolbar-visible-p}), you will find that, when that buffer is
378 displayed in the selected window, the window will have a width of 86 or
379 87 characters---the frame is sized for a 68-pixel left toolbar but the
380 selected window specifies that the left toolbar is not visible, so it is
381 expanded to take up the slack.
382
383 @defvr Specifier toolbar-buttons-captioned-p
384 Whether toolbar buttons are captioned.  This affects which glyphs from a
385 toolbar button descriptor are chosen.  @xref{Toolbar Descriptor Format}.
386 @end defvr
387
388 You can also reset the toolbar to what it was when SXEmacs started up.
389
390 @defvr Constant initial-toolbar-spec
391 The toolbar descriptor used to initialize @code{default-toolbar} at
392 startup.
393 @end defvr