In Files

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

Class/Module Index [+]

Quicksearch

Tk::BLT::Tree

Public Class Methods

destroy(*names) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 619
def self.destroy(*names)
  tk_call('::blt::tree', 'destroy',
          *(names.collect{|n| (n.kind_of?(Tk::BLT::Tree))? n.id: n }) )
end
            
id2obj(id) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 607
def self.id2obj(id)
  TreeID_TBL.mutex.synchronize{
    TreeID_TBL[id]? TreeID_TBL[id]: id
  }
end
            
names(pat = None) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 613
def self.names(pat = None)
  simplelist(tk_call('::blt::tree', 'names', pat)).collect{|name|
    id2obj(name)
  }
end
            
new(name = nil) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 624
def self.new(name = nil)
  TreeID_TBL.mutex.synchronize{
    if name && TreeID_TBL[name]
      TreeID_TBL[name]
    else
      (obj = self.allocate).instance_eval{
        initialize(name)
        TreeID_TBL[@id] = self
      }
      obj
    end
  }
end
            
new(name = nil) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 638
def initialize(name = nil)
  if name
    @path = @id = name
  else
    Tree_ID.mutex.synchronize{
      @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
      Tree_ID[1].succ!
    }
  end

  tk_call('::blt::tree', 'create', @id)
end
            

Public Instance Methods

__destroy_hook__() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 651
def __destroy_hook__
  Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
    Tk::BLT::Tree::Node::TreeNodeID_TBL.delete(@path)
  }
  Tk::BLT::Tree::Tag::TreeTagID_TBL.mutex.synchronize{
    Tk::BLT::Tree::Tag::TreeTagID_TBL.delete(@path)
  }
  Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
    Tk::BLT::Tree::Notify::NotifyID_TBL.delete(@path)
  }
  Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
    Tk::BLT::Tree::Trace::TraceID_TBL.delete(@path)
  }
end
            
__keyonly_optkeys() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 587
def __keyonly_optkeys
  {
    # apply / find  command
    'invert'=>nil, 'leafonly'=>nil, 'nocase'=>nil,

    # apply / find / sort command
    'path'=>nil,

    # copy / restore / restorefile command
    'overwrite'=>nil,

    # copy command
    'recurse'=>nil, 'tags'=>nil,

    # sort command
    'ascii'=>nil, 'decreasing'=>nil, 'disctionary'=>nil,
    'integer'=>nil, 'real'=>nil, 'recurse'=>nil, 'reorder'=>nil,
  }
end
            
ancestor(node1, node2) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 682
def ancestor(node1, node2)
  Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'ancestor',
                                           tagid(node1), tagid(node2)))
end
            
ancestor?(node1, node2) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 787
def ancestor?(node1, node2)
  bool(tk_call('::blt::tree', 'is', 'ancestor',
               tagid(node1), tagid(node2)))
end
            
apply(node, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 687
def apply(node, keys={})
  tk_call('::blt::tree', 'apply', tagid(node), __conv_keyonly_opts(keys))
  self
end
            
attach(tree_obj) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 692
def attach(tree_obj)
  tk_call('::blt::tree', 'attach', tree_obj)
  self
end
            
before?(node1, node2) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 791
def before?(node1, node2)
  bool(tk_call('::blt::tree', 'is', 'before',
               tagid(node1), tagid(node2)))
end
            
children(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 697
def children(node)
  simplelist(tk_call('::blt::tree', 'children', tagid(node))).collect{|n|
    Tk::BLT::Tree::Node.id2obj(self, n)
  }
end
            
copy(src, parent, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 703
def copy(src, parent, keys={})
  id = tk_call('::blt::tree', 'copy', tagid(src), tagid(parent),
               __conv_keyonly_opts(keys))
  Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
end
            
copy_to(src, dest_tree, parent, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 708
def copy_to(src, dest_tree, parent, keys={})
  return copy(src, parent, keys={}) unless dest_tree

  id = tk_call('::blt::tree', 'copy', tagid(src), dest_tree,
               tagid(parent), __conv_keyonly_opts(keys))
  Tk::BLT::Tree::Node.new(dest_tree, nil, 'node'=>id)
end
            
degree(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 716
def degree(node)
  number(tk_call('::blt::tree', 'degree', tagid(node)))
end
            
delete(*nodes) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 720
def delete(*nodes)
  tk_call('::blt::tree', 'delete', *(nodes.collect{|node| tagid(node)}))
  Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
    nodes.each{|node|
      if node.kind_of?(Tk::BLT::Tree::Node)
        Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.id)
      else
        Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.to_s)
      end
    }
  }
  self
end
            
depth(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 734
def depth(node)
  number(tk_call('::blt::tree', 'depth', tagid(node)))
end
            
destroy() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 677
def destroy()
  tk_call('::blt::tree', 'destroy', @id)
  self
end
            
dump(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 738
def dump(node)
  simplelist(tk_call('::blt::tree', 'dump', tagid(node))).collect{|n|
    simplelist(n)
  }
end
            
dump_to_file(node, file) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 744
def dump_to_file(node, file)
  tk_call('::blt::tree', 'dumpfile', tagid(node), file)
  self
end
            
exist?(node, key=None) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 749
def exist?(node, key=None)
  bool(tk_call('::blt::tree', 'exists', tagid(node), key))
end
            
find(node, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 753
def find(node, keys={})
  simplelist(tk_call('::blt::tree', 'find', tagid(node),
                     __conv_keyonly_opts(keys))).collect{|n|
    Tk::BLT::Tree::Node.id2obj(self, n)
  }
end
            
find_child(node, label) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 760
def find_child(node, label)
  ret = tk_call('::blt::tree', 'findchild', tagid(node), label)
  (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
            
first_child(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 765
def first_child(node)
  ret = tk_call('::blt::tree', 'firstchild', tagid(node))
  (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
            
fullpath(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 886
def fullpath(node)
  tk_call('::blt::tree', 'path', tagid(node))
end
            
get(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 770
def get(node)
  Hash[*simplelist(tk_call('::blt::tree', 'get', tagid(node)))]
end
            
get_value(node, key, default_val=None) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 773
def get_value(node, key, default_val=None)
  tk_call('::blt::tree', 'get', tagid(node), key, default_val)
end
            
index(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 777
def index(node)
  Tk::BLT::Tree::Node.id2obj(self,
                             tk_call('::blt::tree', 'index', tagid(node)))
end
            
insert(parent, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 782
def insert(parent, keys={})
  id = tk_call('::blt::tree', 'insert', tagid(parent), keys)
  Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
end
            
keys(node, *nodes) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 805
def keys(node, *nodes)
  if nodes.empty?
    simplelist(tk_call('blt::tree', 'keys', tagid(node)))
  else
    simplelist(tk_call('blt::tree', 'keys', tagid(node),
                       *(nodes.collect{|n| tagid(n)}))).collect{|lst|
      simplelist(lst)
    }
  end
end
            
label(node, text=nil) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 816
def label(node, text=nil)
  if text
    tk_call('::blt::tree', 'label', tagid(node), text)
    text
  else
    tk_call('::blt::tree', 'label', tagid(node))
  end
end
            
last_child(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 825
def last_child(node)
  ret = tk_call('::blt::tree', 'lastchild', tagid(node))
  (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
            
leaf?(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 795
def leaf?(node)
  bool(tk_call('::blt::tree', 'is', 'leaf', tagid(node)))
end
            
move(node, dest, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 836
def move(node, dest, keys={})
  tk_call('::blt::tree', 'move', tagid(node), tagid(dest), keys)
  self
end
            
mutex() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 583
def mutex; @mutex; end
            
next(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 841
def next(node)
  ret = tk_call('::blt::tree', 'next', tagid(node))
  (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
            
next_sibling(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 846
def next_sibling(node)
  ret = tk_call('::blt::tree', 'nextsibling', tagid(node))
  (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
            
notify_create(*args, &b) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 851
def notify_create(*args, &b)
  Tk::BLT::Tree::Notify.new(self, *args, &b)
end
            
notify_delete(id) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 855
def notify_delete(id)
  if id.kind_of?(Tk::BLT::Tree::Notify)
    id.delete
  else
    tk_call(@path, 'notify', 'delete', id)
    Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
      Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
    }
  end
  self
end
            
notify_info(id) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 867
def notify_info(id)
  lst = simplelist(tk_call(@path, 'notify', 'info', tagid(id)))
  lst[0] = Tk::BLT::Tree::Notify.id2obj(self, lst[0])
  lst[1] = simplelist(lst[1]).collect{|flag| flag[1..-1]}
  lst[2] = tk_tcl2ruby(lst[2])
  lst
end
            
notify_names() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 875
def notify_names()
  tk_call(@path, 'notify', 'names').collect{|id|
    Tk::BLT::Tree::Notify.id2obj(self, id)
  }
end
            
parent(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 881
def parent(node)
  ret = tk_call('::blt::tree', 'parent', tagid(node))
  (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
            
position(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 890
def position(node)
  number(tk_call('::blt::tree', 'position', tagid(node)))
end
            
prev_sibling(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 899
def prev_sibling(node)
  ret = tk_call('::blt::tree', 'prevsibling', tagid(node))
  (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
            
previous(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 894
def previous(node)
  ret = tk_call('::blt::tree', 'previous', tagid(node))
  (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
            
restore(node, str, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 904
def restore(node, str, keys={})
  tk_call('::blt::tree', 'restore', tagid(node), str,
          __conv_keyonly_opts(keys))
  self
end
            
restore_from_file(node, file, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 917
def restore_from_file(node, file, keys={})
  tk_call('::blt::tree', 'restorefile', tagid(node), file,
          __conv_keyonly_opts(keys))
  self
end
            
restore_overwrite(node, str, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 909
def restore_overwrite(node, str, keys={})
  keys = __conv_keyonly_opts(keys)
  keys.delete('overwrite')
  keys.delete(:overwrite)
  tk_call('::blt::tree', 'restore', tagid(node), str, '-overwrite', keys)
  self
end
            
restore_overwrite_from_file(node, file, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 922
def restore_overwrite_from_file(node, file, keys={})
  keys = __conv_keyonly_opts(keys)
  keys.delete('overwrite')
  keys.delete(:overwrite)
  tk_call('::blt::tree', 'restorefile', tagid(node), file,
          '-overwrite', keys)
  self
end
            
root(node=None) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 931
def root(node=None)
  Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'root',
                                           tagid(node)))
end
            
root?(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 801
def root?(node)
  bool(tk_call('::blt::tree', 'is', 'root', tagid(node)))
end
            
set(node, data) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 936
def set(node, data)
  unless data.kind_of?(Hash)
    fail ArgumentError, 'Hash is expected for data'
  end
  args = []
  data.each{|k, v|  args << k << v}
  tk_call('::blt::tree', 'set', tagid(node), *args)
  self
end
            
size(node) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 946
def size(node)
  number(tk_call('::blt::tree', 'size', tagid(node)))
end
            
sort(node, keys={}) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 950
def sort(node, keys={})
  tk_call('::blt::tree', 'sort', tagid(node), __conv_keyonly_opts(keys))
  self
end
            
tag_add(tag, *nodes) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 955
def tag_add(tag, *nodes)
  tk_call(@path, 'tag', 'add', tagid(tag), *(nodes.collect{|n| tagid(n)}))
  self
end
            
tag_delete(tag, *nodes) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 960
def tag_delete(tag, *nodes)
  tk_call(@path, 'tag', 'delete', tagid(tag),
          *(nodes.collect{|n| tagid(n)}))
  self
end
            
tag_forget(tag) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 966
def tag_forget(tag)
  tag = tag.id if tag.kind_of?(Tk::BLT::Tree::Tag)
  tk_call(@path, 'tag', 'forget', tag)
  TreeTagID_TBL.mutex.synchronize{
    TreeTagID_TBL[@path].delete(tag)
  }
  self
end
            
tag_get(node, *patterns) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 975
def tag_get(node, *patterns)
  simplelist(tk_call(@tpath, 'tag', 'get', tagid(node),
                     *(patterns.collect{|pat| tagid(pat)}))).collect{|str|
    Tk::BLT::Tree::Tag.id2obj(self, str)
  }
end
            
tag_names(node = None) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 982
def tag_names(node = None)
  simplelist(tk_call(@tpath, 'tag', 'names', tagid(node))).collect{|str|
    Tk::BLT::Tree::Tag.id2obj(self, str)
  }
end
            
tag_nodes(tag) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 988
def tag_nodes(tag)
  simplelist(tk_call(@tpath, 'tag', 'nodes', tagid(tag))).collect{|node|
    Tk::BLT::Tree::Node.id2obj(self, node)
  }
end
            
tag_set(node, *tags) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 994
def tag_set(node, *tags)
  tk_call(@path, 'tag', 'set', tagid(node), *(tags.collect{|t| tagid(t)}))
  self
end
            
tag_unset(node, *tags) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 999
def tag_unset(node, *tags)
  tk_call(@path, 'tag', 'unset', tagid(node),
          *(tags.collect{|t| tagid(t)}))
  self
end
            
tagid(tag) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 666
def tagid(tag)
  if tag.kind_of?(Tk::BLT::Tree::Node) ||
      tag.kind_of?(Tk::BLT::Tree::Tag) ||
      tag.kind_of?(Tk::BLT::Tree::Notify) ||
      tag.kind_of?(Tk::BLT::Tree::Trace)
    tag.id
  else
    tag  # maybe an Array of configure parameters
  end
end
            
trace_create(*args, &b) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 1005
def trace_create(*args, &b)
  Tk::BLT::Tree::Trace.new(self, *args, &b)
end
            
trace_delete(*args) click to toggle source

begin

def trace_delete(*args)
  args.each{|id|
    if id.kind_of?(Tk::BLT::Tree::Trace)
      id.delete
    else
      tk_call(@path, 'trace', 'delete', id)
      Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)
    end
    self
  }
end

end

 
               # File tk/lib/tkextlib/blt/tree.rb, line 1022
def trace_delete(*args)
  args = args.collect{|id| tagid(id)}
  tk_call(@path, 'trace', 'delete', *args)
  Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
    args.each{|id| Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)}
  }
  self
end
            
trace_info(id) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 1031
def trace_info(id)
  lst = simplelist(tk_call(@path, 'trace', 'info', tagid(id)))
  lst[0] = Tk::BLT::Tree::Trace.id2obj(self, lst[0])
  lst[2] = simplelist(lst[2])
  lst[3] = tk_tcl2ruby(lst[3])
  lst
end
            
trace_names() click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 1039
def trace_names()
  tk_call(@path, 'trace', 'names').collect{|id|
    Tk::BLT::Tree::Trace.id2obj(self, id)
  }
end
            
type(node, key) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 1045
def type(node, key)
  tk_call('::blt::tree', 'type', tagid(node), key)
end
            
unset(node, *keys) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 1049
def unset(node, *keys)
  tk_call('::blt::tree', 'unset', tagid(node), *keys)
  self
end
            
values(node, key=None) click to toggle source
 
               # File tk/lib/tkextlib/blt/tree.rb, line 1054
def values(node, key=None)
  simplelist(tk_call('::blt::tree', 'values', tagid(node), key))
end