# $Id: checkbutton.wgt,v 1.7 2003/04/07 00:21:47 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		Checkbutton
Lib		core

Icon		icon_checkbutton.gif
InsertCmd       vTcl::widgets::core::checkbutton::insertCmd
DefaultOptions	-text check
DefaultValues   -activebackground -activeforeground -activeborderwidth \
                -background -foreground -highlightbackground -highlightcolor
DoubleClickCmd	vTcl:set_command
TreeLabel	@vTcl::widgets::core::checkbutton::getWidgetTreeLabel
ClassOption     -_tooltip

Function        "Set Variable..." vTcl::widgets::core::checkbutton::setVariable

namespace eval vTcl::widgets::core::checkbutton {

    proc setVariable {} {
    	global vTcl
    	vTcl:core:set_option $vTcl(w,widget)\
                         -variable \
                         "Variable for $vTcl(w,widget)"
    }

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

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

    proc getWidgetTreeLabel {target} {
	set ttt1 [$target cget -text]
	set ttt2 [$target cget -variable]
	set ttt3 [$target cget -onvalue]
        set ttt4 [$target cget -offvalue]

	if {$ttt2 == ""} {
	    return "CB: $ttt1"
	} else {
	    return "CB: $ttt1 var=$ttt2\(on=$ttt3,off=$ttt4\)"
	}
    }
}

