summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-15 01:18:57 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-15 01:18:57 +0000
commitce1b23b7a5a496f4b6d3ad4627a161b1dc6945fe (patch)
treed7dca8b035286a8a852c021318fa04a4efa43aa8 /ext/tk/lib/tkextlib/tcllib/autoscroll.rb
parent6c6a24826c5fda68e04e71ac17620b0e70bca265 (diff)
* 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
Diffstat (limited to 'ext/tk/lib/tkextlib/tcllib/autoscroll.rb')
-rw-r--r--ext/tk/lib/tkextlib/tcllib/autoscroll.rb59
1 files changed, 46 insertions, 13 deletions
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
+