# $Id: radiobox.wgt,v 1.8 2002/03/15 06:27:55 cgavin Exp $

##############################################################################
#
# Visual TCL - A cross-platform application development environment
#
# Copyright (C) 2001 Christian Gavin
#
# Description file for [Incr Widgets]
#
# 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		Radiobox
Lib		itcl

CreateCmd	::iwidgets::radiobox
Icon		icon_radiobox.gif
DumpChildren	no
MegaWidget	yes
DumpCmd		vTcl::widgets::iwidgets::radiobox::dumpCmd
InsertCmd	vTcl::widgets::iwidgets::radiobox::insertCmd
TagsCmd         vTcl:lib_itcl:tagscmd
DefaultOptions	-labeltext "Radiobox"
DefaultValues   -background -font
ClassOption     -_itcl_radiocheckboxes
GetImagesCmd    vTcl::widgets::iwidgets::boxes::getImagesCmd
GetFontsCmd     vTcl::widgets::iwidgets::boxes::getFontsCmd

Function    "Edit..."   vTcl::widgets::iwidgets::radiobox::editCmd

namespace eval vTcl::widgets::iwidgets::radiobox {

    proc editCmd {} {
        vTcl::itemEdit::edit $::vTcl(w,widget) vTcl::widgets::iwidgets::boxes::edit
    }

    proc dumpCmd {target basename} {
        global vTcl
        set result [vTcl:dump_widget_opt $target $basename]
        set last -1
        catch {set last [$target index end]}

        for {set i 0} {$i <= $last} {incr i} {
            set conf [$target buttonconfigure $i]
            set pairs [vTcl:get_subopts_special $conf $target]

            append result "$vTcl(tab)$basename add rad$i \\\n"
            append result "[vTcl:clean_pairs $pairs]\n"
        }

        return $result
    }

    proc insertCmd {target} {
        $target add radio1   -text {Radio 1}
        $target add radio2   -text {Radio 2}
        $target add radio3   -text {Radio 3}

        vTcl::widgets::iwidgets::boxes::setDefaultValues $target \
            {-activebackground -activeforeground
             -background -disabledforeground
             -font -foreground -highlightbackground
             -highlightcolor -highlightthickness -selectcolor}
    }
}

