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