From f54418b71f57e00d4a50bd86bf7d18b8b5195287 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 27 Nov 2000 09:23:38 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tk.rb | 434 ++++++++++++++++++++++++++++++++++++++++++++----- ext/tk/lib/tkcanvas.rb | 68 +++++++- ext/tk/lib/tkclass.rb | 4 +- ext/tk/lib/tkentry.rb | 123 +++++++++----- ext/tk/lib/tktext.rb | 122 ++++++++++++-- 5 files changed, 651 insertions(+), 100 deletions(-) (limited to 'ext') diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index e5c2c2ece0..a088d5c493 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -485,6 +485,56 @@ module TkCore end end + def after_idle(cmd=Proc.new) + myid = _curr_cmd_id + cmdid = install_cmd(cmd) + tk_call('after','idle',cmdid) + end + + def clock_clicks(ms=nil) + if ms + tk_call('clock','clicks','-milliseconds').to_i + else + tk_call('clock','clicks').to_i + end + end + + def clock_format(clk, form=nil) + if form + tk_call('clock','format',clk,'-format',form).to_i + else + tk_call('clock','format',clk).to_i + end + end + + def clock_formatGMT(clk, form=nil) + if form + tk_call('clock','format',clk,'-format',form,'-gmt','1').to_i + else + tk_call('clock','format',clk,'-gmt','1').to_i + end + end + + def clock_scan(str, base=nil) + if base + tk_call('clock','scan',str,'-base',base).to_i + else + tk_call('clock','scan',str).to_i + end + end + + def clock_scanGMT(str, base=nil) + if base + tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i + else + tk_call('clock','scan',str,'-gmt','1').to_i + end + end + + def clock_seconds + tk_call('clock','seconds').to_i + end + def TkCore.callback(arg) arg = Array(tk_split_list(arg)) _get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg)) @@ -1762,10 +1812,28 @@ module TkPack tk_call 'pack', 'forget' *args end + def info(slave) + ilist = list(tk_call('pack', 'info', slave.epath)) + info = {} + while key = ilist.shift + info[key[1..-1]] = ilist.shift + end + return info + end + def propagate(master, bool=None) - bool(tk_call('pack', 'propagate', master.epath, bool)) + if bool == None + bool(tk_call('pack', 'propagate', master.epath)) + else + tk_call('pack', 'propagate', master.epath, bool) + end + end + + def slaves(master) + list(tk_call('pack', 'slaves', master.epath)) end - module_function :configure, :forget, :propagate + + module_function :configure, :forget, :info, :propagate, :slaves end module TkGrid @@ -1795,6 +1863,32 @@ module TkGrid tk_call "grid", 'rowconfigure', master, index, *hash_kv(args) end + def columnconfiginfo(master, index, slot=nil) + if slot + tk_call 'grid', 'columnconfigure', master, index, "-#{slot}" + else + ilist = list(tk_call('grid', 'columnconfigure', master, index)) + info = {} + while key = ilist.shift + info[key[1..-1]] = ilist.shift + end + info + end + end + + def rowconfiginfo(master, index, slot=nil) + if slot + tk_call 'grid', 'rowconfigure', master, index, "-#{slot}" + else + ilist = list(tk_call('grid', 'rowconfigure', master, index)) + info = {} + while key = ilist.shift + info[key[1..-1]] = ilist.shift + end + info + end + end + def add(widget, *args) configure(widget, *args) end @@ -1812,7 +1906,11 @@ module TkGrid end def propagate(master, bool=None) - bool(tk_call('grid', 'propagate', master.epath, bool)) + if bool == None + bool(tk_call('grid', 'propagate', master.epath)) + else + tk_call('grid', 'propagate', master.epath, bool) + end end def remove(*args) @@ -1823,13 +1921,63 @@ module TkGrid tk_call 'grid', 'size', master end - def slaves(args) - list(tk_call('grid', 'slaves', *hash_kv(args))) + def slaves(master, args) + list(tk_call('grid', 'slaves', master, *hash_kv(args))) end module_function :bbox, :forget, :propagate, :info module_function :remove, :size, :slaves, :location module_function :configure, :columnconfigure, :rowconfigure + module_function :columnconfiginfo, :rowconfiginfo +end + +module TkPlace + include Tk + extend Tk + + def configure(win, slot, value=None) + if slot.kind_of? Hash + tk_call 'place', 'configure', win.epath, *hash_kv(slot) + else + tk_call 'place', 'configure', win.epath, "-#{slot}", value + end + end + + def configinfo(win, slot = nil) + # for >= Tk8.4a2 ? + if slot + conf = tk_split_list(tk_call('place', 'configure', + win.epath, "-#{slot}") ) + conf[0] = conf[0][1..-1] + conf + else + tk_split_simplelist(tk_call('place', 'configure', + win.epath)).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[0] = conf[0][1..-1] + conf + } + end + end + + def forget(win) + tk_call 'place', 'forget', win + end + + def info(win) + ilist = list(tk_call('place', 'info', win.epath)) + info = {} + while key = ilist.shift + info[key[1..-1]] = ilist.shift + end + return info + end + + def slaves(master) + list(tk_call('place', 'slaves', master.epath)) + end + + module_function :configure, :configinfo, :forget, :info, :slaves end module TkOption @@ -1993,7 +2141,12 @@ class TkObject= Tk8.4a2 ? + if slot + conf = tk_split_list(tk_call('place', 'configure', epath, "-#{slot}") ) + conf[0] = conf[0][1..-1] + conf + else + tk_split_simplelist(tk_call('place', + 'configure', epath)).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[0] = conf[0][1..-1] + conf + } + end end - def pack_info() - ilist = list(tk_call('pack', 'info', epath)) + def place_info() + ilist = list(tk_call('place', 'info', epath)) info = {} while key = ilist.shift info[key[1..-1]] = ilist.shift @@ -2160,7 +2451,9 @@ class TkWindow