------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 1995 by International Computer Science Institute            --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  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 Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

-- Author: Holger Klawitter <holger@icsi.berkeley.edu>

class TK_RADIO_CFG
is
    include TK_BUTTON_CFG;
    
    variable(v:TK_VAR) 
    -- Variable associated to this widget. Changes to the variable
    -- cause the widget to update and user actions on this widget
    -- may change the value of the variable.
    is config("variable",v.str); end;
    
    val(s:STR)
    -- Value for the variable when the radiobutton is selected.
    is config("value",s); end;
    
    variable(v:TK_VAR): SAME is variable(v); return self; end;    
    val(s:STR): SAME is val(s); return self; end;

    std: SAME is return new end;
    
end; -- class TK_RADIO_CFG
----------------------------------------------------------------------
class TK_RADIO < $TK_WIDGET
-- Wiget representing radio buttons.
is
    include TK_WIDGET_INCL{TK_RADIO_CFG};
    
    const tk_widget_type: STR := "radiobutton";
    private default_init(c:TK_RADIO_CFG) is
	eval(widget_name+" configure -command ",
	     quote("sather "+path_name+" 0"));
    end;
    private default_config: TK_RADIO_CFG is return TK_RADIO_CFG::std end;
    
    invoke is eval(actual_widget_name,"invoke") end;
    flash is eval(actual_widget_name,"flash") end;
    
    select
    -- Selecing a radio button delselects all other radio buttons
    -- associated to the same variable.
    is eval(actual_widget_name,"select") end;
    
    deselect is eval(actual_widget_name,"deselect") end;

    attr command: ROUT;
    command(c:ROUT): SAME is command(c); return self; end;
    
    act_on(id:INT,args:ARRAY{STR})
    is
	if ~void(command) then command.call; end
    end;
    
end; -- class TK_RADIO
