Understanding Theme Pack format
Skin Look And Feel allows developers to bundle a GTK and a KDE theme into one single archive for easy delivery: a themepack.
A themepack is a ZIP file with a specific format: it contains the GTK theme, the KDE theme and a descriptor written in XML. Several themepacks are available at www.javootoo.com under the SkinLF topic.
Structure
SkinLF ships with a default themepack named themepack.zip located in the lib folder. If we unzip this themepack we will get a folder hierarchy like:
/themepack
/gtk
gtkrc
file01.png
...
/icons
Computer.gif
...
/kde
kde.themerc
file01.png
...
skinlf-themepack.xml
Under the gtk folder you find the gtkrc file and the images used by the GTK theme. The gtkrc file describes the GTK theme and specifies which image to use for each graphical widget. It also provides information about colors. Under the kde folder you find the kde.themerc and the images used by the KDE theme. The kde.themerc describes the KDE theme and specifies which image to use. It also provides information about colors. Under the icons folder you find images used by the look and feel. The images are the images used by the FileChooser for folders and drives, the default icons for JTree opened, closed and leaf nodes, the frame icon for InternalFrames. Finally skinlf-themepack.xml is the descriptor for the themepack, it puts together the gtk theme, the kde theme and the icons. Let's have a closer look to this file.
skinlf-themepack.xml
Here is the file that ships with themepack.zip:
<?xml version="1.0"?>
<skinlf-themepack require="1.1">
<property name="JDesktopPane.backgroundEnabled" value="false" />
<property name="PopupMenu.animation" value="true" />
<font name="Global" value="Tahoma,0,11"/>
<icon name="Tree.openIcon" value="icons/TreeOpen.gif"/>
<icon name="Tree.closedIcon" value="icons/TreeClosed.gif"/>
<icon name="Tree.leafIcon" value="icons/Default.gif"/>
<skin>
<skin url="gtk/gtkrc"></skin>
<skin url="kde/kde.themerc"></skin>
</skin>
</skinlf-themepack>
and the DTD that describes this xml along with comments:
<!-- Skin Look And Feel Theme Pack DTD -->
<!--
A themepack is made of properties, icons and skin
-->
<!ELEMENT skinlf-themepack (property*, icon*, skin)>
<!ATTLIST skinlf-themepack
require CDATA #REQUIRED>
<!--
Each property has a name, a value and an optional type.
The type must be a valid Java classname (fully qualified).
Supported types are:
boolean (it is the default if type is not specified)
The value must be true or false
int
The value must be parseable by Integer.parseInt
String
Any string
Color
The value must be parseable by Color.decode(string), for example #FF0FA3
Insets
The value must be {top,left,bottom,right} for example {5,10,5,10}
Dimension
The value must be {x,y} or x,y, for example {300,100}
EmptyBorder
If the type is EmptyBorder, the value defines the insets of the border
for example {5,10,5,10}
LineBorder
If the type is LineBorder, the additional properties rounded,
thickness and color may be filled. Rounded can be true or false,
thickness is an integer and color a Color like #FF0FA3.
-->
<!ELEMENT property>
<!ATTLIST property
name CDATA #REQUIRED
value CDATA #REQUIRED
type CDATA #IMPLIED
rounded CDATA #IMPLIED
thickness CDATA #IMPLIED
color CDATA #IMPLIED>
<!--
Ability to provide custom font for texts.
NAME is the name of the font that needs to be set.
For example: Button.font, TextArea.font, List.font, Table.font, ...
The special "Global" name will set all fonts to the same value.
VALUE is the font to use with the format: fontname,fonttype,fontsize.
Font name is a valid font name for the platform (for example Tahoma)
Font type is one of 0 (PLAIN), 1 (BOLD), 2 (ITALIC), 3 (BOLD + ITALIC)
Font size is an integer.
Example: <font name="Global" value="Tahoma,0,11"/>
-->
<!ELEMENT font>
<!ATTLIST font
name CDATA #REQUIRED
value CDATA #REQUIRED>
<!--
Ability to provide custom icons.
NAME is the name of the icon.
For example: Tree.openIcon, Tree.closedIcon, Tree.leafIcon, InternalFrame.icon,
OptionPane.errorIcon, OptionPane.informationIcon, OptionPane.warningIcon,
OptionPane.questionIcon
VALUE is the name of the file in the themepack. The value is relative to
the xml file.
Example: <icon name="Tree.openIcon" value="icons/TreeOpen.gif"/>
-->
<!ELEMENT icon>
<!ATTLIST icon
name CDATA #REQUIRED
value CDATA #REQUIRED>
<!--
This section defines the gtk and kde themes used.
A skin can contains other skins in such case a CompoundSkin is created
and allows several themes to provide different parts of the all skin.
Most of the time only one gtk and one kde themes will be provided.
Example:
<skin>
<skin url="gtk/gtkrc"></skin>
<skin url="kde/kde.themerc"></skin>
</skin>
-->
<!ELEMENT skin (skin*)>
<!ATTLIST skin
url CDATA #IMPLIED>
As you can see in this DTD, the xml can contain statements to tweak the themepack without putting your hands in the GTK/KDE themes.
Predefined Properties
SkinLF supports some custom properties that can be defined in the xml and will affect the look and feel at runtime:
| JDesktopPane.backgroundEnabled | true or false. If true, the background of JDesktopPane will be painted with a background picture if it is provided by the themepack. This can slow down the performances that's why it can be enabled only on demand. Default is false. |
| PopupMenu.animation | true or false. If true, popup menu will be fade in when appearing. Default is false. |
| ScrollBar.alternateLayout | true or false. If true, the ScrollBar arrows will be groupped together. Default is false. |
| JSplitPane.alternateUI | true or false. If true, the SplitPane divider will be painted using custom graphics. Default is false (the SplitPane divider uses the BasicSplitPaneUI). |
| EnableBorders | true or false. If true, SkinLF will use pixmaps in the themepack to paint the border of text components. Default is false. |
Examples
If you want to change the border of TextAreas to a black LineBorder you can add to skinlf-themepack.xml:
<property name="TextArea.border"
type="LineBorder"
thickness="1"
color="#000000"/>