Class | TkcItem
In: | tk/lib/tk/canvas.rb
Parent: | TkObject

### Methods

create delete destroy exist? id id2obj new remove type2class

### Included Modules

TkcTagAccess

### Constants

CItemTypeName | = | nil
CItemTypeToClass | = | {}
CItemID_TBL | = | TkCore::INTERP.create_table

### Public Class methods

create(canvas, *args)

[Source]

    # File tk/lib/tk/canvas.rb, line 648
      def self.create(canvas, *args)
        unless self::CItemTypeName
          fail RuntimeError, "#{self} is an abstract class"
        end
        args, fontkeys = _parse_create_args(args)
        idnum = tk_call_without_enc(canvas.path, 'create',
                                    self::CItemTypeName, *args)
        canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty?
        idnum.to_i  # 'canvas item id' is an integer number
      end

id2obj(canvas, id)

[Source]

    # File tk/lib/tk/canvas.rb, line 592
      def TkcItem.id2obj(canvas, id)
        cpath = canvas.path
        return id unless CItemID_TBL[cpath]
        CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
      end

new(parent, *args)

[Source]

    # File tk/lib/tk/canvas.rb, line 660
      def initialize(parent, *args)
        #unless parent.kind_of?(TkCanvas)
        #  fail ArgumentError, "expect TkCanvas for 1st argument"
        #end
        @parent = @c = parent
        @path = parent.path

        @id = create_self(*args) # an integer number as 'canvas item id'
        CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
        CItemID_TBL[@path][@id] = self
      end

type2class(type)

[Source]

    # File tk/lib/tk/canvas.rb, line 588
      def TkcItem.type2class(type)
        CItemTypeToClass[type]
      end

### Public Instance methods

delete()

[Source]

    # File tk/lib/tk/canvas.rb, line 688
      def delete
        @c.delete @id
        CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
        self
      end

destroy()

Alias for delete

exist?()

[Source]

    # File tk/lib/tk/canvas.rb, line 680
      def exist?
        if @c.find_withtag(@id)
          true
        else
          false
        end
      end

id()

[Source]

    # File tk/lib/tk/canvas.rb, line 676
      def id
        @id
      end

remove()

Alias for delete

[Validate]