diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-20 15:15:51 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-20 15:15:51 +0000 |
commit | 342aba0b84ebdfeab49f5ef0c6f9750d59e492f8 (patch) | |
tree | ddc1b5fee6d6f69d09339300c38ece9fbded2675 /ext/tk/lib | |
parent | a679f1861fc6ba25127433325e39d04e32c919c9 (diff) | |
download | ruby-342aba0b84ebdfeab49f5ef0c6f9750d59e492f8.tar.gz |
* ext/tk/lib/tk.rb: add new methods (TkScrollbar#assign, assign_list)
* ext/tk/sample/tkmultilistframe.rb: use TkScrollbar#assign method
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib')
-rw-r--r-- | ext/tk/lib/tk.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 692c781677..7de4cd5f24 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -5107,6 +5107,15 @@ class TkScrollbar<TkWindow WidgetClassNames[WidgetClassName] = self def create_self(keys) + @assigned = [] + @scroll_proc = proc{|*args| + if self.orient == 'horizontal' + @assigned.each{|w| w.xview(*args)} + else # 'vertical' + @assigned.each{|w| w.yview(*args)} + end + } + if keys and keys != None tk_call 'scrollbar', @path, *hash_kv(keys) else @@ -5115,6 +5124,32 @@ class TkScrollbar<TkWindow end private :create_self + def assign(*wins) + begin + self.command(@scroll_proc) if self.cget('command').cmd != @scroll_proc + rescue Exception + self.command(@scroll_proc) + end + orient = self.orient + wins.each{|w| + @assigned << w unless @assigned.index(w) + if orient == 'horizontal' + w.xscrollcommand proc{|first, last| self.set(first, last)} + else # 'vertical' + w.yscrollcommand proc{|first, last| self.set(first, last)} + end + } + self + end + + def assigned_list + begin + return @assigned.dup if self.cget('command').cmd == @scroll_proc + rescue Exception + end + fail RuntimeError, "not depend on the assigned_list" + end + def delta(deltax=None, deltay=None) number(tk_send('delta', deltax, deltay)) end @@ -5146,6 +5181,24 @@ class TkScrollbar<TkWindow end end +class TkXScrollbar<TkScrollbar + def create_self(keys) + keys = {} unless keys + keys['orient'] = 'horizontal' + super(keys) + end + private :create_self +end + +class TkYScrollbar<TkScrollbar + def create_self(keys) + keys = {} unless keys + keys['orient'] = 'vertical' + super(keys) + end + private :create_self +end + class TkTextWin<TkWindow def create_self fail RuntimeError, "TkTextWin is an abstract class" |