diff options
Diffstat (limited to 'ext/tk/sample/demos-en/ctext.rb')
-rw-r--r-- | ext/tk/sample/demos-en/ctext.rb | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/ext/tk/sample/demos-en/ctext.rb b/ext/tk/sample/demos-en/ctext.rb index dbb5e32638..8c10880ed6 100644 --- a/ext/tk/sample/demos-en/ctext.rb +++ b/ext/tk/sample/demos-en/ctext.rb @@ -56,19 +56,28 @@ $ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat', $ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both') # font -textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*' +if $tk_version =~ /^4.*/ + textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*' +else + textFont = 'Helvetica 24' +end # canvas TkcRectangle.new($ctext_canvas, 245, 195, 255, 205, 'outline'=>'black', 'fill'=>'red') +ctag_text_param = { + 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).", + 'width'=>440, 'anchor'=>'n', 'justify'=>'left' +} +if $tk_version =~ /^4.*/ + ctag_text_param['font'] = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*' +else + ctag_text_param['font'] = 'Helvetica 24' +end + $ctag_text = TkcTag.new($ctext_canvas) -$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, - 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).", - 'width'=>440, 'anchor'=>'n', - 'font'=>'-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*', - 'kanjifont'=>'-*--24-*-jisx0208.1983-0', - 'justify'=>'left') ) +$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, ctag_text_param)) $ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y") $ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y") @@ -110,9 +119,14 @@ mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50, 'outline'=>'black', 'fill'=>'red') item.bind('1', proc{$ctag_text.configure 'anchor', 'center'}) -TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', 'anchor'=>'s', - 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', - 'fill'=>'brown') +if $tk_version =~ /^4.*/ + TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', + 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', + 'anchor'=>'s', 'fill'=>'brown') +else + TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position', + 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown') +end # Lastly, create some items that allow the text's justification to be # changed. @@ -123,9 +137,14 @@ color = 'SeaGreen2' mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color -TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', 'anchor'=>'s', - 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', - 'fill'=>'brown') +if $tk_version =~ /^4.*/ + TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', + 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*', + 'anchor'=>'s', 'fill'=>'brown') +else + TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification', + 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown') +end $ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas}) $ctext_canvas.itembind('config', 'Leave', |