diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-06-11 10:03:21 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-06-11 10:03:21 +0000 |
commit | 1bc6f594d3de8dbfb5c165835eaec99bd49327c8 (patch) | |
tree | d535a84c63a5cf779aa1ae83f89ed64f22040471 /lib/tk.rb | |
parent | 3f5b1ec9cb657375a0c467ac70fdd6fbdc97f018 (diff) |
1.1b9_25
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tk.rb')
-rw-r--r-- | lib/tk.rb | 96 |
1 files changed, 94 insertions, 2 deletions
@@ -26,6 +26,9 @@ module TkComm private :error_at def tk_tcl2ruby(val) + if val =~ /^rb_out (c\d+)/ + return Tk_CMDTBL[$1] + end if val.include? ?\s return val.split.collect{|v| tk_tcl2ruby(v)} end @@ -34,8 +37,6 @@ module TkComm val.to_i when /^\./ Tk_WINDOWS[val] - when /^rb_out (c\d+)/ - Tk_CMDTBL[$1] when / / val.split.collect{|elt| tk_tcl2ruby(elt) @@ -134,6 +135,7 @@ module TkComm def _next_cmd_id id = _curr_cmd_id Tk_IDs[0] += 1 + id end def install_cmd(cmd) return '' if cmd == '' @@ -237,6 +239,10 @@ module TkComm TkPack.configure *args end + def grid(*args) + TkGrid.configure *args + end + def after(ms, cmd=Proc.new) myid = _curr_cmd_id tk_call 'after', ms, @@ -786,6 +792,70 @@ module TkPack module_function :configure, :forget, :propagate end +module TkGrid + include Tk + extend Tk + + def bbox(*args) + list(tk_call('grid', 'bbox', *args)) + end + + def configure(widget, *args) + if args[-1].kind_of?(Hash) + keys = args.pop + end + wins = [widget.path] + for i in args + wins.push i.epath + end + tk_call "grid", 'configure', *(wins+hash_kv(keys)) + end + + def columnconfigure(master, index, *args) + tk_call "grid", 'columnconfigure', master, index, *hash_kv(keys) + end + + def rowconfigure(master, index, *args) + tk_call "grid", 'rowconfigure', master, index, *hash_kv(keys) + end + + def add(widget, *args) + configure(widget, *args) + end + + def forget(*args) + tk_call 'grid', 'forget', *args + end + + def info(slave) + list(tk_call('grid', 'info', slave)) + end + + def location(master, x, y) + list(tk_call('grid', 'location', master, x, y)) + end + + def propagate(master, bool=None) + bool(tk_call('grid', 'propagate', master.epath, bool)) + end + + def remove(*args) + tk_call 'grid', 'remove', *args + end + + def size(master) + tk_call 'grid', 'size', master + end + + def slaves(*args) + list(tk_call('grid', 'slaves', *hash_kv(args))) + end + + module_function :bbox, :forget, :propagate, :info + module_function :remove, :size, :slaves, :location + module_function :configure, :columnconfigure, :rowconfigure +end + module TkOption include Tk extend Tk @@ -833,10 +903,18 @@ class TkObject<TkKernel end end + def [](id) + cget id + end + def []=(id, val) configure id, val end + def cget(slot) + tk_tcl2ruby tk_call path, 'cget', "-#{slot}" + end + def configure(slot, value) if value == FALSE value = "0" @@ -891,6 +969,16 @@ class TkWindow<TkObject self end + def grid(keys = nil) + tk_call 'grid', epath, *hash_kv(keys) + self + end + + def ungrid(keys = nil) + tk_call 'grid', 'forget', epath + self + end + def place(keys = nil) tk_call 'place', epath, *hash_kv(keys) self @@ -1131,6 +1219,10 @@ class TkScrollbar<TkWindow end class TkTextWin<TkWindow + def create_self + raise TypeError, "TkTextWin is abstract class" + end + def bbox(index) tk_send 'bbox', index end |