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