[](slot)
click to toggle source
def [](slot)
cget slot
end
[]=(slot, val)
click to toggle source
def []=(slot, val)
configure slot, val
val
end
cget(slot)
click to toggle source
def cget(slot)
configinfo slot
end
command(cmd=nil, &b)
click to toggle source
def command(cmd=nil, &b)
if cmd
configure_cmd('command', cmd)
elsif b
configure_cmd('command', Proc.new(&b))
else
cget('command')
end
end
configinfo(option=nil)
click to toggle source
def configinfo(option=nil)
if !option && TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
lst = tk_split_simplelist(tk_call('tk', 'fontchooser', 'configure'))
ret = []
TkComm.slice_ary(lst, 2){|k, v|
k = k[1..-1]
ret << [k, __configinfo_value(k, v)]
}
ret
else
current_configinfo(option)
end
end
current_configinfo(option=nil)
click to toggle source
def current_configinfo(option=nil)
if option
opt = option.to_s
fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.empty?
__configinfo_value(option.to_s, tk_call('tk','fontchooser',
'configure',"-#{opt}"))
else
lst = tk_split_simplelist(tk_call('tk', 'fontchooser', 'configure'))
ret = {}
TkComm.slice_ary(lst, 2){|k, v|
k = k[1..-1]
ret[k] = __configinfo_value(k, v)
}
ret
end
end
hide()
click to toggle source
def hide
tk_call('tk', 'fontchooser', 'hide')
self
end
method_missing(id, *args)
click to toggle source
def method_missing(id, *args)
name = id.id2name
case args.length
when 1
if name[-1] == ?=
configure name[0..-2], args[0]
args[0]
else
configure name, args[0]
self
end
when 0
begin
cget(name)
rescue
super(id, *args)
end
else
super(id, *args)
end
end
set_for(target, title="Font")
click to toggle source
def set_for(target, title="Font")
if target.kind_of? TkFont
configs = {
:font=>target.actual_hash,
:command=>proc{|fnt, *args|
target.configure(TkFont.actual_hash(fnt))
}
}
elsif target.kind_of? Hash
fnt = target[:font] rescue ''
fnt = fnt.actual_hash if fnt.kind_of?(TkFont)
configs = {
:font => fnt,
:command=>proc{|fnt, *args|
target[:font] = TkFont.actual_hash(fnt)
}
}
else
configs = {
:font=>target.cget_tkstring(:font),
:command=>proc{|fnt, *args|
target.font = TkFont.actual_hash_displayof(fnt, target)
}
}
end
configs[:title] = title if title
configure(configs)
target
end
show()
click to toggle source
def show
tk_call('tk', 'fontchooser', 'show')
self
end
toggle()
click to toggle source
def toggle
cget(:visible) ? hide: show
self
end
unset()
click to toggle source
def unset
configure(:command, nil)
end