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