# File tk/lib/tkextlib/blt/tree.rb, line 374 def self.id2obj(tree, id) tpath = tree.path NotifyID_TBL.mutex.synchronize{ if NotifyID_TBL[tpath] if NotifyID_TBL[tpath][id] NotifyID_TBL[tpath][id] else (obj = self.allocate).instance_eval{ @parent = @tree = tree @tpath = @parent.path @path = @id = id NotifyID_TBL[@tpath] ||= {} NotifyID_TBL[@tpath][@id] = self } obj end else return id end } end
# File tk/lib/tkextlib/blt/tree.rb, line 396 def self.new(tree, *args, &b) NotifyID_TBL.mutex.synchronize{ if tree.kind_of?(Array) # not create tpath = tree[0].path NotifyID_TBL[tpath] ||= {} unless (obj = NotifyID_TBL[tpath][tree[1]]) (NotifyID_TBL[tpath][tree[1]] = obj = self.allocate).instance_eval{ @parent = @tree = tree[0] @tpath = @parent.path @path = @id = tree[1] } end return obj end (obj = self.allocate).instance_eval{ initialize(tree, *args, &b) NotifyID_TBL[@tpath] ||= {} NotifyID_TBL[@tpath][@id] = self } return obj } end
# File tk/lib/tkextlib/blt/tree.rb, line 422 def initialize(tree, *args, &b) @parent = @tree = tree @tpath = @parent.path # if args[0].kind_of?(Proc) || args[0].kind_of?(Method) if TkComm._callback_entry?(args[0]) cmd = args.shift # elsif args[-1].kind_of?(Proc) || args[-1].kind_of?(Method) elsif TkComm._callback_entry?(args[-1]) cmd = args.pop elsif b cmd = Proc.new(&b) else fail ArgumentError, "lack of 'command' argument" end args = args.collect{|arg| '-' << arg.to_s} args << proc{|id, type| cmd.call(Tk::BLT::Tree::Node.id2obj(@tree, id), ((type[0] == ?-)? type[1..-1]: type)) } @path = @id = tk_call(@tpath, 'notify', 'create', *args) end