id2obj(chart, id)
click to toggle source
def Element.id2obj(chart, id)
cpath = chart.path
ElementID_TBL.mutex.synchronize{
return id unless ElementID_TBL[cpath]
ElementID_TBL[cpath][id]? ElementID_TBL[cpath][id]: id
}
end
new(chart, element=nil, keys={})
click to toggle source
def self.new(chart, element=nil, keys={})
if element.kind_of?(Hash)
keys = element
element = nil
end
if keys
keys = _symbolkey2str(keys)
not_create = keys.delete('without_creating')
else
not_create = false
end
obj = nil
ElementID_TBL.mutex.synchronize{
chart_path = chart.path
ElementID_TBL[chart_path] ||= {}
if element && ElementID_TBL[chart_path][element]
obj = ElementID_TBL[chart_path][element]
else
(obj = self.allocate).instance_eval{
if element
@element = @id = element.to_s
else
OBJ_ID.mutex.synchronize{
@element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
OBJ_ID[1].succ!
}
end
@path = @id
@parent = @chart = chart
@cpath = @chart.path
@typename = self.class::ElementTypeName
Element::ElementID_TBL[@cpath][@element] = self
unless not_create
tk_call(@chart, @typename, 'create', @element, keys)
return obj
end
}
end
}
obj.configure(keys) if obj && ! keys.empty?
obj
end
new(chart, element=nil, keys={})
click to toggle source
def initialize(chart, element=nil, keys={})
if element.kind_of?(Hash)
keys = element
element = nil
end
if element
@element = @id = element.to_s
else
OBJ_ID.mutex.synchronize{
@element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
OBJ_ID[1].succ!
}
end
@path = @id
@parent = @chart = chart
@cpath = @chart.path
@typename = self.class::ElementTypeName
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
tk_call(@chart, @typename, 'create', @element, keys)
end
end
type2class(type)
click to toggle source
def Element.type2class(type)
ElementTypeToClass[type]
end
activate(*args)
click to toggle source
def activate(*args)
@chart.element_activate(@id, *args)
end
cget(option)
click to toggle source
def cget(option)
@chart.__send__(@typename + '_cget', @id, option)
end
cget_strict(option)
click to toggle source
def cget_strict(option)
@chart.__send__(@typename + '_cget_strict', @id, option)
end
cget_tkstring(option)
click to toggle source
def cget_tkstring(option)
@chart.__send__(@typename + '_cget_tkstring', @id, option)
end
closest(x, y, var, keys={})
click to toggle source
def closest(x, y, var, keys={})
@chart.__send__(@typename + '_closest', x, y, var, @id, keys)
end
configinfo(key=nil)
click to toggle source
def configinfo(key=nil)
@chart.__send__(@typename + '_configinfo', @id, key)
end
current_configinfo(key=nil)
click to toggle source
def current_configinfo(key=nil)
@chart.__send__('current_' << @typename << '_configinfo', @id, key)
end
deactivate()
click to toggle source
def deactivate
@chart.element_deactivate(@id)
self
end
delete()
click to toggle source
def delete
@chart.element_delete(@id)
self
end
exist?()
click to toggle source
def exist?
@chart.element_exist?(@id)
end
id()
click to toggle source
mutex()
click to toggle source
name()
click to toggle source
to_eval()
click to toggle source
type()
click to toggle source
def type
@chart.element_type(@id)
end