Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # Copyright (c) 1995-1996 Sun Microsystems, Inc. |
2 | # See the file "license.terms" for information on usage and redistribution | |
3 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
4 | # | |
5 | # | |
6 | ||
7 | =head1 NAME | |
8 | ||
9 | setPalette, bisque - Modify the Tk color palette | |
10 | ||
11 | =for category Creating and Configuring Widgets | |
12 | ||
13 | =head1 SYNOPSIS | |
14 | ||
15 | I<$widget>-E<gt>B<setPalette>(I<background>) | |
16 | ||
17 | I<$widget>-E<gt>B<setPalette(>I<name>=E<gt>I<value>?,I<name>=E<gt>I<value ...>?) | |
18 | ||
19 | I<$widget>-E<gt>B<bisque> | |
20 | ||
21 | =head1 DESCRIPTION | |
22 | ||
23 | The B<setPalette> method changes the color scheme for Tk. | |
24 | It does this by modifying the colors of existing widgets and by changing | |
25 | the option database so that future widgets will use the new color scheme. | |
26 | If B<setPalette> is invoked with a single argument, the | |
27 | argument is the name of a color to use as the normal background | |
28 | color; B<setPalette> will compute a complete color palette | |
29 | from this background color. | |
30 | Alternatively, the arguments to B<setPalette> may consist of any number | |
31 | of I<name>-I<value> pairs, where the first argument of the pair | |
32 | is the name of an option in the Tk option database and the second | |
33 | argument is the new value to use for that option. The following | |
34 | database names are currently supported: | |
35 | ||
36 | activeBackground foreground selectColor | |
37 | activeForeground highlightBackground selectBackground | |
38 | background highlightColor selectForeground | |
39 | disabledForeground insertBackground troughColor | |
40 | ||
41 | B<setPalette> tries to compute reasonable defaults for any | |
42 | options that you don't specify. You can specify options other | |
43 | than the above ones and Tk will change those options on widgets as | |
44 | well. This feature may be useful if you are using custom widgets with | |
45 | additional color options. | |
46 | ||
47 | Once it has computed the new value to use for each of the color options, | |
48 | B<setPalette> scans the widget hierarchy to modify the options | |
49 | of all existing widgets. For each widget, it checks to see if any | |
50 | of the above options is defined for the widget. If so, and if the | |
51 | option's current value is the default, then the value is changed; if | |
52 | the option has a value other than the default, B<setPalette> | |
53 | will not change it. The default for an option is the one provided by | |
54 | the widget (B<($w-E<gt>configure('option'))[3]>) unless | |
55 | B<setPalette> has been run previously, in which case it is the | |
56 | value specified in the previous invocation of B<setPalette>. | |
57 | ||
58 | After modifying all the widgets in the application, B<setPalette> | |
59 | adds options to the option database to change the defaults for | |
60 | widgets created in the future. The new options are added at | |
61 | priority B<widgetDefault>, so they will be overridden by options | |
62 | from the .Xdefaults file or options specified on the command-line | |
63 | that creates a widget. | |
64 | ||
65 | The method B<bisque> is provided for backward compatibility: | |
66 | it restores the application's colors to the light brown (``bisque'') | |
67 | color scheme used in Tk 3.6 and earlier versions. | |
68 | ||
69 | =head1 BUGS | |
70 | ||
71 | The use of option database names rather than the configure names is | |
72 | understandable given the mechanism (copied from Tcl/Tk), but | |
73 | is potentially confusing. | |
74 | ||
75 | The interpolation of different 'shades' of color used for 3D effects | |
76 | in 'RGB' space can lead to undesirable changes in 'hue'. | |
77 | Interpolation in 'HSV' (as used in B<Tk::ColorEditor>) would be more | |
78 | robust and X11R5's color support probably even more so. | |
79 | ||
80 | =head1 SEE ALSO | |
81 | ||
82 | L<Tk::options|Tk::options> | |
83 | ||
84 | =head1 KEYWORDS | |
85 | ||
86 | bisque, color, palette | |
87 | ||
88 | =cut | |
89 |