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 22
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 54
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 74
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 92
def apply(keys={})
  @tree.apply(@id, keys)
  self
end
            
children() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 97
def children()
  @tree.children(@id)
end
            
copy(parent, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 101
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 104
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 108
def degree()
  @tree.degree(@id)
end
            
delete() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 112
def delete()
  @tree.delete(@id)
  self
end
            
depth() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 117
def depth()
  @tree.depth(@id)
end
            
dump() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 121
def dump()
  @tree.dump(@id)
end
            
dump_to_file(file) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 125
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 130
def exist?(keys={})
  @tree.exist?(@id, keys)
end
            
find(keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 134
def find(keys={})
  @tree.find(@id, keys)
end
            
find_child(label) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 138
def find_child(label)
  @tree.find_child(@id, label)
end
            
first_child() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 142
def first_child()
  @tree.first_child(@id)
end
            
fullpath() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 199
def fullpath()
  @tree.fullpath(@id)
end
            
get() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 146
def get()
  @tree.get(@id)
end
            
get_value(key, default_val=None) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 149
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 88
def id
  @id
end
            
index() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 153
def index()
  @tree.index(@id)
end
            
keys() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 167
def keys()
  @tree.keys(@id)
end
            
label(text = nil) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 171
def label(text = nil)
  @tree.label(@id, nil)
end
            
label=(text) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 174
def label=(text)
  @tree.label(@id, text)
end
            
last_child() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 178
def last_child()
  @tree.last_child(@id)
end
            
leaf?() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 157
def leaf?()
  @tree.leaf?(@id)
end
            
move(dest, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 182
def move(dest, keys={})
  @tree.keys(@id, dest, keys)
  self
end
            
next() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 187
def next()
  @tree.next(@id)
end
            
next_sibling() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 191
def next_sibling()
  @tree.next_sibling(@id)
end
            
parent() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 195
def parent()
  @tree.parent(@id)
end
            
position() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 203
def position()
  @tree.position(@id)
end
            
prev_sibling() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 211
def prev_sibling()
  @tree.prev_sibling(@id)
end
            
previous() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 207
def previous()
  @tree.previous(@id)
end
            
restore(str, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 215
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 224
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 219
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 228
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 233
def root()
  @tree.root(@id)
  self
end
            
root?() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 163
def root?()
  @tree.root?(@id)
end
            
set(data) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 238
def set(data)
  @tree.set(@id, data)
  self
end
            
size() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 243
def size()
  @tree.size(@id)
end
            
sort(keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 247
def sort(keys={})
  @tree.sort(@id, keys)
  self
end
            
type(key) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 252
def type(key)
  @tree.type(@id, key)
end
            
unset(*keys) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 256
def unset(*keys)
  @tree.unset(@id, *keys)
  self
end
            
values(key=None) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 261
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.

blog comments powered by Disqus