summaryrefslogtreecommitdiffstats
path: root/library/palette.tcl
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-01-25 18:21:40 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-01-25 18:21:40 (GMT)
commitee09dd0c7cfc65378fac95dd53067bcd72b390e9 (patch)
tree9b964605296b4f7dd7bd91a2baa6ebd8c0bf21bc /library/palette.tcl
parent2a147ca9e8cdff6b06499b16942dd0a9b8b92228 (diff)
downloadtk-ee09dd0c7cfc65378fac95dd53067bcd72b390e9.zip
tk-ee09dd0c7cfc65378fac95dd53067bcd72b390e9.tar.gz
tk-ee09dd0c7cfc65378fac95dd53067bcd72b390e9.tar.bz2
* library/bgerror.tcl: Updates to use Tcl 8.4 features. [Patch 1237759] * library/button.tcl:
* library/choosedir.tcl: * library/clrpick.tcl: * library/comdlg.tcl: * library/console.tcl: * library/dialog.tcl: * library/entry.tcl: * library/focus.tcl: * library/listbox.tcl: * library/menu.tcl: * library/msgbox.tcl: * library/palette.tcl: * library/panedwindow.tcl: * library/safetk.tcl: * library/scale.tcl: * library/scrlbar.tcl: * library/spinbox.tcl: * library/tearoff.tcl: * library/text.tcl: * library/tk.tcl: * library/tkfbox.tcl: * library/xmfbox.tcl:
Diffstat (limited to 'library/palette.tcl')
-rw-r--r--library/palette.tcl24
1 files changed, 14 insertions, 10 deletions
diff --git a/library/palette.tcl b/library/palette.tcl
index 55834d3..05d59e7 100644
--- a/library/palette.tcl
+++ b/library/palette.tcl
@@ -3,7 +3,7 @@
# This file contains procedures that change the color palette used
# by Tk.
#
-# RCS: @(#) $Id: palette.tcl,v 1.8 2001/11/29 10:54:21 dkf Exp $
+# RCS: @(#) $Id: palette.tcl,v 1.8.2.1 2006/01/25 18:21:41 dgp Exp $
#
# Copyright (c) 1995-1997 Sun Microsystems, Inc.
#
@@ -52,9 +52,13 @@ proc ::tk_setPalette {args} {
set new(foreground) white
}
}
- set fg [winfo rgb . $new(foreground)]
- set darkerBg [format #%02x%02x%02x [expr {(9*[lindex $bg 0])/2560}] \
- [expr {(9*[lindex $bg 1])/2560}] [expr {(9*[lindex $bg 2])/2560}]]
+
+ # To avoir too many lindex...
+ foreach {fg_r fg_g fg_b} [winfo rgb . $new(foreground)] {break}
+ foreach {bg_r bg_g bg_b} $bg {break}
+
+ set darkerBg [format #%02x%02x%02x [expr {(9*$bg_r)/2560}] \
+ [expr {(9*$bg_g)/2560}] [expr {(9*$bg_b)/2560}]]
foreach i {activeForeground insertBackground selectForeground \
highlightColor} {
if {![info exists new($i)]} {
@@ -63,9 +67,9 @@ proc ::tk_setPalette {args} {
}
if {![info exists new(disabledForeground)]} {
set new(disabledForeground) [format #%02x%02x%02x \
- [expr {(3*[lindex $bg 0] + [lindex $fg 0])/1024}] \
- [expr {(3*[lindex $bg 1] + [lindex $fg 1])/1024}] \
- [expr {(3*[lindex $bg 2] + [lindex $fg 2])/1024}]]
+ [expr {(3*$bg_r + $fg_r)/1024}] \
+ [expr {(3*$bg_g + $fg_g)/1024}] \
+ [expr {(3*$bg_b + $fg_b)/1024}]]
}
if {![info exists new(highlightBackground)]} {
set new(highlightBackground) $new(background)
@@ -76,8 +80,8 @@ proc ::tk_setPalette {args} {
# up by 15% or 1/3 of the way to full white, whichever is
# greater.
- foreach i {0 1 2} {
- set light($i) [expr {[lindex $bg $i]/256}]
+ foreach i {0 1 2} color "$bg_r $bg_g $bg_b" {
+ set light($i) [expr {$color/256}]
set inc1 [expr {($light($i)*15)/100}]
set inc2 [expr {(255-$light($i))/3}]
if {$inc1 > $inc2} {
@@ -128,7 +132,7 @@ proc ::tk_setPalette {args} {
eval [tk::RecolorTree . new]
- catch {destroy .___tk_set_palette}
+ destroy .___tk_set_palette
# Change the option database so that future windows will get the
# same colors.