Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more

In Files

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

Class/Module Index [+]

Quicksearch

Tk::BWidget::Tree::Node

Public Class Methods

id2obj(tree, id) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 322
def self.id2obj(tree, id)
  tpath = tree.path
  TreeNode_TBL.mutex.synchronize{
    if TreeNode_TBL[tpath]
      TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
    else
      id
    end
  }
end
            
new(tree, *args) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 333
def initialize(tree, *args)
  if tree.kind_of?(Tk::BWidget::Tree)
    @tree = tree
    parent = args.shift
    if parent.kind_of?(Tk::BWidget::Tree::Node)
      if parent.tree.path != @tree.path
        fail RuntimeError, 'tree of parent node is not match'
      end
    end
  elsif tree.kind_of?(Tk::BWidget::Tree::Node)
    @tree = tree.tree
    parent = tree.parent
  else
    fail RuntimeError,
      "expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument"
  end

  if args[-1].kind_of?(Hash)
    keys = _symbolkey2str(args.pop)
  else
    keys = {}
  end

  index = keys.delete('index')
  unless args.empty?
    index = args.shift
  end
  index = 'end' unless index

  unless args.empty?
    fail RuntimeError, 'too much arguments'
  end

  @tpath = @tree.path

  if keys.key?('nodename')
    @path = @id = keys.delete('nodename')
  else
    TreeNode_ID.mutex.synchronize{
      @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
      TreeNode_ID[1].succ!
    }
  end

  TreeNode_TBL.mutex.synchronize{
    TreeNode_TBL[@id] = self
    TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
    TreeNode_TBL[@tpath][@id] = self
  }

  @tree.insert(index, parent, @id, keys)
end
            

Public Instance Methods

[](key) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 394
def [](key)
  cget(key)
end
            
[]=(key, val) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 398
def []=(key, val)
  configure(key, val)
  val
end
            
cget(key) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 406
def cget(key)
  @tree.itemcget(@id, key)
end
            
cget_strict(key) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 409
def cget_strict(key)
  @tree.itemcget_strict(@id, key)
end
            
cget_tkstring(key) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 403
def cget_tkstring(key)
  @tree.itemcget_tkstring(@id, key)
end
            
close_tree(recurse=None) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 425
def close_tree(recurse=None)
  @tree.close_tree(@id, recurse)
  self
end
            
configinfo(key=nil) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 417
def configinfo(key=nil)
  @tree.itemconfiginfo(@id, key)
end
            
configure(key, val=None) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 413
def configure(key, val=None)
  @tree.itemconfigure(@id, key, val)
end
            
current_configinfo(key=nil) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 421
def current_configinfo(key=nil)
  @tree.current_itemconfiginfo(@id, key)
end
            
delete() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 430
def delete
  @tree.delete(@id)
  self
end
            
edit(*args) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 435
def edit(*args)
  @tree.edit(@id, *args)
  self
end
            
exist?() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 440
def exist?
  @tree.exist?(@id)
end
            
id() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 390
def id
  @id
end
            
index() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 444
def index
  @tree.index(@id)
end
            
move(index, parent=nil) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 448
def move(index, parent=nil)
  if parent
    @tree.move(parent, @id, index)
  else
    @tree.move(self.parent, @id, index)
  end
end
            
mutex() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 314
def mutex; @mutex; end
            
open?() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 461
def open?
  bool(@tree.itemcget(@id, 'open'))
end
            
open_tree(recurse=None) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 456
def open_tree(recurse=None)
  @tree.open_tree(@id, recurse)
  self
end
            
parent() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 465
def parent
  @tree.parent(@id)
end
            
reorder(neworder) click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 469
def reorder(neworder)
  @tree.reorder(@id, neworder)
end
            
see() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 473
def see
  @tree.see(@id)
end
            
selection_add() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 477
def selection_add
  @tree.selection_add(@id)
end
            
selection_remove() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 481
def selection_remove
  @tree.selection_remove(@id)
end
            
selection_set() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 485
def selection_set
  @tree.selection_set(@id)
end
            
selection_toggle() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 489
def selection_toggle
  @tree.selection_toggle(@id)
end
            
toggle() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 493
def toggle
  @tree.toggle(@id)
end
            
tree() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 386
def tree
  @tree
end
            
visible() click to toggle source
 
               # File tk/lib/tkextlib/bwidget/tree.rb, line 497
def visible
  @tree.visible(@id)
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.