Previous: GTK Names in Emacs, Up: GTK resources
In a GTK style you specify the appearance widgets shall have. You can specify foreground and background color, background pixmap and font. The edit widget (where you edit the text) in Emacs is a GTK widget, but trying to specify a style for the edit widget will have no effect. This is so that Emacs compiled for GTK is compatible with Emacs compiled for other X toolkits. The settings for foreground, background and font for the edit widget is taken from the X resources; see Resources. Here is an example of two style declarations, ‘default’ and ‘ruler’:
pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps" style "default" { font_name = "helvetica 12" bg[NORMAL] = { 0.83, 0.80, 0.73 } bg[SELECTED] = { 0.0, 0.55, 0.55 } bg[INSENSITIVE] = { 0.77, 0.77, 0.66 } bg[ACTIVE] = { 0.0, 0.55, 0.55 } bg[PRELIGHT] = { 0.0, 0.55, 0.55 } fg[NORMAL] = "black" fg[SELECTED] = { 0.9, 0.9, 0.9 } fg[ACTIVE] = "black" fg[PRELIGHT] = { 0.9, 0.9, 0.9 } base[INSENSITIVE] = "#777766" text[INSENSITIVE] = { 0.60, 0.65, 0.57 } bg_pixmap[NORMAL] = "background.xpm" bg_pixmap[INSENSITIVE] = "background.xpm" bg_pixmap[ACTIVE] = "background.xpm" bg_pixmap[PRELIGHT] = "<none>" } style "ruler" = "default" { font_name = "helvetica 8" }
The style ‘ruler’ inherits from ‘default’. This way you can build on existing styles. The syntax for fonts and colors is described below.
As this example shows, it is possible to specify several values for foreground and background depending on the widget's state. The possible states are:
NORMAL
ACTIVE
bg[ACTIVE] = "red"
sets the scroll bar trough to red. Buttons that have been pressed but
not released yet (“armed”) are in this state.
PRELIGHT
SELECTED
INSENSITIVE
fg[INSENSITIVE] = "yellow"
.
Here are the things that can go in a style declaration:
bg[
state] =
colorbg
; it uses base
instead.
base[
state] =
colorbg_pixmap[
state] = "
pixmap"
You can't specify the file by its absolute file name. GTK looks for
the pixmap file in directories specified in pixmap_path
.
pixmap_path
is a colon-separated list of directories within
double quotes, specified at the top level in a gtkrc file
(i.e. not inside a style definition; see example above):
pixmap_path "/usr/share/pixmaps:/usr/include/X11/pixmaps"
fg[
state] =
colortext
.
text[
state] =
colorfont_name = "
font"
There are three ways to specify a color: by name, in hexadecimal form, and with an RGB triplet.
A color name is written within double quotes, for example "red"
.
Hexadecimal form is the same as in X:
#
rrrrggggbbbb, where all three color specs
must have the same number of hex digits (1, 2, 3 or 4).
An RGB triplet looks like {
r,
g,
b }
,
where r, g and b are either integers in the range
0-65535 or floats in the range 0.0-1.0.
Pango font names have the form “family-list style-options size”. family-list is a comma separated list of font families optionally terminated by a comma. This way you can specify several families and the first one found will be used. family corresponds to the second part in an X font name, for example in
-adobe-times-medium-r-normal--12-120-75-75-p-64-iso10646-1
the family name is “times”.
style-options is a whitespace separated list of words where each word
is a style, variant, weight, or stretch. The default value for all of
these is normal
.
A `style' corresponds to the fourth part of an X font name. In X font
names it is the character ‘r’, ‘i’ or ‘o’; in Pango
font names the corresponding values are normal
, italic
,
or oblique
.
A `variant' is either normal
or small-caps
.
Small caps is a font with the lower case characters replaced by
smaller variants of the capital characters.
Weight describes the “boldness” of a font. It corresponds to the third
part of an X font name. It is one of ultra-light
, light
,
normal
, bold
, ultra-bold
, or heavy
.
Stretch gives the width of the font relative to other designs within a
family. It corresponds to the fifth part of an X font name. It is one of
ultra-condensed
, extra-condensed
, condensed
,
semi-condensed
, normal
, semi-expanded
,
expanded
, extra-expanded
, or ultra-expanded
.
size is a decimal number that describes the font size in points.