# $Id: scale.wgt,v 1.5 2002/03/01 06:46:56 cgavin Exp $

##############################################################################
#
# Visual TCL - A cross-platform application development environment
#
# Copyright (C) 2001 Damon Courtney
#
# Description file for Tk Widget
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

##############################################################################
#

Class		Scale

Icon		@vTcl::widgets::core::scale::getIcon
TreeLabel	@vTcl::widgets::core::scale::getWidgetTreeLabel
InsertCmd	vTcl::widgets::core::scale::insertCmd
DefaultValues   -activebackground -background -foreground \
                -highlightbackground -highlightcolor -troughcolor
ClassOption     -_tooltip

## Special proc for setting up icons on the toolbar.
proc vTcl:Scale:ToolBarSetup {} {
    vTcl:toolbar_add Scale "vertical scale" icon_scale_v.gif "-orient vertical"
    vTcl:toolbar_add Scale "horizontal scale" icon_scale_h.gif \
    	"-orient horizontal"
}

namespace eval vTcl::widgets::core::scale {

    proc getIcon {{w ""}} {
    	if {[lempty $w]} {
	    return [list icon_scale_h.gif icon_scale_v.gif]
	}
	if {[catch {$w cget -orient} orient]} {
	    return "icon_scale.gif"
	}
    	if {$orient == "horizontal"} {
	    return "icon_scale_h.gif"
	}
    	return "icon_scale_v.gif"
    }

    proc getWidgetTreeLabel {w} {
        if {[catch {$w cget -orient} orient]} {
	    return "Scale"
	}
        set var [$w cget -variable]
        if {$var != ""} {
            set var " VAR: $var"
        }
        if {$orient == "horizontal"} {
	    return "Horz Scale$var"
	}
        return "Vert Scale$var"
    }

    proc insertCmd {target} {
        set last [lindex [split $target .] end]
        set last [vTcl:rename $last]

        $target configure -variable "[winfo toplevel $target]::$last"
    }
}
