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

In Files

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

Class/Module Index [+]

Quicksearch

Tk::BLT::Treeview::Tag

Public Class Methods

id2obj(tree, name)
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1179
def self.id2obj(tree, name)
  tpath = tree.path
  TreeTagID_TBL.mutex.synchronize{
    if TreeTagID_TBL[tpath]
      if TreeTagID_TBL[tpath][name]
        TreeTagID_TBL[tpath][name]
      else
        #self.new(tree, name)
        (obj = self.allocate).instance_eval{
          @parent = @tree = tree
          @tpath = @parent.path
          @path = @id = name
          TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
          TreeTagID_TBL[@tpath][@id] = self
        }
        obj
      end
    else
      id
    end
  }
end
            
new(tree, *ids)
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1215
def self.new(tree, *ids)
  TreeTagID_TBL.mutex.synchronize{
    (obj = self.allocate).instance_eval{
      if tree.kind_of?(Array)
        initialize(tree[0], tree[1], ids)
      else
        initialize(tree, nil, ids)
      end
      TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
      TreeTagID_TBL[@tpath][@id] = self
    }
    obj
  }
end
            
new(tree, name, ids)
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1230
def initialize(tree, name, ids)
  @parent = @tree = tree
  @tpath = @parent.path

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

  unless ids.empty?
    tk_call(@tpath, 'tag', 'add', @id, *(ids.collect{|id| tagid(id)}))
  end
end
            
new_by_name(tree, name, *ids)
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1202
def self.new_by_name(tree, name, *ids)
  TreeTagID_TBL.mutex.synchronize{
    unless (obj = TreeTagID_TBL[tree.path][name])
      (obj = self.allocate).instance_eval{
        initialize(tree, name, ids)
        TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
        TreeTagID_TBL[@tpath][@id] = self
      }
    end
    obj
  }
end
            

Public Instance Methods

add(*ids)
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1262
def add(*ids)
  tk_call(@tpath, 'tag', 'add', @id, *(ids{|id| tagid(id)}))
  self
end
            
forget()
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1272
def forget
  tk_call(@tpath, 'tag', 'forget', @id)
  self
end
            
id()
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1258
def id
  @id
end
            
mutex()
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1171
def mutex; @mutex; end
            
nodes()
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1277
def nodes
  simplelist(tk_call(@tpath, 'tag', 'nodes', @id)).collect{|id|
    Tk::BLT::Treeview::Node.id2obj(@tree, id)
  }
end
            
remove(*ids)
 
               # File tk/lib/tkextlib/blt/treeview.rb, line 1267
def remove(*ids)
  tk_call(@tpath, 'tag', 'delete', @id, *(ids{|id| tagid(id)}))
  self
end