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