1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/tk/sample/demos-jp/vscale.rb

78 lines
1.9 KiB
Ruby
Raw Normal View History

require "tkcanvas"
if defined?($vscale_demo) && $vscale_demo
$vscale_demo.destroy
$vscale_demo = nil
end
$vscale_demo = TkToplevel.new {|w|
title("Vertical Scale Demonstration")
iconname("vscale")
}
positionWindow($vscale_demo)
msg = TkLabel.new($vscale_demo) {
font $font
wraplength '3.5i'
justify 'left'
# text "<22><><EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD>ĤȾ<C4A4>ľ<EFBFBD>ʥ<EFBFBD><CAA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뤬ɽ<EBA4AC><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD>\
#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǥޥ<C7A5><DEA5><EFBFBD><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD>1<EFBFBD>򥯥<EFBFBD><F2A5AFA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4>ϥɥ<CFA5><C9A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\
#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>Ѥ<EFBFBD><D1A4><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>"
text "<EFBFBD>ˤϥС<EFBFBD><EFBFBD>Ƚķ<EFBFBD><EFBFBD>Υ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뤬ɽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǥޥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υܥ<EFBFBD><EFBFBD><EFBFBD>1 <20>򥯥<EFBFBD><F2A5AFA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><C9A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD>ƥС<C6A5><D0A1>ι<CEB9><E2A4B5><EFBFBD>Ѥ<EFBFBD><D1A4><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ä<EFBFBD><C3A4><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ץܥ<D7A5><DCA5><EFBFBD><EFBFBD>򲡤<EFBFBD><F2B2A1A4>Ƥ<EFBFBD><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
}
msg.pack('side'=>'top', 'padx'=>'.5c')
TkFrame.new($vscale_demo) {|frame|
TkButton.new(frame) {
text <><CEBB>'
command proc {
tmppath = $vscale_demo
$vscale_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text '<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>'
command proc { showCode 'vscale' }
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
TkFrame.new($vscale_demo) {|frame|
borderwidth 10
canvas = TkCanvas.new(frame) {|c|
width 50
height 50
bd 0
highlightthickness 0
TkcPolygon.new(c, 0, 0, 1, 1, 2, 2) {
fill 'SeaGreen3'
tags 'poly'
}
TkcLine.new(c, 0, 0, 1, 1, 2, 2, 0, 0) {
fill 'black'
tags 'line'
}
}.pack('side'=>'left', 'anchor'=>'nw', 'fill'=>'y')
scale = TkScale.new(frame) {
orient 'vertical'
length 284
from 0
to 250
command proc{|value| setHeight(canvas, value)}
tickinterval 50
}.pack('side'=>'left', 'anchor'=>'ne')
scale.set 75
}.pack
def setHeight(w, height)
height = height + 21
y2 = height - 30
if y2 < 21
y2 = 21
end
w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
end