Class Tk::BLT::Tree::Tag
In: tk/lib/tkextlib/blt/tree.rb
Parent: TkObject

Methods

add   delete   forget   id   id2obj   new   nodes   set   unset  

Constants

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

Public Class methods

[Source]

# File tk/lib/tkextlib/blt/tree.rb, line 249
      def self.id2obj(tree, id)
        tpath = tree.path
        return id unless TreeTagID_TBL[tpath]
        if TreeTagID_TBL[tpath][id]
          TreeTagID_TBL[tpath][id]
        else
          self.new(tree, id)
        end
      end

[Source]

# File tk/lib/tkextlib/blt/tree.rb, line 259
      def initialize(tree, tag_str = nil)
        @parent = @tree = tree
        @tpath = @parent.path

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

Public Instance methods

[Source]

# File tk/lib/tkextlib/blt/tree.rb, line 278
      def add(*nodes)
        tk_call(@tpath, 'tag', 'add', @id, *nodes)
        self
      end

[Source]

# File tk/lib/tkextlib/blt/tree.rb, line 283
      def delete(*nodes)
        tk_call(@tpath, 'tag', 'delete', @id, *nodes)
        self
      end

[Source]

# File tk/lib/tkextlib/blt/tree.rb, line 288
      def forget()
        tk_call(@tpath, 'tag', 'forget', @id)
        TreeTagID_TBL[@tpath].delete(@id)
        self
      end

[Source]

# File tk/lib/tkextlib/blt/tree.rb, line 274
      def id
        @id
      end

[Source]

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

[Source]

# File tk/lib/tkextlib/blt/tree.rb, line 300
      def set(node)
        tk_call(@tpath, 'tag', 'set', node, @id)
        self
      end

[Source]

# File tk/lib/tkextlib/blt/tree.rb, line 305
      def unset(node)
        tk_call(@tpath, 'tag', 'unset', node, @id)
        self
      end

[Validate]