Class: Tk::BLT::Tree::Node

Class | Tk::BLT::Tree::Node
In: | tk/lib/tkextlib/blt/tree.rb
Parent: | TkObject

### Methods

apply children copy copy_to degree delete depth dump dump_to_file exist? find find_child first_child fullpath get get_value id id2obj index keys label label= last_child leaf? link? move new new next next_sibling parent position prev_sibling previous restore restore_from_file restore_overwrite restore_overwrite_from_file root root? set size sort type unset values

### Constants

TreeNodeID_TBL | = | TkCore::INTERP.create_table

### Public Class methods

id2obj(tree, id)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 19
          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, 'node'=>Integer(id))
              rescue
                id
              end
            end
          end

new(tree, parent, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 46
          def initialize(tree, parent, keys={})
            @parent = @tree = tree
            @tpath = @parent.path

            parent = tk_call(@tpath, 'root') unless parent

            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
              @path = @id = tk_call(@tpath, 'insert', parent, keys)
            end

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

new(tree, parent, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 33
          def self.new(tree, parent, keys={})
            keys = _symbolkey2str(keys)
            tpath = tree.path

            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

            super(tree, parent, keys)
          end

### Public Instance methods

apply(keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 68
          def apply(keys={})
            @tree.apply(@id, keys)
            self
          end

children()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 73
          def children()
            @tree.children(@id)
          end

copy(parent, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 77
          def copy(parent, keys={})
            @tree.copy(@id, parent, keys)
          end

copy_to(dest_tree, parent, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 80
          def copy_to(dest_tree, parent, keys={})
            @tree.copy_to(@id, dest_tree, parent, keys)
          end

degree()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 84
          def degree()
            @tree.degree(@id)
          end

delete()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 88
          def delete()
            @tree.delete(@id)
            self
          end

depth()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 93
          def depth()
            @tree.depth(@id)
          end

dump()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 97
          def dump()
            @tree.dump(@id)
          end

dump_to_file(file)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 101
          def dump_to_file(file)
            @tree.dump_to_file(@id, file)
            self
          end

exist?(keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 106
          def exist?(keys={})
            @tree.exist?(@id, keys)
          end

find(keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 110
          def find(keys={})
            @tree.find(@id, keys)
          end

find_child(label)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 114
          def find_child(label)
            @tree.find_child(@id, label)
          end

first_child()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 118
          def first_child()
            @tree.first_child(@id)
          end

fullpath()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 175
          def fullpath()
            @tree.fullpath(@id)
          end

get()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 122
          def get()
            @tree.get(@id)
          end

get_value(key, default_val=None)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 125
          def get_value(key, default_val=None)
            @tree.get_value(@id, key, default_val)
          end

id()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 64
          def id
            @id
          end

index()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 129
          def index()
            @tree.index(@id)
          end

keys()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 143
          def keys()
            @tree.keys(@id)
          end

label(text = nil)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 147
          def label(text = nil)
            @tree.label(@id, nil)
          end

label=(text)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 150
          def label=(text)
            @tree.label(@id, text)
          end

last_child()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 154
          def last_child()
            @tree.last_child(@id)
          end

leaf?()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 133
          def leaf?()
            @tree.leaf?(@id)
          end

link?()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 136
          def link?()
            @tree.link?(@id)
          end

move(dest, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 158
          def move(dest, keys={})
            @tree.keys(@id, dest, keys)
            self
          end

next()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 163
          def next()
            @tree.next(@id)
          end

next_sibling()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 167
          def next_sibling()
            @tree.next_sibling(@id)
          end

parent()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 171
          def parent()
            @tree.parent(@id)
          end

position()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 179
          def position()
            @tree.position(@id)
          end

prev_sibling()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 187
          def prev_sibling()
            @tree.prev_sibling(@id)
          end

previous()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 183
          def previous()
            @tree.previous(@id)
          end

restore(str, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 191
          def restore(str, keys={})
            @tree.restore(@id, str, keys)
            self
          end

restore_from_file(file, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 200
          def restore_from_file(file, keys={})
            @tree.restore_from_file(@id, file, keys)
            self
          end

restore_overwrite(str, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 195
          def restore_overwrite(str, keys={})
            @tree.restore_overwrite(@id, str, keys)
            self
          end

restore_overwrite_from_file(file, keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 204
          def restore_overwrite_from_file(file, keys={})
            @tree.restore_overwrite_from_file(@id, file, keys)
            self
          end

root()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 209
          def root()
            @tree.root(@id)
            self
          end

root?()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 139
          def root?()
            @tree.root?(@id)
          end

set(data)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 214
          def set(data)
            @tree.set(@id, data)
            self
          end

size()

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 219
          def size()
            @tree.size(@id)
          end

sort(keys={})

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 223
          def sort(keys={})
            @tree.sort(@id, keys)
            self
          end

type(key)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 228
          def type(key)
            @tree.type(@id, key)
          end

unset(*keys)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 232
          def unset(*keys)
            @tree.unset(@id, *keys)
            self
          end

values(key=None)

[Source]

    # File tk/lib/tkextlib/blt/tree.rb, line 237
          def values(key=None)
            @tree.values(@id, key)
          end

[Validate]