2
# tk/scrollbar.rb : treat scrollbar widget
6
class TkScrollbar<TkWindow
7
TkCommandNames = ['scrollbar'.freeze].freeze
8
WidgetClassName = 'Scrollbar'.freeze
9
WidgetClassNames[WidgetClassName] = self
13
@scroll_proc = proc{|*args|
14
if self.orient == 'horizontal'
15
@assigned.each{|w| w.xview(*args)}
17
@assigned.each{|w| w.yview(*args)}
21
if keys and keys != None
22
#tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
23
tk_call_without_enc(self.class::TkCommandNames[0], @path,
26
#tk_call_without_enc('scrollbar', @path)
27
tk_call_without_enc(self.class::TkCommandNames[0], @path)
32
def propagate_set(src_win, first, last)
34
if self.orient == 'horizontal'
35
@assigned.each{|w| w.xview('moveto', first) if w != src_win}
37
@assigned.each{|w| w.yview('moveto', first) if w != src_win}
43
self.command(@scroll_proc) if self.cget('command').cmd != @scroll_proc
45
self.command(@scroll_proc)
49
@assigned << w unless @assigned.index(w)
50
if orient == 'horizontal'
51
w.xscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
53
w.yscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
56
Tk.update # avoid scrollbar trouble
62
return @assigned.dup if self.cget('command').cmd == @scroll_proc
65
fail RuntimeError, "not depend on the assigned_list"
70
# Tk.update # avoid scrollbar trouble
74
#def delta(deltax=None, deltay=None)
75
def delta(deltax, deltay)
76
number(tk_send_without_enc('delta', deltax, deltay))
79
#def fraction(x=None, y=None)
81
number(tk_send_without_enc('fraction', x, y))
85
tk_send_without_enc('identify', x, y)
89
#ary1 = tk_send('get').split
95
list(tk_send_without_enc('get'))
99
tk_send_without_enc('set', first, last)
103
def activate(element=None)
104
tk_send_without_enc('activate', element)
108
class TkXScrollbar<TkScrollbar
109
def create_self(keys)
110
keys = {} unless keys
111
keys['orient'] = 'horizontal'
117
class TkYScrollbar<TkScrollbar
118
def create_self(keys)
119
keys = {} unless keys
120
keys['orient'] = 'vertical'