Colour properties should be customizable, similar to shape properties. These properties belong into the Option Database.

Colours are the most prominent visual aspects of a Graphical User Interface. A light on dark design is called negative and dark on light is referred to as a positive design. In most environments (real world) a positive design is preferable over a negative one. This however depends on the user’s visual ability. If the computer owner has an over-sensitive eyesight, then a negative design is a must. Similar in dark environments, such as at night, a negative design is a better solution than a positive one.

New LCD-Monitors are distributed with a maladjusted back light. Often, the back light is set to the maximum value and cannot be downturned to an acceptable level (100 candela). Here, a negative design may provide the only means for reaching a non-harmful work environment.

There is a predefined colour set –Colors– available from the »Option DB« preference page, which lists almost every Tk colour property. The colour properties are included in Jeszra’s default resource set.

Example 7.6. Generated Option Database Entries

namespace eval top_1 {
    # Colour properties:    
    option add *Top_1$w(0).highlightBackground \
    option add *Top_1$w(0).highlightColor \
    option add *Top_1$w(1).activeBackground \
    option add *Top_1$w(1).activeForeground \
    option add *Top_1$w(1).selectColor {orange};
    option add *Top_1$w(2).activeBackground \
    option add *Top_1$w(2).activeForeground \
    option add *Top_1$w(2).selectColor {orange};
    # Font and text properties:
    option add *Top_1$w(1).font \
       {{Bitstream vera sans} 12};
    option add *Top_1$w(2).font \
       {{Bitstream vera sans} 12};
    option add *Top_1$w(4).font \
       {{Bitstream vera sans} 12};
    # Special properties for menu entries:
    option add *Top_1$w(1).menu1accelerator {};
    option add *Top_1$w(1).menu1label {File};
    option add *Top_1$w(1).menu2accelerator {};
    option add *Top_1$w(1).menu2label {Edit};

Example 7.6, “Generated Option Database Entries” shows Option Database entries generated for a template »top_1«. The template »top_1« contains five windows. The internal windows are accessible through the template associated array: »w«, where every window is addressed through its index (the index is immutable). The properties are registered on the template class name »Top_1«.

The colour values in Example 7.6, “Generated Option Database Entries” originate from my ~/.Xresources configuration. These values are different from Tk’s default values and thus included in the code generation.

Example 7.7. Excerpt from .Xresources

*borderColor: gray57
*background: darkseagreen4
*foreground: white

*selectColor: orange
*highlightColor: orange
*highlightBackground: darkseagreen4
*activeBackground: seagreen1
*activeForeground: black
*selectForeground: black
*selectBackground: orange3

.Xresources or .Xdefaults X Resource Database are automatically used under the X Window System.

The best approach is to add colour names to the list of ignored properties; albeit wrong Option Database entries are harmless. Option Database entries have no negative effect on the performance of the generated code. Whereas any command line property costs performance. Before Tk 8.5, using the command line could double the evaluation time.