1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/tk/lib/tk/composite.rb: improve configure methods. (based on the proposal of [ruby-talk:99671])

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2004-05-12 04:24:55 +00:00
parent 3b3b856669
commit 6e0085b137
3 changed files with 308 additions and 18 deletions

View file

@ -35,8 +35,20 @@ class TkTextFrame < TkText
hscroll(keys.delete('hscroll'){true})
# set background of the text widget
=begin
color = keys.delete('textbackground')
textbackground(color) if color
=end
# please check the differences of the following definitions
option_methods(
[:scrollbarwidth, :get_scrollbarwidth],
[:textbackground, nil, :textbg_info],
:textborderwidth,
:textrelief
)
# set receiver widgets for configure methods (with alias)
delegate_alias('scrollbarrelief', 'relief', @h_scroll, @v_scroll)
# set receiver widgets for configure methods
delegate('DEFAULT', @text)
@ -62,6 +74,46 @@ class TkTextFrame < TkText
end
end
def textbg_info
info = @text.configinfo(:background)
if TkComm::GET_CONFIGINFO_AS_ARRAY
info[0] = 'textbackground'
info
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
{'textbackground' => info['background']}
end
end
# get/set borderwidth of text widget
def set_textborderwidth(width)
@text.borderwidth(width)
end
def get_textborderwidth
@text.borderwidth
end
def textborderwidth(width = nil)
if width
set_textborderwidth(width)
else
get_textborderwidth
end
end
# set relief of text widget
def textrelief(type)
@text.relief(type)
end
# get/set width of scrollbar
def get_scrollbarwidth
@v_scroll.width
end
def set_scrollbarwidth(width)
@v_scroll.width(width)
@h_scroll.width(width)
end
alias :scrollbarwidth :set_scrollbarwidth
# vertical scrollbar : ON/OFF
def vscroll(mode)
st = TkGrid.info(@v_scroll)
@ -93,7 +145,11 @@ end
################################################
if __FILE__ == $0
f = TkFrame.new.pack('fill'=>'x')
t = TkTextFrame.new.pack
#t = TkTextFrame.new.pack
t = TkTextFrame.new(:textborderwidth=>3,
:textrelief=>:ridge,
:scrollbarrelief=>:ridge).pack
p t.configinfo
TkButton.new(f, 'text'=>'vscr OFF',
'command'=>proc{t.vscroll(false)}).pack('side'=>'right')
TkButton.new(f, 'text'=>'vscr ON',