# class Tk::BLT::Treeview::Tag

### Constants

TreeTagID_TBL
TreeTag_ID

### Public Class Methods

id2obj(tree, name) click to toggle source

    # File 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) click to toggle source

    # File 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) click to toggle source

    # File 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) click to toggle source

    # File 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) click to toggle source

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

forget() click to toggle source

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

id() click to toggle source

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

mutex() click to toggle source

    # File lib/tkextlib/blt/treeview.rb, line 1171
    def mutex; @mutex; end

nodes() click to toggle source

    # File 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) click to toggle source

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

### Private Instance Methods

tagid(tag) click to toggle source

    # File lib/tkextlib/blt/treeview.rb, line 1248
    def tagid(tag)
      if tag.kind_of?(Tk::BLT::Treeview::Node)        || tag.kind_of?(Tk::BLT::Treeview::Tag)
        tag.id
      else
        tag
      end
    end