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

In Files

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

Class/Module Index [+]

Quicksearch

Tk::BLT::Tree::Node

Constants

TreeNodeID_TBL

Public Class Methods

id2obj(tree, id)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 23
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, 'node'=>Integer(id))
          id = Integer(id)
          if bool(tk_call(@tpath, 'exists', id))
            (obj = self.allocate).instance_eval{
              @parent = @tree = tree
              @tpath = tpath
              @path = @id = id
              TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
              TreeNodeID_TBL[@tpath][@id] = self
            }
            obj
          else
            id
          end
        rescue
          id
        end
      end
    else
      id
    end
  }
end
            
new(tree, parent, keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 55
def self.new(tree, parent, keys={})
  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, parent, keys) if parent
      return obj
    end

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

  if (id = keys['node']) && bool(tk_call(@tpath, 'exists', id))
    @path = @id = id
    keys.delete('node')
    tk_call(@tpath, 'move', @id, parent, keys) if parent
  else
    parent = tk_call(@tpath, 'root') unless parent
    @path = @id = tk_call(@tpath, 'insert', parent, keys)
  end
end
            

Public Instance Methods

apply(keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 93
def apply(keys={})
  @tree.apply(@id, keys)
  self
end
            
children()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 98
def children()
  @tree.children(@id)
end
            
copy(parent, keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 102
def copy(parent, keys={})
  @tree.copy(@id, parent, keys)
end
            
copy_to(dest_tree, parent, keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 105
def copy_to(dest_tree, parent, keys={})
  @tree.copy_to(@id, dest_tree, parent, keys)
end
            
degree()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 109
def degree()
  @tree.degree(@id)
end
            
delete()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 113
def delete()
  @tree.delete(@id)
  self
end
            
depth()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 118
def depth()
  @tree.depth(@id)
end
            
dump()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 122
def dump()
  @tree.dump(@id)
end
            
dump_to_file(file)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 126
def dump_to_file(file)
  @tree.dump_to_file(@id, file)
  self
end
            
exist?(keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 131
def exist?(keys={})
  @tree.exist?(@id, keys)
end
            
find(keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 135
def find(keys={})
  @tree.find(@id, keys)
end
            
find_child(label)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 139
def find_child(label)
  @tree.find_child(@id, label)
end
            
first_child()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 143
def first_child()
  @tree.first_child(@id)
end
            
fullpath()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 200
def fullpath()
  @tree.fullpath(@id)
end
            
get()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 147
def get()
  @tree.get(@id)
end
            
get_value(key, default_val=None)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 150
def get_value(key, default_val=None)
  @tree.get_value(@id, key, default_val)
end
            
id()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 89
def id
  @id
end
            
index()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 154
def index()
  @tree.index(@id)
end
            
keys()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 168
def keys()
  @tree.keys(@id)
end
            
label(text = nil)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 172
def label(text = nil)
  @tree.label(@id, nil)
end
            
label=(text)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 175
def label=(text)
  @tree.label(@id, text)
end
            
last_child()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 179
def last_child()
  @tree.last_child(@id)
end
            
leaf?()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 158
def leaf?()
  @tree.leaf?(@id)
end
            
move(dest, keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 183
def move(dest, keys={})
  @tree.keys(@id, dest, keys)
  self
end
            
next()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 188
def next()
  @tree.next(@id)
end
            
next_sibling()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 192
def next_sibling()
  @tree.next_sibling(@id)
end
            
parent()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 196
def parent()
  @tree.parent(@id)
end
            
position()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 204
def position()
  @tree.position(@id)
end
            
prev_sibling()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 212
def prev_sibling()
  @tree.prev_sibling(@id)
end
            
previous()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 208
def previous()
  @tree.previous(@id)
end
            
restore(str, keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 216
def restore(str, keys={})
  @tree.restore(@id, str, keys)
  self
end
            
restore_from_file(file, keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 225
def restore_from_file(file, keys={})
  @tree.restore_from_file(@id, file, keys)
  self
end
            
restore_overwrite(str, keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 220
def restore_overwrite(str, keys={})
  @tree.restore_overwrite(@id, str, keys)
  self
end
            
restore_overwrite_from_file(file, keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 229
def restore_overwrite_from_file(file, keys={})
  @tree.restore_overwrite_from_file(@id, file, keys)
  self
end
            
root()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 234
def root()
  @tree.root(@id)
  self
end
            
root?()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 164
def root?()
  @tree.root?(@id)
end
            
set(data)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 239
def set(data)
  @tree.set(@id, data)
  self
end
            
size()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 244
def size()
  @tree.size(@id)
end
            
sort(keys={})
 
               # File tk/lib/tkextlib/blt/tree.rb, line 248
def sort(keys={})
  @tree.sort(@id, keys)
  self
end
            
type(key)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 253
def type(key)
  @tree.type(@id, key)
end
            
unset(*keys)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 257
def unset(*keys)
  @tree.unset(@id, *keys)
  self
end
            
values(key=None)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 262
def values(key=None)
  @tree.values(@id, key)
end