diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-12 04:24:55 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-12 04:24:55 +0000 |
commit | 6e0085b137fd9f67ca94862b19e2bc6ae4b1fa4f (patch) | |
tree | 3a3319eb3752722d50b75c3c9083bfe4f536e1c4 /ext/tk/sample | |
parent | 3b3b85666933562a2c07e53608dbb34a61e79c80 (diff) | |
download | ruby-6e0085b137fd9f67ca94862b19e2bc6ae4b1fa4f.tar.gz |
* 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
Diffstat (limited to 'ext/tk/sample')
-rw-r--r-- | ext/tk/sample/tktextframe.rb | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/ext/tk/sample/tktextframe.rb b/ext/tk/sample/tktextframe.rb index 5d16f2b0be..72bc7c1876 100644 --- a/ext/tk/sample/tktextframe.rb +++ b/ext/tk/sample/tktextframe.rb @@ -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', |