2011-09-14 13:25:37 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
2004-05-01 12:09:54 -04:00
|
|
|
#
|
|
|
|
# text (embedded windows) widget demo 2 (called by 'widget')
|
|
|
|
#
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# toplevel widget が存在すれば削除する
|
2004-05-01 12:09:54 -04:00
|
|
|
if defined?($twind2_demo) && $twind2_demo
|
2009-03-05 22:56:38 -05:00
|
|
|
$twind2_demo.destroy
|
2004-05-01 12:09:54 -04:00
|
|
|
$twind2_demo = nil
|
|
|
|
end
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# demo 用の toplevel widget を生成
|
2004-05-01 12:09:54 -04:00
|
|
|
$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)
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# frame 生成
|
* 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|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
|
2004-10-11 00:51:21 -04:00
|
|
|
:columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
|
2009-03-05 22:56:38 -05:00
|
|
|
TkGrid('x',
|
2011-09-14 13:25:37 -04:00
|
|
|
TkButton.new(frame, :text=>'コード参照',
|
2009-03-05 22:56:38 -05:00
|
|
|
:image=>$image['view'], :compound=>:left,
|
|
|
|
:command=>proc{showCode 'twind2'}),
|
2011-09-14 13:25:37 -04:00
|
|
|
TkButton.new(frame, :text=>'閉じる',
|
2009-03-05 22:56:38 -05:00
|
|
|
:image=>$image['delete'], :compound=>:left,
|
2004-10-11 00:51:21 -04:00
|
|
|
:command=>proc{
|
|
|
|
tmppath = $twind2_demo
|
|
|
|
$twind2_demo = nil
|
|
|
|
$showVarsWin[tmppath.path] = nil
|
|
|
|
tmppath.destroy
|
2009-03-05 22:56:38 -05:00
|
|
|
}),
|
2004-10-11 00:51:21 -04:00
|
|
|
:padx=>4, :pady=>4)
|
2004-05-01 12:09:54 -04:00
|
|
|
frame.grid_columnconfigure(0, :weight=>1)
|
|
|
|
}
|
|
|
|
$twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# frame 生成
|
2004-05-01 12:09:54 -04:00
|
|
|
$twind2_text = nil
|
2009-03-05 22:56:38 -05:00
|
|
|
TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
|
2004-10-11 00:51:21 -04:00
|
|
|
'relief'=>'sunken') {|f|
|
2004-05-01 12:09:54 -04:00
|
|
|
$twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font,
|
2009-03-05 22:56:38 -05:00
|
|
|
# 'width'=>'70', 'height'=>35, 'wrap'=>'word',
|
|
|
|
'width'=>'70', 'height'=>35, 'wrap'=>'char',
|
2004-10-11 00:51:21 -04:00
|
|
|
'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
|
2004-05-01 12:09:54 -04:00
|
|
|
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')
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# タグ生成
|
2009-03-05 22:56:38 -05:00
|
|
|
$tag2_center = TkTextTag.new($twind2_text,
|
2004-10-11 00:51:21 -04:00
|
|
|
'justify' =>'center',
|
|
|
|
'spacing1'=>'5m',
|
|
|
|
'spacing3'=>'5m' )
|
2009-03-05 22:56:38 -05:00
|
|
|
$tag2_buttons = TkTextTag.new($twind2_text,
|
2004-10-11 00:51:21 -04:00
|
|
|
'lmargin1'=>'1c',
|
|
|
|
'lmargin2'=>'1c',
|
|
|
|
'rmargin' =>'1c',
|
|
|
|
'spacing1'=>'3m',
|
|
|
|
'spacing2'=>0,
|
|
|
|
'spacing3'=>0 )
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# テキストの生成
|
|
|
|
$twind2_text.insert('end', 'テキストウィジェットには色々な種類のアイテム')
|
|
|
|
$twind2_text.insert('end', '(動的なものや静的なものの両方があります)を')
|
|
|
|
$twind2_text.insert('end', '数多く含めることができます。そうしたアイテムは')
|
|
|
|
$twind2_text.insert('end', '行替え、タブ、中央揃えなどの様々な方法で')
|
|
|
|
$twind2_text.insert('end', '配置することができます。')
|
|
|
|
$twind2_text.insert('end', '加えて、テキストウィジェットの内容物が')
|
|
|
|
$twind2_text.insert('end', 'ウィンドウサイズに比べて大きすぎる場合でも')
|
|
|
|
$twind2_text.insert('end', 'すべての方向にスムーズにスクロールさせて')
|
|
|
|
$twind2_text.insert('end', '確認することが可能です。')
|
2004-05-01 12:09:54 -04:00
|
|
|
$twind2_text.insert('end', "\n\n")
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', 'テキストウィジェット上には他のウィジェットを')
|
|
|
|
$twind2_text.insert('end', '含めることもできます。こうしたものは')
|
|
|
|
$twind2_text.insert('end', '「埋め込みウィンドウ」と呼ばれ、その中に')
|
|
|
|
$twind2_text.insert('end', 'いかなるウィジェットでも詰め込むことができます。')
|
|
|
|
$twind2_text.insert('end', '例えば,ここには2つの')
|
|
|
|
$twind2_text.insert('end', 'ボタンウィジェットが埋め込まれています。')
|
|
|
|
$twind2_text.insert('end', '最初のボタンをクリックすると、')
|
|
|
|
$twind2_text.insert('end', '水平方向のスクロールを ')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>TkButton.new($twind2_text) {
|
|
|
|
#text 'ON'
|
2011-09-14 13:25:37 -04:00
|
|
|
text 'オン'
|
2004-10-11 00:51:21 -04:00
|
|
|
command proc{textWindOn2 $twind2_text,$twind2_buttons}
|
|
|
|
cursor 'top_left_arrow'
|
|
|
|
})
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', "にします。また、2つめのボタンをクリックすると\n")
|
|
|
|
$twind2_text.insert('end', '水平方向のスクロールを')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>TkButton.new($twind2_text) {
|
|
|
|
#text 'OFF'
|
2011-09-14 13:25:37 -04:00
|
|
|
text 'オフ'
|
2004-10-11 00:51:21 -04:00
|
|
|
command proc{textWindOff2 $twind2_text}
|
|
|
|
cursor 'top_left_arrow'
|
|
|
|
})
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', "にします。\n\n")
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', '次はもうひとつの例です。')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>TkButton.new($twind2_text) {
|
2011-09-14 13:25:37 -04:00
|
|
|
text 'ここをクリック'
|
2004-10-11 00:51:21 -04:00
|
|
|
command proc{textWindPlot2 $twind2_text}
|
|
|
|
cursor 'top_left_arrow'
|
|
|
|
})
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', 'すると、x-yプロットがここに現れます。')
|
2004-05-01 12:09:54 -04:00
|
|
|
$mark2_plot = TkTextMark.new($twind2_text, 'insert')
|
|
|
|
$mark2_plot.gravity='left'
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', 'マウスでドラッグすることで、')
|
|
|
|
$twind2_text.insert('end', 'プロット上のデータ点を移動することができます。')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>TkButton.new($twind2_text) {
|
2011-09-14 13:25:37 -04:00
|
|
|
text '消去'
|
2004-10-11 00:51:21 -04:00
|
|
|
command proc{textWindDel2 $twind2_text}
|
|
|
|
cursor 'top_left_arrow'
|
|
|
|
})
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', 'をクリックすると元に戻ります。')
|
2004-05-01 12:09:54 -04:00
|
|
|
$twind2_text.insert('end', "\n\n")
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', '表示するテキストなしに埋め込みウィンドウだけを')
|
|
|
|
$twind2_text.insert('end', 'テキストウィジェットに含めることも有用でしょう。')
|
|
|
|
$twind2_text.insert('end', 'この場合、テキストウィジェットは')
|
|
|
|
$twind2_text.insert('end', 'ジオメトリマネージャのように働きます。')
|
|
|
|
$twind2_text.insert('end', '例えば、ここにはテキストウィジェットに')
|
|
|
|
$twind2_text.insert('end', 'よってボタンがきれいに整列して配置されています。')
|
|
|
|
$twind2_text.insert('end', 'これらのボタンをクリックすることで、')
|
|
|
|
$twind2_text.insert('end', 'このテキストウィジェットの背景色を')
|
|
|
|
$twind2_text.insert('end', '変えることができます("デフォルト"ボタンで')
|
|
|
|
$twind2_text.insert('end', '元の色に戻すことができます)。')
|
|
|
|
$twind2_text.insert('end', '"Short"というボタンをクリックすると文字列の長さが')
|
|
|
|
$twind2_text.insert('end', '変わり、テキストウィジェットが自動的に')
|
|
|
|
$twind2_text.insert('end', 'レイアウトを整える様子を見ることができます。')
|
|
|
|
$twind2_text.insert('end', 'もう一度同じボタンを押すと元に戻ります。')
|
2004-05-01 12:09:54 -04:00
|
|
|
$twind2_text.insert('end', "\n")
|
|
|
|
|
|
|
|
btn_default = TkButton.new($twind2_text) {|b|
|
2011-09-14 13:25:37 -04:00
|
|
|
text 'デフォルト'
|
2004-05-01 12:09:54 -04:00
|
|
|
command proc{embDefBg2 $twind2_text}
|
|
|
|
cursor 'top_left_arrow'
|
|
|
|
}
|
|
|
|
TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3)
|
|
|
|
embToggle = TkVariable.new('Short')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
2004-10-11 00:51:21 -04:00
|
|
|
'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
|
|
|
|
},
|
2009-03-05 22:56:38 -05:00
|
|
|
'padx'=>3,
|
2004-10-11 00:51:21 -04:00
|
|
|
'pady'=>2 )
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
|
|
|
|
'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
|
|
|
|
'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
|
|
|
|
'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
|
2004-05-01 12:09:54 -04:00
|
|
|
].each{|twind_color|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>TkButton.new($twind2_text) {
|
|
|
|
text twind_color
|
|
|
|
cursor 'top_left_arrow'
|
|
|
|
command proc{$twind2_text.bg twind_color}
|
|
|
|
},
|
2009-03-05 22:56:38 -05:00
|
|
|
'padx'=>3,
|
2004-10-11 00:51:21 -04:00
|
|
|
'pady'=>2 )
|
2004-05-01 12:09:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$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')
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', "\nborder width や highlightthickness, ")
|
|
|
|
$twind2_text.insert('end', "padding を通常の値から変更することも可能です。\n")
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
|
|
|
'window'=>TkButton.new($twind2_text, :text=>"Big borders",
|
|
|
|
:cursor=>'top_left_arrow',
|
2004-10-11 00:51:21 -04:00
|
|
|
'command'=>proc{
|
|
|
|
textWinBigB2 $twind2_text
|
|
|
|
}))
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
|
|
|
'window'=>TkButton.new($twind2_text, :text=>"Small borders",
|
|
|
|
:cursor=>'top_left_arrow',
|
2004-10-11 00:51:21 -04:00
|
|
|
'command'=>proc{
|
|
|
|
textWinSmallB2 $twind2_text
|
|
|
|
}))
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
|
|
|
'window'=>TkButton.new($twind2_text, :text=>"Big highlight",
|
|
|
|
:cursor=>'top_left_arrow',
|
2004-10-11 00:51:21 -04:00
|
|
|
'command'=>proc{
|
|
|
|
textWinBigH2 $twind2_text
|
|
|
|
}))
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>TkButton.new($twind2_text, :text=>"Small highlight",
|
2009-03-05 22:56:38 -05:00
|
|
|
:cursor=>'top_left_arrow',
|
2004-10-11 00:51:21 -04:00
|
|
|
'command'=>proc{
|
|
|
|
textWinSmallH2 $twind2_text
|
|
|
|
}))
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
|
|
|
'window'=>TkButton.new($twind2_text, :text=>"Big pad",
|
|
|
|
:cursor=>'top_left_arrow',
|
2004-10-11 00:51:21 -04:00
|
|
|
'command'=>proc{
|
|
|
|
textWinBigP2 $twind2_text
|
|
|
|
}))
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextWindow.new($twind2_text, 'end',
|
|
|
|
'window'=>TkButton.new($twind2_text, :text=>"Small pad",
|
|
|
|
:cursor=>'top_left_arrow',
|
2004-10-11 00:51:21 -04:00
|
|
|
'command'=>proc{
|
|
|
|
textWinSmallP2 $twind2_text
|
|
|
|
}))
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
$twind2_text.insert('end', "\n\n更にイメージもテキストウィジェットに")
|
|
|
|
$twind2_text.insert('end', "うまく配置できます:")
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkTextImage.new($twind2_text, 'end',
|
2004-10-11 00:51:21 -04:00
|
|
|
'image'=>TkBitmapImage.new(:file=>[
|
2009-03-05 22:56:38 -05:00
|
|
|
$demo_dir, '..',
|
2004-10-11 00:51:21 -04:00
|
|
|
'images', 'face.xbm'
|
|
|
|
].join(File::Separator)))
|
2004-05-01 12:09:54 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# メソッド定義
|
2004-05-01 12:09:54 -04:00
|
|
|
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)
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcText.new($twind2_plot, 225, 20,
|
2004-10-11 00:51:21 -04:00
|
|
|
'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
|
2004-05-01 12:09:54 -04:00
|
|
|
|
|
|
|
(0..10).each {|i|
|
|
|
|
x = 100 + (i * 30)
|
|
|
|
TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2)
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcText.new($twind2_plot, x, 254,
|
2004-10-11 00:51:21 -04:00
|
|
|
'text'=>10*i, 'font'=>font, 'anchor'=>'n')
|
2004-05-01 12:09:54 -04:00
|
|
|
}
|
|
|
|
(0..5).each {|i|
|
|
|
|
y = 250 - (i * 40)
|
|
|
|
TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2)
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcText.new($twind2_plot, 96, y,
|
2004-10-11 00:51:21 -04:00
|
|
|
'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
|
2004-05-01 12:09:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2009-03-05 22:56:38 -05:00
|
|
|
item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6,
|
2004-10-11 00:51:21 -04:00
|
|
|
'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
|
2004-05-01 12:09:54 -04:00
|
|
|
item.addtag 'point'
|
|
|
|
end
|
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
$twind2_plot.itembind('point', 'Any-Enter',
|
2004-10-11 00:51:21 -04:00
|
|
|
proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'})
|
2009-03-05 22:56:38 -05:00
|
|
|
$twind2_plot.itembind('point', 'Any-Leave',
|
2004-10-11 00:51:21 -04:00
|
|
|
proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
|
2009-03-05 22:56:38 -05:00
|
|
|
$twind2_plot.itembind('point', '1',
|
2004-10-11 00:51:21 -04:00
|
|
|
proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y")
|
2009-03-05 22:56:38 -05:00
|
|
|
$twind2_plot.itembind('point', 'ButtonRelease-1',
|
2004-10-11 00:51:21 -04:00
|
|
|
proc{$twind2_plot.dtag 'selected'})
|
2009-03-05 22:56:38 -05:00
|
|
|
$twind2_plot.bind('B1-Motion',
|
2004-10-11 00:51:21 -04:00
|
|
|
proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y")
|
2004-05-01 12:09:54 -04:00
|
|
|
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
|