summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tk/composite.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib/tk/composite.rb')
-rw-r--r--ext/tk/lib/tk/composite.rb42
1 files changed, 34 insertions, 8 deletions
diff --git a/ext/tk/lib/tk/composite.rb b/ext/tk/lib/tk/composite.rb
index 9a4aafda18..e267c7a22b 100644
--- a/ext/tk/lib/tk/composite.rb
+++ b/ext/tk/lib/tk/composite.rb
@@ -145,16 +145,34 @@ module TkComposite
str.chop << ' @epath=' << @epath.inspect << '>'
end
+ def _get_opt_method_list(arg)
+ m_set, m_cget, m_info = arg
+ m_set = m_set.to_s
+ m_cget = m_set if !m_cget && self.method(m_set).arity == -1
+ m_cget = m_cget.to_s if m_cget
+ m_info = m_info.to_s if m_info
+ [m_set, m_cget, m_info]
+ end
+ private :_get_opt_method_list
+
def option_methods(*opts)
- opts.each{|m_set, m_cget, m_info|
- m_set = m_set.to_s
- m_cget = m_set if !m_cget && self.method(m_set).arity == -1
- m_cget = m_cget.to_s if m_cget
- m_info = m_info.to_s if m_info
- @option_methods[m_set] = {
- :set => m_set, :cget => m_cget, :info => m_info
+ if opts.size == 1 && opts[0].kind_of?(Hash)
+ # {name => [m_set, m_cget, m_info], name => method} style
+ opts[0].each{|name, arg|
+ m_set, m_cget, m_info = _get_opt_method_list(arg)
+ @option_methods[name.to_s] = {
+ :set => m_set, :cget => m_cget, :info => m_info
+ }
}
- }
+ else
+ # [m_set, m_cget, m_info] or method style
+ opts.each{|arg|
+ m_set, m_cget, m_info = _get_opt_method_list(arg)
+ @option_methods[m_set] = {
+ :set => m_set, :cget => m_cget, :info => m_info
+ }
+ }
+ end
end
def delegate_alias(alias_opt, option, *wins)
@@ -215,6 +233,14 @@ module TkComposite
end
private :__cget_delegates
+ def cget_tkstring(slot)
+ if (ret = __cget_delegates(slot)) == None
+ super(slot)
+ else
+ _get_eval_string(ret)
+ end
+ end
+
def cget(slot)
if (ret = __cget_delegates(slot)) == None
super(slot)