Class Tk::BLT::Treeview::Tag
In: tk/lib/tkextlib/blt/treeview.rb
Parent: TkObject

Methods

add   forget   id   id2obj   new   new   new_by_name   nodes   remove  

Included Modules

Tk::BLT::Treeview::TagOrID_Methods

Constants

TreeTagID_TBL = TkCore::INTERP.create_table
TreeTag_ID = ['blt_treeview_tag'.freeze, '00000'.taint].freeze

Public Class methods

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1058
  def self.id2obj(tree, id)
    tpath = tree.path
    return id unless TreeTagID_TBL[tpath]
    if TreeTagID_TBL[tpath][id]
      TreeTagID_TBL[tpath][id]
    else
      begin
        self.new(tree, nil, nil, 'name'=>Integer(id))
      rescue
        id
      end
    end
  end

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1087
  def initialize(tree, name, ids)
    @parent = @tree = tree
    @tpath = @parent.path

    if name
      @path = @id = name
    else
      @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze
      TreeTag_ID[1].succ!
    end

    TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
    TreeTagID_TBL[@tpath][@id] = self

    unless ids.empty?
      tk_call(@tpath, 'tag', 'add', @id, *(ids.collect{|id| tagid(id)}))
    end
  end

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1079
  def self.new(tree, *ids)
    if tree.kind_of?(Array)
      super(tree[0], tree[1], ids)
    else
      super(tree, nil, ids)
    end
  end

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1072
  def self.new_by_name(tree, name, *ids)
    if (obj = TreeTagID_TBL[tree.path][name])
      return obj
    end
    new([tree, name], ids)
  end

Public Instance methods

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1120
  def add(*ids)
    tk_call(@tpath, 'tag', 'add', @id, *(ids{|id| tagid(id)}))
    self
  end

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1130
  def forget
    tk_call(@tpath, 'tag', 'forget', @id)
    self
  end

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1116
  def id
    @id
  end

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1135
  def nodes
    simplelist(tk_call(@tpath, 'tag', 'nodes', @id)).collect{|id|
      Tk::BLT::Treeview::Node.id2obj(@tree, id)
    }
  end

[Source]

# File tk/lib/tkextlib/blt/treeview.rb, line 1125
  def remove(*ids)
    tk_call(@tpath, 'tag', 'delete', @id, *(ids{|id| tagid(id)}))
    self
  end

[Validate]

ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.

Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.

For more information on the Ruby programming language, visit ruby-lang.org.

Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.