# palette.tcl --
#
# This file contains procedures that change the color palette used
# by Tk.
#
# SCCS: @(#) palette.tcl 1.4 96/12/04 10:00:17
#
# Copyright (c) 1995 Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# tk_setPalette --
# Changes the default color scheme for a Tk application by setting
# default colors in the option database and by modifying all of the
# color options for existing widgets that have the default value.
#
# Arguments:
# The arguments consist of either a single color name, which
# will be used as the new background color (all other colors will
# be computed from this) or an even number of values consisting of
# option names and values. The name for an option is the one used
# for the option database, such as activeForeground, not -activeforeground.
proc tk_setPalette args {
global tkPalette
# Create an array that has the complete new palette. If some colors
# aren't specified, compute them from other colors that are specified.
} else {
}
error "must specify a background color"
}
}
set darkerBg [format #%02x%02x%02x [expr (9*[lindex $bg 0])/2560] \
}
}
}
}
# Pick a default active background that islighter than the
# normal background. To do this, round each color component
# up by 15% or 1/3 of the way to full white, whichever is
# greater.
} else {
}
}
}
}
}
}
}
# Walk the widget hierarchy, recoloring all existing windows.
# The option database must be set according to what we do here,
# but it breaks things if we set things in the database while
# we are changing colors...so, tkRecolorTree now returns the
# option database changes that need to be made, and they
# need to be evalled here to take effect.
eval [tkRecolorTree . new]
# Save the options in the global variable tkPalette, for use the
# next time we change the options.
}
# tkRecolorTree --
# This procedure changes the colors in a window and all of its
# descendants, according to information provided by the colors
# argument. This looks at the defaults provided by the option
# database, if it exists, and if not, then it looks at the default
# value of the widget itself.
#
# Arguments:
# w - The name of a window. This window and all its
# descendants are recolored.
# colors - The name of an array variable in the caller,
# which contains color information. Each element
# is named after a widget configuration option, and
# each value is the value for that option.
global tkPalette
upvar $colors c
set result {}
# if the option database has a preference for this
# dbOption, then use it, otherwise use the defaults
# for the widget.
if {[string match {} $defaultcolor]} {
} else {
}
# Change the option database so that future windows will get the
# same colors.
append result ";\noption add *[winfo class $w].$dbOption $c($dbOption)"
}
}
}
append result ";\n[tkRecolorTree $child c]"
}
return $result
}
# tkDarken --
# Given a color name, computes a new color value that darkens (or
# brightens) the given color by a given percent.
#
# Arguments:
# color - Name of starting color.
# perecent - Integer telling how much to brighten or darken as a
# percent: 50 means darken by 50%, 110 means brighten
# by 10%.
}
}
}
format #%02x%02x%02x $red $green $blue
}
# tk_bisque --
# Reset the Tk color palette to the old "bisque" colors.
#
# Arguments:
# None.
proc tk_bisque {} {
tk_setPalette activeBackground #e6ceb1 activeForeground black \
background #ffe4c4 disabledForeground #b0b0b0 foreground black \
highlightBackground #ffe4c4 highlightColor black \
selectBackground #e6ceb1 selectForeground black \
troughColor #cdb79e
}