diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-06 15:06:00 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-06 15:06:00 +0000 |
commit | 1d3d27b42d1371ba6242ec217ca803f107ceb9eb (patch) | |
tree | 8d7e184fd63610124717df8dec31e719901965ad /ext/tk | |
parent | 94df732f8b69356626130e0ec8b2dbc9340082ef (diff) |
forgot some checkins.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk')
-rw-r--r-- | ext/tk/lib/tk.rb | 43 | ||||
-rw-r--r-- | ext/tk/lib/tkvirtevent.rb | 33 |
2 files changed, 49 insertions, 27 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 873c823910..47be8fd974 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -1,7 +1,7 @@ # -# tk.rb - Tk interface modue using tcltklib +# tk.rb - Tk interface module using tcltklib # $Date$ -# by Yukihiro Matsumoto <matz@netlab.co.jp> +# by Yukihiro Matsumoto <matz@netlab.jp> # use Shigehiro's tcltklib require "tcltklib" @@ -351,7 +351,7 @@ module TkComm end if context.kind_of? Array context = context.collect{|ev| - if context.kind_of? TkVirtualEvent + if ev.kind_of? TkVirtualEvent ev.path else ev @@ -397,8 +397,18 @@ module TkComm end } else - tk_split_list(tk_call(*what)).collect{|seq| - seq[1..-2].gsub(/></,',') + tk_split_simplelist(tk_call(*what)).collect!{|seq| + l = seq.scan(/<*[^<>]+>*/).collect!{|subseq| + case (subseq) + when /^<<[^<>]+>>$/ + TkVirtualEvent.getobj(subseq[1..-2]) + when /^<[^<>]+>$/ + subseq[1..-2] + else + subseq.split('') + end + }.flatten + (l.size == 1) ? l[0] : l } end end @@ -1046,6 +1056,12 @@ class TkBindTag BTagID_TBL[id]? BTagID_TBL[id]: id end + ALL = self.new + ALL.instance_eval { + @id = 'all' + BTagID_TBL[@id] = self + } + def initialize(*args) @id = Tk_BINDTAG_ID[0] Tk_BINDTAG_ID[0] = Tk_BINDTAG_ID[0].succ @@ -1063,20 +1079,11 @@ class TkBindTag end class TkBindTagAll<TkBindTag - BindTagALL = [] def TkBindTagAll.new(*args) - if BindTagALL[0] - BindTagALL[0].bind(*args) if args != [] - else - new = super() - BindTagALL[0] = new - end - BindTagALL[0] - end + $stderr.puts "Warning: TkBindTagALL is obsolete. Use TkBindTag::ALL\n" - def initialize(*args) - @id = 'all' - BindTagALL[0].bind(*args) if args != [] + TkBindTag::ALL.bind(*args) if args != [] + TkBindTag::ALL end end @@ -2575,7 +2582,7 @@ class TkWindow<TkObject def bindtags(taglist=nil) if taglist - fail unless taglist.kind_of? Array + fail ArgumentError unless taglist.kind_of? Array tk_call('bindtags', path, taglist) else list(tk_call('bindtags', path)).collect{|tag| diff --git a/ext/tk/lib/tkvirtevent.rb b/ext/tk/lib/tkvirtevent.rb index b31b99062f..d3721e362e 100644 --- a/ext/tk/lib/tkvirtevent.rb +++ b/ext/tk/lib/tkvirtevent.rb @@ -7,12 +7,27 @@ require 'tk' class TkVirtualEvent<TkObject extend Tk - TkVirturlEventID = [0] - TkVirturlEventTBL = {} + TkVirtualEventID = [0] + TkVirtualEventTBL = {} + + class PreDefVirtEvent<self + def initialize(event) + @path = @id = event + TkVirtualEvent::TkVirtualEventTBL[@id] = self + end + end def TkVirtualEvent.getobj(event) - obj = TkVirturlEventTBL[event] - obj ? obj : event + obj = TkVirtualEventTBL[event] + if obj + obj + else + if tk_call('event', 'info').index("<#{event}>") + PreDefVirtEvent.new(event) + else + fail ArgumentError, "undefined virtual event '<#{event}>'" + end + end end def TkVirtualEvent.info @@ -22,8 +37,8 @@ class TkVirtualEvent<TkObject end def initialize(*sequences) - @path = @id = format("<VirtEvent%.4d>", TkVirturlEventID[0]) - TkVirturlEventID[0] += 1 + @path = @id = format("<VirtEvent%.4d>", TkVirtualEventID[0]) + TkVirtualEventID[0] += 1 add(*sequences) end @@ -31,7 +46,7 @@ class TkVirtualEvent<TkObject if sequences != [] tk_call('event', 'add', "<#{@id}>", *(sequences.collect{|seq| "<#{tk_event_sequence(seq)}>"}) ) - TkVirturlEventTBL[@id] = self + TkVirtualEventTBL[@id] = self end self end @@ -39,11 +54,11 @@ class TkVirtualEvent<TkObject def delete(*sequences) if sequences == [] tk_call('event', 'delete', "<#{@id}>") - TkVirturlEventTBL[@id] = nil + TkVirtualEventTBL[@id] = nil else tk_call('event', 'delete', "<#{@id}>", *(sequences.collect{|seq| "<#{tk_event_sequence(seq)}>"}) ) - TkVirturlEventTBL[@id] = nil if info == [] + TkVirtualEventTBL[@id] = nil if info == [] end self end |