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