diff options
author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-06 03:44:00 +0000 |
---|---|---|
committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-06 03:44:00 +0000 |
commit | f2db02042b6922805858791f28b7f76a98e7cdd2 (patch) | |
tree | f09e56363548c6d7e9e465b9d6d383d8a775a7c2 /ext/tk/lib/tk.rb | |
parent | 7d917b1f4d081115779d697746851b7d7142d4eb (diff) |
* ext/tk/lib/{tk.rb,tk/itemconfig.rb}: configure creates
TkVariable if key name is 'variable' or 'textvariable'
by default. [ruby-dev:26749]
* ext/tk/lib/tk/{label,radiobutton}.rb: removed its own
{variable,textvariable} function.
* ext/tk/lib/tk/variable.rb: retains backward conpatibility.
(written by Hidetoshi NAGAI)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8933 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tk.rb')
-rw-r--r-- | ext/tk/lib/tk.rb | 101 |
1 files changed, 98 insertions, 3 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 74fa4f38dd..f0f0271047 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -2233,10 +2233,13 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) end def encoding_convertfrom(str, enc=nil) - # str must be a Tcl's internal string expression in enc. + # str is an usual enc string or a Tcl's internal string expression + # in enc (which is returned from 'encoding_convertto' method). # the return value is a UTF-8 string. enc = encoding_system unless enc - TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str) + ret = TkCore::INTERP.__invoke('encoding', 'convertfrom', enc, str) + ret.instance_variable_set('@encoding', 'utf-8') + ret end alias encoding_convert_from encoding_convertfrom @@ -2245,7 +2248,9 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) # The return value is a Tcl's internal string expression in enc. # To get an usual enc string, use Tk.fromUTF8(ret_val, enc). enc = encoding_system unless enc - TkCore::INTERP.__invoke('encoding', 'convertto', enc, str) + ret = TkCore::INTERP.__invoke('encoding', 'convertto', enc, str) + ret.instance_variable_set('@encoding', 'binary') + ret end alias encoding_convert_to encoding_convertto end @@ -2710,6 +2715,11 @@ module TkConfigMethod end private :__numlistval_optkeys + def __tkvariable_optkeys + ['variable', 'textvariable'] + end + private :__tkvariable_optkeys + def __methodcall_optkeys # { key=>method, ... } {} end @@ -2815,6 +2825,10 @@ module TkConfigMethod 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 @@ -2999,6 +3013,28 @@ module TkConfigMethod 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) @@ -3100,6 +3136,25 @@ module TkConfigMethod 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]] ) @@ -3269,6 +3324,27 @@ module TkConfigMethod 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) @@ -3376,6 +3452,25 @@ module TkConfigMethod 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]] ) |