# File tk/lib/tkextlib/blt/tree.rb, line 400
def self.id2obj(tree, id)
tpath = tree.path
return id unless TraceID_TBL[tpath]
if TraceID_TBL[tpath][id]
TraceID_TBL[tpath][id]
else
begin
self.new([tree, id])
rescue
id
end
end
end
# File tk/lib/tkextlib/blt/tree.rb, line 414
def self.new(tree, *args, &b)
if tree.kind_of?(Array)
# not create
if obj = TraceID_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 427
def initialize(create, tree, node, key, opts, cmd=nil, &b)
@parent = @tree = tree
@tpath = @parent.path
unless create
@path = @id = node # == traceID
return
end
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