------------------------->  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>  <--------------

-- widget_config.sa:
-- Author: Benedict A. Gomes <gomes@samosa.ICSI.Berkeley.EDU>

abstract class $TK_WIDGET_CFG is
    -- General widget configuration
    str: STR;
end;
-------------------------------------------------------------------
class TK_WIDGET_CFG_INCL is
    -- Used by inclusion with all widget configurations. 
    -- It includes all the standard
    -- widget options - please see the Tk man page on "options"
    -- for the meaning and useful values of each of these options
    -- In any particular widget, the relevant options will be made
    -- public during inclusion
    
    private attr option_table: FMAP{STR,STR};
    private config(attrib_name: STR,val: $STR) is
	option_table := option_table.insert(attrib_name,val.str);
    end;
    private deconfig(attrib_name: STR) is
	-- Remove the attribute from the table
	if option_table.test(attrib_name) then
	    option_table := option_table.delete(attrib_name);
	end;
    end;
    
    create: SAME is return new; end;
    
    std: SAME is return new end;
    
    str: STR is
	res ::= #FSTR(" ");
	loop p ::= option_table.pair!;
	    res := res + "-"+p.t1+" "+p.t2+" ";
	end;
	return res.str;
    end;
    
    private quote(s:STR): STR is return "{"+s+"}" end;
    
    -- Only the applicable functions will be made public in  descendant
    private relief_none is deconfig("relief"); end;
    private relief_raised is config("relief","raised") end;
    private relief_sunken is config("relief","sunken") end;
    private relief_flat is config("relief","flat");  end;
    private relief_ridge is config("relief","ridge");  end;
    private relief_groove is config("relief","groove");  end;
    private relief_none:SAME is relief_none;  return self; end;
    private relief_raised:SAME is relief_raised;  return self; end;
    private relief_sunken:SAME is relief_sunken;  return self; end;
    private relief_flat:SAME is relief_flat;  return self; end;
    private relief_ridge:SAME is relief_ridge;  return self; end;
    private relief_groove:SAME is relief_groove;  return self; end;
    
    -- Text justification
    private justify_left is config("justify","left") end;
    private justify_right is config("justify","right") end;
    private justify_center is config("justify","center") end;
    private justify_left:SAME is justify_left;  return self; end;
    private justify_right:SAME is justify_right;  return self; end;
    private justify_center:SAME is justify_center;  return self; end;
    
    private font(f: STR) is config("font",f) end;
    private font(f: STR): SAME is font(f); return self end;
    
    private height(h: FLT) is config("height",h) end;
    private width(w: FLT) is config("width",w) end;
    private char_height(i: INT) is config("height",i) end;
    private char_width(i: INT) is config("width",i) end;
    private padx(w: FLT) is config("padx",w) end;
    private pady(w: FLT) is config("pady",w) end;
    private borderwidth(f: FLT) is config("borderwidth",f); end;
    private foreground(f: STR) is config("foreground",f); end;
    private background(f: STR) is config("background",f); end;
    private highlightcolor(f: STR) is config("highlightcolor",f); end;
    private highlightbackground(f: STR) is config("highlightbackground",f);end;
    private highlightthickness(f: FLT) is config("highlightthickness",f); end;
    private disabledforeground(f: STR) is config("disabledforeground",f); end;
    private activeforeground(f: STR) is config("activeforeground",f); end;
    private activebackground(f: STR) is config("activebackground",f); end;
    private activeborderwidth(f: FLT) is config("activeborderwidth",f); end;
    private selectforeground(f: STR) is config("selectforeground",f); end;
    private selectbackground(f: STR) is config("selectbackground",f); end;
    private selectborderwidth(f: FLT) is config("selectborderwidth",f); end;
    private insertforeground(f: STR) is config("insertforeground",f); end;
    private insertbackground(f: STR) is config("insertbackground",f); end;
    private insertontime(i: INT) is config("insertontime",i); end;
    private insertofftime(i: INT) is config("insertofftime",i); end;
    private insertwidth(f: FLT) is config("insertwidth",f); end;
    private insertborderwidth(f: FLT) is config("insertborderwidth",f); end;

    private text(f: STR) is config("text",quote(f)); end;
    private wraplength(f: FLT) is config("wraplength",f); end;
    
    private height(f: FLT): SAME is height(f);  return self; end;
    private width(f: FLT): SAME is width(f);  return self; end;
    private char_height(i: INT): SAME is char_height(i); return self end;
    private char_width(i: INT): SAME is char_width(i); return self end;
    private padx(f: FLT): SAME is padx(f);  return self; end;
    private pady(f: FLT): SAME is pady(f);  return self; end;
    private borderwidth(f: FLT):SAME is borderwidth(f); return self; end;
    private foreground(f: STR):SAME is foreground(f); return self; end;
    private background(f: STR): SAME is background(f); return self; end;
    private highlightcolor(f: STR): SAME is
	highlightcolor(f); return self;
    end;
    private highlightbackground(f:STR):SAME is 
	highlightbackground(f); return self; 
    end;
    private highlightthickness(f: FLT): SAME is 
	highlightthickness(f); return self; 
    end;
    private disabledforeground(f: STR): SAME is 
	disabledforeground(f); return self; 
    end;
    private activeforeground(f:STR):SAME is 
	activeforeground(f); return self 
    end;
    private activebackground(f: STR): SAME is 
	activebackground(f); return self; 
    end;
    private activeborderwidth(f: FLT): SAME is 
	activeborderwidth(f); return self; 
    end;
    private selectforeground(f: STR): SAME is 
	selectforeground(f); return self; 
    end;
    private selectbackground(f: STR): SAME is 
	selectbackground(f); return self; 
    end;
    private selectborderwidth(f: FLT): SAME is 
	selectborderwidth(f); return self; 
    end;
    private insertforeground(f: STR): SAME is 
	insertforeground(f); return self; 
    end;
    private insertbackground(f: STR): SAME is 
	insertbackground(f); return self; 
    end;
    private insertwidth(f: FLT): SAME is insertwidth(f); return self;  end;
    private insertborderwidth(f: FLT): SAME is 
	insertborderwidth(f); return self;  
    end;
    private insertontime(i: INT):SAME is insertontime(i); return self end;
    private insertofftime(i: INT):SAME is insertofftime(i); return self end;
    private text(f: STR): SAME is text(f); return self; end;
    private wraplength(f: FLT): SAME is wraplength(f); return self; end;
    
    private disable is config("state","disabled") end;
    private normal is config("state","normal") end;
    private active is config("state","active") end;
    private disable: SAME is disable; return self; end;
    private normal: SAME is normal; return self end;
    private active: SAME is active; return self end;
    
end;
-------------------------------------------------------------------


