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