2011-09-14 13:25:37 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
2003-07-31 16:52:40 -04:00
|
|
|
#
|
|
|
|
# canvas item types widget demo (called by 'widget')
|
|
|
|
#
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# toplevel widget が存在すれば削除する
|
2003-07-31 16:52:40 -04:00
|
|
|
if defined?($items_demo) && $items_demo
|
2009-03-05 22:56:38 -05:00
|
|
|
$items_demo.destroy
|
2003-07-31 16:52:40 -04:00
|
|
|
$items_demo = nil
|
|
|
|
end
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# demo 用の toplevel widget を生成
|
2003-07-31 16:52:40 -04:00
|
|
|
$items_demo = TkToplevel.new {|w|
|
|
|
|
title("Canvas Item Demonstration")
|
|
|
|
iconname("Items")
|
|
|
|
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($items_demo).pack(:fill=>:both, :expand=>true)
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# label 生成
|
* 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
|
|
|
TkLabel.new(base_frame) {
|
2003-07-31 16:52:40 -04:00
|
|
|
font $font
|
|
|
|
wraplength '5i'
|
|
|
|
justify 'left'
|
2011-09-14 13:25:37 -04:00
|
|
|
text "このウィンドウにはキャンバス widget が入っており、その中にはキャンバス widget がサポートする様々なタイプのアイテムの例が入っています。次のような操作ができます。\n ボタン-1 ドラッグ:\tアイテムを動かす。\n ボタン-2 ドラッグ:\t見えている部分をずらす。\n ボタン-3 ドラッグ:\t領域を囲う。\n コントロール-F:\t領域の下のアイテムを表示する。"
|
2003-07-31 16:52:40 -04:00
|
|
|
}.pack('side'=>'top')
|
|
|
|
|
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
|
|
|
TkFrame.new(base_frame) {|frame|
|
2003-07-31 16:52:40 -04:00
|
|
|
TkButton.new(frame) {
|
2011-09-14 13:25:37 -04:00
|
|
|
#text '了解'
|
|
|
|
text '閉じる'
|
2003-07-31 16:52:40 -04:00
|
|
|
command proc{
|
|
|
|
tmppath = $items_demo
|
|
|
|
$items_demo = nil
|
|
|
|
tmppath.destroy
|
|
|
|
}
|
|
|
|
}.pack('side'=>'left', 'expand'=>'yes')
|
|
|
|
|
|
|
|
TkButton.new(frame) {
|
2011-09-14 13:25:37 -04:00
|
|
|
text 'コード参照'
|
2003-07-31 16:52:40 -04:00
|
|
|
command proc{showCode 'items'}
|
|
|
|
}.pack('side'=>'left', 'expand'=>'yes')
|
|
|
|
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# frame 生成
|
2003-07-31 16:52:40 -04:00
|
|
|
cvs = nil
|
* 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
|
|
|
TkFrame.new(base_frame) {|cf|
|
2011-09-14 13:25:37 -04:00
|
|
|
# canvas 生成
|
2003-07-31 16:52:40 -04:00
|
|
|
cvs = TkCanvas.new(cf) {|c|
|
|
|
|
focus
|
|
|
|
scrollregion '0c 0c 30c 24c'
|
|
|
|
width '15c'
|
|
|
|
height '10c'
|
|
|
|
relief 'sunken'
|
|
|
|
borderwidth 2
|
|
|
|
|
|
|
|
hs = TkScrollbar.new(cf) {|s|
|
|
|
|
orient 'horizontal'
|
|
|
|
command proc{|*args| c.xview(*args)}
|
|
|
|
c.xscrollcommand proc{|first,last| s.set first,last}
|
|
|
|
}
|
|
|
|
|
|
|
|
vs = TkScrollbar.new(cf) {|s|
|
|
|
|
command proc{|*args| c.yview(*args)}
|
|
|
|
c.yscrollcommand proc{|first,last| s.set first,last}
|
|
|
|
}
|
|
|
|
|
|
|
|
if $tk_version =~ /^4\.[01]/
|
|
|
|
hs.pack('side'=>'bottom', 'fill'=>'x')
|
|
|
|
vs.pack('side'=>'right', 'fill'=>'y')
|
|
|
|
c.pack('in'=>cf, 'expand'=>'yes', 'fill'=>'both')
|
|
|
|
|
|
|
|
else
|
2009-03-05 22:56:38 -05:00
|
|
|
c.grid('in'=>cf, 'row'=>0, 'column'=>0,
|
2004-10-11 00:51:21 -04:00
|
|
|
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
|
2009-03-05 22:56:38 -05:00
|
|
|
vs.grid('row'=>0, 'column'=>1,
|
2004-10-11 00:51:21 -04:00
|
|
|
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
|
2009-03-05 22:56:38 -05:00
|
|
|
hs.grid('row'=>1, 'column'=>0,
|
2004-10-11 00:51:21 -04:00
|
|
|
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
|
2003-07-31 16:52:40 -04:00
|
|
|
TkGrid.rowconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
|
|
|
|
TkGrid.columnconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
}
|
|
|
|
}.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
|
|
|
|
|
|
|
|
# Display a 3x3 rectangular grid
|
|
|
|
TkcRectangle.new(cvs, '0c', '0c', '30c', '24c', 'width'=>2)
|
|
|
|
TkcLine.new(cvs, '0c', '8c', '30c', '8c', 'width'=>2)
|
|
|
|
TkcLine.new(cvs, '0c', '16c', '30c', '16c', 'width'=>2)
|
|
|
|
TkcLine.new(cvs, '10c', '0c', '10c', '24c', 'width'=>2)
|
|
|
|
TkcLine.new(cvs, '20c', '0c', '20c', '24c', 'width'=>2)
|
|
|
|
|
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets'
instate/state/identify method to avoid the conflict with standard
widget options. Those methods are renamed to ttk_instate/ttk_state/
ttk_identify (tile_instate/tile_state/tile_identify are available
too). Although I don't recommend, if you realy need old methods,
please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before
"require 'tkextlib/tile'".
* ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!"
is obsolete. It outputs warning. To control default widget set,
use "Tk.default_widget_set = :Ttk".
* ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and
__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind
as module methods of TkConfigMethod. It may help users to wrap old
Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets.
Ttk widgets don't have some options of standard widgets which are
control the view of widgets. When set ignore-mode true, configure
method tries to ignoure such unknown options with no exception.
Of course, it may raise other troubles on the GUI design.
So, those are a little danger methods.
* ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__
method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method
are defind as module methods of TkItemConfigMethod as the same
purpose as TkConfigMethod's ones.
* ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for
wrapping old Ruby/Tk scripts (which use standard widgets) to use
Ttk (Tile) widgets as default.
* ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state
method instead of instate/state method.
* ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb,
ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's
are replaced to "instance_exec(self)".
* ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not
a character code on Ruby1.9).
* ext/tk/lib/tk/variable.rb: support new style of operation argument
on Tcl/Tk's 'trace' command for variables.
* ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix
* ext/tk/sammple/demos-jp/textpeer.rb,
ext/tk/sammple/demos-en/textpeer.rb: new widget demo.
* ext/tk/tcltklib.c: decrase SEGV troubles (probably)
* ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9
* ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably)
* ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command
to make Tcl/Tk theme sources (based on different version of Tile
extension) available.
(Tk::Tile::__define_LoadImages_proc_for_comaptibility__)
* ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames
(Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets
as toplevel widgets.
* ext/tk/lib/tkextlib/tile/style.rb: ditto.
(Tk::Tile::Style.__define_wrapper_proc_for_compatibility__)
* ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get
properties as a hash. metrics_hash method returns a boolean value
for 'fixed' option. But metrics method returns numeric value
(0 or 1) for 'fixed' option, because of backward compatibility.
* ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure.
* ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep
doesn't block the eventloop. It will be better to use the method
in event callbacks.
* ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-29 01:25:12 -04:00
|
|
|
if $tk_version =~ /^4.*/
|
|
|
|
font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
|
|
|
|
font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
|
|
|
|
else
|
|
|
|
font1 = 'Helvetica 12'
|
|
|
|
font2 = 'Helvetica 24 bold'
|
|
|
|
end
|
2003-07-31 16:52:40 -04:00
|
|
|
if TkWinfo.depth($root).to_i > 1
|
|
|
|
blue = 'DeepSkyBlue3'
|
|
|
|
red = 'red'
|
|
|
|
bisque = 'bisque3'
|
|
|
|
green = 'SeaGreen3'
|
|
|
|
else
|
|
|
|
blue = 'black'
|
|
|
|
red = 'black'
|
|
|
|
bisque = 'black'
|
|
|
|
green = 'black'
|
|
|
|
end
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
# tag オブジェクトを生成
|
2003-07-31 16:52:40 -04:00
|
|
|
$tag_item = TkcGroup.new(cvs)
|
|
|
|
|
|
|
|
# Set up demos within each of the areas of the grid.
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '5c', '.2c', 'text'=>'ライン', 'anchor'=>'n')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcLine.new(cvs, '1c', '1c', '3c', '1c', '1c', '4c', '3c', '4c',
|
|
|
|
'width'=>2, 'fill'=>blue, 'capstyle'=>'butt',
|
2004-10-11 00:51:21 -04:00
|
|
|
'join'=>'miter', 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcLine.new(cvs, '4.67c','1c','4.67c','4c', 'arrow'=>'last', 'tags'=>$tag_item)
|
|
|
|
TkcLine.new(cvs, '6.33c','1c','6.33c','4c', 'arrow'=>'both', 'tags'=>$tag_item)
|
|
|
|
TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c',
|
|
|
|
'8.6c','1.4c','8.4c','1.4c','8.4c','4.4c',
|
|
|
|
'width'=>3, 'fill'=>red, 'tags'=>$tag_item )
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'stipple'=>'@'+[$demo_dir,'..',
|
2009-03-05 22:56:38 -05:00
|
|
|
'images','gray25.xbm'].join(File::Separator),
|
2004-10-11 00:51:21 -04:00
|
|
|
'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c',
|
2009-03-05 22:56:38 -05:00
|
|
|
'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round',
|
2004-10-11 00:51:21 -04:00
|
|
|
'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcText.new(cvs, '15c', '.2c',
|
2011-09-14 13:25:37 -04:00
|
|
|
'text'=>'曲線 (滑らかにつないだ直線)', 'anchor'=>'n')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcLine.new(cvs, '11c','4c','11.5c','1c','13.5c','1c','14c','4c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item )
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item )
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'16.5c','4.5c','13.5c','7.5c','12c','6c',
|
2009-03-05 22:56:38 -05:00
|
|
|
'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round',
|
2004-10-11 00:51:21 -04:00
|
|
|
'stipple'=>'@'+[$demo_dir, '..',
|
2009-03-05 22:56:38 -05:00
|
|
|
'images', 'gray25.xbm'].join(File::Separator),
|
2004-10-11 00:51:21 -04:00
|
|
|
'fill'=>red, 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '25c', '.2c', 'text'=>'多角形', 'anchor'=>'n')
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcPolygon.new(cvs, '21c','1.0c','22.5c','1.75c','24c','1.0c','23.25c','2.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c',
|
2009-03-05 22:56:38 -05:00
|
|
|
'fill'=>'green', 'outline'=>'black', 'width'=>4,
|
2004-10-11 00:51:21 -04:00
|
|
|
'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'28c','1c','29c','1c','29c','4c','29c','4c',
|
|
|
|
'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c',
|
2009-03-05 22:56:38 -05:00
|
|
|
'7.5c','22c','7.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'stipple'=>'@' + [$demo_dir, '..',
|
2004-05-01 12:09:54 -04:00
|
|
|
'images', 'gray25.xbm'].join(File::Separator),
|
2004-10-11 00:51:21 -04:00
|
|
|
'outline'=>'black', 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '5c', '8.2c', 'text'=>'矩形', 'anchor'=>'n')
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'fill'=>green, 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'',
|
2004-10-11 00:51:21 -04:00
|
|
|
'stipple'=>'@'+[$demo_dir,'..',
|
|
|
|
'images','gray25.xbm'].join(File::Separator),
|
|
|
|
'fill'=>blue, 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '15c', '8.2c', 'text'=>'楕円', 'anchor'=>'n')
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcOval.new(cvs, '11c','9.5c','14c','12.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'fill'=>green, 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'',
|
2004-10-11 00:51:21 -04:00
|
|
|
'stipple'=>'@'+[$demo_dir,'..',
|
|
|
|
'images','gray25.xbm'].join(File::Separator),
|
|
|
|
'fill'=>blue, 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '25c', '8.2c', 'text'=>'テキスト', 'anchor'=>'n')
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcRectangle.new(cvs, '22.4c','8.9c','22.6c','9.1c')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcText.new(cvs, '22.5c', '9c', 'anchor'=>'n', 'font'=>font1, 'width'=>'4c',
|
2011-09-14 13:25:37 -04:00
|
|
|
'text'=>'短いテキスト。ワードラップ、左揃え、アンカーは北(上)。□は各テキストのアンカーポイントを示す。', 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcRectangle.new(cvs, '25.4c','10.9c','25.6c','11.1c')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue,
|
2011-09-14 13:25:37 -04:00
|
|
|
'text'=>"いくつかの行。\nそれぞれ独立に\n行揃え。\n全て左端がアンカーされている。", 'justify'=>'center', 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c')
|
|
|
|
if $tk_version =~ /^4\.[01]/
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
|
2004-10-11 00:51:21 -04:00
|
|
|
'stipple'=>'@' + [$demo_dir, '..',
|
2003-07-31 16:52:40 -04:00
|
|
|
'images', 'grey.5'].join(File::Separator),
|
2004-10-11 00:51:21 -04:00
|
|
|
'text'=>'Stippled characters', 'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
else
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
|
|
|
|
'stipple'=>'gray50', 'text'=>'Stippled characters',
|
2004-10-11 00:51:21 -04:00
|
|
|
'tags'=>$tag_item )
|
2003-07-31 16:52:40 -04:00
|
|
|
end
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '5c', '16.2c', 'text'=>'弧', 'anchor'=>'n')
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black',
|
2004-10-11 00:51:21 -04:00
|
|
|
'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item)
|
2009-03-05 22:56:38 -05:00
|
|
|
#TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
|
|
|
|
# 'outline'=>blue, 'start'=>135, 'extent'=>270,
|
2004-10-11 00:51:21 -04:00
|
|
|
# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator),
|
|
|
|
# 'tags'=>$tag_item)
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
|
|
|
|
'outline'=>blue, 'start'=>135, 'extent'=>270,
|
2004-10-11 00:51:21 -04:00
|
|
|
'outlinestipple'=>'@'+[$demo_dir, '..',
|
2004-05-01 12:09:54 -04:00
|
|
|
'images','gray25.xbm'].join(File::Separator),
|
2004-10-11 00:51:21 -04:00
|
|
|
'tags'=>$tag_item)
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice',
|
|
|
|
'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90,
|
2004-10-11 00:51:21 -04:00
|
|
|
'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcArc.new(cvs, '5.5c','20.5c','9.5c','23.5c', 'width'=>'4m', 'style'=>'chord',
|
2009-03-05 22:56:38 -05:00
|
|
|
'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270,
|
2004-10-11 00:51:21 -04:00
|
|
|
'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '15c', '16.2c', 'text'=>'ビットマップ', 'anchor'=>'n')
|
2003-07-31 16:52:40 -04:00
|
|
|
#TkcBitmap.new(cvs, '13c','20c',
|
2004-10-11 00:51:21 -04:00
|
|
|
# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator),
|
|
|
|
# 'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcBitmap.new(cvs, '13c','20c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'bitmap'=>'@' + [$demo_dir, '..',
|
2004-05-01 12:09:54 -04:00
|
|
|
'images', 'face.xbm'].join(File::Separator),
|
2004-10-11 00:51:21 -04:00
|
|
|
'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
#TkcBitmap.new(cvs, '17c','18.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator),
|
|
|
|
# 'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcBitmap.new(cvs, '17c','18.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'bitmap'=>'@' + [$demo_dir, '..',
|
|
|
|
'images', 'noletter.xbm'].join(File::Separator),
|
|
|
|
'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
#TkcBitmap.new(cvs, '17c','21.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator),
|
|
|
|
# 'tags'=>$tag_item)
|
2011-09-14 13:25:37 -04:00
|
|
|
# ↓の形式でも可能
|
2003-07-31 16:52:40 -04:00
|
|
|
TkcBitmap.new(cvs, '17c','21.5c') {
|
2004-05-01 12:09:54 -04:00
|
|
|
bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator)
|
2003-07-31 16:52:40 -04:00
|
|
|
tags $tag_item
|
|
|
|
}
|
|
|
|
#TkcBitmap.new(cvs, '17c','21.5c') {
|
|
|
|
# bitmap '@' + ['images', 'letters'].join(File::Separator)
|
|
|
|
# tags $tag_item
|
|
|
|
#}
|
|
|
|
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '25c', '16.2c', 'text'=>'ウィンドウ', 'anchor'=>'n')
|
2003-07-31 16:52:40 -04:00
|
|
|
TkButton.new(cvs) {|b|
|
2011-09-14 13:25:37 -04:00
|
|
|
text '押してね'
|
2003-07-31 16:52:40 -04:00
|
|
|
command proc{butPress cvs, red}
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcWindow.new(cvs, '21c','18c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
}
|
|
|
|
TkEntry.new(cvs, 'width'=>20, 'relief'=>'sunken') {|e|
|
2011-09-14 13:25:37 -04:00
|
|
|
insert 'end', '編集してね'
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcWindow.new(cvs, '21c','21c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
}
|
2009-03-05 22:56:38 -05:00
|
|
|
TkScale.new(cvs, 'from'=>0, 'to'=>100, 'length'=>'6c', 'sliderlength'=>'.4c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'width'=>'.5c', 'tickinterval'=>0 ) {|scl|
|
2009-03-05 22:56:38 -05:00
|
|
|
TkcWindow.new(cvs, '28.5c','17.5c',
|
2004-10-11 00:51:21 -04:00
|
|
|
'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item)
|
2003-07-31 16:52:40 -04:00
|
|
|
}
|
2011-09-14 13:25:37 -04:00
|
|
|
TkcText.new(cvs, '21c', '17.9c', 'text'=>'ボタン:', 'anchor'=>'sw')
|
|
|
|
TkcText.new(cvs, '21c', '20.9c', 'text'=>'エントリ:', 'anchor'=>'sw')
|
|
|
|
TkcText.new(cvs, '28.5c', '17.4c', 'text'=>'スケール:', 'anchor'=>'s')
|
2003-07-31 16:52:40 -04:00
|
|
|
|
|
|
|
# Set up event bindings for canvas:
|
|
|
|
cvs.itembind($tag_item, 'Any-Enter', proc{itemEnter cvs})
|
|
|
|
cvs.itembind($tag_item, 'Any-Leave', proc{itemLeave cvs})
|
|
|
|
cvs.bind('2', proc{|x,y| cvs.scan_mark x,y}, '%x %y')
|
|
|
|
cvs.bind('B2-Motion', proc{|x,y| cvs.scan_dragto x,y}, '%x %y')
|
|
|
|
cvs.bind('3', proc{|x,y| itemMark cvs,x,y}, '%x %y')
|
|
|
|
cvs.bind('B3-Motion', proc{|x,y| itemStroke cvs,x,y}, '%x %y')
|
|
|
|
cvs.bind('Control-f', proc{itemsUnderArea cvs})
|
|
|
|
cvs.bind('1', proc{|x,y| itemStartDrag cvs,x,y}, '%x %y')
|
|
|
|
cvs.bind('B1-Motion', proc{|x,y| itemDrag cvs,x,y}, '%x %y')
|
|
|
|
# Utility methods for highlighting the item under the pointer
|
|
|
|
|
|
|
|
$restoreCmd = nil
|
|
|
|
def itemEnter (c)
|
|
|
|
if TkWinfo.depth(c).to_i == 1
|
|
|
|
$restoreCmd = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
type = c.itemtype('current')
|
|
|
|
if type == TkcWindow
|
|
|
|
$restoreCmd = nil
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if type == TkcBitmap
|
|
|
|
bg = (c.itemconfiginfo('current', 'background'))[4]
|
|
|
|
$restoreCmd = proc{c.itemconfigure 'current', 'background', bg}
|
|
|
|
c.itemconfigure 'current', 'background', 'SteelBlue2'
|
|
|
|
return
|
|
|
|
end
|
|
|
|
fill = (c.itemconfiginfo('current', 'fill'))[4]
|
|
|
|
if (type == TkcRectangle || type == TkcOval || type == TkcArc) && fill == []
|
|
|
|
outline = (c.itemconfiginfo('current', 'outline'))[4]
|
|
|
|
$restoreCmd = proc{c.itemconfigure 'current', 'outline', outline}
|
|
|
|
c.itemconfigure 'current', 'outline', 'SteelBlue2'
|
|
|
|
else
|
|
|
|
$restoreCmd = proc{c.itemconfigure 'current', 'fill', fill}
|
|
|
|
c.itemconfigure 'current', 'fill', 'SteelBlue2'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def itemLeave(c)
|
|
|
|
$restoreCmd.call if $restoreCmd
|
|
|
|
end
|
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
# Utility methods for stroking out a rectangle and printing what's
|
2003-07-31 16:52:40 -04:00
|
|
|
# underneath the rectangle's area.
|
|
|
|
|
|
|
|
def itemMark(c,x,y)
|
|
|
|
$areaX1 = c.canvasx(x)
|
|
|
|
$areaY1 = c.canvasy(y)
|
|
|
|
c.delete 'area'
|
|
|
|
end
|
|
|
|
|
|
|
|
def itemStroke(c,x,y)
|
|
|
|
x = c.canvasx(x)
|
|
|
|
y = c.canvasy(y)
|
|
|
|
if $areaX1 != x && $areaY1 != y
|
|
|
|
c.delete 'area'
|
2009-03-05 22:56:38 -05:00
|
|
|
c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y,
|
2004-10-11 00:51:21 -04:00
|
|
|
'-outline', 'black')
|
2003-07-31 16:52:40 -04:00
|
|
|
$areaX2 = x
|
|
|
|
$areaY2 = y
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def itemsUnderArea(c)
|
|
|
|
area = c.find_withtag('area')
|
|
|
|
items = []
|
|
|
|
c.find_enclosed($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
|
|
|
|
items.push(i) if i.gettags.include?($tag_item)
|
|
|
|
}
|
|
|
|
print "Items enclosed by area: #{items.inspect}\n"; STDOUT.flush
|
|
|
|
items.clear
|
|
|
|
c.find_overlapping($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
|
|
|
|
items.push(i) if i.gettags.include?($tag_item)
|
|
|
|
}
|
|
|
|
print "Items overlapping area: #{items.inspect}\n"; STDOUT.flush
|
|
|
|
end
|
|
|
|
|
|
|
|
$areaX1 = 0
|
|
|
|
$areaY1 = 0
|
|
|
|
$areaX2 = 0
|
|
|
|
$areaY2 = 0
|
|
|
|
|
|
|
|
# Utility methods to support dragging of items.
|
|
|
|
|
|
|
|
def itemStartDrag(c,x,y)
|
|
|
|
$lastX = c.canvasx(x)
|
|
|
|
$lastY = c.canvasy(y)
|
|
|
|
end
|
|
|
|
|
|
|
|
def itemDrag(c,x,y)
|
|
|
|
x = c.canvasx(x)
|
|
|
|
y = c.canvasy(y)
|
2004-05-01 12:09:54 -04:00
|
|
|
c.move('current', x - $lastX, y - $lastY)
|
2003-07-31 16:52:40 -04:00
|
|
|
$lastX = x
|
|
|
|
$lastY = y
|
|
|
|
end
|
|
|
|
|
2009-03-05 22:56:38 -05:00
|
|
|
# Method that's invoked when the button embedded in the canvas
|
2003-07-31 16:52:40 -04:00
|
|
|
# is invoked.
|
|
|
|
|
|
|
|
def butPress(w,color)
|
2009-03-05 22:56:38 -05:00
|
|
|
i = TkcText.new(w, '25c', '18.1c',
|
2011-09-14 13:25:37 -04:00
|
|
|
'text'=>'いてて!!', 'fill'=>color, 'anchor'=>'n')
|
2003-07-31 16:52:40 -04:00
|
|
|
Tk.after(500, proc{w.delete i})
|
|
|
|
end
|