# File tk/lib/tkextlib/blt/tree.rb, line 478
def self.id2obj(tree, id)
tpath = tree.path
TraceID_TBL.mutex.synchronize{
if TraceID_TBL[tpath]
if TraceID_TBL[tpath][id]
TraceID_TBL[tpath][id]
else
begin
# self.new([tree, id])
(obj = self.allocate).instance_eval{
@parent = @tree = tree
@tpath = @parent.path
@path = @id = node # == traceID
TraceID_TBL[@tpath] ||= {}
TraceID_TBL[@tpath][@id] = self
}
obj
rescue
id
end
end
else
id
end
}
end
# File tk/lib/tkextlib/blt/tree.rb, line 505
def self.new(tree, *args, &b)
TraceID_TBL.mutex.synchronize{
if tree.kind_of?(Array)
# not create
tpath = tree[0].path
TraceID_TBL[tpath] ||= {}
unless (obj = TraceID_TBL[tpath][tree[1]])
(TraceID_TBL[tpath][tree[1]] =
obj = self.allocate).instance_eval{
@parent = @tree = tree
@tpath = @parent.path
@path = @id = tree[1] # == traceID
}
end
return obj
end
# super(true, tree, *args, &b)
(obj = self.allocate).instance_eval{
initialize(tree, *args, &b)
TraceID_TBL[@tpath] ||= {}
TraceID_TBL[@tpath][@id] = self
}
return obj
}
end
# File tk/lib/tkextlib/blt/tree.rb, line 532
def initialize(tree, node, key, opts, cmd=nil, &b)
@parent = @tree = tree
@tpath = @parent.path
if !cmd
if b
cmd = Proc.new(&b)
else
fail ArgumentError, "lack of 'command' argument"
end
end
@path = @id = tk_call(@tpath, 'trace', 'create', node, key, opts,
proc{|t, id, k, ops|
tobj = Tk::BLT::Tree.id2obj(t)
if tobj.kind_of?(Tk::BLT::Tree)
nobj = Tk::BLT::Tree::Node.id2obj(tobj, id)
else
nobj = id
end
cmd.call(tobj, nobj, k, ops)
})
end