* encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.
* parse.y (pragma_encoding): encoding specification pragma.
* parse.y (rb_intern3): encoding specified symbols.
* string.c (rb_str_length): length based on characters.
for older behavior, bytesize method added.
* string.c (rb_str_index_m): index based on characters. rindex as
well.
* string.c (succ_char): encoding aware succeeding string.
* string.c (rb_str_reverse): reverse based on characters.
* string.c (rb_str_inspect): encoding aware string description.
* string.c (rb_str_upcase_bang): encoding aware case conversion.
downcase, capitalize, swapcase as well.
* string.c (rb_str_tr_bang): tr based on characters. delete,
squeeze, tr_s, count as well.
* string.c (rb_str_split_m): split based on characters.
* string.c (rb_str_each_line): encoding aware each_line.
* string.c (rb_str_each_char): added. iteration based on
characters.
* string.c (rb_str_strip_bang): encoding aware whitespace
stripping. lstrip, rstrip as well.
* string.c (rb_str_justify): encoding aware justifying (ljust,
rjust, center).
* string.c (str_encoding): get encoding attribute from a string.
* re.c (rb_reg_initialize): encoding aware regular expression
* sprintf.c (rb_str_format): formatting (i.e. length count) based
on characters.
* io.c (rb_io_getc): getc to return one-character string.
for older behavior, getbyte method added.
* ext/stringio/stringio.c (strio_getc): ditto.
* io.c (rb_io_ungetc): allow pushing arbitrary string at the
current reading point.
* ext/stringio/stringio.c (strio_ungetc): ditto.
* ext/strscan/strscan.c: encoding support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 23:29:39 -04:00
|
|
|
|
# -*- coding: euc-jp -*-
|
2003-07-31 16:52:40 -04:00
|
|
|
|
#
|
|
|
|
|
# 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) {
|
2004-05-01 12:09:54 -04:00
|
|
|
|
#text 'λ<><CEBB>'
|
|
|
|
|
text '<27>Ĥ<EFBFBD><C4A4><EFBFBD>'
|
2003-07-31 16:52:40 -04:00
|
|
|
|
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>'
|
2004-05-01 12:09:54 -04:00
|
|
|
|
command proc{showCode 'menu8x'}
|
2003-07-31 16:52:40 -04:00
|
|
|
|
}.pack('side'=>'left', 'expand'=>'yes')
|
|
|
|
|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
|
|
|
|
|
|
|
|
|
else ; # Tk8.x
|
|
|
|
|
|
2005-12-06 11:05:50 -05:00
|
|
|
|
begin
|
|
|
|
|
windowingsystem = Tk.windowingsystem()
|
|
|
|
|
rescue
|
|
|
|
|
windowingsystem = ""
|
|
|
|
|
end
|
|
|
|
|
|
2003-07-31 16:52:40 -04:00
|
|
|
|
# label <20><><EFBFBD><EFBFBD>
|
|
|
|
|
TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
|
2005-12-06 11:05:50 -05:00
|
|
|
|
if $tk_platform['platform'] == 'macintosh' ||
|
|
|
|
|
windowingsystem == "classic" || windowingsystem == "aqua"
|
2003-07-31 16:52:40 -04:00
|
|
|
|
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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2A4B9A4>Ȥ<EFBFBD><C8A4><EFBFBD>Ω<EFBFBD><CEA9><EFBFBD><EFBFBD><EFBFBD>뤳<EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>")
|
|
|
|
|
end
|
|
|
|
|
}.pack('side'=>'top')
|
|
|
|
|
|
|
|
|
|
# <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',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'bd'=>1, 'font'=>['Helvetica', '10'], 'anchor'=>'w')\
|
2003-07-31 16:52:40 -04:00
|
|
|
|
.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) {
|
2004-05-01 12:09:54 -04:00
|
|
|
|
#text 'λ<><CEBB>'
|
|
|
|
|
text '<27>Ĥ<EFBFBD><C4A4><EFBFBD>'
|
2003-07-31 16:52:40 -04:00
|
|
|
|
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>'
|
2004-05-01 12:09:54 -04:00
|
|
|
|
command proc{showCode 'menu8x'}
|
2003-07-31 16:52:40 -04:00
|
|
|
|
}.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})
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-06 11:05:50 -05:00
|
|
|
|
if $tk_platform['platform'] == 'macintosh' ||
|
|
|
|
|
windowingsystem == "classic" || windowingsystem == "aqua"
|
2003-07-31 16:52:40 -04:00
|
|
|
|
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>)",
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'underline'=>14, 'accelerator'=>"Meta+#{c}",
|
|
|
|
|
'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
|
2003-07-31 16:52:40 -04:00
|
|
|
|
$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>)',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'command'=>proc{print "Hello(<28><><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4><EFBFBD>)\n"},
|
|
|
|
|
'accelerator'=>"#{modifier}+H", 'underline'=>6)
|
2003-07-31 16:52:40 -04:00
|
|
|
|
$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>)',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'command'=>proc{print "Goodbye(<28><><EFBFBD>褦<EFBFBD>ʤ<EFBFBD>)\n"},
|
|
|
|
|
'accelerator'=>"#{modifier}+G", 'underline'=>6)
|
2003-07-31 16:52:40 -04:00
|
|
|
|
$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>)',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'menu'=>cascade_check, 'underline'=>0)
|
2003-07-31 16:52:40 -04:00
|
|
|
|
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>',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'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])} )
|
2003-07-31 16:52:40 -04:00
|
|
|
|
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>)',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'menu'=>cascade_radio, 'underline'=>0)
|
2003-07-31 16:52:40 -04:00
|
|
|
|
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>',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'command'=>proc{showVars($menu8x_demo,
|
|
|
|
|
['<27>ݥ<EFBFBD><DDA5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD>', pointSize],
|
|
|
|
|
['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', style])} )
|
2003-07-31 16:52:40 -04:00
|
|
|
|
invoke 1
|
|
|
|
|
invoke 7
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TkMenu.new(m, 'tearoff'=>false) {|icon_menu|
|
|
|
|
|
m.add('cascade', 'label'=>'Icons', 'menu'=>icon_menu, 'underline'=>0)
|
|
|
|
|
add('command',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'bitmap'=>'@'+[$demo_dir,'..',
|
|
|
|
|
'images','pattern.xbm'].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>')} )
|
2003-07-31 16:52:40 -04:00
|
|
|
|
['info', 'questhead', 'error'].each{|icon|
|
|
|
|
|
add('command', 'bitmap'=>icon, 'hidemargin'=>1,
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'command'=>proc{print "You invoked the #{icon} bitmap\n"})
|
2003-07-31 16:52:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'command'=>proc{print "You invoked \"#{i}\"\n"})
|
2003-07-31 16:52:40 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
2004-10-11 00:51:21 -04:00
|
|
|
|
'command'=>proc{print "You invoked \"#{c}\"\n"})
|
2003-07-31 16:52:40 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$menu8x_demo.configure('menu'=>m)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TkMenu.bind('<MenuSelect>',
|
2004-10-11 00:51:21 -04:00
|
|
|
|
proc{|w|
|
|
|
|
|
begin
|
|
|
|
|
label = w.entrycget('active', 'label')
|
|
|
|
|
rescue
|
|
|
|
|
label = ' '
|
|
|
|
|
end
|
|
|
|
|
$menu8xstatus.value = label
|
|
|
|
|
Tk.update('idletasks')
|
|
|
|
|
}, '%W')
|
2003-07-31 16:52:40 -04:00
|
|
|
|
|
|
|
|
|
end ; # Tk 8.x
|