aboutsummaryrefslogtreecommitdiffstats
path: root/ext/tk/lib
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-20 15:15:51 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-20 15:15:51 +0000
commit342aba0b84ebdfeab49f5ef0c6f9750d59e492f8 (patch)
treeddc1b5fee6d6f69d09339300c38ece9fbded2675 /ext/tk/lib
parenta679f1861fc6ba25127433325e39d04e32c919c9 (diff)
downloadruby-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.rb53
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"