From fd98eab86abfa7f7a8e72ac7cfc4b614d40d2b9a Mon Sep 17 00:00:00 2001 From: nagai Date: Fri, 30 May 2008 02:16:07 +0000 Subject: [PATCH] * ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: fail to rerun 'showCode' when a 'code' window exists. * ext/tk/sample/demos-en/toolbar.rb, ext/tk/sample/demos-en/ttkprogress.rb: fail to show UTF-8 chars. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/sample/demos-en/toolbar.rb | 10 +++++--- ext/tk/sample/demos-en/ttkprogress.rb | 6 ++--- ext/tk/sample/demos-en/widget | 35 +++++++++++++------------- ext/tk/sample/demos-jp/widget | 36 +++++++++++++-------------- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/ext/tk/sample/demos-en/toolbar.rb b/ext/tk/sample/demos-en/toolbar.rb index 700db68146..5cf863717b 100644 --- a/ext/tk/sample/demos-en/toolbar.rb +++ b/ext/tk/sample/demos-en/toolbar.rb @@ -18,11 +18,12 @@ $toolbar_demo = TkToplevel.new {|w| base_frame = Ttk::Frame.new($toolbar_demo).pack(:fill=>:both, :expand=>true) if Tk.windowingsystem != 'aqua' - msg = Ttk::Label.new(base_frame, :wraplength=>'4i', :text=><'4i', + :text=>Tk::UTF8_String.new(<'4i', :text=><'4i', + :text=>Tk::UTF8_String.new(<:both, :expand=>true) Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left, - :text=><:top, :fill=>:x) + :text=>Tk::UTF8_String.new(<:top, :fill=>:x) Below are two progress bars. \ -The top one is a \u201Cdeterminate\u201D progress bar, \ +The top one is a \\u201Cdeterminate\\u201D progress bar, \ which is used for showing how far through a defined task the program has got. \ -The bottom one is an \u201Cindeterminate\u201D progress bar, \ +The bottom one is an \\u201Cindeterminate\\u201D progress bar, \ which is used to show that the program is busy \ but does not know how long for. Both are run here in self-animated mode, \ which can be turned on and off using the buttons underneath. diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget index dc40f0a95f..2d390d18a3 100644 --- a/ext/tk/sample/demos-en/widget +++ b/ext/tk/sample/demos-en/widget @@ -775,6 +775,12 @@ def showCode1(demo) TkLabel.new(f,'text'=>' pos:').pack('side'=>'left') posnum =TkLabel.new(f,'text'=>'').pack('side'=>'left') + $set_linenum = proc{|w| + line, pos = w.index('insert').split('.') + linenum.text = line + posnum.text = pos + } + f.pack('side'=>'bottom', 'expand'=>'true', 'fill'=>'x') if $tk_version =~ /^4\.[01]/ @@ -837,20 +843,15 @@ def showCode1(demo) btag = TkBindTag.new - set_linenum = proc{|w| - line, pos = w.index('insert').split('.') - linenum.text = line - posnum.text = pos - } - btag.bind('Key', set_linenum, '%W') - btag.bind('Button', set_linenum, '%W') + btag.bind('Key', $set_linenum, '%W') + btag.bind('Button', $set_linenum, '%W') btags = $code_text.bindtags btags.insert(btags.index($code_text.class) + 1, btag) $code_text.bindtags = btags - set_linenum.call($code_text) + $set_linenum.call($code_text) fid.close end @@ -879,6 +880,12 @@ def showCode2(demo) TkLabel.new(lf, :text=>' pos:').pack(:side=>:left) posnum =TkLabel.new(lf, :text=>'').pack(:side=>:left) + $set_linenum = proc{|w| + line, pos = w.index('insert').split('.') + linenum.text = line + posnum.text = pos + } + b_dis = TkButton.new(bf, :text=>'Dismiss', :default=>:active, :command=>proc{ $code_window.destroy @@ -923,20 +930,14 @@ def showCode2(demo) btag = TkBindTag.new - set_linenum = proc{|w| - line, pos = w.index('insert').split('.') - linenum.text = line - posnum.text = pos - } - - btag.bind('Key', set_linenum, '%W') - btag.bind('Button', set_linenum, '%W') + btag.bind('Key', $set_linenum, '%W') + btag.bind('Button', $set_linenum, '%W') btags = $code_text.bindtags btags.insert(btags.index($code_text.class) + 1, btag) $code_text.bindtags = btags - set_linenum.call($code_text) + $set_linenum.call($code_text) fid.close end diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget index 60ec5b5e96..45757fc819 100644 --- a/ext/tk/sample/demos-jp/widget +++ b/ext/tk/sample/demos-jp/widget @@ -814,6 +814,12 @@ def showCode1(demo) TkLabel.new(f,'text'=>' pos:').pack('side'=>'left') posnum =TkLabel.new(f,'text'=>'').pack('side'=>'left') + $set_linenum = proc{|w| + line, pos = w.index('insert').split('.') + linenum.text = line + posnum.text = pos + } + f.pack('side'=>'bottom', 'expand'=>'true', 'fill'=>'x') if $tk_version =~ /^4\.[01]/ @@ -875,20 +881,14 @@ def showCode1(demo) btag = TkBindTag.new - set_linenum = proc{|w| - line, pos = w.index('insert').split('.') - linenum.text = line - posnum.text = pos - } - - btag.bind('Key', set_linenum, '%W') - btag.bind('Button', set_linenum, '%W') + btag.bind('Key', $set_linenum, '%W') + btag.bind('Button', $set_linenum, '%W') btags = $code_text.bindtags btags.insert(btags.index($code_text.class) + 1, btag) $code_text.bindtags = btags - set_linenum.call($code_text) + $set_linenum.call($code_text) fid.close end @@ -917,6 +917,12 @@ def showCode2(demo) TkLabel.new(lf, :text=>' pos:').pack(:side=>:left) posnum =TkLabel.new(lf, :text=>'').pack(:side=>:left) + $set_linenum = proc{|w| + line, pos = w.index('insert').split('.') + linenum.text = line + posnum.text = pos + } + #b_dis = TkButton.new(bf, :text=>'λ²ò', :default=>:active, b_dis = TkButton.new(bf, :text=>'ÊĤ¸¤ë', :default=>:active, :command=>proc{ @@ -962,20 +968,14 @@ def showCode2(demo) btag = TkBindTag.new - set_linenum = proc{|w| - line, pos = w.index('insert').split('.') - linenum.text = line - posnum.text = pos - } - - btag.bind('Key', set_linenum, '%W') - btag.bind('Button', set_linenum, '%W') + btag.bind('Key', $set_linenum, '%W') + btag.bind('Button', $set_linenum, '%W') btags = $code_text.bindtags btags.insert(btags.index($code_text.class) + 1, btag) $code_text.bindtags = btags - set_linenum.call($code_text) + $set_linenum.call($code_text) fid.close end