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/bind.rb

126 lines
3.9 KiB
Ruby
Raw Normal View History

#
# text (tag bindings) widget demo (called by 'widget')
#
# toplevel widget <20><>¸<EFBFBD>ߤ<EFBFBD><DFA4><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if defined?($bind_demo) && $bind_demo
$bind_demo.destroy
$bind_demo = nil
end
# demo <20>Ѥ<EFBFBD> toplevel widget <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$bind_demo = TkToplevel.new {|w|
title("Text Demonstration - Tag Bindings")
iconname("bind")
positionWindow(w)
}
# frame <20><><EFBFBD><EFBFBD>
TkFrame.new($bind_demo) {|frame|
TkButton.new(frame) {
#text 'λ<><CEBB>'
text '<27>Ĥ<EFBFBD><C4A4><EFBFBD>'
command proc{
tmppath = $bind_demo
$bind_demo = nil
tmppath.destroy
}
}.pack('side'=>'left', 'expand'=>'yes')
TkButton.new(frame) {
text '<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>'
command proc{showCode 'bind'}
}.pack('side'=>'left', 'expand'=>'yes')
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# bind <20>ѥ᥽<D1A5>å<EFBFBD>
def tag_binding_for_bind_demo(tag, enter_style, leave_style)
tag.bind('Any-Enter', proc{tag.configure enter_style})
tag.bind('Any-Leave', proc{tag.configure leave_style})
end
# text <20><><EFBFBD><EFBFBD>
TkText.new($bind_demo){|t|
# <20><><EFBFBD><EFBFBD>
setgrid 'true'
width 60
height 24
font $font
wrap 'word'
TkScrollbar.new($bind_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')
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if TkWinfo.depth($root).to_i > 1
tagstyle_bold = {'background'=>'#43ce80', 'relief'=>'raised',
'borderwidth'=>1}
tagstyle_normal = {'background'=>'', 'relief'=>'flat'}
else
tagstyle_bold = {'foreground'=>'white', 'background'=>'black'}
tagstyle_normal = {'foreground'=>'', 'background'=>''}
end
# <20>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
insert 'insert', "<EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>widget<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><EFBFBD><EFBFBD>Ȥ<EFBFBD>Tcl<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><EFBF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><EFBFBD><EFBFBD>Υǥ<EFBFBD>Ϥޤ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
"
insert('end', '1. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Х<EFBFBD> widget <20>˺<EFBFBD><CBBA><EFBFBD>ȤΤǤ<CEA4><C7A4><EFBFBD><EBA5A2><EFBFBD>ƥ<EFBFBD><C6A5>μ<EFBFBD><CEBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ˴ؤ<CBB4><D8A4><EFBFBD><EBA5B5><EFBFBD>ץ롣', (d1 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end', '2. <20><>ñ<EFBFBD><C3B1> 2<><32><EFBFBD><EFBFBD><EFBFBD>Υץ<CEA5><D7A5>åȡ<C3A5><C8A1>ǡ<EFBFBD><C7A1><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ư<EFBFBD><C6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>롣', (d2 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end', '3. <20>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>Υ<EFBFBD><CEA5>󥫡<EFBFBD><F3A5ABA1>ȹ<EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>',
(d3 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end', '4. <20><EFBFBD>󥢥<EFBFBD><F3A5A2A5>ƥ<EFBFBD><C6A5>Τ<EFBFBD><CEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƭ<EFBFBD>η<EFBFBD><CEB7>Υ<EFBFBD><CEA5>ǥ<EFBFBD><C7A5><EFBFBD><EFBFBD><EFBFBD>',
(d4 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end', '5. <20><><EFBFBD>֥<EFBFBD><D6A5>ȥåפ<C3A5><D7A4>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>뤿<EFBFBD><EBA4BF><EFBFBD>ε<EFBFBD>ǽ<EFBFBD>Ĥ<EFBFBD><C4A4>Υ<CEA5><EFBFBD><E9A1BC>',
(d5 = TkTextTag.new(t)) )
insert('end', "\n\n")
insert('end',
'6. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Х<EFBFBD><D0A5><EFBFBD><EFBFBD>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD>äƥ<C3A4><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA4B9><EFBFBD>Τ<EFBFBD><CEA4>򼨤<EFBFBD><F2BCA8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åɡ<C3A5>',
(d6 = TkTextTag.new(t)) )
# binding
[d1, d2, d3, d4, d5, d6].each{|tag|
tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal)
}
d1.bind('1',
proc{
eval(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`,
_null_binding)
})
d2.bind('1',
proc{
eval(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`,
_null_binding)
})
d3.bind('1',
proc{
eval(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`,
_null_binding)
})
d4.bind('1',
proc{
eval(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`,
_null_binding)
})
d5.bind('1',
proc{
eval(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`,
_null_binding)
})
d6.bind('1',
proc{
eval(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`,
_null_binding)
})
TkTextMarkInsert.new(t, '0.0')
configure('state','disabled')
}