Skip to content

Commit

Permalink
* ext/tk/lib/tk/scrollable.rb: divide Scrollable module into X_Scroll…
Browse files Browse the repository at this point in the history
…able

  and Y_Scrollable
* ext/tk/lib/tk/entry.rb: include X_Scrollable instead of Scrollable
* ext/tk/lib/tk/autoload.rb: define autoload for X_Scrollable and Y_Scrollable


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nagai committed Nov 5, 2004
1 parent 1c222a1 commit b4cb871
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
@@ -1,3 +1,13 @@
Fri Nov 5 18:12:42 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>

* ext/tk/lib/tk/scrollable.rb: divide Scrollable module into
X_Scrollable and Y_Scrollable

* ext/tk/lib/tk/entry.rb: include X_Scrollable instead of Scrollable

* ext/tk/lib/tk/autoload.rb: define autoload for X_Scrollable and
Y_Scrollable

Fri Nov 5 16:05:32 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>

* ext/tk/lib/tk.rb: TkComm._at() supprts both of "@x,y" and "@x"
Expand Down
2 changes: 2 additions & 0 deletions ext/tk/lib/tk/autoload.rb
Expand Up @@ -173,6 +173,8 @@ def TkPlace(*args); TkPlace.configure(*args); end
module Tk
autoload :Clock, 'tk/clock'
autoload :OptionObj, 'tk/optionobj'
autoload :X_Scrollable, 'tk/scrollable'
autoload :Y_Scrollable, 'tk/scrollable'
autoload :Scrollable, 'tk/scrollable'
autoload :Wm, 'tk/wm'

Expand Down
2 changes: 1 addition & 1 deletion ext/tk/lib/tk/entry.rb
Expand Up @@ -9,7 +9,7 @@
require 'tk/validation'

class TkEntry<TkLabel
include Scrollable
include X_Scrollable
include TkValidation

TkCommandNames = ['entry'.freeze].freeze
Expand Down
41 changes: 25 additions & 16 deletions ext/tk/lib/tk/scrollable.rb
Expand Up @@ -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
Expand All @@ -31,6 +26,25 @@ def xview_scroll(*index)
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'))
Expand All @@ -46,16 +60,6 @@ def yview_scroll(*index)
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
Expand All @@ -67,4 +71,9 @@ def yscrollbar(bar=nil)
@yscrollbar
end
end

module Scrollable
include X_Scrollable
include Y_Scrollable
end
end

0 comments on commit b4cb871

Please sign in to comment.