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

385 lines
14 KiB
Ruby
Raw Normal View History

* 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 -*-
#
# text (embedded windows) widget demo 2 (called by 'widget')
#
# toplevel widget <20><>¸<EFBFBD>ߤ<EFBFBD><DFA4><EFBFBD><EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if defined?($twind2_demo) && $twind2_demo
$twind2_demo.destroy
$twind2_demo = nil
end
# demo <20>Ѥ<EFBFBD> toplevel widget <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$twind2_demo = TkToplevel.new {|w|
title("Text Demonstration - Embedded Windows 2")
iconname("Embedded Windows")
positionWindow(w)
}
* ext/tk/tcltklib.c: SEGV when tcltk-stubs is enabled. * ext/tk/tcltklib.c: avoid error on a shared object. * ext/tk/extconf.rb: support --with-tcltkversion * ext/tk/README.tcltklib: add document about --with-tcltkversion * ext/tk/lib/tk.rb, ext/tk/lib/multi-tk.rb, ext/tk/lib/remote-tk.rb: not work on $SAFE==4 * ext/tk/lib/multi-tk.rb: Object#methods returns Symbols on Ruby1.9. * ext/tk/lib/tk/timer.rb: add TkTimer#at_end(proc) to register the procedure which called at end of the timer. * ext/tk/lib/tk.rb, ext/tk/lib/tk/itemfont.rb, ext/tk/lib/font.rb: support __IGNORE_UNKNOWN_CONFIGURE_OPTION__ about font options. * ext/tk/lib/*: treat __IGNORE_UNKNOWN_CONFIGURE_OPTION__ * ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb, ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb, ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb: bug fix. * ext/tk/lib/tk/text.rb: typo. call a wrong method. * ext/tk/lib/tk/itemconfig.rb: ditto. * ext/tk/lib/tk.rb, ext/tk/lib/tk/itemconfig.rb, ext/tk/lib/tk/canvas.rb: support alias names of option keys. * ext/tk/lib/tk/grid.rb: lack of module-method definitions. * ext/tk/lib/tk/pack.rb, ext/tk/lib/tk/grid.rb: increase supported parameter patterns of configure method. * ext/tk/lib/tk.rb: add TkWindow#grid_anchor, grid_column, grid_row. * ext/tk/lib/tk/wm.rb: methods of Tk::Wm_for_General module cannot pass the given block to methods of Tk::Wm module. * ext/tk/lib/tk/wm.rb: Wm#overrideredirect overwrites arguemnt to an invalid value. * ext/tk/lib/tk.rb: fix memory (object) leak bug. * ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: fix memory leak. * ext/tk/sample/demos-jp/aniwave.rb, ext/tk/sample/demos-en/aniwave.rb: bug fix. * ext/tk/lib/tkextlib/blt/component.rb, ext/tk/lib/tkextlib/tile/tentry.rb, ext/tk/lib/tkextlib/tile/treeview.rb: ditto. * ext/tk/lib/tkextlib/tile/tpaned.rb: improve TPaned#add. * ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget, ext/tk/sample/demos-jp/style.rb, ext/tk/sample/demos-en/style.rb, ext/tk/sample/demos-jp/bind.rb, ext/tk/sample/demos-en/bind.rb: bug fix. * ext/tk/sample/ttk_wrapper.rb: ditto. * ext/tk/sample/ttk_wrapper.rb: support "if __FILE__ == $0" idiom. * ext/tk/sample/tktextio.rb: add binding for 'Ctrl-u' at console mode. * ext/tk/lib/tkextlib/tile.rb, ext/tk/lib/tkextlib/tile/style.rb, ext/tk/sample/ttk_wrapper.rb: improve treating and control themes. add Tk::Tile.themes and Tk::Tile.set_theme(theme). * ext/tk/lib/tkextlib/tile.rb: lack of autoload definitions. * ext/tk/lib/tkextlib/tile/tnotebook.rb: cannot use kanji (not UTF-8) characters for headings. * ext/tk/lib/tkextlib/tkDND/shape.rb: wrong package name. * ext/tk/tkutil/tkutil.c: improve handling callback-subst-keys. Now, support longnam-keys (e.g. '%CTT' on tkdnd-2.0; however, still not support tkdnd-2.0 on tkextlib), and symbols of parameters (e.g. :widget=>'%W', :keycode=>'%k', '%x'=>:x, '%X'=>:root_x, and so on; those are attributes of event object). It means that Ruby/Tk accepts not only "widget.bind(ev, '%W', '%k', ...){|w, k, ...| ... }", but also "widget.bind(ev, :widget, :keycode, ...){|w, k, ...| ... }". It is potentially incompatible, when user passes symbols to the arguments of the callback block (the block receives the symbols as strings). I think that is very rare case (probably, used by Ruby/Tk experts only). When causes such trouble, please give strings instead of such symbol parameters (e.g. call Symbol#to_s method). * ext/tk/lib/tk/event.rb, ext/tk/lib/tk/validation.rb, ext/tk/lib/tkextlib/blt/treeview.rb, ext/tk/lib/tkextlib/winico/winico.rb: ditto. * ext/tk/tkutil/tkutil.c: strings are available on subst_tables on TkUtil::CallbackSubst class (it is useful on Ruby 1.9). * ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tkextlib/iwidgets/hierarchy.rb, ext/tk/lib/tkextlib/iwidgets/spinner.rb, ext/tk/lib/tkextlib/iwidgets/entryfield.rb, ext/tk/lib/tkextlib/iwidgets/calendar.rb, ext/tk/lib/tkextlib/blt/dragdrop.rb, ext/tk/lib/tkextlib/tkDND/tkdnd.rb, ext/tk/lib/tkextlib/treectrl/tktreectrl.rb, ext/tk/lib/tkextlib/tktable/tktable.rb: disable code piece became unnecessary by reason of the changes of ext/tk/tkutil/tkutil.c. * ext/tk/lib/tk.rb, ext/tk/lib/multi-tk.rb: change strategy to define the constant WITH_ENCODING. * ext/tk/lib/tk.rb: fix bug on Tk::Encoding.tk_encoding_names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-10 16:59:10 -04:00
base_frame = TkFrame.new($twind2_demo).pack(:fill=>:both, :expand=>true)
# frame <20><><EFBFBD><EFBFBD>
* ext/tk/tcltklib.c: SEGV when tcltk-stubs is enabled. * ext/tk/tcltklib.c: avoid error on a shared object. * ext/tk/extconf.rb: support --with-tcltkversion * ext/tk/README.tcltklib: add document about --with-tcltkversion * ext/tk/lib/tk.rb, ext/tk/lib/multi-tk.rb, ext/tk/lib/remote-tk.rb: not work on $SAFE==4 * ext/tk/lib/multi-tk.rb: Object#methods returns Symbols on Ruby1.9. * ext/tk/lib/tk/timer.rb: add TkTimer#at_end(proc) to register the procedure which called at end of the timer. * ext/tk/lib/tk.rb, ext/tk/lib/tk/itemfont.rb, ext/tk/lib/font.rb: support __IGNORE_UNKNOWN_CONFIGURE_OPTION__ about font options. * ext/tk/lib/*: treat __IGNORE_UNKNOWN_CONFIGURE_OPTION__ * ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb, ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb, ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb: bug fix. * ext/tk/lib/tk/text.rb: typo. call a wrong method. * ext/tk/lib/tk/itemconfig.rb: ditto. * ext/tk/lib/tk.rb, ext/tk/lib/tk/itemconfig.rb, ext/tk/lib/tk/canvas.rb: support alias names of option keys. * ext/tk/lib/tk/grid.rb: lack of module-method definitions. * ext/tk/lib/tk/pack.rb, ext/tk/lib/tk/grid.rb: increase supported parameter patterns of configure method. * ext/tk/lib/tk.rb: add TkWindow#grid_anchor, grid_column, grid_row. * ext/tk/lib/tk/wm.rb: methods of Tk::Wm_for_General module cannot pass the given block to methods of Tk::Wm module. * ext/tk/lib/tk/wm.rb: Wm#overrideredirect overwrites arguemnt to an invalid value. * ext/tk/lib/tk.rb: fix memory (object) leak bug. * ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: fix memory leak. * ext/tk/sample/demos-jp/aniwave.rb, ext/tk/sample/demos-en/aniwave.rb: bug fix. * ext/tk/lib/tkextlib/blt/component.rb, ext/tk/lib/tkextlib/tile/tentry.rb, ext/tk/lib/tkextlib/tile/treeview.rb: ditto. * ext/tk/lib/tkextlib/tile/tpaned.rb: improve TPaned#add. * ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget, ext/tk/sample/demos-jp/style.rb, ext/tk/sample/demos-en/style.rb, ext/tk/sample/demos-jp/bind.rb, ext/tk/sample/demos-en/bind.rb: bug fix. * ext/tk/sample/ttk_wrapper.rb: ditto. * ext/tk/sample/ttk_wrapper.rb: support "if __FILE__ == $0" idiom. * ext/tk/sample/tktextio.rb: add binding for 'Ctrl-u' at console mode. * ext/tk/lib/tkextlib/tile.rb, ext/tk/lib/tkextlib/tile/style.rb, ext/tk/sample/ttk_wrapper.rb: improve treating and control themes. add Tk::Tile.themes and Tk::Tile.set_theme(theme). * ext/tk/lib/tkextlib/tile.rb: lack of autoload definitions. * ext/tk/lib/tkextlib/tile/tnotebook.rb: cannot use kanji (not UTF-8) characters for headings. * ext/tk/lib/tkextlib/tkDND/shape.rb: wrong package name. * ext/tk/tkutil/tkutil.c: improve handling callback-subst-keys. Now, support longnam-keys (e.g. '%CTT' on tkdnd-2.0; however, still not support tkdnd-2.0 on tkextlib), and symbols of parameters (e.g. :widget=>'%W', :keycode=>'%k', '%x'=>:x, '%X'=>:root_x, and so on; those are attributes of event object). It means that Ruby/Tk accepts not only "widget.bind(ev, '%W', '%k', ...){|w, k, ...| ... }", but also "widget.bind(ev, :widget, :keycode, ...){|w, k, ...| ... }". It is potentially incompatible, when user passes symbols to the arguments of the callback block (the block receives the symbols as strings). I think that is very rare case (probably, used by Ruby/Tk experts only). When causes such trouble, please give strings instead of such symbol parameters (e.g. call Symbol#to_s method). * ext/tk/lib/tk/event.rb, ext/tk/lib/tk/validation.rb, ext/tk/lib/tkextlib/blt/treeview.rb, ext/tk/lib/tkextlib/winico/winico.rb: ditto. * ext/tk/tkutil/tkutil.c: strings are available on subst_tables on TkUtil::CallbackSubst class (it is useful on Ruby 1.9). * ext/tk/lib/tk/spinbox.rb, ext/tk/lib/tkextlib/iwidgets/hierarchy.rb, ext/tk/lib/tkextlib/iwidgets/spinner.rb, ext/tk/lib/tkextlib/iwidgets/entryfield.rb, ext/tk/lib/tkextlib/iwidgets/calendar.rb, ext/tk/lib/tkextlib/blt/dragdrop.rb, ext/tk/lib/tkextlib/tkDND/tkdnd.rb, ext/tk/lib/tkextlib/treectrl/tktreectrl.rb, ext/tk/lib/tkextlib/tktable/tktable.rb: disable code piece became unnecessary by reason of the changes of ext/tk/tkutil/tkutil.c. * ext/tk/lib/tk.rb, ext/tk/lib/multi-tk.rb: change strategy to define the constant WITH_ENCODING. * ext/tk/lib/tk.rb: fix bug on Tk::Encoding.tk_encoding_names. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-10 16:59:10 -04:00
$twind2_buttons = TkFrame.new(base_frame) {|frame|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
TkGrid('x',
TkButton.new(frame, :text=>'<27><><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD>',
:image=>$image['view'], :compound=>:left,
:command=>proc{showCode 'twind2'}),
TkButton.new(frame, :text=>'<27>Ĥ<EFBFBD><C4A4><EFBFBD>',
:image=>$image['delete'], :compound=>:left,
:command=>proc{
tmppath = $twind2_demo
$twind2_demo = nil
$showVarsWin[tmppath.path] = nil
tmppath.destroy
}),
:padx=>4, :pady=>4)
frame.grid_columnconfigure(0, :weight=>1)
}
$twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
# frame <20><><EFBFBD><EFBFBD>
$twind2_text = nil
TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
'relief'=>'sunken') {|f|
$twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font,
# 'width'=>'70', 'height'=>35, 'wrap'=>'word',
'width'=>'70', 'height'=>35, 'wrap'=>'char',
'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
TkScrollbar.new(f) {|s|
command proc{|*args| t.yview(*args)}
t.yscrollcommand proc{|first,last| s.set first,last}
}.pack('side'=>'right', 'fill'=>'y')
}.pack('expand'=>'yes', 'fill'=>'both')
}.pack('expand'=>'yes', 'fill'=>'both')
# <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$tag2_center = TkTextTag.new($twind2_text,
'justify' =>'center',
'spacing1'=>'5m',
'spacing3'=>'5m' )
$tag2_buttons = TkTextTag.new($twind2_text,
'lmargin1'=>'1c',
'lmargin2'=>'1c',
'rmargin' =>'1c',
'spacing1'=>'3m',
'spacing2'=>0,
'spacing3'=>0 )
# <20>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD><EFBFBD>
$twind2_text.insert('end', '<27>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤˤϿ<CBA4><CFBF><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD>ƥ<EFBFBD>')
$twind2_text.insert('end', '<27><>ưŪ<C6B0>ʤ<EFBFBD><CAA4>Τ<EFBFBD><CEA4><EFBFBD>Ū<EFBFBD>ʤ<EFBFBD><CAA4>Τ<EFBFBD>ξ<EFBFBD><CEBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4>ˤ<EFBFBD>')
$twind2_text.insert('end', '<27><>¿<EFBFBD><C2BF><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>')
$twind2_text.insert('end', '<27><><EFBFBD>ؤ<EFBFBD><D8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>ʤɤ<CAA4><C9A4>͡<EFBFBD><CDA1><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD><CBA1>')
$twind2_text.insert('end', '<27><><EFBFBD>֤<EFBFBD><D6A4><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>')
$twind2_text.insert('end', '<27>ä<EFBFBD><C3A4>ơ<EFBFBD><C6A1>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD>ʪ<EFBFBD><CAAA>')
$twind2_text.insert('end', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><C9A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>٤<EFBFBD><D9A4><EFBFBD><E7A4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD>')
$twind2_text.insert('end', '<27><><EFBFBD>٤Ƥ<D9A4><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˥<EFBFBD><CBA5><EFBFBD><E0A1BC><EFBFBD>˥<EFBFBD><CBA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA4B5><EFBFBD><EFBFBD>')
$twind2_text.insert('end', '<27><>ǧ<EFBFBD><C7A7><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD>ǽ<EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>')
$twind2_text.insert('end', "\n\n")
$twind2_text.insert('end', '<27>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȾ<C3A5><C8BE>ˤ<EFBFBD>¾<EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5>')
$twind2_text.insert('end', '<27>ޤ<EFBFBD><DEA4><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τ<EFBFBD>')
$twind2_text.insert('end', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߥ<EFBFBD><DFA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><C9A5>פȸƤФ졢<D0A4><ECA1A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
$twind2_text.insert('end', '<27><><EFBFBD><EFBFBD><EFBFBD>ʤ륦<CAA4><EBA5A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤǤ<C8A4><C7A4>ͤ<EFBFBD><CDA4><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>')
$twind2_text.insert('end', '<27><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤϣ<CBA4><CFA3>Ĥ<EFBFBD>')
$twind2_text.insert('end', '<27>ܥ<EFBFBD><DCA5>󥦥<EFBFBD><F3A5A6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD>')
$twind2_text.insert('end', '<27>ǽ<EFBFBD><C7BD>Υܥ<CEA5><DCA5><EFBFBD><EFBFBD>򥯥<EFBFBD><F2A5AFA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>')
$twind2_text.insert('end', '<27><>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ')
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text) {
#text 'ON'
text '<27><><EFBFBD><EFBFBD>'
command proc{textWindOn2 $twind2_text,$twind2_buttons}
cursor 'top_left_arrow'
})
$twind2_text.insert('end', "<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>\n")
$twind2_text.insert('end', '<27><>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD>Υ<EFBFBD><CEA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text) {
#text 'OFF'
text '<27><><EFBFBD><EFBFBD>'
command proc{textWindOff2 $twind2_text}
cursor 'top_left_arrow'
})
$twind2_text.insert('end', "<EFBFBD>ˤ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>\n\n")
$twind2_text.insert('end', '<27><><EFBFBD>Ϥ⤦<CFA4>ҤȤĤ<C8A4><C4A4><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>')
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text) {
text '<27><><EFBFBD><EFBFBD><EFBFBD>򥯥<EFBFBD><F2A5AFA5>å<EFBFBD>'
command proc{textWindPlot2 $twind2_text}
cursor 'top_left_arrow'
})
$twind2_text.insert('end', '<27><><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>x-y<>ץ<EFBFBD><D7A5>åȤ<C3A5><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>')
$mark2_plot = TkTextMark.new($twind2_text, 'insert')
$mark2_plot.gravity='left'
$twind2_text.insert('end', '<27>ޥ<EFBFBD><DEA5><EFBFBD><EFBFBD>ǥɥ<C7A5><C9A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD>Ȥǡ<C8A4>')
$twind2_text.insert('end', '<27>ץ<EFBFBD><D7A5>åȾ<C3A5><C8BE>Υǡ<CEA5><C7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ư<EFBFBD><C6B0><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>')
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text) {
text '<27>õ<EFBFBD>'
command proc{textWindDel2 $twind2_text}
cursor 'top_left_arrow'
})
$twind2_text.insert('end', '<27>򥯥<EFBFBD><F2A5AFA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȸ<EFBFBD><C8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>')
$twind2_text.insert('end', "\n\n")
$twind2_text.insert('end', <><C9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>Ȥʤ<C8A4><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߥ<EFBFBD><DFA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɥ<EFBFBD><C9A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
$twind2_text.insert('end', '<27>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ˴ޤ<CBB4><DEA4><EFBFBD>Ȥ<EFBFBD>ͭ<EFBFBD>ѤǤ<D1A4><C7A4><EFBFBD><E7A4A6>')
$twind2_text.insert('end', '<27><><EFBFBD>ξ<EFBFBD><CEBE><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5>')
$twind2_text.insert('end', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5>ޥ͡<DEA5><CDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Τ<CEA4><E8A4A6>Ư<EFBFBD><C6AF><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>')
$twind2_text.insert('end', '<27><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤϥƥ<CFA5><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5>')
$twind2_text.insert('end', '<27><><EFBFBD>äƥܥ<C6A5><DCA5>󤬤<EFBFBD><F3A4ACA4><EFBFBD><ECA4A4><EFBFBD><EFBFBD><EFBFBD>󤷤<EFBFBD><F3A4B7A4><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>ޤ<EFBFBD><DEA4><EFBFBD>')
$twind2_text.insert('end', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Υܥ<CEA5><DCA5><EFBFBD><EFBFBD>򥯥<EFBFBD><F2A5AFA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD>Ȥǡ<C8A4>')
$twind2_text.insert('end', '<27><><EFBFBD>Υƥ<CEA5><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4>طʿ<D8B7><CABF><EFBFBD>')
$twind2_text.insert('end', '<27>Ѥ<EFBFBD><D1A4><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD>("<22>ǥե<C7A5><D5A5><EFBFBD><EFBFBD><EFBFBD>"<22>ܥ<EFBFBD><DCA5><EFBFBD><EFBFBD><EFBFBD>')
$twind2_text.insert('end', '<27><><EFBFBD>ο<EFBFBD><CEBF><EFBFBD><EFBFBD><EFBFBD><E1A4B9><EFBFBD>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD>)<29><>')
$twind2_text.insert('end', '"Short"<22>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD><EFBFBD>򥯥<EFBFBD><F2A5AFA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD>')
$twind2_text.insert('end', '<27>Ѥ<EFBFBD><D1A4><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<C3A5><C8A4><EFBFBD>ưŪ<C6B0><C5AA>')
$twind2_text.insert('end', '<27><EFBFBD><ECA5A4><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻҤ򸫤뤳<F2B8ABA4>Ȥ<EFBFBD><C8A4>Ǥ<EFBFBD><C7A4>ޤ<EFBFBD><DEA4><EFBFBD>')
$twind2_text.insert('end', '<27><EFBFBD><E2A4A6><EFBFBD><EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>ܥ<EFBFBD><DCA5><EFBFBD><EFBFBD>򲡤<EFBFBD><F2B2A1A4>ȸ<EFBFBD><C8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>')
$twind2_text.insert('end', "\n")
btn_default = TkButton.new($twind2_text) {|b|
text '<27>ǥե<C7A5><D5A5><EFBFBD><EFBFBD><EFBFBD>'
command proc{embDefBg2 $twind2_text}
cursor 'top_left_arrow'
}
TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3)
embToggle = TkVariable.new('Short')
TkTextWindow.new($twind2_text, 'end',
'window'=>TkCheckButton.new($twind2_text) {
textvariable embToggle
indicatoron 0
variable embToggle
onvalue 'A much longer string'
offvalue 'Short'
cursor 'top_left_arrow'
pady 5
padx 2
},
'padx'=>3,
'pady'=>2 )
[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
].each{|twind_color|
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text) {
text twind_color
cursor 'top_left_arrow'
command proc{$twind2_text.bg twind_color}
},
'padx'=>3,
'pady'=>2 )
}
$tag2_buttons.add(btn_default, 'end')
$text_normal2 = {}
$text_normal2['border'] = $twind2_text.cget('borderwidth')
$text_normal2['highlight'] = $twind2_text.cget('highlightthickness')
$text_normal2['pad'] = $twind2_text.cget('padx')
$twind2_text.insert('end', "\nborder width <20><> highlightthickness, ")
$twind2_text.insert('end', "padding <20><><EFBFBD>̾<EFBFBD><CCBE><EFBFBD><EFBFBD>ͤ<EFBFBD><CDA4><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD>ǽ<EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>\n")
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text, :text=>"Big borders",
:cursor=>'top_left_arrow',
'command'=>proc{
textWinBigB2 $twind2_text
}))
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text, :text=>"Small borders",
:cursor=>'top_left_arrow',
'command'=>proc{
textWinSmallB2 $twind2_text
}))
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text, :text=>"Big highlight",
:cursor=>'top_left_arrow',
'command'=>proc{
textWinBigH2 $twind2_text
}))
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text, :text=>"Small highlight",
:cursor=>'top_left_arrow',
'command'=>proc{
textWinSmallH2 $twind2_text
}))
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text, :text=>"Big pad",
:cursor=>'top_left_arrow',
'command'=>proc{
textWinBigP2 $twind2_text
}))
TkTextWindow.new($twind2_text, 'end',
'window'=>TkButton.new($twind2_text, :text=>"Small pad",
:cursor=>'top_left_arrow',
'command'=>proc{
textWinSmallP2 $twind2_text
}))
$twind2_text.insert('end', "\n\n<EFBFBD><EFBFBD><EFBFBD>˥<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>åȤ<EFBFBD>")
$twind2_text.insert('end', "<EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤Ǥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>")
TkTextImage.new($twind2_text, 'end',
'image'=>TkBitmapImage.new(:file=>[
$demo_dir, '..',
'images', 'face.xbm'
].join(File::Separator)))
# <20><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD>
def textWinBigB2(w)
w.borderwidth 15
end
def textWinSmallB2(w)
w.borderwidth $text_normal2['border']
end
def textWinBigH2(w)
w.highlightthickness 15
end
def textWinSmallH2(w)
w.highlightthickness $text_normal2['highlight']
end
def textWinBigP2(w)
w.configure(:padx=>15, :pady=>15)
end
def textWinSmallP2(w)
w.configure(:padx=>$text_normal2['pad'], :pady=>$text_normal2['pad'])
end
def textWindOn2 (w,f)
if defined? $twind2_scroll
begin
$twind2_scroll.destroy
rescue
end
$twind2_scroll = nil
end
base = TkWinfo.parent( TkWinfo.parent(w) )
$twind2_scroll = TkScrollbar.new(base) {|s|
orient 'horizontal'
command proc{|*args| w.xview(*args)}
w.xscrollcommand proc{|first,last| s.set first,last}
w.wrap 'none'
pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
}
return nil
end
def textWindOff2 (w)
if defined? $twind2_scroll
begin
$twind2_scroll.destroy
rescue
end
$twind2_scroll = nil
end
w.xscrollcommand ''
#w.wrap 'word'
w.wrap 'char'
end
def textWindPlot2 (t)
if (defined? $twind2_plot) && (TkWinfo.exist?($twind2_plot))
return
end
$twind2_plot = TkCanvas.new(t) {
relief 'sunken'
width 450
height 300
cursor 'top_left_arrow'
}
#font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
font = 'Helvetica 18'
TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2)
TkcLine.new($twind2_plot, 100, 250, 100, 50, 'width'=>2)
TkcText.new($twind2_plot, 225, 20,
'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
(0..10).each {|i|
x = 100 + (i * 30)
TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2)
TkcText.new($twind2_plot, x, 254,
'text'=>10*i, 'font'=>font, 'anchor'=>'n')
}
(0..5).each {|i|
y = 250 - (i * 40)
TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2)
TkcText.new($twind2_plot, 96, y,
'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
}
for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
x = 100 + (3*xx)
y = 250 - (4*yy)/5
item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6,
'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
item.addtag 'point'
end
$twind2_plot.itembind('point', 'Any-Enter',
proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'})
$twind2_plot.itembind('point', 'Any-Leave',
proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
$twind2_plot.itembind('point', '1',
proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y")
$twind2_plot.itembind('point', 'ButtonRelease-1',
proc{$twind2_plot.dtag 'selected'})
$twind2_plot.bind('B1-Motion',
proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y")
while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
$twind2_text.delete $mark2_plot
end
$twind2_text.insert $mark2_plot,"\n"
TkTextWindow.new($twind2_text, $mark2_plot, 'window'=>$twind2_plot)
$tag2_center.add $mark2_plot
$twind2_text.insert $mark2_plot,"\n"
end
$embPlot2 = {'lastX'=>0, 'lastY'=>0}
def embPlotDown2 (w, x, y)
w.dtag 'selected'
w.addtag_withtag 'selected', 'current'
w.raise 'current'
$embPlot2['lastX'] = x
$embPlot2['lastY'] = y
end
def embPlotMove2 (w, x, y)
w.move 'selected', x - $embPlot2['lastX'], y - $embPlot2['lastY']
$embPlot2['lastX'] = x
$embPlot2['lastY'] = y
end
def textWindDel2 (w)
if (defined? $twind2_text) && TkWinfo.exist?($twind2_plot)
$twind2_text.delete $twind2_plot
$twind2_plot = nil
while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
$twind2_text.delete $mark2_plot
end
$twind2_text.insert $mark2_plot," "
end
end
def embDefBg2 (w)
w['background'] = w.configinfo('background')[3]
end