]> code.delx.au - gnu-emacs/blob - man/xresources.texi
(Lisp Interaction): Minor addition.
[gnu-emacs] / man / xresources.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1987, 1993, 1994, 1995, 1997, 2001, 2002, 2003,
3 @c 2004, 2005, 2006 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node X Resources, Antinews, Emacs Invocation, Top
6 @appendix X Options and Resources
7
8 You can customize some X-related aspects of Emacs behavior using X
9 resources, as is usual for programs that use X. On MS-Windows, you
10 can customize some of the same aspects using the system registry.
11 @xref{MS-Windows Registry}. Likewise, the Mac Carbon port emulates X
12 resources using the Preferences system. @xref{Mac Environment Variables}.
13
14 When Emacs is built using an `X toolkit', such as Lucid or LessTif,
15 you need to use X resources to customize the appearance of the
16 widgets, including the menu-bar, scroll-bar, and dialog boxes. This
17 is because the libraries that implement these don't provide for
18 customization through Emacs. GTK+ widgets use a separate system of
19 `GTK resources', which we will also describe.
20
21 @menu
22 * Resources:: Using X resources with Emacs (in general).
23 * Table of Resources:: Table of specific X resources that affect Emacs.
24 * Face Resources:: X resources for customizing faces.
25 * Lucid Resources:: X resources for Lucid menus.
26 * LessTif Resources:: X resources for LessTif and Motif menus.
27 * GTK resources:: Resources for GTK widgets.
28 @end menu
29
30 @node Resources
31 @appendixsec X Resources
32 @cindex resources
33 @cindex X resources
34 @cindex @file{~/.Xdefaults} file
35 @cindex @file{~/.Xresources} file
36
37 Programs running under the X Window System organize their user
38 options under a hierarchy of classes and resources. You can specify
39 default values for these options in your X resources file, usually
40 named @file{~/.Xdefaults} or @file{~/.Xresources}.
41 If changes in @file{~/.Xdefaults} do not
42 take effect, it is because your X server stores its own list of
43 resources; to update them, use the shell command @command{xrdb}---for
44 instance, @samp{xrdb ~/.Xdefaults}.
45
46 Each line in the file specifies a value for one option or for a
47 collection of related options, for one program or for several programs
48 (optionally even for all programs).
49
50 @cindex Registry (MS-Windows)
51 MS-Windows systems don't support @file{~/.Xdefaults} files, but
52 Emacs compiled for Windows looks for X resources in the Windows
53 Registry, under the key @samp{HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs}
54 and then under the key @samp{HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs}.
55 The menu and scrollbars are native widgets on MS-Windows, so they are
56 only customizable via the system-wide settings in the Display Control
57 Panel. You can also set resources using the @samp{-xrm} command line
58 option (see below.)
59
60 Programs define named resources with particular meanings. They also
61 define how to group resources into named classes. For instance, in
62 Emacs, the @samp{internalBorder} resource controls the width of the
63 internal border, and the @samp{borderWidth} resource controls the width
64 of the external border. Both of these resources are part of the
65 @samp{BorderWidth} class. Case distinctions are significant in these
66 names.
67
68 Every resource definition is associated with a specific program
69 name---the name of the executable file that you ran. For Emacs, that
70 is normally @samp{emacs}. To specify a definition for all instances
71 of Emacs, regardless of their names, use @samp{Emacs}.
72
73 In @file{~/.Xdefaults}, you can specify a value for a single resource
74 on one line, like this:
75
76 @example
77 emacs.borderWidth: 2
78 @end example
79
80 @noindent
81 Or you can use a class name to specify the same value for all resources
82 in that class. Here's an example:
83
84 @example
85 emacs.BorderWidth: 2
86 @end example
87
88 If you specify a value for a class, it becomes the default for all
89 resources in that class. You can specify values for individual
90 resources as well; these override the class value, for those particular
91 resources. Thus, this example specifies 2 as the default width for all
92 borders, but overrides this value with 4 for the external border:
93
94 @example
95 emacs.BorderWidth: 2
96 emacs.borderWidth: 4
97 @end example
98
99 The order in which the lines appear in the file does not matter.
100 Also, command-line options always override the X resources file.
101 Here is a list of X command-line options and their corresponding
102 resource names.
103
104 @table @samp
105 @item -name @var{name}
106 @opindex --name
107 @itemx --name=@var{name}
108 @cindex resource name, command-line argument
109 Use @var{name} as the resource name (and the title) for the initial
110 Emacs frame. This option does not affect subsequent frames, but Lisp
111 programs can specify frame names when they create frames.
112
113 If you don't specify this option, the default is to use the Emacs
114 executable's name as the resource name.
115
116 @item -xrm @var{resource-values}
117 @opindex --xrm
118 @itemx --xrm=@var{resource-values}
119 @cindex resource values, command-line argument
120 Specify X resource values for this Emacs job (see below).
121 @end table
122
123 For consistency, @samp{-name} also specifies the name to use for
124 other resource values that do not belong to any particular frame.
125
126 The resources that name Emacs invocations also belong to a class; its
127 name is @samp{Emacs}. If you write @samp{Emacs} instead of
128 @samp{emacs}, the resource applies to all frames in all Emacs jobs,
129 regardless of frame titles and regardless of the name of the executable
130 file. Here is an example:
131
132 @example
133 Emacs.BorderWidth: 2
134 Emacs.borderWidth: 4
135 @end example
136
137 You can specify a string of additional resource values for Emacs to
138 use with the command line option @samp{-xrm @var{resources}}. The text
139 @var{resources} should have the same format that you would use inside a file
140 of X resources. To include multiple resource specifications in
141 @var{resources}, put a newline between them, just as you would in a file.
142 You can also use @samp{#include "@var{filename}"} to include a file full
143 of resource specifications. Resource values specified with @samp{-xrm}
144 take precedence over all other resource specifications.
145
146 One way to experiment with the effect of different resource settings
147 is to use the @code{editres} program. Select @samp{Get Tree} from the
148 @samp{Commands} menu, then click on an Emacs frame. This will display
149 a tree showing the structure of X toolkit widgets used in an Emacs
150 frame. Select one of them, such as @samp{menubar}, then select
151 @samp{Show Resource Box} from the @samp{Commands} menu. This displays
152 a list of all the meaningful X resources and allows you to edit them.
153 Changes take effect immediately if you click on the @samp{Apply} button.
154 (See the @code{editres} man page for more details.)
155
156 @node Table of Resources
157 @appendixsec Table of X Resources for Emacs
158
159 This table lists the resource names that designate options for
160 Emacs, not counting those for the appearance of the menu bar, each
161 with the class that it belongs to:
162
163 @table @asis
164 @item @code{background} (class @code{Background})
165 Background color name.
166
167 @item @code{bitmapIcon} (class @code{BitmapIcon})
168 Use a bitmap icon (a picture of a gnu) if @samp{on}, let the window
169 manager choose an icon if @samp{off}.
170
171 @item @code{borderColor} (class @code{BorderColor})
172 Color name for the external border.
173
174 @item @code{borderWidth} (class @code{BorderWidth})
175 Width in pixels of the external border.
176
177 @item @code{cursorColor} (class @code{Foreground})
178 Color name for text cursor (point).
179
180 @item @code{cursorBlink} (class @code{CursorBlink})
181 Specifies whether to make the cursor blink. The default is @samp{on}. Use
182 @samp{off} or @samp{false} to turn cursor blinking off.
183
184 @item @code{font} (class @code{Font})
185 Font name for text (or fontset name, @pxref{Fontsets}).
186
187 @item @code{foreground} (class @code{Foreground})
188 Color name for text.
189
190 @item @code{geometry} (class @code{Geometry})
191 Window size and position. Be careful not to specify this resource as
192 @samp{emacs*geometry}, because that may affect individual menus as well
193 as the Emacs frame itself.
194
195 If this resource specifies a position, that position applies only to the
196 initial Emacs frame (or, in the case of a resource for a specific frame
197 name, only that frame). However, the size, if specified here, applies to
198 all frames.
199
200 @item @code{fullscreen} (class @code{Fullscreen})
201 The desired fullscreen size. The value can be one of @code{fullboth},
202 @code{fullwidth} or @code{fullheight}, which correspond to
203 the command-line options @samp{-fs}, @samp{-fw}, and @samp{-fh}
204 (@pxref{Window Size X}).
205
206 Note that this applies to all frames created, not just the initial
207 one.
208
209 @item @code{iconName} (class @code{Title})
210 Name to display in the icon.
211
212 @item @code{internalBorder} (class @code{BorderWidth})
213 Width in pixels of the internal border.
214
215 @item @code{lineSpacing} (class @code{LineSpacing})
216 @cindex line spacing
217 @cindex leading
218 Additional space (@dfn{leading}) between lines, in pixels.
219
220 @item @code{menuBar} (class @code{MenuBar})
221 @cindex menu bar
222 Give frames menu bars if @samp{on}; don't have menu bars if
223 @samp{off}. @xref{Lucid Resources}, and @ref{LessTif Resources}, for
224 how to control the appearance of the menu bar if you have one.
225
226 @item @code{minibuffer} (class @code{Minibuffer})
227 If @samp{none}, don't make a minibuffer in this frame.
228 It will use a separate minibuffer frame instead.
229
230 @item @code{paneFont} (class @code{Font})
231 @cindex font for menus
232 Font name for menu pane titles, in non-toolkit versions of Emacs.
233
234 @item @code{pointerColor} (class @code{Foreground})
235 Color of the mouse cursor.
236
237 @item @code{privateColormap} (class @code{PrivateColormap})
238 If @samp{on}, use a private color map, in the case where the ``default
239 visual'' of class PseudoColor and Emacs is using it.
240
241 @item @code{reverseVideo} (class @code{ReverseVideo})
242 Switch foreground and background default colors if @samp{on}, use colors as
243 specified if @samp{off}.
244
245 @item @code{screenGamma} (class @code{ScreenGamma})
246 @cindex gamma correction
247 Gamma correction for colors, equivalent to the frame parameter
248 @code{screen-gamma}.
249
250 @item @code{selectionFont} (class @code{SelectionFont})
251 Font name for pop-up menu items, in non-toolkit versions of Emacs. (For
252 toolkit versions, see @ref{Lucid Resources}, also see @ref{LessTif
253 Resources}.)
254
255 @item @code{selectionTimeout} (class @code{SelectionTimeout})
256 Number of milliseconds to wait for a selection reply.
257 If the selection owner doesn't reply in this time, we give up.
258 A value of 0 means wait as long as necessary.
259
260 @item @code{synchronous} (class @code{Synchronous})
261 @cindex debugging X problems
262 @cindex synchronous X mode
263 Run Emacs in synchronous mode if @samp{on}. Synchronous mode is
264 useful for debugging X problems.
265
266 @item @code{title} (class @code{Title})
267 Name to display in the title bar of the initial Emacs frame.
268
269 @item @code{toolBar} (class @code{ToolBar})
270 @cindex tool bar
271 Number of lines to reserve for the tool bar. A zero value suppresses
272 the tool bar. If the value is non-zero and
273 @code{auto-resize-tool-bars} is non-@code{nil}, the tool bar's size
274 will be changed automatically so that all tool bar items are visible.
275
276 @item @code{useXIM} (class @code{UseXIM})
277 @cindex XIM
278 @cindex X input methods
279 @cindex input methods, X
280 Turn off use of X input methods (XIM) if @samp{false} or @samp{off}.
281 This is only relevant if your Emacs is actually built with XIM
282 support. It is potentially useful to turn off XIM for efficiency,
283 especially slow X client/server links.
284
285 @item @code{verticalScrollBars} (class @code{ScrollBars})
286 Give frames scroll bars if @samp{on}; don't have scroll bars if
287 @samp{off}.
288
289 @item @code{visualClass} (class @code{VisualClass})
290 Specify the ``visual'' that X should use. This tells X how to handle
291 colors.
292
293 The value should start with one of @samp{TrueColor},
294 @samp{PseudoColor}, @samp{DirectColor}, @samp{StaticColor},
295 @samp{GrayScale}, and @samp{StaticGray}, followed by
296 @samp{-@var{depth}}, where @var{depth} is the number of color planes.
297 Most terminals only allow a few ``visuals,'' and the @samp{dpyinfo}
298 program outputs information saying which ones.
299 @end table
300
301 @node Face Resources
302 @appendixsec X Resources for Faces
303
304 You can also use resources to customize the appearance of particular
305 faces (@pxref{Faces}):
306
307 @table @code
308 @item @var{face}.attributeFont
309 Font for face @var{face}.
310 @item @var{face}.attributeForeground
311 Foreground color for face @var{face}.
312 @item @var{face}.attributeBackground
313 Background color for face @var{face}.
314 @item @var{face}.attributeUnderline
315 Underline flag for face @var{face}. Use @samp{on} or @samp{true} for
316 yes.
317 @item @var{face}.attributeFamily
318 Font family for face @var{face}.
319 @item @var{face}.attributeWidth
320 Relative proportional width of the font to use for face @var{face}.
321 It should be one of @code{ultra-condensed}, @code{extra-condensed},
322 @code{condensed}, @code{semi-condensed}, @code{normal},
323 @code{semi-expanded}, @code{expanded}, @code{extra-expanded}, or
324 @code{ultra-expanded}.
325 @item @var{face}.attributeHeight
326 Height of the font to use for face @var{face}: either an integer
327 specifying the height in units of 1/10@dmn{pt}, or a floating point
328 number that specifies a scale factor to scale the underlying face's
329 default font, or a function to be called with the default height which
330 will return a new height.
331 @item @var{face}.attributeWeight
332 A weight to use for the face @var{face}. It must be one of
333 @code{ultra-bold}, @code{extra-bold}, @code{bold},
334 @code{semi-bold}, @code{normal}, @code{semi-light}, @code{light},
335 @code{extra-light}, @code{ultra-light}.
336 @item @var{face}.attributeSlant
337 The slant to use for the font of face @var{face}. It must be one of
338 @code{italic}, @code{oblique}, @code{normal},
339 @code{reverse-italic}, or @code{reverse-oblique}.
340 @item @var{face}.attributeStrikeThrough
341 Whether the face @var{face} should be drawn with a line striking
342 through the characters.
343 @item @var{face}.attributeOverline
344 Whether the characters in the face @var{face} should be overlined.
345 @item @var{face}.attributeBox
346 Whether to draw a box around the characters in face @var{face}.
347 @item @var{face}.attributeInverse
348 Whether to display the characters in face @var{face} in inverse
349 video.
350 @item @var{face}.attributeStipple
351 The name of a pixmap data file to use for the stipple pattern, or
352 @code{false} to not use stipple for the face @var{face}.
353 @item @var{face}.attributeBackgroundPixmap
354 The background pixmap for the face @var{face}. Should be a name of a
355 pixmap file or @code{false}.
356 @item @var{face}.attributeBold
357 Whether to draw the characters in the face @var{face} as bold.
358 @item @var{face}.attributeItalic
359 Whether to draw the characters in the face @var{face} as italic.
360 @end table
361
362 @node Lucid Resources
363 @appendixsec Lucid Menu X Resources
364 @cindex Menu X Resources (Lucid widgets)
365 @cindex Lucid Widget X Resources
366
367 If the Emacs installed at your site was built to use the X toolkit
368 with the Lucid menu widgets, then the menu bar is a separate widget and
369 has its own resources. The resource names contain @samp{pane.menubar}
370 (following, as always, the name of the Emacs invocation, or @samp{Emacs},
371 which stands for all Emacs invocations). Specify them like this:
372
373 @example
374 Emacs.pane.menubar.@var{resource}: @var{value}
375 @end example
376
377 @noindent
378 For example, to specify the font @samp{8x16} for the menu-bar items,
379 write this:
380
381 @example
382 Emacs.pane.menubar.font: 8x16
383 @end example
384
385 @noindent
386 Resources for @emph{non-menubar} toolkit pop-up menus have
387 @samp{menu*}, in like fashion. For example, to specify the font
388 @samp{8x16} for the pop-up menu items, write this:
389
390 @example
391 Emacs.menu*.font: 8x16
392 @end example
393
394 @noindent
395 For dialog boxes, use @samp{dialog} instead of @samp{menu}:
396
397 @example
398 Emacs.dialog*.font: 8x16
399 @end example
400
401 @noindent
402 The Lucid menus can display multilingual text in your locale. For more
403 information about fontsets see the man page for XCreateFontSet. To enable
404 multilingual menu text you specify a fontSet resource instead of the font
405 resource. If both font and fontSet resources are specified, the fontSet
406 resource is used. To specify
407 @samp{-*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*} for both the popup and
408 menu bar menus, write this:
409
410 @example
411 Emacs*fontSet: -*-helvetica-medium-r-*--*-120-*-*-*-*-*-*,*
412 @end example
413
414 @noindent
415 Experience shows that on some systems you may need to add
416 @samp{shell.}@: before the @samp{pane.menubar} or @samp{menu*}. On
417 some other systems, you must not add @samp{shell.}.
418
419 Here is a list of the specific resources for menu bars and pop-up menus:
420
421 @table @code
422 @item font
423 Font for menu item text.
424 @item fontSet
425 Fontset for menu item text.
426 @item foreground
427 Color of the foreground.
428 @item background
429 Color of the background.
430 @item buttonForeground
431 In the menu bar, the color of the foreground for a selected item.
432 @item horizontalSpacing
433 Horizontal spacing in pixels between items. Default is 3.
434 @item verticalSpacing
435 Vertical spacing in pixels between items. Default is 2.
436 @item arrowSpacing
437 Horizontal spacing between the arrow (which indicates a submenu) and
438 the associated text. Default is 10.
439 @item shadowThickness
440 Thickness of shadow line around the widget. Default is 1.
441
442 Also determines the thickness of shadow lines around other objects,
443 for instance 3D buttons and arrows. If you have the impression that
444 the arrows in the menus do not stand out clearly enough or that the
445 difference between ``in'' and ``out'' buttons is difficult to see, set
446 this to 2. If you have no problems with visibility, the default
447 probably looks better. The background color may also have some effect
448 on the contrast.
449 @item margin
450 The margin of the menu bar, in characters. Default is 1.
451 @end table
452
453 @node LessTif Resources
454 @appendixsec LessTif Menu X Resources
455 @cindex Menu X Resources (LessTif widgets)
456 @cindex LessTif Widget X Resources
457
458 If the Emacs installed at your site was built to use the X toolkit
459 with the LessTif or Motif widgets, then the menu bar, the dialog
460 boxes, the pop-up menus, and the file-selection box are separate
461 widgets and have their own resources.
462
463 The resource names for the menu bar contain @samp{pane.menubar}
464 (following, as always, the name of the Emacs invocation, or
465 @samp{Emacs}, which stands for all Emacs invocations). Specify them
466 like this:
467
468 @smallexample
469 Emacs.pane.menubar.@var{subwidget}.@var{resource}: @var{value}
470 @end smallexample
471
472 Each individual string in the menu bar is a subwidget; the subwidget's
473 name is the same as the menu item string. For example, the word
474 @samp{File} in the menu bar is part of a subwidget named
475 @samp{emacs.pane.menubar.File}. Most likely, you want to specify the
476 same resources for the whole menu bar. To do this, use @samp{*} instead
477 of a specific subwidget name. For example, to specify the font
478 @samp{8x16} for the menu-bar items, write this:
479
480 @smallexample
481 Emacs.pane.menubar.*.fontList: 8x16
482 @end smallexample
483
484 @noindent
485 This also specifies the resource value for submenus.
486
487 Each item in a submenu in the menu bar also has its own name for X
488 resources; for example, the @samp{File} submenu has an item named
489 @samp{Save (current buffer)}. A resource specification for a submenu
490 item looks like this:
491
492 @smallexample
493 Emacs.pane.menubar.popup_*.@var{menu}.@var{item}.@var{resource}: @var{value}
494 @end smallexample
495
496 @noindent
497 For example, here's how to specify the font for the @samp{Save (current
498 buffer)} item:
499
500 @smallexample
501 Emacs.pane.menubar.popup_*.File.Save (current buffer).fontList: 8x16
502 @end smallexample
503
504 @noindent
505 For an item in a second-level submenu, such as @samp{Complete Word}
506 under @samp{Spell Checking} under @samp{Tools}, the resource fits this
507 template:
508
509 @smallexample
510 Emacs.pane.menubar.popup_*.popup_*.@var{menu}.@var{resource}: @var{value}
511 @end smallexample
512
513 @noindent
514 For example,
515
516 @smallexample
517 Emacs.pane.menubar.popup_*.popup_*.Spell Checking.Complete Word: @var{value}
518 @end smallexample
519
520 @noindent
521 (This should be one long line.)
522
523 It's impossible to specify a resource for all the menu-bar items
524 without also specifying it for the submenus as well. So if you want the
525 submenu items to look different from the menu bar itself, you must ask
526 for that in two steps. First, specify the resource for all of them;
527 then, override the value for submenus alone. Here is an example:
528
529 @smallexample
530 Emacs.pane.menubar.*.fontList: 8x16
531 Emacs.pane.menubar.popup_*.fontList: 8x16
532 @end smallexample
533
534 @noindent
535 For LessTif pop-up menus, use @samp{menu*} instead of
536 @samp{pane.menubar}. For example, to specify the font @samp{8x16} for
537 the pop-up menu items, write this:
538
539 @smallexample
540 Emacs.menu*.fontList: 8x16
541 @end smallexample
542
543 @noindent
544 For LessTif dialog boxes, use @samp{dialog} instead of @samp{menu}:
545
546 @example
547 Emacs.dialog*.fontList: 8x16
548 Emacs.dialog*.foreground: hotpink
549 @end example
550
551 To specify resources for the LessTif file-selection box, use
552 @samp{fsb*}, like this:
553
554 @example
555 Emacs.fsb*.fontList: 8x16
556 @end example
557
558 @iftex
559 @medbreak
560 @end iftex
561 Here is a list of the specific resources for LessTif menu bars and
562 pop-up menus:
563
564 @table @code
565 @item armColor
566 The color to show in an armed button.
567 @item fontList
568 The font to use.
569 @item marginBottom
570 @itemx marginHeight
571 @itemx marginLeft
572 @itemx marginRight
573 @itemx marginTop
574 @itemx marginWidth
575 Amount of space to leave around the item, within the border.
576 @item borderWidth
577 The width of the border around the menu item, on all sides.
578 @item shadowThickness
579 The width of the border shadow.
580 @item bottomShadowColor
581 The color for the border shadow, on the bottom and the right.
582 @item topShadowColor
583 The color for the border shadow, on the top and the left.
584 @end table
585
586
587 @node GTK resources
588 @appendixsec GTK resources
589 @cindex GTK resources and customization
590 @cindex resource files for GTK
591 @cindex @file{~/.gtkrc-2.0} file
592 @cindex @file{~/.emacs.d/gtkrc} file
593
594 If Emacs was built to use the GTK widget set, then the menu bar,
595 scroll bar and the dialogs are customized with the standard GTK
596 customization file, @file{~/.gtkrc-2.0}, or with the Emacs specific
597 file @file{~/.emacs.d/gtkrc}. We recommend that you use
598 @file{~/.emacs.d/gtkrc} for customizations, since @file{~/.gtkrc-2.0}
599 seems to be ignored when running GConf with GNOME. These files apply
600 only to GTK widget features. To customize Emacs font, background,
601 faces, etc., use the normal X resources (@pxref{Resources}).
602
603 Some GTK themes override these mechanisms, which means that using
604 these mechanisms will not work to customize them.
605
606 In these files you first define a style and say what it means; then
607 you specify to apply the style to various widget types (@pxref{GTK
608 widget names}). Here is an example of how to change the font for
609 Emacs menus:
610
611 @smallexample
612 # @r{Define the style @samp{metafont}.}
613 style "menufont"
614 @{
615 font_name = "helvetica bold 14" # This is a Pango font name
616 @}
617
618 # @r{Specify that widget type @samp{*emacs-menuitem*} uses @samp{metafont}.}
619 widget "*emacs-menuitem*" style "menufont"
620 @end smallexample
621
622 Here is a more elaborate example, showing how to change the parts of
623 the scroll bar:
624
625 @smallexample
626 style "scroll"
627 @{
628 fg[NORMAL] = "red"@ @ @ @ @ # @r{The arrow color.}
629 bg[NORMAL] = "yellow"@ @ # @r{The thumb and background around the arrow.}
630 bg[ACTIVE] = "blue"@ @ @ @ # @r{The trough color.}
631 bg[PRELIGHT] = "white"@ # @r{The thumb color when the mouse is over it.}
632 @}
633
634 widget "*verticalScrollBar*" style "scroll"
635 @end smallexample
636
637 There are also parameters that affect GTK as a whole. For example,
638 the property @code{gtk-font-name} sets the default font for GTK. You
639 must use Pango font names (@pxref{GTK styles}). A GTK resources file
640 that just sets a default font looks like this:
641
642 @smallexample
643 gtk-font-name = "courier 12"
644 @end smallexample
645
646 The GTK resources file is fully described in the GTK API document.
647 This can be found in
648 @file{@var{prefix}/share/gtk-doc/html/gtk/gtk-resource-files.html},
649 where @file{prefix} is the directory in which the GTK libraries were
650 installed (usually @file{/usr} or @file{/usr/local}). You can also
651 find the document online, at
652 @uref{http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html}.
653
654 @menu
655 * GTK widget names:: How widgets in GTK are named in general.
656 * GTK Names in Emacs:: GTK widget names in Emacs.
657 * GTK styles:: What can be customized in a GTK widget.
658 @end menu
659
660 @node GTK widget names
661 @appendixsubsec GTK widget names
662 @cindex GTK widget names
663
664 A GTK widget is specified by its @dfn{widget class} and
665 @dfn{widget name}. The widget class is the type of the widget: for
666 example, @code{GtkMenuBar}. The widget name is the name given to a
667 specific widget. A widget always has a class, but need not have a
668 name.
669
670 @dfn{Absolute names} are sequences of widget names or widget
671 classes, corresponding to hierarchies of widgets embedded within
672 other widgets. For example, if a @code{GtkWindow} named @code{top}
673 contains a @code{GtkVBox} named @code{box}, which in turn contains
674 a @code{GtkMenuBar} called @code{menubar}, the absolute class name
675 of the menu-bar widget is @code{GtkWindow.GtkVBox.GtkMenuBar}, and
676 its absolute widget name is @code{top.box.menubar}.
677
678 When assigning a style to a widget, you can use the absolute class
679 name or the absolute widget name.
680
681 There are two commands to specify changes for widgets:
682
683 @table @asis
684 @item @code{widget_class}
685 specifies a style for widgets based on the absolute class name.
686
687 @item @code{widget}
688 specifies a style for widgets based on the absolute class name,
689 or just the class.
690 @end table
691
692 @noindent
693 You must specify the class and the style in double-quotes, and put
694 these commands at the top level in the GTK customization file, like
695 this:
696
697 @smallexample
698 style "menufont"
699 @{
700 font_name = "helvetica bold 14"
701 @}
702
703 widget "top.box.menubar" style "menufont"
704 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "menufont"
705 @end smallexample
706
707 Matching of absolute names uses shell wildcard syntax: @samp{*}
708 matches zero or more characters and @samp{?} matches one character.
709 This example assigns @code{base_style} to all widgets:
710
711 @smallexample
712 widget "*" style "base_style"
713 @end smallexample
714
715 Given the absolute class name @code{GtkWindow.GtkVBox.GtkMenuBar}
716 and the corresponding absolute widget name @code{top.box.menubar}, all
717 these examples specify @code{my_style} for the menu bar:
718
719 @smallexample
720 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
721 widget_class "GtkWindow.*.GtkMenuBar" style "my_style"
722 widget_class "*GtkMenuBar" style "my_style"
723 widget "top.box.menubar" style "my_style"
724 widget "*box*menubar" style "my_style"
725 widget "*menubar" style "my_style"
726 widget "*menu*" style "my_style"
727 @end smallexample
728
729 @node GTK Names in Emacs
730 @appendixsubsec GTK Widget Names in Emacs
731 @cindex GTK widget names
732 @cindex GTK widget classes
733
734 In Emacs, the top level widget for a frame is a @code{GtkWindow}
735 that contains a @code{GtkVBox}. The @code{GtkVBox} contains the
736 @code{GtkMenuBar} and a @code{GtkFixed} widget. The vertical scroll
737 bars, @code{GtkVScrollbar}, are contained in the @code{GtkFixed}
738 widget. The text you write in Emacs is drawn in the @code{GtkFixed}
739 widget.
740
741 Dialogs in Emacs are @code{GtkDialog} widgets. The file dialog is a
742 @code{GtkFileSelection} widget.
743
744 @noindent
745 To set a style for the menu bar using the absolute class name, use:
746
747 @smallexample
748 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
749 @end smallexample
750
751 @noindent
752 For the scroll bar, the absolute class name is:
753
754 @smallexample
755 widget_class
756 "GtkWindow.GtkVBox.GtkFixed.GtkVScrollbar"
757 style "my_style"
758 @end smallexample
759
760 @noindent
761 The names for the emacs widgets, and their classes, are:
762
763 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
764 @item @code{emacs-filedialog}
765 @tab @code{GtkFileSelection}
766 @item @code{emacs-dialog}
767 @tab @code{GtkDialog}
768 @item @code{Emacs}
769 @tab @code{GtkWindow}
770 @item @code{pane}
771 @tab @code{GtkVHbox}
772 @item @code{emacs}
773 @tab @code{GtkFixed}
774 @item @code{verticalScrollBar}
775 @tab @code{GtkVScrollbar}
776 @item @code{emacs-toolbar}
777 @tab @code{GtkToolbar}
778 @item @code{menubar}
779 @tab @code{GtkMenuBar}
780 @item @code{emacs-menuitem}
781 @tab anything in menus
782 @end multitable
783
784 @noindent
785 Thus, for Emacs you can write the two examples above as:
786
787 @smallexample
788 widget "Emacs.pane.menubar" style "my_style"
789 widget "Emacs.pane.emacs.verticalScrollBar" style "my_style"
790 @end smallexample
791
792 GTK absolute names are quite strange when it comes to menus
793 and dialogs. The names do not start with @samp{Emacs}, as they are
794 free-standing windows and not contained (in the GTK sense) by the
795 Emacs GtkWindow. To customize the dialogs and menus, use wildcards like this:
796
797 @smallexample
798 widget "*emacs-dialog*" style "my_dialog_style"
799 widget "*emacs-filedialog* style "my_file_style"
800 widget "*emacs-menuitem* style "my_menu_style"
801 @end smallexample
802
803 If you specify a customization in @file{~/.emacs.d/gtkrc}, then it
804 automatically applies only to Emacs, since other programs don't read
805 that file. For example, the drop down menu in the file dialog can not
806 be customized by any absolute widget name, only by an absolute class
807 name. This is because the widgets in the drop down menu do not
808 have names and the menu is not contained in the Emacs GtkWindow. To
809 have all menus in Emacs look the same, use this in
810 @file{~/.emacs.d/gtkrc}:
811
812 @smallexample
813 widget_class "*Menu*" style "my_menu_style"
814 @end smallexample
815
816 @node GTK styles
817 @appendixsubsec GTK styles
818 @cindex GTK styles
819
820 In a GTK style you specify the appearance widgets shall have. You
821 can specify foreground and background color, background pixmap and
822 font. The edit widget (where you edit the text) in Emacs is a GTK
823 widget, but trying to specify a style for the edit widget will have no
824 effect. This is so that Emacs compiled for GTK is compatible with
825 Emacs compiled for other X toolkits. The settings for foreground,
826 background and font for the edit widget is taken from the X resources;
827 @pxref{Resources}. Here is an example of two style declarations,
828 @samp{default} and @samp{ruler}:
829
830 @smallexample
831 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
832
833 style "default"
834 @{
835 font_name = "helvetica 12"
836
837 bg[NORMAL] = @{ 0.83, 0.80, 0.73 @}
838 bg[SELECTED] = @{ 0.0, 0.55, 0.55 @}
839 bg[INSENSITIVE] = @{ 0.77, 0.77, 0.66 @}
840 bg[ACTIVE] = @{ 0.0, 0.55, 0.55 @}
841 bg[PRELIGHT] = @{ 0.0, 0.55, 0.55 @}
842
843 fg[NORMAL] = "black"
844 fg[SELECTED] = @{ 0.9, 0.9, 0.9 @}
845 fg[ACTIVE] = "black"
846 fg[PRELIGHT] = @{ 0.9, 0.9, 0.9 @}
847
848 base[INSENSITIVE] = "#777766"
849 text[INSENSITIVE] = @{ 0.60, 0.65, 0.57 @}
850
851 bg_pixmap[NORMAL] = "background.xpm"
852 bg_pixmap[INSENSITIVE] = "background.xpm"
853 bg_pixmap[ACTIVE] = "background.xpm"
854 bg_pixmap[PRELIGHT] = "<none>"
855
856 @}
857
858 style "ruler" = "default"
859 @{
860 font_name = "helvetica 8"
861 @}
862
863 @end smallexample
864
865 The style @samp{ruler} inherits from @samp{default}. This way you can build
866 on existing styles. The syntax for fonts and colors is described below.
867
868 As this example shows, it is possible to specify several values for
869 foreground and background depending on the widget's @dfn{state}. The
870 possible states are:
871
872 @table @code
873 @item NORMAL
874 This is the default state for widgets.
875 @item ACTIVE
876 This is the state for a widget that is ready to do something. It is
877 also for the trough of a scroll bar, i.e. @code{bg[ACTIVE] = "red"}
878 sets the scroll bar trough to red. Buttons that have been pressed but
879 not released yet (``armed'') are in this state.
880 @item PRELIGHT
881 This is the state for a widget that can be manipulated, when the mouse
882 pointer is over it---for example when the mouse is over the thumb in
883 the scroll bar or over a menu item. When the mouse is over a button
884 that is not pressed, the button is in this state.
885 @item SELECTED
886 This is the state for data that has been selected by the user. It can
887 be selected text or items selected in a list. This state is not used
888 in Emacs.
889 @item INSENSITIVE
890 This is the state for widgets that are visible, but they can not be
891 manipulated in the usual way---for example, buttons that can't be
892 pressed, and disabled menu items. To display disabled menu items in
893 yellow, use @code{fg[INSENSITIVE] = "yellow"}.
894 @end table
895
896 Here are the things that can go in a style declaration:
897
898 @table @code
899 @item bg[@var{state}] = @var{color}
900 This specifies the background color for the widget. Note that
901 editable text doesn't use @code{bg}; it uses @code{base} instead.
902
903 @item base[@var{state}] = @var{color}
904 This specifies the background color for editable text. In Emacs, this
905 color is used for the background of the text fields in the file
906 dialog.
907
908 @item bg_pixmap[@var{state}] = "@var{pixmap}"
909 This specifies an image background (instead of a background color).
910 @var{pixmap} should be the image file name. GTK can use a number of
911 image file formats, including XPM, XBM, GIF, JPEG and PNG. If you
912 want a widget to use the same image as its parent, use
913 @samp{<parent>}. If you don't want any image, use @samp{<none>}.
914 @samp{<none>} is the way to cancel a background image inherited from a
915 parent style.
916
917 You can't specify the file by its absolute file name. GTK looks for
918 the pixmap file in directories specified in @code{pixmap_path}.
919 @code{pixmap_path} is a colon-separated list of directories within
920 double quotes, specified at the top level in a @file{gtkrc} file
921 (i.e. not inside a style definition; see example above):
922
923 @smallexample
924 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
925 @end smallexample
926
927 @item fg[@var{state}] = @var{color}
928 This specifies the foreground color for widgets to use. It is the
929 color of text in menus and buttons, and the color for the arrows in
930 the scroll bar. For editable text, use @code{text}.
931
932 @item text[@var{state}] = @var{color}
933 This is the color for editable text. In Emacs, this color is used for the
934 text fields in the file dialog.
935
936 @item font_name = "@var{font}"
937 This specifies the font for text in the widget. @var{font} is a
938 Pango font name, for example @samp{Sans Italic 10}, @samp{Helvetica
939 Bold 12}, @samp{Courier 14}, @samp{Times 18}. See below for exact
940 syntax. The names are case insensitive.
941 @end table
942
943 There are three ways to specify a color: by name, in hexadecimal
944 form, and with an RGB triplet.
945
946 @noindent
947 A color name is written within double quotes, for example @code{"red"}.
948
949 @noindent
950 Hexadecimal form is the same as in X:
951 @code{#@var{rrrr}@var{gggg}@var{bbbb}}, where all three color specs
952 must have the same number of hex digits (1, 2, 3 or 4).
953
954 @noindent
955 An RGB triplet looks like @code{@{ @var{r}, @var{g}, @var{b} @}},
956 where @var{r}, @var{g} and @var{b} are either integers in the range
957 0-65535 or floats in the range 0.0-1.0.
958
959 Pango font names have the form ``@var{family-list} @var{style-options}
960 @var{size}''.
961 @cindex Pango font name
962 @noindent
963 @var{family-list} is a comma separated list of font families optionally
964 terminated by a comma. This way you can specify several families and the
965 first one found will be used. @var{family} corresponds to the second part in
966 an X font name, for example in
967
968 @smallexample
969 -adobe-times-medium-r-normal--12-120-75-75-p-64-iso10646-1
970 @end smallexample
971
972 @noindent
973 the family name is ``times''.
974
975 @noindent
976 @var{style-options} is a whitespace separated list of words where each word
977 is a style, variant, weight, or stretch. The default value for all of
978 these is @code{normal}.
979
980 @noindent
981 A `style' corresponds to the fourth part of an X font name. In X font
982 names it is the character @samp{r}, @samp{i} or @samp{o}; in Pango
983 font names the corresponding values are @code{normal}, @code{italic},
984 or @code{oblique}.
985
986 @noindent
987 A `variant' is either @code{normal} or @code{small-caps}.
988 Small caps is a font with the lower case characters replaced by
989 smaller variants of the capital characters.
990
991 @noindent
992 Weight describes the ``boldness'' of a font. It corresponds to the third
993 part of an X font name. It is one of @code{ultra-light}, @code{light},
994 @code{normal}, @code{bold}, @code{ultra-bold}, or @code{heavy}.
995
996 @noindent
997 Stretch gives the width of the font relative to other designs within a
998 family. It corresponds to the fifth part of an X font name. It is one of
999 @code{ultra-condensed}, @code{extra-condensed}, @code{condensed},
1000 @code{semi-condensed}, @code{normal}, @code{semi-expanded},
1001 @code{expanded}, @code{extra-expanded}, or @code{ultra-expanded}.
1002
1003 @noindent
1004 @var{size} is a decimal number that describes the font size in points.
1005
1006 @ignore
1007 arch-tag: 9b6ff773-48b6-41f6-b2f9-f114b8bdd97f
1008 @end ignore