module TkConfigMethod
Public Class Methods
__IGNORE_UNKNOWN_CONFIGURE_OPTION__()
click to toggle source
# File lib/tk.rb, line 3603 def TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ @mode || false end
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode)
click to toggle source
# File lib/tk.rb, line 3606 def TkConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) @mode = (mode)? true: false end
Public Instance Methods
[](id)
click to toggle source
# File lib/tk.rb, line 3733 def [](id) cget(id) end
[]=(id, val)
click to toggle source
# File lib/tk.rb, line 3737 def []=(id, val) configure(id, val) val end
__check_available_configure_options(keys)
click to toggle source
# File lib/tk.rb, line 3930 def __check_available_configure_options(keys) availables = self.current_configinfo.keys # add non-standard keys availables |= __font_optkeys.map{|k| [k.to_s, "latin#{k}", "ascii#{k}", "kanji#{k}"] }.flatten availables |= __methodcall_optkeys.keys.map{|k| k.to_s} availables |= __keyonly_optkeys.keys.map{|k| k.to_s} keys = _symbolkey2str(keys) keys.delete_if{|k, v| !(availables.include?(k))} end
cget(slot)
click to toggle source
# File lib/tk.rb, line 3831 def cget(slot) unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ __cget_core(slot) else begin __cget_core(slot) rescue => e if current_configinfo.has_key?(slot.to_s) # error on known option fail e else # unknown option nil end end end end
cget_strict(slot)
click to toggle source
# File lib/tk.rb, line 3848 def cget_strict(slot) # never use TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ __cget_core(slot) end
cget_tkstring(option)
click to toggle source
# File lib/tk.rb, line 3742 def cget_tkstring(option) opt = option.to_s fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.length == 0 tk_call_without_enc(*(__cget_cmd << "-#{opt}")) end
config_hash_kv(keys, enc_mode = nil, conf = nil)
click to toggle source
# File lib/tk.rb, line 3727 def config_hash_kv(keys, enc_mode = nil, conf = nil) hash_kv(__conv_keyonly_opts(keys), enc_mode, conf) end
configinfo(slot = nil)
click to toggle source
# File lib/tk.rb, line 4741 def configinfo(slot = nil) if slot && TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ begin __configinfo_core(slot) rescue Array.new(__configinfo_struct.values.max).unshift(slot.to_s) end else __configinfo_core(slot) end end
configure(slot, value=None)
click to toggle source
# File lib/tk.rb, line 3944 def configure(slot, value=None) unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ __configure_core(slot, value) else if slot.kind_of?(Hash) begin __configure_core(slot) rescue slot = __check_available_configure_options(slot) __configure_core(slot) unless slot.empty? end else begin __configure_core(slot, value) rescue => e if current_configinfo.has_key?(slot.to_s) # error on known option fail e else # unknown option nil end end end end self end
configure_cmd(slot, value)
click to toggle source
# File lib/tk.rb, line 3972 def configure_cmd(slot, value) configure(slot, install_cmd(value)) end
current_configinfo(slot = nil)
click to toggle source
# File lib/tk.rb, line 4753 def current_configinfo(slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if slot org_slot = slot begin conf = configinfo(slot) if ( ! __configinfo_struct[:alias] \ || conf.size > __configinfo_struct[:alias] + 1 ) return {conf[0] => conf[-1]} end slot = conf[__configinfo_struct[:alias]] end while(org_slot != slot) fail RuntimeError, "there is a configure alias loop about '#{org_slot}'" else ret = {} configinfo().each{|cnf| if ( ! __configinfo_struct[:alias] \ || cnf.size > __configinfo_struct[:alias] + 1 ) ret[cnf[0]] = cnf[-1] end } ret end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY ret = {} configinfo(slot).each{|key, cnf| ret[key] = cnf[-1] if cnf.kind_of?(Array) } ret end end
Private Instance Methods
__boolval_optkeys()
click to toggle source
# File lib/tk.rb, line 3646 def __boolval_optkeys ['exportselection', 'jump', 'setgrid', 'takefocus'] end
__cget_cmd()
click to toggle source
# File lib/tk.rb, line 3610 def __cget_cmd [self.path, 'cget'] end
__cget_core(slot)
click to toggle source
# File lib/tk.rb, line 3748 def __cget_core(slot) orig_slot = slot slot = slot.to_s if slot.length == 0 fail ArgumentError, "Invalid option `#{orig_slot.inspect}'" end _, real_name = __optkey_aliases.find{|k, v| k.to_s == slot} if real_name slot = real_name.to_s end if ( method = _symbolkey2str(__val2ruby_optkeys())[slot] ) optval = tk_call_without_enc(*(__cget_cmd << "-#{slot}")) begin return method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG return optval end end if ( method = _symbolkey2str(__methodcall_optkeys)[slot] ) return self.__send__(method) end case slot when /^(#{__numval_optkeys.join('|')})$/ begin number(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) rescue nil end when /^(#{__numstrval_optkeys.join('|')})$/ num_or_str(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) when /^(#{__boolval_optkeys.join('|')})$/ begin bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) rescue nil end when /^(#{__listval_optkeys.join('|')})$/ simplelist(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) when /^(#{__numlistval_optkeys.join('|')})$/ conf = tk_call_without_enc(*(__cget_cmd << "-#{slot}")) if conf =~ /^[0-9+-]/ list(conf) else conf end when /^(#{__strval_optkeys.join('|')})$/ _fromUTF8(tk_call_without_enc(*(__cget_cmd << "-#{slot}"))) when /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/ fontcode = $1 fontkey = $2 fnt = tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{fontkey}")), true) unless fnt.kind_of?(TkFont) fnt = fontobj(fontkey) end if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ # obsolete; just for compatibility fnt.kanji_font else fnt end when /^(#{__tkvariable_optkeys.join('|')})$/ v = tk_call_without_enc(*(__cget_cmd << "-#{slot}")) (v.empty?)? nil: TkVarAccess.new(v) else tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{slot}")), true) end end
__config_cmd()
click to toggle source
# File lib/tk.rb, line 3615 def __config_cmd [self.path, 'configure'] end
__configinfo_core(slot = nil)
click to toggle source
# File lib/tk.rb, line 3976 def __configinfo_core(slot = nil) if TkComm::GET_CONFIGINFO_AS_ARRAY if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) fontkey = $2 # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")), false, true) conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] if ( ! __configinfo_struct[:alias] \ || conf.size > __configinfo_struct[:alias] + 1 ) fnt = conf[__configinfo_struct[:default_value]] if TkFont.is_system_font?(fnt) conf[__configinfo_struct[:default_value]] = TkNamedFont.new(fnt) end conf[__configinfo_struct[:current_value]] = fontobj(fontkey) elsif ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 \ && conf[__configinfo_struct[:alias]][0] == ?- ) conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end conf else if slot slot = slot.to_s _, real_name = __optkey_aliases.find{|k, v| k.to_s == slot} if real_name slot = real_name.to_s end case slot when /^(#{__val2ruby_optkeys().keys.join('|')})$/ method = _symbolkey2str(__val2ruby_optkeys())[slot] conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd() << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) optval = conf[__configinfo_struct[:default_value]] begin val = method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG val = optval end conf[__configinfo_struct[:default_value]] = val end if ( conf[__configinfo_struct[:current_value]] ) optval = conf[__configinfo_struct[:current_value]] begin val = method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG val = optval end conf[__configinfo_struct[:current_value]] = val end when /^(#{__methodcall_optkeys.keys.join('|')})$/ method = _symbolkey2str(__methodcall_optkeys)[slot] return [slot, '', '', '', self.__send__(method)] when /^(#{__numval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) begin conf[__configinfo_struct[:default_value]] = number(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil end end if ( conf[__configinfo_struct[:current_value]] ) begin conf[__configinfo_struct[:current_value]] = number(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil end end when /^(#{__numstrval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) conf[__configinfo_struct[:default_value]] = num_or_str(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) conf[__configinfo_struct[:current_value]] = num_or_str(conf[__configinfo_struct[:current_value]]) end when /^(#{__boolval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) begin conf[__configinfo_struct[:default_value]] = bool(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil end end if ( conf[__configinfo_struct[:current_value]] ) begin conf[__configinfo_struct[:current_value]] = bool(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil end end when /^(#{__listval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) conf[__configinfo_struct[:default_value]] = simplelist(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) conf[__configinfo_struct[:current_value]] = simplelist(conf[__configinfo_struct[:current_value]]) end when /^(#{__numlistval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] \ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) conf[__configinfo_struct[:default_value]] = list(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] \ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) conf[__configinfo_struct[:current_value]] = list(conf[__configinfo_struct[:current_value]]) end when /^(#{__strval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) when /^(#{__tkvariable_optkeys.join('|')})$/ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]]) v = conf[__configinfo_struct[:default_value]] if v.empty? conf[__configinfo_struct[:default_value]] = nil else conf[__configinfo_struct[:default_value]] = TkVarAccess.new(v) end end if ( conf[__configinfo_struct[:current_value]] ) v = conf[__configinfo_struct[:current_value]] if v.empty? conf[__configinfo_struct[:current_value]] = nil else conf[__configinfo_struct[:current_value]] = TkVarAccess.new(v) end end else # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) # conf = tk_split_list(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), 0, false, true) conf = tk_split_list(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), 1, false, true) end conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] if ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 \ && conf[__configinfo_struct[:alias]][0] == ?- ) conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end conf else # ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__confinfo_cmd))).collect{|conflist| # conf = tk_split_simplelist(conflist) ret = tk_split_simplelist(tk_call_without_enc(*__confinfo_cmd), false, false).collect{|conflist| conf = tk_split_simplelist(conflist, false, true) conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] optkey = conf[__configinfo_struct[:key]] case optkey when /^(#{__val2ruby_optkeys().keys.join('|')})$/ method = _symbolkey2str(__val2ruby_optkeys())[optkey] if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) optval = conf[__configinfo_struct[:default_value]] begin val = method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG val = optval end conf[__configinfo_struct[:default_value]] = val end if ( conf[__configinfo_struct[:current_value]] ) optval = conf[__configinfo_struct[:current_value]] begin val = method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG val = optval end conf[__configinfo_struct[:current_value]] = val end when /^(#{__strval_optkeys.join('|')})$/ # do nothing when /^(#{__numval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin conf[__configinfo_struct[:default_value]] = number(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil end end if ( conf[__configinfo_struct[:current_value]] ) begin conf[__configinfo_struct[:current_value]] = number(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil end end when /^(#{__numstrval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) conf[__configinfo_struct[:default_value]] = num_or_str(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) conf[__configinfo_struct[:current_value]] = num_or_str(conf[__configinfo_struct[:current_value]]) end when /^(#{__boolval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin conf[__configinfo_struct[:default_value]] = bool(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil end end if ( conf[__configinfo_struct[:current_value]] ) begin conf[__configinfo_struct[:current_value]] = bool(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil end end when /^(#{__listval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) conf[__configinfo_struct[:default_value]] = simplelist(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) conf[__configinfo_struct[:current_value]] = simplelist(conf[__configinfo_struct[:current_value]]) end when /^(#{__numlistval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] \ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) conf[__configinfo_struct[:default_value]] = list(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] \ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) conf[__configinfo_struct[:current_value]] = list(conf[__configinfo_struct[:current_value]]) end when /^(#{__tkvariable_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) v = conf[__configinfo_struct[:default_value]] if v.empty? conf[__configinfo_struct[:default_value]] = nil else conf[__configinfo_struct[:default_value]] = TkVarAccess.new(v) end end if ( conf[__configinfo_struct[:current_value]] ) v = conf[__configinfo_struct[:current_value]] if v.empty? conf[__configinfo_struct[:current_value]] = nil else conf[__configinfo_struct[:current_value]] = TkVarAccess.new(v) end end else if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) if conf[__configinfo_struct[:default_value]].index('{') conf[__configinfo_struct[:default_value]] = tk_split_list(conf[__configinfo_struct[:default_value]]) else conf[__configinfo_struct[:default_value]] = tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) end end if conf[__configinfo_struct[:current_value]] if conf[__configinfo_struct[:current_value]].index('{') conf[__configinfo_struct[:current_value]] = tk_split_list(conf[__configinfo_struct[:current_value]]) else conf[__configinfo_struct[:current_value]] = tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) end end end if ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 \ && conf[__configinfo_struct[:alias]][0] == ?- ) conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end conf } __font_optkeys.each{|optkey| optkey = optkey.to_s fontconf = ret.assoc(optkey) if fontconf && fontconf.size > 2 ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/} fnt = fontconf[__configinfo_struct[:default_value]] if TkFont.is_system_font?(fnt) fontconf[__configinfo_struct[:default_value]] \ = TkNamedFont.new(fnt) end fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) ret.push(fontconf) end } __methodcall_optkeys.each{|optkey, m| ret << [optkey.to_s, '', '', '', self.__send__(m)] } ret end end else # ! TkComm::GET_CONFIGINFO_AS_ARRAY if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) fontkey = $2 # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")), false, true) conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] if ( ! __configinfo_struct[:alias] \ || conf.size > __configinfo_struct[:alias] + 1 ) fnt = conf[__configinfo_struct[:default_value]] if TkFont.is_system_font?(fnt) conf[__configinfo_struct[:default_value]] = TkNamedFont.new(fnt) end conf[__configinfo_struct[:current_value]] = fontobj(fontkey) { conf.shift => conf } elsif ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 ) if conf[__configinfo_struct[:alias]][0] == ?- conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end { conf[0] => conf[1] } else { conf.shift => conf } end else if slot slot = slot.to_s _, real_name = __optkey_aliases.find{|k,var| k.to_s == slot} if real_name slot = real_name.to_s end case slot when /^(#{__val2ruby_optkeys().keys.join('|')})$/ method = _symbolkey2str(__val2ruby_optkeys())[slot] conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) optval = conf[__configinfo_struct[:default_value]] begin val = method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG val = optval end conf[__configinfo_struct[:default_value]] = val end if ( conf[__configinfo_struct[:current_value]] ) optval = conf[__configinfo_struct[:current_value]] begin val = method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG val = optval end conf[__configinfo_struct[:current_value]] = val end when /^(#{__methodcall_optkeys.keys.join('|')})$/ method = _symbolkey2str(__methodcall_optkeys)[slot] return {slot => ['', '', '', self.__send__(method)]} when /^(#{__numval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin conf[__configinfo_struct[:default_value]] = number(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil end end if ( conf[__configinfo_struct[:current_value]] ) begin conf[__configinfo_struct[:current_value]] = number(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil end end when /^(#{__numstrval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) conf[__configinfo_struct[:default_value]] = num_or_str(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) conf[__configinfo_struct[:current_value]] = num_or_str(conf[__configinfo_struct[:current_value]]) end when /^(#{__boolval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin conf[__configinfo_struct[:default_value]] = bool(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil end end if ( conf[__configinfo_struct[:current_value]] ) begin conf[__configinfo_struct[:current_value]] = bool(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil end end when /^(#{__listval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) conf[__configinfo_struct[:default_value]] = simplelist(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) conf[__configinfo_struct[:current_value]] = simplelist(conf[__configinfo_struct[:current_value]]) end when /^(#{__numlistval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] \ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) conf[__configinfo_struct[:default_value]] = list(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] \ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) conf[__configinfo_struct[:current_value]] = list(conf[__configinfo_struct[:current_value]]) end when /^(#{__tkvariable_optkeys.join('|')})$/ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) v = conf[__configinfo_struct[:default_value]] if v.empty? conf[__configinfo_struct[:default_value]] = nil else conf[__configinfo_struct[:default_value]] = TkVarAccess.new(v) end end if ( conf[__configinfo_struct[:current_value]] ) v = conf[__configinfo_struct[:current_value]] if v.empty? conf[__configinfo_struct[:current_value]] = nil else conf[__configinfo_struct[:current_value]] = TkVarAccess.new(v) end end when /^(#{__strval_optkeys.join('|')})$/ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true) else # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")))) conf = tk_split_list(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), 0, false, true) end conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] if ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 ) if conf[__configinfo_struct[:alias]][0] == ?- conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end { conf[0] => conf[1] } else { conf.shift => conf } end else ret = {} # tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__confinfo_cmd))).each{|conflist| # conf = tk_split_simplelist(conflist) tk_split_simplelist(tk_call_without_enc(*__confinfo_cmd), false, false).each{|conflist| conf = tk_split_simplelist(conflist, false, true) conf[__configinfo_struct[:key]] = conf[__configinfo_struct[:key]][1..-1] optkey = conf[__configinfo_struct[:key]] case optkey when /^(#{__val2ruby_optkeys().keys.join('|')})$/ method = _symbolkey2str(__val2ruby_optkeys())[optkey] if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) optval = conf[__configinfo_struct[:default_value]] begin val = method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG val = optval end conf[__configinfo_struct[:default_value]] = val end if ( conf[__configinfo_struct[:current_value]] ) optval = conf[__configinfo_struct[:current_value]] begin val = method.call(optval) rescue => e warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG val = optval end conf[__configinfo_struct[:current_value]] = val end when /^(#{__strval_optkeys.join('|')})$/ # do nothing when /^(#{__numval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin conf[__configinfo_struct[:default_value]] = number(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil end end if ( conf[__configinfo_struct[:current_value]] ) begin conf[__configinfo_struct[:current_value]] = number(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil end end when /^(#{__numstrval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) conf[__configinfo_struct[:default_value]] = num_or_str(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) conf[__configinfo_struct[:current_value]] = num_or_str(conf[__configinfo_struct[:current_value]]) end when /^(#{__boolval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) begin conf[__configinfo_struct[:default_value]] = bool(conf[__configinfo_struct[:default_value]]) rescue conf[__configinfo_struct[:default_value]] = nil end end if ( conf[__configinfo_struct[:current_value]] ) begin conf[__configinfo_struct[:current_value]] = bool(conf[__configinfo_struct[:current_value]]) rescue conf[__configinfo_struct[:current_value]] = nil end end when /^(#{__listval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) conf[__configinfo_struct[:default_value]] = simplelist(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] ) conf[__configinfo_struct[:current_value]] = simplelist(conf[__configinfo_struct[:current_value]]) end when /^(#{__numlistval_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] \ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ ) conf[__configinfo_struct[:default_value]] = list(conf[__configinfo_struct[:default_value]]) end if ( conf[__configinfo_struct[:current_value]] \ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ ) conf[__configinfo_struct[:current_value]] = list(conf[__configinfo_struct[:current_value]]) end when /^(#{__tkvariable_optkeys.join('|')})$/ if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) v = conf[__configinfo_struct[:default_value]] if v.empty? conf[__configinfo_struct[:default_value]] = nil else conf[__configinfo_struct[:default_value]] = TkVarAccess.new end end if ( conf[__configinfo_struct[:current_value]] ) v = conf[__configinfo_struct[:current_value]] if v.empty? conf[__configinfo_struct[:current_value]] = nil else conf[__configinfo_struct[:current_value]] = TkVarAccess.new end end else if ( __configinfo_struct[:default_value] \ && conf[__configinfo_struct[:default_value]] ) if conf[__configinfo_struct[:default_value]].index('{') conf[__configinfo_struct[:default_value]] = tk_split_list(conf[__configinfo_struct[:default_value]]) else conf[__configinfo_struct[:default_value]] = tk_tcl2ruby(conf[__configinfo_struct[:default_value]]) end end if conf[__configinfo_struct[:current_value]] if conf[__configinfo_struct[:current_value]].index('{') conf[__configinfo_struct[:current_value]] = tk_split_list(conf[__configinfo_struct[:current_value]]) else conf[__configinfo_struct[:current_value]] = tk_tcl2ruby(conf[__configinfo_struct[:current_value]]) end end end if ( __configinfo_struct[:alias] \ && conf.size == __configinfo_struct[:alias] + 1 ) if conf[__configinfo_struct[:alias]][0] == ?- conf[__configinfo_struct[:alias]] = conf[__configinfo_struct[:alias]][1..-1] end ret[conf[0]] = conf[1] else ret[conf.shift] = conf end } __font_optkeys.each{|optkey| optkey = optkey.to_s fontconf = ret[optkey] if fontconf.kind_of?(Array) ret.delete(optkey) ret.delete('latin' << optkey) ret.delete('ascii' << optkey) ret.delete('kanji' << optkey) fnt = fontconf[__configinfo_struct[:default_value]] if TkFont.is_system_font?(fnt) fontconf[__configinfo_struct[:default_value]] \ = TkNamedFont.new(fnt) end fontconf[__configinfo_struct[:current_value]] = fontobj(optkey) ret[optkey] = fontconf end } __methodcall_optkeys.each{|optkey, m| ret[optkey.to_s] = ['', '', '', self.__send__(m)] } ret end end end end
__configinfo_struct()
click to toggle source
# File lib/tk.rb, line 3625 def __configinfo_struct {:key=>0, :alias=>1, :db_name=>1, :db_class=>2, :default_value=>3, :current_value=>4} end
__configure_core(slot, value=None)
click to toggle source
# File lib/tk.rb, line 3853 def __configure_core(slot, value=None) if slot.kind_of? Hash slot = _symbolkey2str(slot) __optkey_aliases.each{|alias_name, real_name| alias_name = alias_name.to_s if slot.has_key?(alias_name) slot[real_name.to_s] = slot.delete(alias_name) end } __methodcall_optkeys.each{|key, method| value = slot.delete(key.to_s) self.__send__(method, value) if value } __ruby2val_optkeys.each{|key, method| key = key.to_s slot[key] = method.call(slot[key]) if slot.has_key?(key) } __keyonly_optkeys.each{|defkey, undefkey| conf = slot.find{|kk, vv| kk == defkey.to_s} if conf k, v = conf if v slot[k] = None else slot[undefkey.to_s] = None if undefkey slot.delete(k) end end } if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/}) font_configure(slot) elsif slot.size > 0 tk_call(*(__config_cmd.concat(hash_kv(slot)))) end else orig_slot = slot slot = slot.to_s if slot.length == 0 fail ArgumentError, "Invalid option `#{orig_slot.inspect}'" end _, real_name = __optkey_aliases.find{|k, v| k.to_s == slot} if real_name slot = real_name.to_s end if ( conf = __keyonly_optkeys.find{|k, v| k.to_s == slot} ) defkey, undefkey = conf if value tk_call(*(__config_cmd << "-#{defkey}")) elsif undefkey tk_call(*(__config_cmd << "-#{undefkey}")) end elsif ( method = _symbolkey2str(__ruby2val_optkeys)[slot] ) tk_call(*(__config_cmd << "-#{slot}" << method.call(value))) elsif ( method = _symbolkey2str(__methodcall_optkeys)[slot] ) self.__send__(method, value) elsif (slot =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/) if value == None fontobj($2) else font_configure({slot=>value}) end else tk_call(*(__config_cmd << "-#{slot}" << value)) end end self end
__confinfo_cmd()
click to toggle source
# File lib/tk.rb, line 3620 def __confinfo_cmd __config_cmd end
__conv_keyonly_opts(keys)
click to toggle source
# File lib/tk.rb, line 3704 def __conv_keyonly_opts(keys) return keys unless keys.kind_of?(Hash) keyonly = __keyonly_optkeys keys2 = {} keys.each{|k, v| optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s} if optkey defkey, undefkey = optkey if v keys2[defkey.to_s] = None elsif undefkey keys2[undefkey.to_s] = None else # remove key end else keys2[k.to_s] = v end } keys2 end
__keyonly_optkeys()
click to toggle source
# File lib/tk.rb, line 3699 def __keyonly_optkeys # { def_key=>undef_key or nil, ... } {} end
__listval_optkeys()
click to toggle source
# File lib/tk.rb, line 3662 def __listval_optkeys [] end
__methodcall_optkeys()
click to toggle source
# File lib/tk.rb, line 3692 def __methodcall_optkeys # { key=>method, ... } # The method is used to both of get and set. # Usually, the 'key' will not be a widget option. {} end
__numlistval_optkeys()
click to toggle source
# File lib/tk.rb, line 3667 def __numlistval_optkeys [] end
__numstrval_optkeys()
click to toggle source
# File lib/tk.rb, line 3641 def __numstrval_optkeys [] end
__numval_optkeys()
click to toggle source
# File lib/tk.rb, line 3636 def __numval_optkeys [] end
__optkey_aliases()
click to toggle source
# File lib/tk.rb, line 3631 def __optkey_aliases {} end
__ruby2val_optkeys()
click to toggle source
# File lib/tk.rb, line 3684 def __ruby2val_optkeys # { key=>proc, ... } # The method is used to convert a ruby's object to a opt-value. # When set the value of the option "key", "proc.call(value)" is called. # That is, "-#{key} #{proc.call(value)}". {} end
__strval_optkeys()
click to toggle source
# File lib/tk.rb, line 3651 def __strval_optkeys [ 'text', 'label', 'show', 'data', 'file', 'activebackground', 'activeforeground', 'background', 'disabledforeground', 'disabledbackground', 'foreground', 'highlightbackground', 'highlightcolor', 'insertbackground', 'selectbackground', 'selectforeground', 'troughcolor' ] end
__tkvariable_optkeys()
click to toggle source
# File lib/tk.rb, line 3672 def __tkvariable_optkeys ['variable', 'textvariable'] end
__val2ruby_optkeys()
click to toggle source
# File lib/tk.rb, line 3677 def __val2ruby_optkeys # { key=>proc, ... } # The method is used to convert a opt-value to a ruby's object. # When get the value of the option "key", "proc.call(value)" is called. {} end