Class: Tk::BLT::Tree::Tag (Ruby 2.3.4)

In Files

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

Class/Module Index [+]

Quicksearch

Tk::BLT::Tree::Tag

Public Class Methods

id2obj(tree, id)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 282
def self.id2obj(tree, id)
  tpath = tree.path
  TreeTagID_TBL.mutex.synchronize{
    if TreeTagID_TBL[tpath]
      if TreeTagID_TBL[tpath][id]
        TreeTagID_TBL[tpath][id]
      else
        begin
          # self.new(tree, id)
          (obj = self.allocate).instance_eval{
            @parent = @tree = tree
            @tpath = @parent.path
            @path = @id = id.dup.freeze if id
            TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
            TreeTagID_TBL[@tpath][@id] = self
          }
          obj
        rescue
          id
        end
      end
    else
      id
    end
  }
end
            
new(tree, tag_str = nil)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 309
def initialize(tree, tag_str = nil)
  @parent = @tree = tree
  @tpath = @parent.path

  if tag_str
    @path = @id = tag_str.dup.freeze
  else
    TreeTag_ID.mutex.synchronize{
      @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
      TreeTag_ID[1].succ!
    }
  end
  TreeTagID_TBL.mutex.synchronize{
    TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
    TreeTagID_TBL[@tpath][@id] = self
  }
end
            

Public Instance Methods

add(*nodes)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 331
def add(*nodes)
  tk_call(@tpath, 'tag', 'add', @id, *nodes)
  self
end
            
delete(*nodes)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 336
def delete(*nodes)
  tk_call(@tpath, 'tag', 'delete', @id, *nodes)
  self
end
            
forget()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 341
def forget()
  tk_call(@tpath, 'tag', 'forget', @id)
  TreeTagID_TBL.mutex.synchronize{
    TreeTagID_TBL[@tpath].delete(@id)
  }
  self
end
            
id()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 327
def id
  @id
end
            
mutex()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 278
def mutex; @mutex; end
            
nodes()
 
               # File tk/lib/tkextlib/blt/tree.rb, line 349
def nodes()
  simplelist(tk_call(@tpath, 'tag', 'nodes', @id)).collect{|node|
    Tk::BLT::Tree::Node.id2obj(@path, node)
  }
end
            
set(node)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 355
def set(node)
  tk_call(@tpath, 'tag', 'set', node, @id)
  self
end
            
unset(node)
 
               # File tk/lib/tkextlib/blt/tree.rb, line 360
def unset(node)
  tk_call(@tpath, 'tag', 'unset', node, @id)
  self
end