diff options
Diffstat (limited to 'ext/tk/lib/tk/scrollable.rb')
-rw-r--r-- | ext/tk/lib/tk/scrollable.rb | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/ext/tk/lib/tk/scrollable.rb b/ext/tk/lib/tk/scrollable.rb index 74816a9228..ec27b76467 100644 --- a/ext/tk/lib/tk/scrollable.rb +++ b/ext/tk/lib/tk/scrollable.rb @@ -4,17 +4,12 @@ require 'tk' module Tk - module Scrollable + module X_Scrollable def xscrollcommand(cmd=Proc.new) configure_cmd 'xscrollcommand', cmd # Tk.update # avoid scrollbar trouble self end - def yscrollcommand(cmd=Proc.new) - configure_cmd 'yscrollcommand', cmd - # Tk.update # avoid scrollbar trouble - self - end def xview(*index) if index.size == 0 @@ -31,6 +26,25 @@ module Tk xview('scroll', *index) end + def xscrollbar(bar=nil) + if bar + @xscrollbar = bar + @xscrollbar.orient 'horizontal' + self.xscrollcommand {|*arg| @xscrollbar.set(*arg)} + @xscrollbar.command {|*arg| self.xview(*arg)} + Tk.update # avoid scrollbar trouble + end + @xscrollbar + end + end + + module Y_Scrollable + def yscrollcommand(cmd=Proc.new) + configure_cmd 'yscrollcommand', cmd + # Tk.update # avoid scrollbar trouble + self + end + def yview(*index) if index.size == 0 list(tk_send_without_enc('yview')) @@ -46,16 +60,6 @@ module Tk yview('scroll', *index) end - def xscrollbar(bar=nil) - if bar - @xscrollbar = bar - @xscrollbar.orient 'horizontal' - self.xscrollcommand {|*arg| @xscrollbar.set(*arg)} - @xscrollbar.command {|*arg| self.xview(*arg)} - Tk.update # avoid scrollbar trouble - end - @xscrollbar - end def yscrollbar(bar=nil) if bar @yscrollbar = bar @@ -67,4 +71,9 @@ module Tk @yscrollbar end end + + module Scrollable + include X_Scrollable + include Y_Scrollable + end end |