Class Tk::BWidget::Tree::Node
In: tk/lib/tkextlib/bwidget/tree.rb
Parent: TkObject

Methods

[]   []=   cget   close_tree   configinfo   configure   current_configinfo   delete   edit   exist?   id   id2obj   index   move   new   open?   open_tree   parent   reorder   see   selection_add   selection_remove   selection_set   selection_toggle   toggle   tree   visible  

Included Modules

TkTreatTagFont

Constants

TreeNode_TBL = TkCore::INTERP.create_table
TreeNode_ID = ['bw:node'.freeze, '00000'.taint].freeze

Public Class methods

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 270
  def self.id2obj(tree, id)
    tpath = tree.path
    return id unless TreeNode_TBL[tpath]
    TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 276
  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
      @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
      TreeNode_ID[1].succ!
    end

    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

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 333
  def [](key)
    cget(key)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 337
  def []=(key, val)
    configure(key, val)
    val
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 342
  def cget(key)
    @tree.itemcget(@id, key)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 358
  def close_tree(recurse=None)
    @tree.close_tree(@id, recurse)
    self
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 350
  def configinfo(key=nil)
    @tree.itemconfiginfo(@id, key)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 346
  def configure(key, val=None)
    @tree.itemconfigure(@id, key, val)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 354
  def current_configinfo(key=nil)
    @tree.current_itemconfiginfo(@id, key)
  end

[Source]

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

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 368
  def edit(*args)
    @tree.edit(@id, *args)
    self
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 373
  def exist?
    @tree.exist?(@id)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 329
  def id
    @id
  end

[Source]

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

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 381
  def move(index, parent=nil)
    if parent
      @tree.move(parent, @id, index)
    else
      @tree.move(self.parent, @id, index)
    end
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 394
  def open?
    bool(@tree.itemcget(@id, 'open'))
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 389
  def open_tree(recurse=None)
    @tree.open_tree(@id, recurse)
    self
  end

[Source]

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

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 402
  def reorder(neworder)
    @tree.reorder(@id, neworder)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 406
  def see
    @tree.see(@id)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 410
  def selection_add
    @tree.selection_add(@id)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 414
  def selection_remove
    @tree.selection_remove(@id)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 418
  def selection_set
    @tree.selection_set(@id)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 422
  def selection_toggle
    @tree.selection_toggle(@id)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 426
  def toggle
    @tree.toggle(@id)
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 325
  def tree
    @tree
  end

[Source]

# File tk/lib/tkextlib/bwidget/tree.rb, line 430
  def visible
    @tree.visible(@id)
  end

[Validate]