Introduction to SDL/Swing Styles
SDL/Swing has a rich styling framework similar to CSS. All style information is contained within three files. When the framework starts up it loads resources/styles/paints.sdl, resources/styles/style_parts.sdl and then resources/styles/styles.sdl. All of these are optional.
Paints
The paints file is used to describe paints of type
color, pattern, and gradient. These are read in using
the PaintBox class. All patterns should be placed in
resources/patterns. The order is important (colors
then patterns followed by gradients) because gradients
reference colors by name.
Gradients are defined by listed a start color / pattern,
an end color / pattern, a mid point from 0 to 1 (defaults
to .5), and a direction. Directions can be one of:
The default is "horizontal"
Notes:
1. The colors "white" and "black" are implicitly available.
2. In the color variants "darkest", "very_dark", "dark",
"light", "very light", "lightest" and "transparent"
can be used in combination with names declared in the
colors block like so:
Example:
Style Parts
The style parts file contains fonts and borders. You can use paints
declared in the paints.sdl file by name.
Fonts
Fonts are use the format
identifier name size=(int) bold=(on|off) italic=(on|off)
Example
Borders
Borders use the format
Each class has its own attributes. All attributes are optional except:
A) the "color" attribute of line and matte border
B) the "inner" and "outer" attributes of compound border (these can also be defined as
children of the compound border tag)
C) the "normal" and "pressed" attributes of button border (these can also be defined as
children of the button border tag along with an optional "rollover" border)
Attributes for each class
Empty borders and Matte borders also have shorthand versions. They can simply be expressed as a string like so:
More Examples
Styles
Styles can be applied to a component with the "styles" pseudo property
within an SDL/Swing component definition like so:
In the styles.sdl file the "garish" style is defined like so:
Multiple styles can be applied to a single component like so:
In addition to styles specific to particular component types, generic styles can be defined under the tag "any" like so:
Example styles.sdl