Back to main page

5. Using themes

Creating dialogs requires a lot of information for the single elements. How big is a font? which font sould be used? Which color should the background have, etc? Adding this information to each single widget result in lots of redundant information. If the same look should be applied to several widgets, the problem of changing each and every widget's properties gets annoying. To follow this part, have a look at the tutorials/03 folder.

5.1. Theme classes

To face the problem of recurring properties disko makes use of classes. That are basically are sets of widget properties bound to a name. These defintions are stored in file theme.xml in the theme folder themes/<cthemename>/. The default look of widgets could be changed there as well. In this example the theme is stored in themes/default/.

Example 3. theme.xml contents

    <mmstheme name="default">
        <class
            name = "myLabelClass"
            type = "label"
            font.name = "DejaVuSansMono.ttf"
            font.size = "18"
            alignment = "center"
            color	  =	"#999999ff"
            selcolor  = "#ccccccff"/>
        <class
            name = "default_rootwindow"
            type = "rootwindow"

            alignment = "center"
            w         = "100%"
            h         = "100%"
            bgcolor     = "#000000ff"
            opacity     = "255"
        />
    </mmstheme>
This puts the font settings for the label class myLabelClass and the default behaviour for the root window together. The label class could now be applied to the dialog.xml

The theme.xml in the turial's directory is filled with more properties to try around with.

The resulting window should look like this, similar to the last example.

5.2. dialog files using themes

The dialog file now looks far more friendly, as the long property lists have vanished.

    <mmsdialog>
        <rootwindow>
            <label class="myLabelClass" name="label1"/>
        </rootwindow>
    </mmsdialog>