From ce1b23b7a5a496f4b6d3ad4627a161b1dc6945fe Mon Sep 17 00:00:00 2001 From: nagai Date: Thu, 15 Jul 2004 01:18:57 +0000 Subject: * ext/tk/, ext/tcltklib/: bug fix * ext/tk/lib/tk.rb: better operation for SIGINT when processing callbacks. * ext/tk/lib/tk/msgcat.rb: ditto. * ext/tk/lib/tk/variable.rb: ditto. * ext/tk/lib/tk/timer.rb: ditto. * ext/tk/lib/tk/validation.rb: add Tk::ValidateConfigure.__def_validcmd() to define validatecommand methods easier * ext/tk/lib/tk.rb (_genobj_for_tkwidget): support autoload Tk ext classes * ext/tk/lib/tk/canvas.rb and so on: remove the parent widget type check for items (e.g. canvas items; depends on the class) to avoid some troubles on Tk extension widget class definition. * ext/tk/lib/tkextlib/: add Iwidget and TkTable extension support * ext/tk/sample/tkextlib/: add samples of Iwidget and TkTable git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tkextlib/tcllib/autoscroll.rb | 59 +++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 13 deletions(-) (limited to 'ext/tk/lib/tkextlib/tcllib/autoscroll.rb') diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb index 117ed8d98a..d0cb2812cb 100644 --- a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb +++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb @@ -38,31 +38,40 @@ module Tk '' end end + + def self.not_available + fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment." + end + + def self.autoscroll(win) + Tk::Tcllib::Autoscroll.not_available + end + + def self.unautoscroll(win) + Tk::Tcllib::Autoscroll.not_available + end end end end -# TkPackage.require('autoscroll', '1.0') -TkPackage.require('autoscroll') - module Tk module Scrollable def autoscroll(mode = nil) case mode when :x, 'x' if @xscrollbar - tk_send_without_enc('::autoscroll::autoscroll', @xscrollbar) + Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar) end when :y, 'y' if @yscrollbar - tk_send_without_enc('::autoscroll::autoscroll', @yscrollbar) + Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar) end when nil, :both, 'both' if @xscrollbar - tk_send_without_enc('::autoscroll::autoscroll', @xscrollbar) + Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar) end if @yscrollbar - tk_send_without_enc('::autoscroll::autoscroll', @yscrollbar) + Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar) end else fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected" @@ -73,18 +82,18 @@ module Tk case mode when :x, 'x' if @xscrollbar - tk_send_without_enc('::autoscroll::unautoscroll', @xscrollbar) + Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar) end when :y, 'y' if @yscrollbar - tk_send_without_enc('::autoscroll::unautoscroll', @yscrollbar) + Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar) end when nil, :both, 'both' if @xscrollbar - tk_send_without_enc('::autoscroll::unautoscroll', @xscrollbar) + Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar) end if @yscrollbar - tk_send_without_enc('::autoscroll::unautoscroll', @yscrollbar) + Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar) end else fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected" @@ -98,12 +107,36 @@ class TkScrollbar def autoscroll # Arranges for the already existing scrollbar to be mapped # and unmapped as needed. - tk_send_without_enc('::autoscroll::autoscroll', @path) + #tk_call_without_enc('::autoscroll::autoscroll', @path) + Tk::Tcllib::Autoscroll.autoscroll(self) self end def unautoscroll # Returns the scrollbar to its original static state. - tk_send_without_enc('::autoscroll::unautoscroll', @path) + #tk_call_without_enc('::autoscroll::unautoscroll', @path) + Tk::Tcllib::Autoscroll.unautoscroll(self) self end end + +# TkPackage.require('autoscroll', '1.0') +TkPackage.require('autoscroll') + +module Tk + module Tcllib + class << Autoscroll + undef not_available + end + + module Autoscroll + def self.autoscroll(win) + tk_call_without_enc('::autoscroll::autoscroll', win.path) + end + + def self.unautoscroll(win) + tk_call_without_enc('::autoscroll::unautoscroll', win.path) + end + end + end +end + -- cgit v1.2.3