This is not necessarily the current version of this TIP.
| TIP: | 154 |
| Title: | Add Named Colors to Tk |
| Version: | $Revision: 1.3 $ |
| Author: | Damon Courtney <damon at unreality dot com> |
| State: | Draft |
| Type: | Project |
| Tcl-Version: | 8.5 |
| Vote: | Pending |
| Created: | Wednesday, 03 September 2003 |
This TIP proposes the addition of a color command at the Tk level to allow developers to create named colors as they can already do with both fonts and images.
Named fonts and images go a long way toward making Tk able to modify a lot of options on a global scale simply by adjusting a single item. Tk already simulates some version of named colors on Windows with the use of values like 'SystemButtonFace' and 'SystemWindowFrame'. These color names map to values pre-defined in Windows. On UNIX, we have to kind of fake these things around.
With the addition of named colors, we can simply define default colors in UNIX that correspond to existing named colors on Windows. So, we could create 'SystemButtonFace' as a named color on UNIX, and any Windows program using those color names would port to UNIX without a change.
I propose the introduction of a new command, 'color':
color <option> ?arg ..?
color create <colorName> ?option ..? Creates a new named color.
-color <color> -dark1 <color> -light1 <color>
color cget <colorName> <option> Standard function to get an option value.
color configure <colorName> ?option ..? Standard function to configure a color's values.
color exists <colorName> Determine if a named color exists.
color names ?pattern? Returns a list of all named colors, including ones created by Tk.
color delete <colorName> Deletes a named color.
The -color option specifies any acceptable color in Tk as the color to use. The -light1 and -dark1 options specify the border shadings to use for this color when it is used as a border. They are named with a 1 because I think in the future we will end up with more levels of shading. Windows already has two levels, we just ignore the second one.
Beyond the color command, we need to implement a default set of standard colors that will exist across all platforms. As proposed by some, I think these should be named Tk*. The current list (reflected in the Windows color list) would be:
TkButtonFace TkButtonText TkDisabledText TkHighlight TkHighlightText TkMenu TkMenuText TkScrollbar TkWindow TkWindowFrame TkWindowText
If there are others, I'm not sure what they are. This list can easily be expanded over time as most of them will be created at the Tcl-level.
As part of this TIP, the core widgets should also be modified to use the new Tk* named colors as their defaults for all platforms. The named colors will still be created from system defaults on each system. The UNIX colors will most likely come from whatever comes out of TIP #172.
This document has been placed in the public domain.
This is not necessarily the current version of this TIP.