class TkcItem
Constants
- CItemID_TBL
- CItemTypeName
- CItemTypeToClass
Public Class Methods
create(canvas, *args)
click to toggle source
# File lib/tk/canvas.rb, line 731 def self.create(canvas, *args) unless self::CItemTypeName fail RuntimeError, "#{self} is an abstract class" end args, fontkeys, methodkeys = _parse_create_args(args) idnum = tk_call_without_enc(canvas.path, 'create', self::CItemTypeName, *args) canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty? canvas.itemconfigure(idnum, methodkeys) unless methodkeys.empty? idnum.to_i # 'canvas item id' is an integer number end
id2obj(canvas, id)
click to toggle source
# File lib/tk/canvas.rb, line 663 def TkcItem.id2obj(canvas, id) cpath = canvas.path CItemID_TBL.mutex.synchronize{ if CItemID_TBL[cpath] CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id else id end } end
new(parent, *args)
click to toggle source
# File lib/tk/canvas.rb, line 744 def initialize(parent, *args) #unless parent.kind_of?(Tk::Canvas) # fail ArgumentError, "expect Tk::Canvas for 1st argument" #end @parent = @c = parent @path = parent.path @id = create_self(*args) # an integer number as 'canvas item id' CItemID_TBL.mutex.synchronize{ CItemID_TBL[@path] = {} unless CItemID_TBL[@path] CItemID_TBL[@path][@id] = self } end
type2class(type)
click to toggle source
# File lib/tk/canvas.rb, line 659 def TkcItem.type2class(type) CItemTypeToClass[type] end
Private Class Methods
_parse_create_args(args)
click to toggle source
# File lib/tk/canvas.rb, line 675 def self._parse_create_args(args) fontkeys = {} methodkeys = {} if args[-1].kind_of? Hash keys = _symbolkey2str(args.pop) if args.size == 0 args = keys.delete('coords') unless args.kind_of?(Array) fail "coords parameter must be given by an Array" end end #['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key| # fontkeys[key] = keys.delete(key) if keys.key?(key) #} __item_font_optkeys(nil).each{|key| fkey = key.to_s fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey) fkey = "kanji#{key}" fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey) fkey = "latin#{key}" fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey) fkey = "ascii#{key}" fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey) } __item_optkey_aliases(nil).each{|alias_name, real_name| alias_name = alias_name.to_s if keys.has_key?(alias_name) keys[real_name.to_s] = keys.delete(alias_name) end } __item_methodcall_optkeys(nil).each{|key| key = key.to_s methodkeys[key] = keys.delete(key) if keys.key?(key) } __item_ruby2val_optkeys(nil).each{|key, method| key = key.to_s keys[key] = method.call(keys[key]) if keys.has_key?(key) } #args = args.flatten.concat(hash_kv(keys)) args = args.flatten.concat(itemconfig_hash_kv(nil, keys)) else args = args.flatten end [args, fontkeys, methodkeys] end
Public Instance Methods
delete()
click to toggle source
# File lib/tk/canvas.rb, line 774 def delete @c.delete @id CItemID_TBL.mutex.synchronize{ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path] } self end
exist?()
click to toggle source
# File lib/tk/canvas.rb, line 766 def exist? if @c.find_withtag(@id) true else false end end
id()
click to toggle source
# File lib/tk/canvas.rb, line 762 def id @id end
Private Instance Methods
create_self(*args)
click to toggle source
# File lib/tk/canvas.rb, line 757 def create_self(*args) self.class.create(@c, *args) # return an integer number as 'canvas item id' end