mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
220 lines
8.9 KiB
Ruby
220 lines
8.9 KiB
Ruby
|
#
|
|||
|
# menus widget demo (called by 'widget')
|
|||
|
#
|
|||
|
|
|||
|
# toplevel widget <20><>¸<EFBFBD>ߤ<EFBFBD><DFA4><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if defined?($menu8x_demo) && $menu8x_demo
|
|||
|
$menu8x_demo.destroy
|
|||
|
$menu8x_demo = nil
|
|||
|
end
|
|||
|
|
|||
|
# demo <20>Ѥ<EFBFBD> toplevel widget <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$menu8x_demo = TkToplevel.new {|w|
|
|||
|
title("Menu Demonstration (Tk8.x)")
|
|||
|
iconname("menu")
|
|||
|
positionWindow(w)
|
|||
|
}
|
|||
|
|
|||
|
# version check
|
|||
|
if $tk_version.to_f < 8.0
|
|||
|
|
|||
|
# label <20><><EFBFBD><EFBFBD>
|
|||
|
TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
|
|||
|
text("<EFBFBD>¹Ԥ<EFBFBD><EFBFBD>褦<EFBFBD>Ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ץȤ<EFBFBD> Tk8.0 <20>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѤǤ<D1A4><C7A4>뵡ǽ<EBB5A1><C7BD><EFBFBD><EFBFBD><EFBFBD>Ѥ<EFBFBD><D1A4>Ƥ<EFBFBD><C6A4>뤿<EFBFBD>ᡢ<EFBFBD><E1A1A2><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD> Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} <20>Ǥ<EFBFBD><C7A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˼¹ԤǤ<D4A4><C7A4>ޤ<EFBFBD><DEA4><EFBFBD><F3A1A3A4>äƥǥ<C6A5><C7A5>μ¹Ԥ<C2B9><D4A4><EFBFBD><EFBFBD>ߤ<EFBFBD><DFA4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB>ȥܥ<C8A5><DCA5><EFBFBD><EFBFBD><EFBFBD><F2B2A1A4><EFBFBD><EFBFBD>Ȥǡ<C8A4><C7A1>¹Ԥ<C2B9><D4A4><EFBFBD><EFBFBD>ߤ<EFBFBD><DFA4>줿<EFBFBD><ECA4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ץȤΥ<C8A4><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<F2BBB2BE><C8A4>뤳<EFBFBD>Ȥϲ<C8A4>ǽ<EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>")
|
|||
|
}.pack('side'=>'top')
|
|||
|
|
|||
|
# frame <20><><EFBFBD><EFBFBD>
|
|||
|
TkFrame.new($menu8x_demo) {|frame|
|
|||
|
TkButton.new(frame) {
|
|||
|
text 'λ<><CEBB>'
|
|||
|
command proc{
|
|||
|
tmppath = $menu8x_demo
|
|||
|
$menu8x_demo = nil
|
|||
|
tmppath.destroy
|
|||
|
}
|
|||
|
}.pack('side'=>'left', 'expand'=>'yes')
|
|||
|
|
|||
|
TkButton.new(frame) {
|
|||
|
text '<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>'
|
|||
|
command proc{showCode 'menu'}
|
|||
|
}.pack('side'=>'left', 'expand'=>'yes')
|
|||
|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
|||
|
|
|||
|
else ; # Tk8.x
|
|||
|
|
|||
|
# label <20><><EFBFBD><EFBFBD>
|
|||
|
TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
|
|||
|
if $tk_platform['platform'] == 'macintosh'
|
|||
|
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><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>Command-X <20><><EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD><CFA4><EFBFBD><EFBFBD>ȡ<EFBFBD>X<EFBFBD><58><EFBFBD><EFBFBD><EFBFBD>ޥ<EFBFBD><DEA5>ɥ<EFBFBD><C9A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD>ʤ<EFBFBD><CAA4>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>졼<EFBFBD><ECA1BC><EFBFBD><EFBFBD><EFBFBD>Ȥä<C8A4><C3A4><EFBFBD><EFBFBD>ܵ<EFBFBD>ư<EFBFBD><C6B0><EFBFBD>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
|||
|
|
|||
|
# <20><><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
$menu8xstatus = TkVariable.new(" ")
|
|||
|
TkFrame.new($menu8x_demo) {|frame|
|
|||
|
TkLabel.new(frame, 'textvariable'=>$menu8xstatus, 'relief'=>'sunken',
|
|||
|
'bd'=>1, 'font'=>['Helvetica', '10'], 'anchor'=>'w')\
|
|||
|
.pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
|
|||
|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
|
|||
|
|
|||
|
# frame <20><><EFBFBD><EFBFBD>
|
|||
|
TkFrame.new($menu8x_demo) {|frame|
|
|||
|
TkButton.new(frame) {
|
|||
|
text 'λ<><CEBB>'
|
|||
|
command proc{
|
|||
|
tmppath = $menu8x_demo
|
|||
|
$menu8x_demo = nil
|
|||
|
tmppath.destroy
|
|||
|
}
|
|||
|
}.pack('side'=>'left', 'expand'=>'yes')
|
|||
|
|
|||
|
TkButton.new(frame) {
|
|||
|
text '<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>'
|
|||
|
command proc{showCode 'menu'}
|
|||
|
}.pack('side'=>'left', 'expand'=>'yes')
|
|||
|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
|||
|
|
|||
|
# menu <20><><EFBFBD><EFBFBD>
|
|||
|
TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m|
|
|||
|
TkMenu.new(m, 'tearoff'=>false) {|file_menu|
|
|||
|
m.add('cascade', 'label'=>'File', 'menu'=>file_menu, 'underline'=>0)
|
|||
|
add('command', 'label'=>'<27><><EFBFBD><EFBFBD> ...', 'command'=>proc{fail '<27><><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD><CFA1>ǥ<EFBFBD><C7A5>Ǥ<EFBFBD><C7A4>Τ<EFBFBD>"<22><><EFBFBD><EFBFBD> ..."<22><><EFBFBD>Ф<EFBFBD><D0A4>륢<EFBFBD><EBA5A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>'})
|
|||
|
add('command', 'label'=>'<27><><EFBFBD><EFBFBD>', 'command'=>proc{fail '<27><><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD><CFA1>ǥ<EFBFBD><C7A5>Ǥ<EFBFBD><C7A4>Τ<EFBFBD>"<22><><EFBFBD><EFBFBD>"<22><><EFBFBD>Ф<EFBFBD><D0A4>륢<EFBFBD><EBA5A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>'})
|
|||
|
add('command', 'label'=>'<27><>¸', 'command'=>proc{fail '<27><><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD><CFA1>ǥ<EFBFBD><C7A5>Ǥ<EFBFBD><C7A4>Τ<EFBFBD>"<22><>¸"<22><><EFBFBD>Ф<EFBFBD><D0A4>륢<EFBFBD><EBA5A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>'})
|
|||
|
add('command', 'label'=>'<27><>¸(<28><><EFBFBD><EFBFBD>) ...', 'command'=>proc{fail '<27><><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD><CFA1>ǥ<EFBFBD><C7A5>Ǥ<EFBFBD><C7A4>Τ<EFBFBD>"<22><>¸(<28><><EFBFBD><EFBFBD>) ..."<22><><EFBFBD>Ф<EFBFBD><D0A4>륢<EFBFBD><EBA5A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>'})
|
|||
|
add('separator')
|
|||
|
add('command', 'label'=>'<27>ץ<EFBFBD><D7A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ...', 'command'=>proc{fail '<27><><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD><CFA1>ǥ<EFBFBD><C7A5>Ǥ<EFBFBD><C7A4>Τ<EFBFBD>"<22>ץ<EFBFBD><D7A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ..."<22><><EFBFBD>Ф<EFBFBD><D0A4>륢<EFBFBD><EBA5A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>'})
|
|||
|
add('command', 'label'=>'<27>ץ<EFBFBD><D7A5><EFBFBD><EFBFBD><EFBFBD> ...', 'command'=>proc{fail '<27><><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD><CFA1>ǥ<EFBFBD><C7A5>Ǥ<EFBFBD><C7A4>Τ<EFBFBD>"<22>ץ<EFBFBD><D7A5><EFBFBD><EFBFBD><EFBFBD> ..."<22><><EFBFBD>Ф<EFBFBD><D0A4>륢<EFBFBD><EBA5A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>'})
|
|||
|
add('separator')
|
|||
|
add('command', 'label'=>'<27><>λ', 'command'=>proc{$menu8x_demo.destroy})
|
|||
|
}
|
|||
|
|
|||
|
if $tk_platform['platform'] == 'macintosh'
|
|||
|
modifier = 'Command'
|
|||
|
elsif $tk_platform['platform'] == 'windows'
|
|||
|
modifier = 'Control'
|
|||
|
else
|
|||
|
modifier = 'Meta'
|
|||
|
end
|
|||
|
|
|||
|
TkMenu.new(m, 'tearoff'=>false) {|basic_menu|
|
|||
|
m.add('cascade', 'label'=>'Basic', 'menu'=>basic_menu, 'underline'=>0)
|
|||
|
add('command', 'label'=>'<27><><EFBFBD>⤷<EFBFBD>ʤ<EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD>')
|
|||
|
['A','B','C','D','E','F','G'].each{|c|
|
|||
|
# add('command', 'label'=>"ʸ<><CAB8> \"#{c}\" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 'underline'=>4,
|
|||
|
add('command', 'label'=>"Print letter \"#{c}\" (ʸ<><CAB8> \"#{c}\" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)",
|
|||
|
'underline'=>14, 'accelerator'=>"Meta+#{c}",
|
|||
|
'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
|
|||
|
$menu8x_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
TkMenu.new(m, 'tearoff'=>false) {|cascade_menu|
|
|||
|
m.add('cascade', 'label'=>'Cascades', 'menu'=>cascade_menu, 'underline'=>0)
|
|||
|
add('command', 'label'=>'Print hello(<28><><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>)',
|
|||
|
'command'=>proc{print "Hello(<28><><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>)\n"},
|
|||
|
'accelerator'=>"#{modifier}+H", 'underline'=>6)
|
|||
|
$menu8x_demo.bind("#{modifier}-h", proc{print "Hello(<28><><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>)\n"})
|
|||
|
add('command', 'label'=>'Print goodbye(<28><><EFBFBD>褦<EFBFBD>ʤ<EFBFBD>)',
|
|||
|
'command'=>proc{print "Goodbye(<28><><EFBFBD>褦<EFBFBD>ʤ<EFBFBD>)\n"},
|
|||
|
'accelerator'=>"#{modifier}+G", 'underline'=>6)
|
|||
|
$menu8x_demo.bind("#{modifier}-g", proc{print "Goodbye(<28><><EFBFBD>褦<EFBFBD>ʤ<EFBFBD>)\n"})
|
|||
|
|
|||
|
TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
|
|||
|
cascade_menu.add('cascade', 'label'=>'Check buttons(<28><><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD><C3A5>ܥ<EFBFBD><DCA5><EFBFBD>)',
|
|||
|
'menu'=>cascade_check, 'underline'=>0)
|
|||
|
oil = TkVariable.new(0)
|
|||
|
add('check', 'label'=>'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>oil)
|
|||
|
trans = TkVariable.new(0)
|
|||
|
add('check', 'label'=>'<27>ȥ<EFBFBD><C8A5>ߥå<DFA5><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>trans)
|
|||
|
brakes = TkVariable.new(0)
|
|||
|
add('check', 'label'=>'<27>֥졼<D6A5><ECA1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>brakes)
|
|||
|
lights = TkVariable.new(0)
|
|||
|
add('check', 'label'=>'<27>饤<EFBFBD><E9A5A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>lights)
|
|||
|
add('separator')
|
|||
|
add('command', 'label'=>'<27><><EFBFBD>ߤ<EFBFBD><DFA4>ͤ<EFBFBD>ɽ<EFBFBD><C9BD>',
|
|||
|
'command'=>proc{showVars($menu8x_demo,
|
|||
|
['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', oil],
|
|||
|
['<27>ȥ<EFBFBD><C8A5>ߥå<DFA5><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', trans],
|
|||
|
['<27>֥졼<D6A5><ECA1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', brakes],
|
|||
|
['<27>饤<EFBFBD><E9A5A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', lights])} )
|
|||
|
invoke 1
|
|||
|
invoke 3
|
|||
|
}
|
|||
|
|
|||
|
TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
|
|||
|
cascade_menu.add('cascade', 'label'=>'Radio buttons(<28>饸<EFBFBD><E9A5B8><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD>)',
|
|||
|
'menu'=>cascade_radio, 'underline'=>0)
|
|||
|
pointSize = TkVariable.new
|
|||
|
add('radio', 'label'=>'10 <20>ݥ<EFBFBD><DDA5><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>pointSize, 'value'=>10)
|
|||
|
add('radio', 'label'=>'14 <20>ݥ<EFBFBD><DDA5><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>pointSize, 'value'=>14)
|
|||
|
add('radio', 'label'=>'18 <20>ݥ<EFBFBD><DDA5><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>pointSize, 'value'=>18)
|
|||
|
add('radio', 'label'=>'24 <20>ݥ<EFBFBD><DDA5><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>pointSize, 'value'=>24)
|
|||
|
add('radio', 'label'=>'32 <20>ݥ<EFBFBD><DDA5><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>pointSize, 'value'=>32)
|
|||
|
add('separator')
|
|||
|
style = TkVariable.new
|
|||
|
add('radio', 'label'=>'<27><><EFBFBD><EFBFBD><EFBFBD>ޥ<EFBFBD>', 'variable'=>style, 'value'=>'roman')
|
|||
|
add('radio', 'label'=>'<27>ܡ<EFBFBD><DCA1><EFBFBD><EFBFBD><EFBFBD>', 'variable'=>style, 'value'=>'bold')
|
|||
|
add('radio', 'label'=>'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>å<EFBFBD>', 'variable'=>style, 'value'=>'italic')
|
|||
|
add('separator')
|
|||
|
add('command', 'label'=>'<27><><EFBFBD>ߤ<EFBFBD><DFA4>ͤ<EFBFBD>ɽ<EFBFBD><C9BD>',
|
|||
|
'command'=>proc{showVars($menu8x_demo,
|
|||
|
['<27>ݥ<EFBFBD><DDA5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD>', pointSize],
|
|||
|
['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', style])} )
|
|||
|
invoke 1
|
|||
|
invoke 7
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
TkMenu.new(m, 'tearoff'=>false) {|icon_menu|
|
|||
|
m.add('cascade', 'label'=>'Icons', 'menu'=>icon_menu, 'underline'=>0)
|
|||
|
add('command',
|
|||
|
'bitmap'=>'@'+[$demo_dir,'images','pattern.bmp'].join(File::Separator),
|
|||
|
'hidemargin'=>1,
|
|||
|
'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
|
|||
|
'text'=>'<27><><EFBFBD><EFBFBD><EFBFBD>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F2A4B7A4><EFBFBD><EFBFBD>˥塼<CBA5>ι<EFBFBD><CEB9>ܤϥƥ<CFA5><C6A5><EFBFBD><EFBFBD>ȤǤϤʤ<CFA4><CAA4>ӥåȥޥåפ<C3A5>ɽ<EFBFBD><C9BD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD>¾<EFBFBD>Υ<EFBFBD><CEA5>˥塼<CBA5><E5A1BC><EFBFBD>ܤ<EFBFBD><DCA4>Ѥ<EFBFBD><D1A4><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>',
|
|||
|
'bitmap'=>'', 'default'=>0,
|
|||
|
'buttons'=>'λ<><CEBB>')} )
|
|||
|
['info', 'questhead', 'error'].each{|icon|
|
|||
|
add('command', 'bitmap'=>icon, 'hidemargin'=>1,
|
|||
|
'command'=>proc{print "You invoked the #{icon} bitmap\n"})
|
|||
|
}
|
|||
|
|
|||
|
entryconfigure(2, 'columnbreak'=>1)
|
|||
|
}
|
|||
|
|
|||
|
TkMenu.new(m, 'tearoff'=>false) {|more_menu|
|
|||
|
m.add('cascade', 'label'=>'More', 'menu'=>more_menu, 'underline'=>0)
|
|||
|
[ '<27><><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD>','<27>̤Υ<CCA4><CEA5><EFBFBD><EFBFBD>ȥ<EFBFBD>','<27><><EFBFBD>⤷<EFBFBD>ʤ<EFBFBD>','<27>ۤȤ<DBA4><C8A4>ɲ<EFBFBD><C9B2>⤷<EFBFBD>ʤ<EFBFBD>',
|
|||
|
'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τ<EFBFBD>' ].each{|i|
|
|||
|
add('command', 'label'=>i,
|
|||
|
'command'=>proc{print "You invoked \"#{i}\"\n"})
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
TkMenu.new(m) {|colors_menu|
|
|||
|
m.add('cascade', 'label'=>'Colors', 'menu'=>colors_menu, 'underline'=>1)
|
|||
|
['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
|
|||
|
add('command', 'label'=>c, 'background'=>c,
|
|||
|
'command'=>proc{print "You invoked \"#{c}\"\n"})
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
$menu8x_demo.configure('menu'=>m)
|
|||
|
}
|
|||
|
|
|||
|
TkMenu.bind('<MenuSelect>',
|
|||
|
proc{|w|
|
|||
|
begin
|
|||
|
label = w.entrycget('active', 'label')
|
|||
|
rescue
|
|||
|
label = ' '
|
|||
|
end
|
|||
|
$menu8xstatus.value = label
|
|||
|
Tk.update('idletasks')
|
|||
|
}, '%W')
|
|||
|
|
|||
|
end ; # Tk 8.x
|