diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-31 20:52:40 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-31 20:52:40 +0000 |
commit | 75362fbd47cedf4b4906a361a6c54bc4ad8ea5ec (patch) | |
tree | 33e458bfb8dcf84face1eb34acede77b68ff5d8d /ext/tk/lib | |
parent | 0cdf0d99c1e5164c53676a39265ff99120c8a026 (diff) |
* (IMPORTANT BUG FIX) scan of event keywords doesn't work on recent
versions of Tck/Tk
* (bug fix) initialize error of instance variable on TkComposite
* (bug fix) initialize error on encoding-system on MultiTkIp
* (bug fix) trouble on destroying widgets
* (new) add JP and EN version of Ruby/Tk widget demos
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib')
-rw-r--r-- | ext/tk/lib/multi-tk.rb | 43 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 55 |
2 files changed, 73 insertions, 25 deletions
diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb index 99c25f2595..af94204252 100644 --- a/ext/tk/lib/multi-tk.rb +++ b/ext/tk/lib/multi-tk.rb @@ -174,6 +174,8 @@ class MultiTkIp @@DEFAULT_MASTER = self.allocate @@DEFAULT_MASTER.instance_eval{ + @encoding = [] + @tk_windows = {} @tk_table_list = [] @@ -433,6 +435,8 @@ class MultiTkIp fail ArgumentError, "expecting a Hash object for the 2nd argument" end + @encoding = [] + @tk_windows = {} @tk_table_list = [] @@ -792,6 +796,10 @@ end # class methods to delegate to TclTkIp class << MultiTkIp + def method_missing(id, *args) + __getip.send(id, *args) + end + def make_safe __getip.make_safe end @@ -1141,6 +1149,41 @@ class MultiTkIp end end + +# encoding convert +class MultiTkIp + # from tkencoding.rb by [email protected] + alias __eval _eval + alias __invoke _invoke + private :__eval + private :__invoke + + def encoding + @encoding[0] + end + def encoding=(enc) + @encoding[0] = enc + end + + def _eval(cmd) + if @encoding[0] != nil + _fromUTF8(__eval(_toUTF8(cmd, @encoding[0])), @encoding[0]) + else + __eval(cmd) + end + end + + def _invoke(*cmds) + if defined?(@encoding[0]) && @encoding[0] != nil + cmds = cmds.collect{|cmd| _toUTF8(cmd, @encoding[0])} + _fromUTF8(__invoke(*cmds), @encoding[0]) + else + __invoke(*cmds) + end + end +end + + # end of MultiTkIp definition MultiTkIp.freeze # defend against modification diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index b25c5f3a1c..0a9aacaaa5 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -407,7 +407,13 @@ module TkComm if num = EV_KEY.index($1) case EV_TYPE[num] when ?n - arg_cnv << TkComm::number(arg_val[idx]) + begin + val = TkComm::number(arg_val[idx]) + rescue ArgumentError + # ignore --> no convert + val = TkComm::string(arg_val[idx]) + end + arg_cnv << val when ?s arg_cnv << TkComm::string(arg_val[idx]) when ?b @@ -3748,24 +3754,28 @@ class TkWindow<TkObject self end - def _destroy_children + def destroy + super children = [] rexp = /^#{self.path}\.[^.]+$/ TkCore::INTERP.tk_windows.each{|path, obj| - children << obj if path =~ rexp + children << [path, obj] if path =~ rexp } - children.each{|obj| obj.destroy} - end - private :_destroy_children - - def destroy - super - _destroy_children if defined?(@cmdtbl) for id in @cmdtbl uninstall_cmd id end end + + children.each{|path, obj| + if defined?(@cmdtbl) + for id in @cmdtbl + uninstall_cmd id + end + end + TkCore::INTERP.tk_windows.delete(path) + } + tk_call 'destroy', epath uninstall_win end @@ -5020,6 +5030,9 @@ module TkComposite extend Tk def initialize(parent=nil, *args) + @delegates = {} + @delegates['DEFAULT'] = @frame + if parent.kind_of? Hash keys = _symbolkey2str(parent) parent = keys['parent'] @@ -5031,10 +5044,6 @@ module TkComposite @path = @epath = @frame.path initialize_composite(*args) end - unless defined? @delegates - @delegates = {} - @delegates['DEFAULT'] = @frame - end end def epath @@ -5148,21 +5157,17 @@ end # widget_destroy_hook require 'tkvirtevent' -TkBindTag::ALL.bind(TkVirtualEvent.new('Destroy'), proc{|widget| - if widget.respond_to?(:path) - w = widget.path - else - w = widget.to_s - end - if widget.respond_to?(:__destroy_hook__) - begin - if TkCore::INTERP._invoke('winfo','exist',w) == '1' +TkBindTag::ALL.bind(TkVirtualEvent.new('Destroy'), proc{|xpath| + path = xpath[1..-1] + if (widget = TkCore::INTERP.tk_windows[path]) + if widget.respond_to?(:__destroy_hook__) + begin widget.__destroy_hook__ + rescue Exception end - rescue Exception end end - }, '%W') + }, 'x%W') # autoload autoload :TkCanvas, 'tkcanvas' |