(Fx_create_frame): Don't call Qface_set_after_frame_default.
[emacs.git] / man / xresources.texi
blobf2a5f22ba30b7fd73d5519a1112c037b805c549a
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, Command Arguments, 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}.  X resources are the only way to customize
11 tooltip windows and LessTif menus, since the libraries that implement
12 them don't provide for customization through Emacs.  This appendix
13 describes the X resources that Emacs recognizes and how to use them.
15 @menu
16 * Resources::           Using X resources with Emacs (in general).
17 * Table of Resources::  Table of specific X resources that affect Emacs.
18 * Face Resources::      X resources for customizing faces.
19 * Lucid Resources::     X resources for Lucid menus.
20 * LessTif Resources::   X resources for LessTif and Motif menus.
21 * GTK resources::       Resources for GTK widgets.
22 @end menu
24 @node Resources
25 @appendixsec X Resources
26 @cindex resources
27 @cindex X resources
28 @cindex @file{~/.Xdefaults} file
29 @cindex @file{~/.Xresources} file
31   Programs running under the X Window System organize their user
32 options under a hierarchy of classes and resources.  You can specify
33 default values for these options in your X resources file, usually
34 named @file{~/.Xdefaults} or @file{~/.Xresources}.
35 If changes in @file{~/.Xdefaults} do not
36 take effect, it is because your X server stores its own list of
37 resources; to update them, use the shell command @command{xrdb}---for
38 instance, @samp{xrdb ~/.Xdefaults}.
40   Each line in the file specifies a value for one option or for a
41 collection of related options, for one program or for several programs
42 (optionally even for all programs).
44 @cindex Registry (MS-Windows)
45   MS-Windows systems don't support @file{~/.Xdefaults} files, but
46 Emacs compiled for Windows looks for X resources in the Windows
47 Registry, under the key @samp{HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs}
48 and then under the key @samp{HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs}.
50   Programs define named resources with particular meanings.  They also
51 define how to group resources into named classes.  For instance, in
52 Emacs, the @samp{internalBorder} resource controls the width of the
53 internal border, and the @samp{borderWidth} resource controls the width
54 of the external border.  Both of these resources are part of the
55 @samp{BorderWidth} class.  Case distinctions are significant in these
56 names.
58   In @file{~/.Xdefaults}, you can specify a value for a single resource
59 on one line, like this:
61 @example
62 emacs.borderWidth: 2
63 @end example
65 @noindent
66 Or you can use a class name to specify the same value for all resources
67 in that class.  Here's an example:
69 @example
70 emacs.BorderWidth: 2
71 @end example
73   If you specify a value for a class, it becomes the default for all
74 resources in that class.  You can specify values for individual
75 resources as well; these override the class value, for those particular
76 resources.  Thus, this example specifies 2 as the default width for all
77 borders, but overrides this value with 4 for the external border:
79 @example
80 emacs.BorderWidth: 2
81 emacs.borderWidth: 4
82 @end example
84   The order in which the lines appear in the file does not matter.
85 Also, command-line options always override the X resources file.
87   The string @samp{emacs} in the examples above is also a resource
88 name.  It actually represents the name of the executable file that you
89 invoke to run Emacs.  If Emacs is installed under a different name, it
90 looks for resources under that name instead of @samp{emacs}.
92 @table @samp
93 @item -name @var{name}
94 @opindex --name
95 @itemx --name=@var{name}
96 @cindex resource name, command-line argument
97 Use @var{name} as the resource name (and the title) for the initial
98 Emacs frame.  This option does not affect subsequent frames, but Lisp
99 programs can specify frame names when they create frames.
101 If you don't specify this option, the default is to use the Emacs
102 executable's name as the resource name.
104 @item -xrm @var{resource-values}
105 @opindex --xrm
106 @itemx --xrm=@var{resource-values}
107 @cindex resource values, command-line argument
108 Specify X resource values for this Emacs job (see below).
109 @end table
111   For consistency, @samp{-name} also specifies the name to use for
112 other resource values that do not belong to any particular frame.
114   The resources that name Emacs invocations also belong to a class; its
115 name is @samp{Emacs}.  If you write @samp{Emacs} instead of
116 @samp{emacs}, the resource applies to all frames in all Emacs jobs,
117 regardless of frame titles and regardless of the name of the executable
118 file.  Here is an example:
120 @example
121 Emacs.BorderWidth: 2
122 Emacs.borderWidth: 4
123 @end example
125   You can specify a string of additional resource values for Emacs to
126 use with the command line option @samp{-xrm @var{resources}}.  The text
127 @var{resources} should have the same format that you would use inside a file
128 of X resources.  To include multiple resource specifications in
129 @var{resources}, put a newline between them, just as you would in a file.
130 You can also use @samp{#include "@var{filename}"} to include a file full
131 of resource specifications.  Resource values specified with @samp{-xrm}
132 take precedence over all other resource specifications.
134   One way to experiment with the effect of different resource settings
135 is to use the @code{editres} program.  Select @samp{Get Tree} from the
136 @samp{Commands} menu, then click on an Emacs frame.  This will display
137 a tree showing the structure of X toolkit widgets used in an Emacs
138 frame.  Select one of them, such as @samp{menubar}, then select
139 @samp{Show Resource Box} from the @samp{Commands} menu.  This displays
140 a list of all the meaningful X resources and allows you to edit them.
141 Changes take effect immediately if you click on the @samp{Apply} button.
143 @node Table of Resources
144 @appendixsec Table of X Resources for Emacs
146   This table lists the resource names that designate options for
147 Emacs, not counting those for the appearance of the menu bar, each
148 with the class that it belongs to:
150 @table @asis
151 @item @code{background} (class @code{Background})
152 Background color name.
154 @item @code{bitmapIcon} (class @code{BitmapIcon})
155 Use a bitmap icon (a picture of a gnu) if @samp{on}, let the window
156 manager choose an icon if @samp{off}.
158 @item @code{borderColor} (class @code{BorderColor})
159 Color name for the external border.
161 @item @code{borderWidth} (class @code{BorderWidth})
162 Width in pixels of the external border.
164 @item @code{cursorColor} (class @code{Foreground})
165 Color name for text cursor (point).
167 @item @code{font} (class @code{Font})
168 Font name for text (or fontset name, @pxref{Fontsets}).
170 @item @code{foreground} (class @code{Foreground})
171 Color name for text.
173 @item @code{geometry} (class @code{Geometry})
174 Window size and position.  Be careful not to specify this resource as
175 @samp{emacs*geometry}, because that may affect individual menus as well
176 as the Emacs frame itself.
178 If this resource specifies a position, that position applies only to the
179 initial Emacs frame (or, in the case of a resource for a specific frame
180 name, only that frame).  However, the size, if specified here, applies to
181 all frames.
183 @item @code{fullscreen} (class @code{Fullscreen})
184 The desired fullscreen size.  The value can be one of @code{fullboth},
185 @code{fullwidth} or @code{fullheight}, which correspond to
186 the command-line options @samp{-fs}, @samp{-fw}, and @samp{-fh}
187 (@pxref{Window Size X}).
189 Note that this applies to all frames created, not just the initial
190 one.
192 @item @code{iconName} (class @code{Title})
193 Name to display in the icon.
195 @item @code{internalBorder} (class @code{BorderWidth})
196 Width in pixels of the internal border.
198 @item @code{lineSpacing} (class @code{LineSpacing})
199 @cindex line spacing
200 @cindex leading
201 Additional space (@dfn{leading}) between lines, in pixels.
203 @item @code{menuBar} (class @code{MenuBar})
204 @cindex menu bar
205 Give frames menu bars if @samp{on}; don't have menu bars if
206 @samp{off}.  @xref{Lucid Resources}, and @ref{LessTif Resources}, for
207 how to control the appearance of the menu bar if you have one.
209 @item @code{minibuffer} (class @code{Minibuffer})
210 If @samp{none}, don't make a minibuffer in this frame.
211 It will use a separate minibuffer frame instead.
213 @item @code{paneFont} (class @code{Font})
214 @cindex font for menus
215 Font name for menu pane titles, in non-toolkit versions of Emacs.
217 @item @code{pointerColor} (class @code{Foreground})
218 Color of the mouse cursor.
220 @item @code{privateColormap} (class @code{PrivateColormap})
221 If @samp{on}, use a private color map, in the case where the ``default
222 visual'' of class PseudoColor and Emacs is using it.
224 @item @code{reverseVideo} (class @code{ReverseVideo})
225 Switch foreground and background default colors if @samp{on}, use colors as
226 specified if @samp{off}.
228 @item @code{screenGamma} (class @code{ScreenGamma})
229 @cindex gamma correction
230 Gamma correction for colors, equivalent to the frame parameter
231 @code{screen-gamma}.
233 @item @code{selectionFont} (class @code{SelectionFont})
234 Font name for pop-up menu items, in non-toolkit versions of Emacs.  (For
235 toolkit versions, see @ref{Lucid Resources}, also see @ref{LessTif
236 Resources}.)
238 @item @code{selectionTimeout} (class @code{SelectionTimeout})
239 Number of milliseconds to wait for a selection reply.
240 If the selection owner doesn't reply in this time, we give up.
241 A value of 0 means wait as long as necessary.
243 @item @code{synchronous} (class @code{Synchronous})
244 @cindex debugging X problems
245 @cindex synchronous X mode
246 Run Emacs in synchronous mode if @samp{on}.  Synchronous mode is
247 useful for debugging X problems.
249 @item @code{title} (class @code{Title})
250 Name to display in the title bar of the initial Emacs frame.
252 @item @code{toolBar} (class @code{ToolBar})
253 @cindex tool bar
254 Number of lines to reserve for the tool bar.  A zero value suppresses
255 the tool bar.  If the value is non-zero and
256 @code{auto-resize-tool-bars} is non-@code{nil}, the tool bar's size
257 will be changed automatically so that all tool bar items are visible.
259 @item @code{useXIM} (class @code{UseXIM})
260 @cindex XIM
261 @cindex X input methods
262 @cindex input methods, X
263 Turn off use of X input methods (XIM) if @samp{false} or @samp{off}.
264 This is only relevant if your Emacs is actually built with XIM
265 support.  It is potentially useful to turn off XIM for efficiency,
266 especially slow X client/server links.
268 @item @code{verticalScrollBars} (class @code{ScrollBars})
269 Give frames scroll bars if @samp{on}; don't have scroll bars if
270 @samp{off}.
271 @end table
273 @node Face Resources
274 @appendixsec X Resources for Faces
276   You can also use resources to customize the appearance of particular
277 faces (@pxref{Faces}):
279 @table @code
280 @item @var{face}.attributeFont
281 Font for face @var{face}.
282 @item @var{face}.attributeForeground
283 Foreground color for face @var{face}.
284 @item @var{face}.attributeBackground
285 Background color for face @var{face}.
286 @item @var{face}.attributeUnderline
287 Underline flag for face @var{face}.  Use @samp{on} or @samp{true} for
288 yes.
289 @item @var{face}.attributeFamily
290 Font family for face @var{face}.
291 @item @var{face}.attributeWidth
292 Relative proportional width of the font to use for face @var{face}.
293 It should be one of @code{ultra-condensed}, @code{extra-condensed},
294 @code{condensed}, @code{semi-condensed}, @code{normal},
295 @code{semi-expanded}, @code{expanded}, @code{extra-expanded}, or
296 @code{ultra-expanded}.
297 @item @var{face}.attributeHeight
298 Height of the font to use for face @var{face}: either an integer
299 specifying the height in units of 1/10@dmn{pt}, or a floating point
300 number that specifies a scale factor to scale the underlying face's
301 default font, or a function to be called with the default height which
302 will return a new height.
303 @item @var{face}.attributeWeight
304 A weight to use for the face @var{face}.  It must be one of
305 @code{ultra-bold}, @code{extra-bold}, @code{bold},
306 @code{semi-bold}, @code{normal}, @code{semi-light}, @code{light},
307 @code{extra-light}, @code{ultra-light}.
308 @item @var{face}.attributeSlant
309 The slant to use for the font of face @var{face}.  It must be one of
310 @code{italic}, @code{oblique}, @code{normal},
311 @code{reverse-italic}, or @code{reverse-oblique}.
312 @item @var{face}.attributeStrikeThrough
313 Whether the face @var{face} should be drawn with a line striking
314 through the characters.
315 @item @var{face}.attributeOverline
316 Whether the characters in the face @var{face} should be overlined.
317 @item @var{face}.attributeBox
318 Whether to draw a box around the characters in face @var{face}.
319 @item @var{face}.attributeInverse
320 Whether to display the characters in face @var{face} in inverse
321 video.
322 @item @var{face}.attributeStipple
323 The name of a pixmap data file to use for the stipple pattern, or
324 @code{false} to not use stipple for the face @var{face}.
325 @item @var{face}.attributeBackgroundPixmap
326 The background pixmap for the face @var{face}.  Should be a name of a
327 pixmap file or @code{false}.
328 @item @var{face}.attributeBold
329 Whether to draw the characters in the face @var{face} as bold.
330 @item @var{face}.attributeItalic
331 Whether to draw the characters in the face @var{face} as italic.
332 @end table
334 @node Lucid Resources
335 @appendixsec Lucid Menu X Resources
336 @cindex Menu X Resources (Lucid widgets)
337 @cindex Lucid Widget X Resources
339   If the Emacs installed at your site was built to use the X toolkit
340 with the Lucid menu widgets, then the menu bar is a separate widget and
341 has its own resources.  The resource names contain @samp{pane.menubar}
342 (following, as always, the name of the Emacs invocation, or @samp{Emacs},
343 which stands for all Emacs invocations).  Specify them like this:
345 @example
346 Emacs.pane.menubar.@var{resource}:  @var{value}
347 @end example
349 @noindent
350 For example, to specify the font @samp{8x16} for the menu-bar items,
351 write this:
353 @example
354 Emacs.pane.menubar.font:  8x16
355 @end example
357 @noindent
358 Resources for @emph{non-menubar} toolkit pop-up menus have
359 @samp{menu*}, in like fashion.  For example, to specify the font
360 @samp{8x16} for the pop-up menu items, write this:
362 @example
363 Emacs.menu*.font:       8x16
364 @end example
366 @noindent
367 For dialog boxes, use @samp{dialog} instead of @samp{menu}:
369 @example
370 Emacs.dialog*.font:     8x16
371 @end example
373 @noindent
374 Experience shows that on some systems you may need to add
375 @samp{shell.}@: before the @samp{pane.menubar} or @samp{menu*}.  On
376 some other systems, you must not add @samp{shell.}.
378   Here is a list of the specific resources for menu bars and pop-up menus:
380 @table @code
381 @item font
382 Font for menu item text.
383 @item foreground
384 Color of the foreground.
385 @item background
386 Color of the background.
387 @item buttonForeground
388 In the menu bar, the color of the foreground for a selected item.
389 @item horizontalSpacing
390 Horizontal spacing in pixels between items.  Default is 3.
391 @item verticalSpacing
392 Vertical spacing in pixels between items.  Default is 1.
393 @item arrowSpacing
394 Horizontal spacing between the arrow (which indicates a submenu) and
395 the associated text.  Default is 10.
396 @item shadowThickness
397 Thickness of shadow line around the widget.
398 @item margin
399 The margin of the menu bar, in characters.  The default of 4 makes the
400 menu bar appear like the LessTif/Motif one.
401 @end table
403 @node LessTif Resources
404 @appendixsec LessTif Menu X Resources
405 @cindex Menu X Resources (LessTif widgets)
406 @cindex LessTif Widget X Resources
408   If the Emacs installed at your site was built to use the X toolkit
409 with the LessTif or Motif widgets, then the menu bar, the dialog
410 boxes, the pop-up menus, and the file-selection box are separate
411 widgets and have their own resources.
413   The resource names for the menu bar contain @samp{pane.menubar}
414 (following, as always, the name of the Emacs invocation, or
415 @samp{Emacs}, which stands for all Emacs invocations).  Specify them
416 like this:
418 @smallexample
419 Emacs.pane.menubar.@var{subwidget}.@var{resource}:  @var{value}
420 @end smallexample
422   Each individual string in the menu bar is a subwidget; the subwidget's
423 name is the same as the menu item string.  For example, the word
424 @samp{File} in the menu bar is part of a subwidget named
425 @samp{emacs.pane.menubar.File}.  Most likely, you want to specify the
426 same resources for the whole menu bar.  To do this, use @samp{*} instead
427 of a specific subwidget name.  For example, to specify the font
428 @samp{8x16} for the menu-bar items, write this:
430 @smallexample
431 Emacs.pane.menubar.*.fontList:  8x16
432 @end smallexample
434 @noindent
435 This also specifies the resource value for submenus.
437   Each item in a submenu in the menu bar also has its own name for X
438 resources; for example, the @samp{File} submenu has an item named
439 @samp{Save (current buffer)}.  A resource specification for a submenu
440 item looks like this:
442 @smallexample
443 Emacs.pane.menubar.popup_*.@var{menu}.@var{item}.@var{resource}: @var{value}
444 @end smallexample
446 @noindent
447 For example, here's how to specify the font for the @samp{Save (current
448 buffer)} item:
450 @smallexample
451 Emacs.pane.menubar.popup_*.File.Save (current buffer).fontList: 8x16
452 @end smallexample
454 @noindent
455 For an item in a second-level submenu, such as @samp{Complete Word}
456 under @samp{Spell Checking} under @samp{Tools}, the resource fits this
457 template:
459 @smallexample
460 Emacs.pane.menubar.popup_*.popup_*.@var{menu}.@var{resource}: @var{value}
461 @end smallexample
463 @noindent
464 For example,
466 @smallexample
467 Emacs.pane.menubar.popup_*.popup_*.Spell Checking.Complete Word: @var{value}
468 @end smallexample
470 @noindent
471 (This should be one long line.)
473   It's impossible to specify a resource for all the menu-bar items
474 without also specifying it for the submenus as well.  So if you want the
475 submenu items to look different from the menu bar itself, you must ask
476 for that in two steps.  First, specify the resource for all of them;
477 then, override the value for submenus alone.  Here is an example:
479 @smallexample
480 Emacs.pane.menubar.*.fontList:  8x16
481 Emacs.pane.menubar.popup_*.fontList: 8x16
482 @end smallexample
484 @noindent
485 For LessTif pop-up menus, use @samp{menu*} instead of
486 @samp{pane.menubar}.  For example, to specify the font @samp{8x16} for
487 the pop-up menu items, write this:
489 @smallexample
490 Emacs.menu*.fontList:  8x16
491 @end smallexample
493 @noindent
494 For LessTif dialog boxes, use @samp{dialog} instead of @samp{menu}:
496 @example
497 Emacs.dialog*.fontList: 8x16
498 Emacs.dialog*.foreground: hotpink
499 @end example
501 To specify resources for the LessTif file-selection box, use
502 @samp{fsb*}, like this:
504 @example
505 Emacs.fsb*.fontList: 8x16
506 @end example
508 @iftex
509 @medbreak
510 @end iftex
511   Here is a list of the specific resources for LessTif menu bars and
512 pop-up menus:
514 @table @code
515 @item armColor
516 The color to show in an armed button.
517 @item fontList
518 The font to use.
519 @item marginBottom
520 @itemx marginHeight
521 @itemx marginLeft
522 @itemx marginRight
523 @itemx marginTop
524 @itemx marginWidth
525 Amount of space to leave around the item, within the border.
526 @item borderWidth
527 The width of the border around the menu item, on all sides.
528 @item shadowThickness
529 The width of the border shadow.
530 @item bottomShadowColor
531 The color for the border shadow, on the bottom and the right.
532 @item topShadowColor
533 The color for the border shadow, on the top and the left.
534 @end table
537 @node GTK resources
538 @appendixsec GTK resources
539 @cindex GTK resources and customization
540 @cindex resource files for GTK
541 @cindex @file{~/.gtkrc-2.0} file
542 @cindex @file{~/.emacs.d/gtkrc} file
544   If the Emacs installed at your site was built to use the GTK widget set,
545 then the menu bar, scroll bar and the dialogs can be customized with
546 the standard GTK @file{~/.gtkrc-2.0} file or with the Emacs specific
547 @file{~/.emacs.d/gtkrc} file; note that these files are only for
548 customizing specific GTK widget features.  To customize Emacs font,
549 background, faces etc., use the normal X resources, see @ref{Resources}.
551 In these files you first defines a style and then how to apply that style
552 to widgets (@pxref{GTK widget names}).  Here is an example of how to
553 change the font for Emacs menus:
555 @smallexample
556 # This is a comment.
557 style "menufont"
559   font_name = "helvetica bold 14"  # This is a Pango font name
562 widget "*emacs-menuitem*" style "menufont"
564 @end smallexample
566   There are some things you can set without using any style or widget name,
567 which affect GTK as a whole.  Most of these are poorly documented, but can
568 be found in the `Properties' section of the documentation page for
569 @code{GtkSetting}, in the GTK document references below.
571 One property of interest is @code{gtk-font-name} which sets the default
572 font for GTK; you must use Pango font names (@pxref{GTK styles}).  A
573 @file{~/.gtkrc-2.0} file that just sets a default font looks like this:
575 @smallexample
576 gtk-font-name = "courier 12"
577 @end smallexample
580   If GTK at your site is installed under @var{prefix},
581 the resource file syntax is fully described in the GTK API
582 document
583 @file{@var{prefix}/share/gtk-doc/html/gtk/gtk-resource-files.html}.
584 @var{prefix} is usually @file{/usr} or @file{/usr/local}.
585 You can find the same document online at
586 @uref{http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html}.
589 @menu
590 * GTK widget names::      How widgets in GTK are named in general.
591 * GTK names in Emacs::    GTK widget names in Emacs.
592 * GTK styles::            What can be customized in a GTK widget.
593 @end menu
596 @node GTK widget names
597 @appendixsubsec GTK widget names
598 @cindex GTK widget names
600   Widgets are specified by widget class or by widget name.
601 The widget class is the type of the widget, for example @code{GtkMenuBar}.
602 The widget name is the name given to a specific widget within a program.
603 A widget always have a class but it is not mandatory to give a name to
604 a widget.  Absolute names are sequences of widget names or
605 widget classes, corresponding to hierarchies of widgets embedded within
606 other widgets.  For example, if a @code{GtkWindow} contains a @code{GtkVBox}
607 which in turn contains a @code{GtkMenuBar}, the absolute class name
608 is @code{GtkWindow.GtkVBox.GtkMenuBar}.
610 @noindent
611 If the widgets are named ``top'', ``box'' and ``menubar'', the absolute
612 widget name is @code{top.box.menubar},
614   When assigning a style to a widget, you can use the absolute class
615 name or the absolute widget name.
616 There are two commands:  @code{widget_class} will assign a style to
617 widgets, matching only against the absolute class name.
618 The command @code{widget} will match the absolute widget name,
619 but if there is no name for a widget in the hierarchy, the class is matched.
620 These commands require the absolute name and the style name to be
621 within  double quotes.  These commands are written at the top level in a
622 @file{~/.gtkrc-2.0} file, like this:
624 @smallexample
625 style "menufont"
627   font_name = "helvetica bold 14"
630 widget "top.box.menubar" style "menufont"
631 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "menufont"
632 @end smallexample
635   Matching of absolute names is done with shell ``glob'' syntax, that is
636 @samp{*} matches zero or more characters and @samp{?} matches one character.
637 So the following would assign @code{base_style} to all widgets:
639 @smallexample
640 widget "*" style "base_style"
641 @end smallexample
643   Given the absolute class name @code{GtkWindow.GtkVBox.GtkMenuBar}
644 and the corresponding absolute widget name @code{top.box.menubar},
645 the following all assign @code{my_style} to the menu bar:
647 @smallexample
648 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
649 widget_class "GtkWindow.*.GtkMenuBar" style "my_style"
650 widget_class "*GtkMenuBar" style "my_style"
651 widget "top.box.menubar" style "my_style"
652 widget "*box*menubar" style "my_style"
653 widget "*menubar" style "my_style"
654 widget "*menu*" style "my_style"
655 @end smallexample
657 @node GTK names in Emacs
658 @appendixsubsec GTK names in Emacs
659 @cindex GTK widget names
660 @cindex GTK widget classes
662   In Emacs the top level widget for a frame is a @code{GtkWindow} that
663 contains a @code{GtkVBox}.  The @code{GtkVBox} contains the
664 @code{GtkMenuBar} and a @code{GtkFixed} widget.
665 The vertical scroll bars, @code{GtkVScrollbar},
666 are contained in the @code{GtkFixed} widget.
667 The text you write in Emacs is drawn in the @code{GtkFixed} widget.
669   Dialogs in Emacs are @code{GtkDialog} widgets.  The file dialog is a
670 @code{GtkFileSelection} widget.
672 @noindent
673 To set a style for the menu bar using the absolute class name, use:
675 @smallexample
676 widget_class "GtkWindow.GtkVBox.GtkMenuBar" style "my_style"
677 @end smallexample
679 @noindent
680 For the scroll bar, the absolute class name is:
682 @smallexample
683 widget_class
684   "GtkWindow.GtkVBox.GtkFixed.GtkVScrollbar"
685      style "my_style"
686 @end smallexample
688 @noindent
689 The names for the emacs widgets, and their classes, are:
691 @multitable {@code{verticalScrollbar plus}} {@code{GtkFileSelection} and some}
692 @item @code{emacs-filedialog}
693 @tab @code{GtkFileSelection}
694 @item @code{emacs-dialog}
695 @tab @code{GtkDialog}
696 @item @code{Emacs}
697 @tab @code{GtkWindow}
698 @item @code{pane}
699 @tab @code{GtkVHbox}
700 @item @code{emacs}
701 @tab @code{GtkFixed}
702 @item @code{verticalScrollbar}
703 @tab @code{GtkVScrollbar}
704 @item @code{emacs-toolbar}
705 @tab @code{GtkToolbar}
706 @item @code{menubar}
707 @tab @code{GtkMenuBar}
708 @item @code{emacs-menuitem}
709 @tab anything in menus
710 @end multitable
712 @noindent
713 Thus, for Emacs you can write the two examples above as:
715 @smallexample
716 widget "Emacs.pane.menubar" style "my_style"
717 widget "Emacs.pane.emacs.verticalScrollbar" style "my_style"
718 @end smallexample
720   GTK absolute names are quite strange when it comes to menus
721 and dialogs.  The names do not start with @samp{Emacs}, as they are
722 free-standing windows and not contained (in the GTK sense) by the
723 Emacs GtkWindow.  To customize the dialogs and menus, use wildcards like this:
725 @smallexample
726 widget "*emacs-dialog*" style "my_dialog_style"
727 widget "*emacs-filedialog* style "my_file_style"
728 widget "*emacs-menuitem* style "my_menu_style"
729 @end smallexample
731   An alternative is to put customization into @file{~/.emacs.d/gtkrc}.
732 This file is only read by Emacs, so anything in @file{~/.emacs.d/gtkrc}
733 affects Emacs but leaves other applications unaffected.
734 For example, the drop down menu in the file dialog can not
735 be customized by any absolute widget name, only by an absolute
736 class name.  This is so because the widgets in the drop down menu does not
737 have names and the menu is not contained in the Emacs GtkWindow.
738 To have all menus in Emacs look the same, use this in @file{~/.emacs.d/gtkrc}:
740 @smallexample
741 widget_class "*Menu*" style "my_menu_style"
742 @end smallexample
744 @node GTK styles
745 @appendixsubsec GTK styles
746 @cindex GTK styles
748   In a GTK style you specify the appearance widgets shall have.  You
749 can specify foreground and background color, background pixmap and font.
750 The edit widget (where you edit the text) in Emacs is a GTK widget,
751 but trying to specify a style for the edit widget will have no effect.
752 This is so that Emacs compiled for GTK is compatible with Emacs compiled
753 for other X toolkits.  The settings for foreground, background and font
754 for the edit widget is taken from the X resources; @pxref{Resources}.
755 Here is an example of two style declarations, ``default'' and ``ruler'':
757 @smallexample
759 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
761 style "default"
763   font_name = "helvetica 12"
765   bg[NORMAL] = @{ 0.83, 0.80, 0.73 @}
766   bg[SELECTED] = @{ 0.0, 0.55, 0.55 @}
767   bg[INSENSITIVE] = @{ 0.77, 0.77, 0.66 @}
768   bg[ACTIVE] = @{ 0.0, 0.55, 0.55 @}
769   bg[PRELIGHT] = @{ 0.0, 0.55, 0.55 @}
771   fg[NORMAL] = "black"
772   fg[SELECTED] = @{ 0.9, 0.9, 0.9 @}
773   fg[ACTIVE] = "black"
774   fg[PRELIGHT] = @{ 0.9, 0.9, 0.9 @}
776   base[INSENSITIVE] = "#777766"
777   text[INSENSITIVE] = @{ 0.60, 0.65, 0.57 @}
779   bg_pixmap[NORMAL] = "background.xpm"
780   bg_pixmap[INSENSITIVE] = "background.xpm"
781   bg_pixmap[ACTIVE] = "background.xpm"
782   bg_pixmap[PRELIGHT] = "<none>"
786 style "ruler" = "default"
788   font_name = "helvetica 8"
791 @end smallexample
793   The style ``ruler'' inherits from ``default''.  This way you can build
794 on existing styles.  The syntax for fonts and colors is described below.
796   As this example shows, it is possible to specify several values
797 for foreground and background depending on which state the widget has.
798 The possible states are
799 @table @code
800 @item NORMAL
801 This is the default state for widgets.
802 @item ACTIVE
803 This is the state for a widget that is ready to do something.  It is
804 also for the trough of a scroll bar, i.e.  @code{bg[ACTIVE] = "red"}
805 sets the scroll bar trough to red.  Buttons that have been pressed but
806 not released yet (``armed'') are in this state.
807 @item PRELIGHT
808 This is the state when widgets that can be manipulated have the mouse
809 pointer over them.  For example when the mouse is over the thumb in the
810 scroll bar or over a menu item.  When the mouse is over a button that
811 is not pressed, the button is in this state.
812 @item SELECTED
813 This is the state when some data has been selected by the user.  It can
814 be selected text or items selected in a list.
815 There is no place in Emacs where this setting has any effect.
816 @item INSENSITIVE
817 This is the state for widgets that are visible, but they can not be
818 manipulated like they normally can.  For example, buttons that can't be
819 pressed and menu items that can't be selected.
820 Text for menu items that are not available can be set to yellow with
821 @code{fg[INSENSITIVE] = "yellow"}.
822 @end table
824 Here are the things that can go in a style declaration:
826 @table @code
827 @item bg[@var{state}] = @var{color}
828 This is the background color widgets use.  This background is not used for
829 editable text, use @code{base} for that.
831 @item base[@var{state}] = @var{color}
832 This is the background color for editable text.
833 In Emacs, this color is used for the background of the text fields in the
834 file dialog.
836 @item bg_pixmap[@var{state}] = "@var{pixmap}"
837 You can specify a pixmap to be used instead of the background color.
838 @var{pixmap} is a file name.  GTK can use a number of file formats,
839 including XPM, XBM, GIF, JPEG and PNG.  If you want a widget to use the same
840 pixmap as its parent, use @samp{<parent>}.  If you don't want any
841 pixmap use @samp{<none>}.  Using @samp{<none>} can be useful
842 if your style inherits a style that does specify a pixmap.
844   GTK looks for the pixmap in directories specified in @code{pixmap_path}.
845 It is not possible to refer to a file by its absolute path name.
846 @code{pixmap_path} is a colon-separated list of directories within double
847 quotes, specified at the top level in a @file{gtkrc} file (i.e. not inside
848 a style definition; see example above):
850 @smallexample
851 pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
852 @end smallexample
854 @item fg[@var{state}] = @var{color}
855 This is the foreground color widgets use.  This is the color
856 of text in menus and buttons.  It is also the color for the arrows in the
857 scroll bar.  For editable text, use @code{text}.
859 @item text[@var{state}] = @var{color}
860 This is the color for editable text.  In Emacs, this color is used for the
861 text fields in the file dialog.
863 @item font_name = "@var{font}"
864 This is the font a widget shall use.  @var{font} is a Pango font name,
865 for example ``Sans Italic 10'', ``Helvetica Bold 12'', ``Courier 14'',
866 ``Times 18''.  See below for exact syntax.  The names are case insensitive.
867 @end table
869   Colors are specified in three ways, a name, a hexadecimal form or
870 an RGB triplet.
872 @noindent
873 A color name is written within double quotes, for example @code{"red"}.
875 @noindent
876 A hexadecimal form is written within double quotes.  There are four forms,
877 @code{#rrrrggggbbbb}, @code{#rrrgggbbb},
878 @code{#rrggbb}, or @code{#rgb}.  In each of these r, g and b are hex digits.
880 @noindent
881 An RGB triplet looks like @code{@{ r, g, b @}}, where r, g and b are either
882 integers in the range 0-65535 or floats in the range 0.0-1.0.
884   Pango font names have the form ``@var{family-list} @var{style-options}
885 @var{size}''.
886 @cindex Pango font name
887 @noindent
888 @var{family-list} is a comma separated list of font families optionally
889 terminated by a comma.  This way you can specify several families and the
890 first one found will be used.  @var{family} corresponds to the second part in
891 an X font name, for example in
893 @smallexample
894 -adobe-times-medium-r-normal--12-120-75-75-p-64-iso10646-1
895 @end smallexample
897 @noindent
898 the family name is ``times''.
900 @noindent
901 @var{style-options} is a whitespace separated list of words where each word
902 is a style, variant, weight, or stretch.  The default value for all of
903 these is @code{normal}.
905 @noindent
906 A `style' corresponds to the fourth part of an X font name.  In X font
907 names it is the character ``r'', ``i'' or ``o''; in Pango font names the
908 corresponding values are @code{normal}, @code{italic}, or @code{oblique}.
910 @noindent
911 A `variant' is either @code{normal} or @code{small-caps}.
912 Small caps is a font with the lower case characters replaced by
913 smaller variants of the capital characters.
915 @noindent
916 Weight describes the ``boldness'' of a font.  It corresponds to the third
917 part of an X font name.  It is one of @code{ultra-light}, @code{light},
918 @code{normal}, @code{bold}, @code{ultra-bold}, or @code{heavy}.
920 @noindent
921 Stretch gives the width of the font relative to other designs within a
922 family.  It corresponds to the fifth part of an X font name.  It is one of
923 @code{ultra-condensed}, @code{extra-condensed}, @code{condensed},
924 @code{semi-condensed}, @code{normal}, @code{semi-expanded},
925 @code{expanded}, @code{extra-expanded}, or @code{ultra-expanded}.
927 @noindent
928 @var{size} is a decimal number that describes the font size in points.