From 11dbedfaad4a9a9521ece2198a8dc491678b1902 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 29 Aug 2007 04:06:12 +0000 Subject: add tag v1_8_6_5001 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_5001@13304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby_1_8_6/ext/tk/sample/demos-en/text.rb | 126 ++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 ruby_1_8_6/ext/tk/sample/demos-en/text.rb (limited to 'ruby_1_8_6/ext/tk/sample/demos-en/text.rb') diff --git a/ruby_1_8_6/ext/tk/sample/demos-en/text.rb b/ruby_1_8_6/ext/tk/sample/demos-en/text.rb new file mode 100644 index 0000000000..4bb4b6bc7e --- /dev/null +++ b/ruby_1_8_6/ext/tk/sample/demos-en/text.rb @@ -0,0 +1,126 @@ +# text.rb +# +# This demonstration script creates a text widget that describes +# the basic editing functions. +# +# text (basic facilities) widget demo (called by 'widget') +# + +# toplevel widget +if defined?($text_demo) && $text_demo + $text_demo.destroy + $text_demo = nil +end + +# demo toplevel widget +$text_demo = TkToplevel.new {|w| + title("Text Demonstration - Basic Facilities") + iconname("text") + positionWindow(w) +} + +# version check +if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0) + undo_support = false +else + undo_support = true +end + +# frame +TkFrame.new($text_demo) {|frame| + TkButton.new(frame) { + text 'Dismiss' + command proc{ + tmppath = $text_demo + $text_demo = nil + tmppath.destroy + } + }.pack('side'=>'left', 'expand'=>'yes') + + TkButton.new(frame) { + text 'Show Code' + command proc{showCode 'text'} + }.pack('side'=>'left', 'expand'=>'yes') +}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') + +# text +TkText.new($text_demo){|t| + relief 'sunken' + bd 2 + setgrid 1 + height 30 + if undo_support + undo true + autoseparators true + end + TkScrollbar.new($text_demo) {|s| + pack('side'=>'right', 'fill'=>'y') + command proc{|*args| t.yview(*args)} + t.yscrollcommand proc{|first,last| s.set first,last} + } + pack('expand'=>'yes', 'fill'=>'both') + + # + insert('0.0', <