Class: Tk::BLT::Treeview::Node (Ruby 2.3.4)

In Files

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

Class/Module Index [+]

Quicksearch

Tk::BLT::Treeview::Node

Public Class Methods

id2obj(tree, id)
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1058
def self.id2obj(tree, id)
  tpath = tree.path
  TreeNodeID_TBL.mutex.synchronize{
    if TreeNodeID_TBL[tpath]
      if TreeNodeID_TBL[tpath][id]
        TreeNodeID_TBL[tpath][id]
      else
        begin
          # self.new(tree, nil, nil, 'node'=>Integer(id))
          unless (tk_call(@tpath, 'get', id)).empty?
            id = Integer(id)
            (obj = self.allocate).instance_eval{
              @parent = @tree = tree
              @tpath = @parent.path
              @path = @id = id
              TreeNodeID_TBL[@tpath] ||= {}
              TreeNodeID_TBL[@tpath][@id] = self
            }
            obj
          else
            id
          end
        rescue
          id
        end
      end
    else
      id
    end
  }
end
            
new(tree, pos, parent=nil, keys={})
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1090
def self.new(tree, pos, parent=nil, keys={})
  if parent.kind_of?(Hash)
    keys = parent
    parent = nil
  end

  keys = _symbolkey2str(keys)
  tpath = tree.path

  TreeNodeID_TBL.mutex.synchronize{
    TreeNodeID_TBL[tpath] ||= {}
    if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
      keys.delete('node')
      tk_call(tree.path, 'move', id, pos, parent) if parent
      return obj
    end

    #super(tree, pos, parent, keys)
    (obj = self.allocate).instance_eval{
      initialize(tree, pos, parent, keys)
      TreeNodeID_TBL[tpath][@id] = self
    }
    obj
  }
end
            
new(tree, pos, parent, keys)
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1116
def initialize(tree, pos, parent, keys)
  @parent = @tree = tree
  @tpath = @parent.path

  if (id = keys['node'])
    # if tk_call(@tpath, 'get', id).empty?
    #   fail RuntimeError, "not exist the node '#{id}'"
    # end
    @path = @id = id
    tk_call(@tpath, 'move', @id, pos, tagid(parent)) if parent
    configure(keys) if keys && ! keys.empty?
  else
    name = nil
    TreeNode_ID.mutex.synchronize{
      name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
      TreeNode_ID[1].succ!
    }

    at = keys.delete['at']

    if parent
      if parent.kind_of?(Tk::BLT::Treeview::Node) ||
          parent.kind_of?(Tk::BLT::Treeview::Tag)
        path = [get_full(parent.id)[0], name]
        at = nil # ignore 'at' option
      else
        path = [parent.to_s, name]
      end
    else
      path = name
    end

    if at
      @id = tk_call(@tpath, 'insert', '-at', tagid(at), pos, path, keys)
    else
      @id = tk_call(@tpath, 'insert', pos, path, keys)
    end
    @path = @id
  end
end
            

Public Instance Methods

id()
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1157
def id
  @id
end
            
mutex()
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1050
def mutex; @mutex; end