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