# File tk/lib/tkextlib/blt/tree.rb, line 317
def self.id2obj(tree, id)
tpath = tree.path
return id unless NotifyID_TBL[tpath]
if NotifyID_TBL[tpath][id]
NotifyID_TBL[tpath][id]
else
begin
self.new([tree, id])
rescue
id
end
end
end
# File tk/lib/tkextlib/blt/tree.rb, line 331
def self.new(tree, *args, &b)
if tree.kind_of?(Array)
# not create
if obj = NotifyID_TBL[tree[0].path][tree[1]]
return obj
else
return super(false, tree[0], tree[1])
end
end
super(true, tree, *args, &b)
end
# File tk/lib/tkextlib/blt/tree.rb, line 344
def initialize(create, tree, *args, &b)
@parent = @tree = tree
@tpath = @parent.path
unless create
@path = @id = args[0]
return
end
# 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