In Files

  • tk/lib/tkextlib/blt/tree.rb

Class/Module Index [+]

Quicksearch

Tk::BLT::Tree::Trace

Constants

TraceID_TBL

Public Class Methods

id2obj(tree, id) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 479
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
            
new(tree, *args, &b) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 506
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
            
new(tree, node, key, opts, cmd=nil, &b) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 533
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
            

Public Instance Methods

delete() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 561
def delete()
  tk_call(@tpath, 'trace', 'delete', @id)
  TraceID_TBL.mutex.synchronize{
    TraceID_TBL[tpath].delete(@id)
  }
  self
end
            
id() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 557
def id
  @id
end
            
info() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 569
def info()
  lst = simplelist(tk_call(@tpath, 'trace', 'info', id))
  lst[0] = Tk::BLT::Tree::Trace.id2obj(@tree, lst[0])
  lst[2] = simplelist(lst[2])
  lst[3] = tk_tcl2ruby(lst[3])
  lst
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.