In Files

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

Class/Module Index [+]

Quicksearch

Tk::BLT::Treeview::Node

Public Class Methods

id2obj(tree, id) click to toggle source
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 974
def self.id2obj(tree, id)
  tpath = tree.path
  return id unless TreeNodeID_TBL[tpath]
  if TreeNodeID_TBL[tpath][id]
    TreeNodeID_TBL[tpath][id]
  else
    begin
      self.new(tree, nil, nil, 'node'=>Integer(id))
    rescue
      id
    end
  end
end
            
new(tree, pos, parent=nil, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 988
def self.new(tree, pos, parent=nil, keys={})
  if parent.kind_of?(Hash)
    keys = parent
    parent = nil
  end

  keys = _symbolkey2str(keys)
  tpath = tree.path

  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)
end
            
new(tree, pos, parent, keys) click to toggle source
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1006
def initialize(tree, pos, parent, keys)
  @parent = @tree = tree
  @tpath = @parent.path

  if (id = keys['node'])
    @path = @id = id
    tk_call(@tpath, 'move', @id, pos, tagid(parent)) if parent
  else
    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

  TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
  TreeNodeID_TBL[@tpath][@id] = self
end
            

Public Instance Methods

id() click to toggle source
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1043
def id
  @id
end