mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
af0c875e26
commit
e6697a6405
220 changed files with 7112 additions and 1277 deletions
117
ChangeLog
117
ChangeLog
|
@ -1,3 +1,120 @@
|
|||
Wed Jun 11 05:55:31 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* 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.
|
||||
|
||||
Wed Jun 11 03:40:37 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* lib/find.rb (Find#find): Return an enumerator if no block is
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2008-05-12 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tkextlib/tkDND/shape.rb: wrong package name.
|
||||
|
||||
--------------< ... some changes ... >------------------
|
||||
|
||||
2007-05-26 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||
|
||||
* ext/tk/lib/tkextlib/tcllib/tablelist.rb: fix typo.
|
||||
|
|
|
@ -5,10 +5,14 @@ Tcl/Tk libraries or header files are installed but are not found, you can
|
|||
give the information by arguments of the 'configure' script. Please give
|
||||
some or all of the following options.
|
||||
|
||||
--with-tcltkversion=<version>
|
||||
force version of Tcl/Tk libaray
|
||||
(e.g. libtcl8.4g.so ==> --with-tcltkversion=8.4g)
|
||||
|
||||
--with-tcllib=<libname> (e.g. libtcl8.4.so ==> --with-tcllib=tcl8.4)
|
||||
--with-tklib=<libname> (e.g. libtk8.4.so ==> --with-tklib=tk8.4)
|
||||
|
||||
--enable-tcltk_stubs (if you force to enable stubs)
|
||||
--enable-tcltk-stubs (if you force to enable stubs)
|
||||
|
||||
--with-tcl-dir=<path>
|
||||
equal to "--with-tcl-include=<path>/include --with-tcl-lib=<path>/lib"
|
||||
|
|
|
@ -48,15 +48,60 @@ tk_ldir2 = with_config("tk-lib")
|
|||
tcl_ldir2 = with_config("tcl-lib")
|
||||
x11_ldir2 = with_config("X11-lib")
|
||||
|
||||
tk_ldir_list = [tk_ldir2, tk_ldir]
|
||||
tcl_ldir_list = [tcl_ldir2, tcl_ldir]
|
||||
|
||||
tklib = with_config("tklib")
|
||||
tcllib = with_config("tcllib")
|
||||
stubs = enable_config("tcltk_stubs") || with_config("tcltk_stubs")
|
||||
|
||||
tcltk_version = with_config("tcltkversion")
|
||||
|
||||
use_X = with_config("X11", (! is_win32))
|
||||
|
||||
def find_tcl(tcllib, stubs, *opt_paths)
|
||||
def check_tcltk_version(version)
|
||||
return [nil, nil] unless version
|
||||
|
||||
version = version.strip
|
||||
|
||||
tclver = version.dup
|
||||
tkver = version.dup
|
||||
|
||||
major = dot = minor = dot = plvl = ext = nil
|
||||
|
||||
if version =~ /^(\d)(\.?)(\d)(\.?)(\d*)(.*)$/
|
||||
major = $1; minor_dot = $2; minor = $3; plvl_dot = $4; plvl = $5; ext = $6
|
||||
dot = ! minor_dot.empty?
|
||||
if plvl_dot.empty? && ! plvl.empty?
|
||||
minor << plvl
|
||||
end
|
||||
elsif version =~ /^(\d)(\.?)(\d?)(.*)$/
|
||||
major = $1; minor_dot = $2; minor = $3; ext = $4
|
||||
dot = ! minor_dot.empty?
|
||||
else # unknown -> believe user
|
||||
return [tclver, tkver]
|
||||
end
|
||||
|
||||
# check Tcl7.6 / Tk4.2 ?
|
||||
if major == "7" # Tcl7.6 ( not support Tclversion < 7.6 )
|
||||
# Tk4.2
|
||||
tkver = "4" + ((dot)? ".": "") + ((minor.empty)? "": "2") + ext
|
||||
elsif major == "4" # Tk4.2 ( not support Tkversion < 4.2 )
|
||||
# Tcl7.6
|
||||
tclver = "7" + ((dot)? ".": "") + ((minor.empty)? "": "6") + ext
|
||||
end
|
||||
|
||||
[tclver, tkver]
|
||||
end
|
||||
|
||||
def find_tcl(tcllib, stubs, version, *opt_paths)
|
||||
default_paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
|
||||
paths = opt_paths.compact.concat(default_paths)
|
||||
default_paths << "/Tcl/lib" # default for ActiveTcl
|
||||
|
||||
if (paths = opt_paths.compact).empty?
|
||||
paths = default_paths
|
||||
end
|
||||
|
||||
if stubs
|
||||
func = "Tcl_InitStubs"
|
||||
lib = "tclstub"
|
||||
|
@ -64,25 +109,42 @@ def find_tcl(tcllib, stubs, *opt_paths)
|
|||
func = "Tcl_FindExecutable"
|
||||
lib = "tcl"
|
||||
end
|
||||
if tcllib
|
||||
find_library(tcllib, func, *paths)
|
||||
|
||||
if version && ! version.empty?
|
||||
versions = [version]
|
||||
else
|
||||
%w[8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.6].find { |ver|
|
||||
find_library("#{lib}#{ver}", func, *paths) or
|
||||
find_library("#{lib}#{ver.delete('.')}", func, *paths) or
|
||||
find_library("#{lib}#{ver}g", func, *paths) or
|
||||
find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
|
||||
find_library("tcl#{ver}", func, *paths) or
|
||||
find_library("tcl#{ver.delete('.')}", func, *paths) or
|
||||
find_library("tcl#{ver}g", func, *paths) or
|
||||
find_library("tcl#{ver.delete('.')}g", func, *paths)
|
||||
} || find_library(lib, func, *paths)
|
||||
versions = %w[8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.6]
|
||||
end
|
||||
|
||||
if tcllib
|
||||
st = find_library(tcllib, func, *paths)
|
||||
else
|
||||
st = versions.find { |ver|
|
||||
find_library("#{lib}#{ver}", func, *paths) or
|
||||
find_library("#{lib}#{ver.delete('.')}", func, *paths) or
|
||||
find_library("#{lib}#{ver}g", func, *paths) or
|
||||
find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
|
||||
find_library("tcl#{ver}", func, *paths) or
|
||||
find_library("tcl#{ver.delete('.')}", func, *paths) or
|
||||
find_library("tcl#{ver}g", func, *paths) or
|
||||
find_library("tcl#{ver.delete('.')}g", func, *paths)
|
||||
} || (!version && find_library(lib, func, *paths))
|
||||
end
|
||||
|
||||
unless st
|
||||
puts("Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
|
||||
end
|
||||
st
|
||||
end
|
||||
|
||||
def find_tk(tklib, stubs, *opt_paths)
|
||||
def find_tk(tklib, stubs, version, *opt_paths)
|
||||
default_paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
|
||||
paths = opt_paths.compact.concat(default_paths)
|
||||
default_paths << "/Tcl/lib" # default for ActiveTcl
|
||||
|
||||
if (paths = opt_paths.compact).empty?
|
||||
paths = default_paths
|
||||
end
|
||||
|
||||
if stubs
|
||||
func = "Tk_InitStubs"
|
||||
lib = "tkstub"
|
||||
|
@ -90,27 +152,43 @@ def find_tk(tklib, stubs, *opt_paths)
|
|||
func = "Tk_Init"
|
||||
lib = "tk"
|
||||
end
|
||||
if tklib
|
||||
find_library(tklib, func, *paths)
|
||||
|
||||
if version && ! version.empty?
|
||||
versions = [version]
|
||||
else
|
||||
%w[8.6 8.5 8.4 8.3 8.2 8.1 8.0 4.2].find { |ver|
|
||||
find_library("#{lib}#{ver}", func, *paths) or
|
||||
find_library("#{lib}#{ver.delete('.')}", func, *paths) or
|
||||
find_library("#{lib}#{ver}g", func, *paths) or
|
||||
find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
|
||||
find_library("tk#{ver}", func, *paths) or
|
||||
find_library("tk#{ver.delete('.')}", func, *paths) or
|
||||
find_library("tk#{ver}g", func, *paths) or
|
||||
find_library("tk#{ver.delete('.')}g", func, *paths)
|
||||
} || find_library(lib, func, *paths)
|
||||
versions = %w[8.6 8.5 8.4 8.3 8.2 8.1 8.0 4.2]
|
||||
end
|
||||
|
||||
if tklib
|
||||
st = find_library(tklib, func, *paths)
|
||||
else
|
||||
st = versions.find { |ver|
|
||||
find_library("#{lib}#{ver}", func, *paths) or
|
||||
find_library("#{lib}#{ver.delete('.')}", func, *paths) or
|
||||
find_library("#{lib}#{ver}g", func, *paths) or
|
||||
find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
|
||||
find_library("tk#{ver}", func, *paths) or
|
||||
find_library("tk#{ver.delete('.')}", func, *paths) or
|
||||
find_library("tk#{ver}g", func, *paths) or
|
||||
find_library("tk#{ver.delete('.')}g", func, *paths)
|
||||
} || (!version && find_library(lib, func, *paths))
|
||||
end
|
||||
|
||||
unless st
|
||||
puts("Warning:: cannot find Tk library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
|
||||
end
|
||||
st
|
||||
end
|
||||
|
||||
def find_X11(*opt_paths)
|
||||
default_paths =
|
||||
[ "/usr/X11/lib", "/usr/lib/X11", "/usr/X11R6/lib", "/usr/openwin/lib" ]
|
||||
paths = opt_paths.compact.concat(default_paths)
|
||||
find_library("X11", "XOpenDisplay", *paths)
|
||||
st = find_library("X11", "XOpenDisplay", *paths)
|
||||
unless st
|
||||
puts("Warning:: cannot find X11 library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options. If your Tcl/Tk don't require X11, please try --without-X11.")
|
||||
end
|
||||
st
|
||||
end
|
||||
|
||||
def pthread_check()
|
||||
|
@ -291,11 +369,13 @@ EOF
|
|||
end
|
||||
end
|
||||
|
||||
if have_header("tcl.h") && have_header("tk.h") &&
|
||||
tclver, tkver = check_tcltk_version(tcltk_version)
|
||||
|
||||
if have_header("tcl.h") && have_header("tk.h") &&
|
||||
( tcltk_framework ||
|
||||
( ( !use_X || find_X11(x11_ldir2, x11_ldir) ) &&
|
||||
find_tcl(tcllib, stubs, tcl_ldir2, tcl_ldir) &&
|
||||
find_tk(tklib, stubs, tk_ldir2, tk_ldir) ) )
|
||||
find_tcl(tcllib, stubs, tclver, *tcl_ldir_list) &&
|
||||
find_tk(tklib, stubs, tkver, *tk_ldir_list) ) )
|
||||
$CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS' if stubs
|
||||
$CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
|
||||
|
||||
|
@ -322,6 +402,8 @@ if have_header("tcl.h") && have_header("tk.h") &&
|
|||
$INSTALLFILES ||= []
|
||||
$INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
|
||||
|
||||
have_func("rb_hash_lookup", "ruby.h")
|
||||
|
||||
# create
|
||||
$defs << %[-DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
|
||||
$defs << %[-DRUBY_RELEASE_DATE=\\"#{RUBY_RELEASE_DATE}\\"]
|
||||
|
|
|
@ -28,7 +28,13 @@ class << TclTkIp
|
|||
if Thread.current.group != ThreadGroup::Default
|
||||
raise SecurityError, 'only ThreadGroup::Default can call TclTkIp.new'
|
||||
end
|
||||
__new__(*args)
|
||||
obj = __new__(*args)
|
||||
obj.instance_eval{
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
}
|
||||
obj
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -115,7 +121,8 @@ class MultiTkIp
|
|||
BASE_DIR = File.dirname(__FILE__)
|
||||
|
||||
WITH_RUBY_VM = Object.const_defined?(:VM) && ::VM.class == Class
|
||||
WITH_ENCODING = Object.const_defined?(:Encoding) && ::Encoding.class == Class
|
||||
WITH_ENCODING = defined?(::Encoding.default_external)
|
||||
#WITH_ENCODING = Object.const_defined?(:Encoding) && ::Encoding.class == Class
|
||||
|
||||
(@@SLAVE_IP_ID = ['slave'.freeze, '0'.taint]).instance_eval{
|
||||
@mutex = Mutex.new
|
||||
|
@ -226,8 +233,8 @@ class MultiTkIp
|
|||
def call(*args)
|
||||
unless @ip.deleted?
|
||||
current = Thread.current
|
||||
backup_ip = current['callback_ip']
|
||||
current['callback_ip'] = @ip
|
||||
backup_ip = current[:callback_ip]
|
||||
current[:callback_ip] = @ip
|
||||
begin
|
||||
ret = @ip.cb_eval(@cmd, *args)
|
||||
fail ret if ret.kind_of?(Exception)
|
||||
|
@ -260,7 +267,7 @@ class MultiTkIp
|
|||
fail e
|
||||
end
|
||||
ensure
|
||||
current['callback_ip'] = backup_ip
|
||||
current[:callback_ip] = backup_ip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -753,14 +760,23 @@ class MultiTkIp
|
|||
current[:mutex] = mutex = Mutex.new
|
||||
current[:root_check] = cond_var = ConditionVariable.new
|
||||
|
||||
status = [nil]
|
||||
def status.value
|
||||
self[0]
|
||||
end
|
||||
def status.value=(val)
|
||||
self[0] = val
|
||||
end
|
||||
current[:status] = status
|
||||
|
||||
begin
|
||||
current[:status] = interp.mainloop(true)
|
||||
current[:status].value = interp.mainloop(true)
|
||||
rescue Exception=>e
|
||||
current[:status] = e
|
||||
current[:status].value = e
|
||||
ensure
|
||||
mutex.synchronize{ cond_var.broadcast }
|
||||
end
|
||||
current[:status] = interp.mainloop(false)
|
||||
current[:status].value = interp.mainloop(false)
|
||||
}
|
||||
until @interp_thread[:interp]
|
||||
Thread.pass
|
||||
|
@ -778,6 +794,12 @@ class MultiTkIp
|
|||
end
|
||||
end
|
||||
|
||||
@interp.instance_eval{
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
}
|
||||
|
||||
@ip_name = nil
|
||||
|
||||
@callback_status = [].taint
|
||||
|
@ -951,8 +973,9 @@ class MultiTkIp
|
|||
begin
|
||||
class << subclass
|
||||
self.methods.each{|m|
|
||||
name = m.to_s
|
||||
begin
|
||||
unless m == '__id__' || m == '__send__' || m == 'freeze'
|
||||
unless name == '__id__' || name == '__send__' || name == 'freeze'
|
||||
undef_method(m)
|
||||
end
|
||||
rescue Exception
|
||||
|
@ -1157,6 +1180,11 @@ class MultiTkIp
|
|||
# safe interpreter
|
||||
ip_name = _create_slave_ip_name
|
||||
slave_ip = @interp.create_slave(ip_name, true)
|
||||
slave_ip.instance_eval{
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
}
|
||||
@slave_ip_tbl[ip_name] = slave_ip
|
||||
def slave_ip.safe_base?
|
||||
true
|
||||
|
@ -1199,6 +1227,11 @@ class MultiTkIp
|
|||
|
||||
ip_name = _create_slave_ip_name
|
||||
slave_ip = @interp.create_slave(ip_name, false)
|
||||
slave_ip.instance_eval{
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
}
|
||||
slave_ip._invoke('set', 'argv0', name) if name.kind_of?(String)
|
||||
slave_ip._invoke('set', 'argv', _keys2opts(keys))
|
||||
@interp._invoke('load', '', 'Tk', ip_name)
|
||||
|
@ -1268,9 +1301,21 @@ class MultiTkIp
|
|||
# create master-ip
|
||||
unless WITH_RUBY_VM
|
||||
@interp = TclTkIp.new(name, _keys2opts(tk_opts))
|
||||
@interp.instance_eval{
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
}
|
||||
|
||||
else ### Ruby 1.9 !!!!!!!!!!!
|
||||
@interp_thread = Thread.new{
|
||||
Thread.current[:interp] = interp = TclTkIp.new(name, _keys2opts(tk_opts))
|
||||
interp.instance_eval{
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
}
|
||||
|
||||
#sleep
|
||||
TclTkLib.mainloop(true)
|
||||
}
|
||||
|
@ -1400,8 +1445,8 @@ class MultiTkIp
|
|||
|
||||
def self.__getip
|
||||
current = Thread.current
|
||||
if TclTkLib.mainloop_thread? != false && current['callback_ip']
|
||||
return current['callback_ip']
|
||||
if TclTkLib.mainloop_thread? != false && current[:callback_ip]
|
||||
return current[:callback_ip]
|
||||
end
|
||||
if current.group == ThreadGroup::Default
|
||||
@@DEFAULT_MASTER
|
||||
|
@ -1993,12 +2038,12 @@ class MultiTkIp
|
|||
cmd = args.shift
|
||||
end
|
||||
current = Thread.current
|
||||
backup_ip = current['callback_ip']
|
||||
current['callback_ip'] = self
|
||||
backup_ip = current[:callback_ip]
|
||||
current[:callback_ip] = self
|
||||
begin
|
||||
eval_proc_core(false, cmd, *args)
|
||||
ensure
|
||||
current['callback_ip'] = backup_ip
|
||||
current[:callback_ip] = backup_ip
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2016,8 +2061,8 @@ class MultiTkIp
|
|||
if TclTkLib.mainloop_thread? == true
|
||||
# call from eventloop
|
||||
current = Thread.current
|
||||
backup_ip = current['callback_ip']
|
||||
current['callback_ip'] = self
|
||||
backup_ip = current[:callback_ip]
|
||||
current[:callback_ip] = self
|
||||
begin
|
||||
eval_proc_core(false,
|
||||
proc{|safe, *params|
|
||||
|
@ -2025,7 +2070,7 @@ class MultiTkIp
|
|||
cmd.call(*params)
|
||||
}, *args)
|
||||
ensure
|
||||
current['callback_ip'] = backup_ip
|
||||
current[:callback_ip] = backup_ip
|
||||
end
|
||||
else
|
||||
eval_proc_core(true,
|
||||
|
@ -2170,6 +2215,10 @@ end
|
|||
# event loop
|
||||
# all master/slave IPs are controled by only one event-loop
|
||||
class << MultiTkIp
|
||||
def default_master?
|
||||
__getip == @@DEFAULT_MASTER
|
||||
end
|
||||
|
||||
def mainloop(check_root = true)
|
||||
__getip.mainloop(check_root)
|
||||
end
|
||||
|
@ -2431,7 +2480,7 @@ class MultiTkIp
|
|||
def mainloop(check_root = true, restart_on_dead = true)
|
||||
raise SecurityError, "no permission to manipulate" unless self.manipulable?
|
||||
|
||||
unless WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
|
||||
if WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
|
||||
return @interp_thread.value if @interp_thread
|
||||
end
|
||||
|
||||
|
@ -3289,6 +3338,42 @@ class << MultiTkIp
|
|||
def encoding_table
|
||||
__getip.encoding_table
|
||||
end
|
||||
|
||||
def force_default_encoding=(mode)
|
||||
__getip.force_default_encoding=(mode)
|
||||
end
|
||||
|
||||
def force_default_encoding?
|
||||
__getip.force_default_encoding?
|
||||
end
|
||||
|
||||
def default_encoding=(enc)
|
||||
__getip.default_encoding=(enc)
|
||||
end
|
||||
|
||||
def encoding=(enc)
|
||||
__getip.encoding=(enc)
|
||||
end
|
||||
|
||||
def encoding_name
|
||||
__getip.encoding_name
|
||||
end
|
||||
|
||||
def encoding_obj
|
||||
__getip.encoding_obj
|
||||
end
|
||||
alias encoding encoding_name
|
||||
alias default_encoding encoding_name
|
||||
|
||||
def encoding_convertfrom(str, enc=None)
|
||||
__getip.encoding_convertfrom(str, enc)
|
||||
end
|
||||
alias encoding_convert_from encoding_convertfrom
|
||||
|
||||
def encoding_convertto(str, enc=None)
|
||||
__getip.encoding_convertto(str, enc)
|
||||
end
|
||||
alias encoding_convert_to encoding_convertto
|
||||
end
|
||||
class MultiTkIp
|
||||
def encoding_table
|
||||
|
@ -3339,6 +3424,7 @@ end
|
|||
|
||||
|
||||
# remove methods for security
|
||||
=begin
|
||||
class MultiTkIp
|
||||
INTERP_THREAD = @@DEFAULT_MASTER.instance_variable_get('@interp_thread')
|
||||
INTERP_MUTEX = INTERP_THREAD[:mutex]
|
||||
|
@ -3362,6 +3448,34 @@ class MultiTkIp
|
|||
remove_const(:INTERP_MUTEX)
|
||||
remove_const(:INTERP_ROOT_CHECK)
|
||||
end
|
||||
=end
|
||||
if MultiTkIp::WITH_RUBY_VM &&
|
||||
! MultiTkIp::RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
|
||||
class MultiTkIp
|
||||
INTERP_THREAD = @@DEFAULT_MASTER.instance_variable_get('@interp_thread')
|
||||
INTERP_THREAD_STATUS = INTERP_THREAD[:status]
|
||||
INTERP_MUTEX = INTERP_THREAD[:mutex]
|
||||
INTERP_ROOT_CHECK = INTERP_THREAD[:root_check]
|
||||
end
|
||||
module TkCore
|
||||
INTERP_THREAD = MultiTkIp::INTERP_THREAD
|
||||
INTERP_THREAD_STATUS = MultiTkIp::INTERP_THREAD_STATUS
|
||||
INTERP_MUTEX = MultiTkIp::INTERP_MUTEX
|
||||
INTERP_ROOT_CHECK = MultiTkIp::INTERP_ROOT_CHECK
|
||||
end
|
||||
class MultiTkIp
|
||||
remove_const(:INTERP_THREAD)
|
||||
remove_const(:INTERP_THREAD_STATUS)
|
||||
remove_const(:INTERP_MUTEX)
|
||||
remove_const(:INTERP_ROOT_CHECK)
|
||||
end
|
||||
end
|
||||
|
||||
class MultiTkIp
|
||||
# undef_method :instance_eval
|
||||
undef_method :instance_variable_get
|
||||
undef_method :instance_variable_set
|
||||
end
|
||||
# end of MultiTkIp definition
|
||||
|
||||
# defend against modification
|
||||
|
|
|
@ -88,6 +88,10 @@ class RemoteTkIp
|
|||
@slave_ip_tbl = {}
|
||||
@slave_ip_top = {}
|
||||
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
|
||||
@tk_windows.taint unless @tk_windows.tainted?
|
||||
@tk_table_list.taint unless @tk_table_list.tainted?
|
||||
@slave_ip_tbl.taint unless @slave_ip_tbl.tainted?
|
||||
|
|
254
ext/tk/lib/tk.rb
254
ext/tk/lib/tk.rb
|
@ -21,6 +21,17 @@ class TclTkIp
|
|||
# for RemoteTkIp
|
||||
''
|
||||
end
|
||||
|
||||
alias __initialize__ initialize
|
||||
private :__initialize__
|
||||
|
||||
def initialize(*args)
|
||||
__initialize__(*args)
|
||||
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
end
|
||||
end
|
||||
|
||||
# define TkComm module (step 1: basic functions)
|
||||
|
@ -775,7 +786,7 @@ end
|
|||
private :_curr_cmd_id, :_next_cmd_id
|
||||
module_function :_curr_cmd_id, :_next_cmd_id
|
||||
|
||||
def install_cmd(cmd)
|
||||
def TkComm.install_cmd(cmd, local_cmdtbl=nil)
|
||||
return '' if cmd == ''
|
||||
begin
|
||||
ns = TkCore::INTERP._invoke_without_enc('namespace', 'current')
|
||||
|
@ -794,6 +805,15 @@ end
|
|||
@cmdtbl = [] unless defined? @cmdtbl
|
||||
@cmdtbl.taint unless @cmdtbl.tainted?
|
||||
@cmdtbl.push id
|
||||
|
||||
if local_cmdtbl && local_cmdtbl.kind_of?(Array)
|
||||
begin
|
||||
local_cmdtbl << id
|
||||
rescue Exception
|
||||
# ignore
|
||||
end
|
||||
end
|
||||
|
||||
#return Kernel.format("rb_out %s", id);
|
||||
if ns
|
||||
'rb_out' << TkCore::INTERP._ip_id_ << ' ' << ns << ' ' << id
|
||||
|
@ -801,14 +821,30 @@ end
|
|||
'rb_out' << TkCore::INTERP._ip_id_ << ' ' << id
|
||||
end
|
||||
end
|
||||
def uninstall_cmd(id)
|
||||
def TkComm.uninstall_cmd(id, local_cmdtbl=nil)
|
||||
#id = $1 if /rb_out\S* (c(_\d+_)?\d+)/ =~ id
|
||||
id = $4 if id =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
|
||||
|
||||
if local_cmdtbl && local_cmdtbl.kind_of?(Array)
|
||||
begin
|
||||
local_cmdtbl.delete(id)
|
||||
rescue Exception
|
||||
# ignore
|
||||
end
|
||||
end
|
||||
@cmdtbl.delete(id)
|
||||
|
||||
#Tk_CMDTBL.delete(id)
|
||||
TkCore::INTERP.tk_cmd_tbl.delete(id)
|
||||
end
|
||||
# private :install_cmd, :uninstall_cmd
|
||||
module_function :install_cmd, :uninstall_cmd
|
||||
# module_function :install_cmd, :uninstall_cmd
|
||||
def install_cmd(cmd)
|
||||
TkComm.install_cmd(cmd, @cmdtbl)
|
||||
end
|
||||
def uninstall_cmd(id)
|
||||
TkComm.uninstall_cmd(id, @cmdtbl)
|
||||
end
|
||||
|
||||
=begin
|
||||
def install_win(ppath,name=nil)
|
||||
|
@ -1074,7 +1110,8 @@ module TkCore
|
|||
extend TkComm
|
||||
|
||||
WITH_RUBY_VM = Object.const_defined?(:VM) && ::VM.class == Class
|
||||
WITH_ENCODING = Object.const_defined?(:Encoding) && ::Encoding.class == Class
|
||||
WITH_ENCODING = defined?(::Encoding.default_external)
|
||||
#WITH_ENCODING = Object.const_defined?(:Encoding) && ::Encoding.class == Class
|
||||
|
||||
unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
|
||||
### Ruby 1.9 !!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
@ -1110,17 +1147,26 @@ module TkCore
|
|||
Thread.current[:interp] = e
|
||||
raise e
|
||||
end
|
||||
Thread.current[:status] = nil
|
||||
|
||||
status = [nil]
|
||||
def status.value
|
||||
self[0]
|
||||
end
|
||||
def status.value=(val)
|
||||
self[0] = val
|
||||
end
|
||||
|
||||
Thread.current[:status] = status
|
||||
#sleep
|
||||
|
||||
begin
|
||||
Thread.current[:status] = TclTkLib.mainloop(true)
|
||||
Thread.current[:status].value = TclTkLib.mainloop(true)
|
||||
rescue Exception=>e
|
||||
Thread.current[:status] = e
|
||||
Thread.current[:status].value = e
|
||||
ensure
|
||||
INTERP_MUTEX.synchronize{ INTERP_ROOT_CHECK.broadcast }
|
||||
end
|
||||
Thread.current[:status] = TclTkLib.mainloop(false)
|
||||
Thread.current[:status].value = TclTkLib.mainloop(false)
|
||||
}
|
||||
|
||||
until INTERP_THREAD[:interp]
|
||||
|
@ -1130,11 +1176,15 @@ module TkCore
|
|||
raise INTERP_THREAD[:interp] if INTERP_THREAD[:interp].kind_of? Exception
|
||||
|
||||
INTERP = INTERP_THREAD[:interp]
|
||||
INTERP_THREAD_STATUS = INTERP_THREAD[:status]
|
||||
end
|
||||
|
||||
def INTERP.__getip
|
||||
self
|
||||
end
|
||||
def INTERP.default_master?
|
||||
true
|
||||
end
|
||||
|
||||
INTERP.instance_eval{
|
||||
# @tk_cmd_tbl = {}.taint
|
||||
|
@ -1155,6 +1205,10 @@ module TkCore
|
|||
@init_ip_env = [].taint # table of Procs
|
||||
@add_tk_procs = [].taint # table of [name, args, body]
|
||||
|
||||
@force_default_encoding ||= [false].taint
|
||||
@encoding ||= [nil].taint
|
||||
def @encoding.to_s; self.join(nil); end
|
||||
|
||||
@cb_entry_class = Class.new(TkCallbackEntry){
|
||||
class << self
|
||||
def inspect
|
||||
|
@ -1273,7 +1327,7 @@ module TkCore
|
|||
}) << ' %W')
|
||||
|
||||
INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '',
|
||||
"bind all <#{WIDGET_DESTROY_HOOK}> {}")
|
||||
"catch { bind all <#{WIDGET_DESTROY_HOOK}> {} }")
|
||||
|
||||
INTERP.add_tk_procs('rb_out', 'ns args', <<-'EOL')
|
||||
if [regexp {^::} $ns] {
|
||||
|
@ -1441,7 +1495,9 @@ module TkCore
|
|||
|
||||
def after(ms, cmd=Proc.new)
|
||||
cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(cmdid); ret})
|
||||
tk_call_without_enc("after",ms,cmdid) # return id
|
||||
after_id = tk_call_without_enc("after",ms,cmdid)
|
||||
after_id.instance_variable_set('@cmdid', cmdid)
|
||||
after_id
|
||||
end
|
||||
=begin
|
||||
def after(ms, cmd=Proc.new)
|
||||
|
@ -1471,7 +1527,9 @@ module TkCore
|
|||
|
||||
def after_idle(cmd=Proc.new)
|
||||
cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(cmdid); ret})
|
||||
tk_call_without_enc('after','idle',cmdid)
|
||||
after_id = tk_call_without_enc('after','idle',cmdid)
|
||||
after_id.instance_variable_set('@cmdid', cmdid)
|
||||
after_id
|
||||
end
|
||||
=begin
|
||||
def after_idle(cmd=Proc.new)
|
||||
|
@ -1489,6 +1547,11 @@ module TkCore
|
|||
|
||||
def after_cancel(afterId)
|
||||
tk_call_without_enc('after','cancel',afterId)
|
||||
if (cmdid = afterId.instance_variable_get('@cmdid'))
|
||||
afterId.instance_variable_set('@cmdid', nil)
|
||||
uninstall_cmd(cmdid)
|
||||
end
|
||||
afterId
|
||||
end
|
||||
|
||||
def windowingsystem
|
||||
|
@ -1611,14 +1674,19 @@ module TkCore
|
|||
if !TkCore::WITH_RUBY_VM || TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
|
||||
TclTkLib.mainloop(check_root)
|
||||
else ### Ruby 1.9 !!!!!
|
||||
unless TkCore::INTERP.default_master?
|
||||
# [MultiTkIp] slave interp ?
|
||||
return TkCore::INTERP._thread_tkwait('window', '.') if check_root
|
||||
end
|
||||
|
||||
begin
|
||||
TclTkLib.set_eventloop_window_mode(true)
|
||||
if check_root
|
||||
INTERP_MUTEX.synchronize{
|
||||
INTERP_ROOT_CHECK.wait(INTERP_MUTEX)
|
||||
status = INTERP_THREAD[:status]
|
||||
if status
|
||||
INTERP_THREAD[:status] = nil
|
||||
status = INTERP_THREAD_STATUS.value
|
||||
if status && TkCore::INTERP.default_master?
|
||||
INTERP_THREAD_STATUS.value = nil if $SAFE < 4
|
||||
raise status if status.kind_of?(Exception)
|
||||
end
|
||||
}
|
||||
|
@ -2458,7 +2526,8 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
|
|||
alias default_encoding encoding_name
|
||||
|
||||
def tk_encoding_names
|
||||
TkComm.simplelist(TkCore::INTERP._invoke_without_enc(Tk::Encoding::ENCNAMES_CMD[0], Tk::Encoding::ENCNAMES_CMD[1]))
|
||||
#TkComm.simplelist(TkCore::INTERP._invoke_without_enc(Tk::Encoding::ENCNAMES_CMD[0], Tk::Encoding::ENCNAMES_CMD[1]))
|
||||
TkComm.simplelist(TkCore::INTERP._invoke_without_enc('encoding', 'names'))
|
||||
end
|
||||
def encoding_names
|
||||
self.tk_encoding_names.find_all{|name|
|
||||
|
@ -2592,16 +2661,16 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
|
|||
|
||||
class TclTkIp
|
||||
def force_default_encoding=(mode)
|
||||
@force_default_encoding = (mode)? true: false
|
||||
@force_default_encoding[0] = (mode)? true: false
|
||||
end
|
||||
|
||||
def force_default_encoding?
|
||||
@force_default_encoding ||= false
|
||||
@force_default_encoding[0] ||= false
|
||||
end
|
||||
|
||||
def default_encoding=(name)
|
||||
name = name.name if name.kind_of?(::Encoding) if Tk::WITH_ENCODING
|
||||
@encoding = name
|
||||
name = name.name if Tk::WITH_ENCODING && name.kind_of?(::Encoding)
|
||||
@encoding[0] = name.to_s.dup
|
||||
end
|
||||
|
||||
# from tkencoding.rb by ttate@jaist.ac.jp
|
||||
|
@ -2612,16 +2681,16 @@ if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
|
|||
end
|
||||
|
||||
def encoding_name
|
||||
(@encoding)? @encoding.dup: nil
|
||||
(@encoding[0])? @encoding[0].dup: nil
|
||||
end
|
||||
alias encoding encoding_name
|
||||
alias default_encoding encoding_name
|
||||
|
||||
def encoding_obj
|
||||
if Tk::WITH_ENCODING
|
||||
Tk::Encoding.tcl2rb_encoding(@encoding)
|
||||
Tk::Encoding.tcl2rb_encoding(@encoding[0])
|
||||
else
|
||||
(@encoding)? @encoding.dup: nil
|
||||
(@encoding[0])? @encoding[0].dup: nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3211,7 +3280,15 @@ module TkTreatFont
|
|||
next
|
||||
else
|
||||
fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << fnt))
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << fnt))
|
||||
else
|
||||
begin
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << fnt))
|
||||
rescue
|
||||
# ignore
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
next
|
||||
|
@ -3265,7 +3342,15 @@ module TkTreatFont
|
|||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << ltn))
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << ltn))
|
||||
else
|
||||
begin
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << ltn))
|
||||
rescue => e
|
||||
# ignore
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -3317,7 +3402,15 @@ module TkTreatFont
|
|||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
knj = hash_kv(knj) if knj.kind_of?(Hash)
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << knj))
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << knj))
|
||||
else
|
||||
begin
|
||||
tk_call(*(__config_cmd << "-#{optkey}" << knj))
|
||||
rescue => e
|
||||
# ignore
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -3447,6 +3540,11 @@ module TkConfigMethod
|
|||
end
|
||||
private :__configinfo_struct
|
||||
|
||||
def __optkey_aliases
|
||||
{}
|
||||
end
|
||||
private :__optkey_aliases
|
||||
|
||||
def __numval_optkeys
|
||||
[]
|
||||
end
|
||||
|
@ -3561,6 +3659,11 @@ module TkConfigMethod
|
|||
fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
|
||||
end
|
||||
|
||||
alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
if ( method = _symbolkey2str(__val2ruby_optkeys())[slot] )
|
||||
optval = tk_call_without_enc(*(__cget_cmd << "-#{slot}"))
|
||||
begin
|
||||
|
@ -3635,14 +3738,35 @@ module TkConfigMethod
|
|||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
__cget_core(slot)
|
||||
else
|
||||
__cget_core(slot) rescue nil
|
||||
begin
|
||||
__cget_core(slot)
|
||||
rescue => e
|
||||
if current_configinfo.has_key?(slot.to_s)
|
||||
# error on known option
|
||||
fail e
|
||||
else
|
||||
# unknown option
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
def cget_strict(slot)
|
||||
# never use TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
__cget_core(slot)
|
||||
end
|
||||
|
||||
def __configure_core(slot, value=None)
|
||||
if slot.kind_of? Hash
|
||||
slot = _symbolkey2str(slot)
|
||||
|
||||
__optkey_aliases.each{|alias_name, real_name|
|
||||
alias_name = alias_name.to_s
|
||||
if slot.has_key?(alias_name)
|
||||
slot[real_name.to_s] = slot.delete(alias_name)
|
||||
end
|
||||
}
|
||||
|
||||
__methodcall_optkeys.each{|key, method|
|
||||
value = slot.delete(key.to_s)
|
||||
self.__send__(method, value) if value
|
||||
|
@ -3679,6 +3803,11 @@ module TkConfigMethod
|
|||
fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
|
||||
end
|
||||
|
||||
alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
if ( conf = __keyonly_optkeys.find{|k, v| k.to_s == slot} )
|
||||
defkey, undefkey = conf
|
||||
if value
|
||||
|
@ -3730,7 +3859,17 @@ module TkConfigMethod
|
|||
__configure_core(slot) unless slot.empty?
|
||||
end
|
||||
else
|
||||
__configure_core(slot, value) rescue nil
|
||||
begin
|
||||
__configure_core(slot, value)
|
||||
rescue => e
|
||||
if current_configinfo.has_key?(slot.to_s)
|
||||
# error on known option
|
||||
fail e
|
||||
else
|
||||
# unknown option
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
self
|
||||
|
@ -3766,6 +3905,12 @@ module TkConfigMethod
|
|||
else
|
||||
if slot
|
||||
slot = slot.to_s
|
||||
|
||||
alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
case slot
|
||||
when /^(#{__val2ruby_optkeys().keys.join('|')})$/
|
||||
method = _symbolkey2str(__val2ruby_optkeys())[slot]
|
||||
|
@ -4139,6 +4284,12 @@ module TkConfigMethod
|
|||
else
|
||||
if slot
|
||||
slot = slot.to_s
|
||||
|
||||
alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
case slot
|
||||
when /^(#{__val2ruby_optkeys().keys.join('|')})$/
|
||||
method = _symbolkey2str(__val2ruby_optkeys())[slot]
|
||||
|
@ -4734,6 +4885,13 @@ class TkWindow<TkObject
|
|||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
}
|
||||
|
||||
__optkey_aliases.each{|alias_name, real_name|
|
||||
alias_name = alias_name.to_s
|
||||
if keys.has_key?(alias_name)
|
||||
keys[real_name.to_s] = keys.delete(alias_name)
|
||||
end
|
||||
}
|
||||
|
||||
__methodcall_optkeys.each{|key|
|
||||
key = key.to_s
|
||||
methodkeys[key] = keys.delete(key) if keys.key?(key)
|
||||
|
@ -4771,12 +4929,25 @@ class TkWindow<TkObject
|
|||
else
|
||||
begin
|
||||
tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
|
||||
rescue
|
||||
rescue => e
|
||||
tk_call_without_enc(cmd, @path)
|
||||
keys = __check_available_configure_options(keys)
|
||||
unless keys.empty?
|
||||
tk_call_without_enc('destroy', @path)
|
||||
tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
|
||||
begin
|
||||
# try to configure
|
||||
configure(keys)
|
||||
rescue
|
||||
# fail => includes options adaptable when creattion only?
|
||||
begin
|
||||
tk_call_without_enc('destroy', @path)
|
||||
rescue
|
||||
# cannot rescue options error
|
||||
fail e
|
||||
else
|
||||
# re-create widget
|
||||
tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4916,6 +5087,15 @@ class TkWindow<TkObject
|
|||
self
|
||||
end
|
||||
|
||||
def grid_anchor(anchor=None)
|
||||
if anchor == None
|
||||
TkGrid.anchor(self)
|
||||
else
|
||||
TkGrid.anchor(self, anchor)
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
def grid_forget
|
||||
#tk_call('grid', 'forget', epath)
|
||||
TkGrid.forget(self)
|
||||
|
@ -4947,12 +5127,14 @@ class TkWindow<TkObject
|
|||
TkGrid.columnconfigure(self, index, keys)
|
||||
end
|
||||
alias grid_columnconfigure grid_columnconfig
|
||||
alias grid_column grid_columnconfig
|
||||
|
||||
def grid_rowconfig(index, keys)
|
||||
#tk_call('grid', 'rowconfigure', epath, index, *hash_kv(keys))
|
||||
TkGrid.rowconfigure(self, index, keys)
|
||||
end
|
||||
alias grid_rowconfigure grid_rowconfig
|
||||
alias grid_row grid_rowconfig
|
||||
|
||||
def grid_columnconfiginfo(index, slot=nil)
|
||||
#if slot
|
||||
|
@ -5195,11 +5377,13 @@ class TkWindow<TkObject
|
|||
end
|
||||
|
||||
children.each{|path, obj|
|
||||
if defined?(@cmdtbl)
|
||||
for id in @cmdtbl
|
||||
uninstall_cmd id
|
||||
obj.instance_eval{
|
||||
if defined?(@cmdtbl)
|
||||
for id in @cmdtbl
|
||||
uninstall_cmd id
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
TkCore::INTERP.tk_windows.delete(path)
|
||||
}
|
||||
|
||||
|
@ -5317,7 +5501,7 @@ TkWidget = TkWindow
|
|||
#Tk.freeze
|
||||
|
||||
module Tk
|
||||
RELEASE_DATE = '2008-03-29'.freeze
|
||||
RELEASE_DATE = '2008-06-11'.freeze
|
||||
|
||||
autoload :AUTO_PATH, 'tk/variable'
|
||||
autoload :TCL_PACKAGE_PATH, 'tk/variable'
|
||||
|
|
|
@ -168,6 +168,8 @@ class Tk::Canvas<TkWindow
|
|||
#tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
|
||||
number(tk_send_without_enc('canvasy', screen_y, *args))
|
||||
end
|
||||
alias canvas_x canvasx
|
||||
alias canvas_y canvasy
|
||||
|
||||
def coords(tag, *args)
|
||||
if args == []
|
||||
|
@ -642,6 +644,13 @@ class TkcItem<TkObject
|
|||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
}
|
||||
|
||||
__item_optkey_aliases(nil).each{|alias_name, real_name|
|
||||
alias_name = alias_name.to_s
|
||||
if keys.has_key?(alias_name)
|
||||
keys[real_name.to_s] = keys.delete(alias_name)
|
||||
end
|
||||
}
|
||||
|
||||
__item_methodcall_optkeys(nil).each{|key|
|
||||
key = key.to_s
|
||||
methodkeys[key] = keys.delete(key) if keys.key?(key)
|
||||
|
|
|
@ -63,6 +63,9 @@ module TkcTagAccess
|
|||
def cget(option)
|
||||
@c.itemcget(@id, option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@c.itemcget_strict(@id, option)
|
||||
end
|
||||
|
||||
def configure(key, value=None)
|
||||
@c.itemconfigure(@id, key, value)
|
||||
|
|
|
@ -181,6 +181,57 @@ module TkComposite
|
|||
delegate_alias(option, option, *wins)
|
||||
end
|
||||
|
||||
def __cget_delegates(slot)
|
||||
slot = slot.to_s
|
||||
|
||||
if @option_methods.include?(slot)
|
||||
if @option_methods[slot][:cget]
|
||||
return self.__send__(@option_methods[slot][:cget])
|
||||
else
|
||||
if @option_setting[slot]
|
||||
return @option_setting[slot]
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tbl = @delegates[slot]
|
||||
tbl = @delegates['DEFAULT'] unless tbl
|
||||
|
||||
begin
|
||||
if tbl
|
||||
opt, wins = tbl[-1]
|
||||
opt = slot if opt == 'DEFAULT'
|
||||
if wins && wins[-1]
|
||||
# return wins[-1].cget(opt)
|
||||
return wins[-1].cget_strict(opt)
|
||||
end
|
||||
end
|
||||
rescue
|
||||
end
|
||||
|
||||
return None
|
||||
end
|
||||
private :__cget_delegates
|
||||
|
||||
def cget(slot)
|
||||
if (ret = __cget_delegates(slot)) == None
|
||||
super(slot)
|
||||
else
|
||||
ret
|
||||
end
|
||||
end
|
||||
|
||||
def cget_strict(slot)
|
||||
if (ret = __cget_delegates(slot)) == None
|
||||
super(slot)
|
||||
else
|
||||
ret
|
||||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
def cget(slot)
|
||||
slot = slot.to_s
|
||||
|
||||
|
@ -212,6 +263,7 @@ module TkComposite
|
|||
|
||||
super(slot)
|
||||
end
|
||||
=end
|
||||
|
||||
def configure(slot, value=None)
|
||||
if slot.kind_of? Hash
|
||||
|
|
|
@ -352,6 +352,14 @@ module TkEvent
|
|||
nil
|
||||
]
|
||||
|
||||
# [ <'%' subst-key str>, <proc type char>, <instance var (accessor) name>]
|
||||
# the subst-key string will be converted to a bytecode (128+idx).
|
||||
LONGKEY_TBL = [
|
||||
# for example, for %CTT and %CST subst-key on tkdnd-2.0
|
||||
# ['CTT', ?l, :drop_target_type],
|
||||
# ['CST', ?l, :drop_source_type],
|
||||
]
|
||||
|
||||
# [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
|
||||
PROC_TBL = [
|
||||
[ ?n, TkComm.method(:num_or_str) ],
|
||||
|
@ -371,6 +379,7 @@ module TkEvent
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -386,6 +395,7 @@ module TkEvent
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
# setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
|
||||
#
|
||||
|
@ -399,7 +409,8 @@ module TkEvent
|
|||
# ( which are Tcl strings ) to ruby objects based on the key string
|
||||
# that is generated by _get_subst_key() or _get_all_subst_keys().
|
||||
#
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL)
|
||||
# _setup_subst_table(KEY_TBL, LONGKEY_TBL, PROC_TBL) # if use longname-keys
|
||||
|
||||
#
|
||||
# NOTE: The order of parameters which passed to callback procedure is
|
||||
|
@ -447,6 +458,7 @@ module TkEvent
|
|||
extra_args_tbl = klass._get_extra_args_tbl
|
||||
|
||||
if args.compact.size > 0
|
||||
args.map!{|arg| klass._sym2subst(arg)}
|
||||
args = args.join(' ')
|
||||
keys = klass._get_subst_key(args)
|
||||
|
||||
|
|
|
@ -1056,7 +1056,13 @@ class TkFont
|
|||
|
||||
keys = _symbolkey2str(args.pop).update(fontslot)
|
||||
args.concat(hash_kv(keys))
|
||||
tk_call(*args)
|
||||
begin
|
||||
tk_call(*args)
|
||||
rescue => e
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
fail e
|
||||
end
|
||||
end
|
||||
Tk_FontUseTBL.mutex.synchronize{
|
||||
Tk_FontUseTBL[[win, tag, optkey].join(';')] = self
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ module TkGrid
|
|||
list(tk_call_without_enc('grid', 'bbox', *args))
|
||||
end
|
||||
|
||||
=begin
|
||||
def configure(win, *args)
|
||||
if args[-1].kind_of?(Hash)
|
||||
opts = args.pop
|
||||
|
@ -53,6 +54,48 @@ module TkGrid
|
|||
tk_call_without_enc('grid', 'configure', *params)
|
||||
end
|
||||
end
|
||||
=end
|
||||
def configure(*args)
|
||||
if args[-1].kind_of?(Hash)
|
||||
opts = args.pop
|
||||
else
|
||||
opts = {}
|
||||
end
|
||||
fail ArgumentError, 'no widget is given' if args.empty?
|
||||
params = []
|
||||
args.flatten(1).each{|win|
|
||||
case win
|
||||
when '-', ?- # RELATIVE PLACEMENT (increase columnspan)
|
||||
params.push('-')
|
||||
when /^-+$/ # RELATIVE PLACEMENT (increase columnspan)
|
||||
params.concat(win.to_s.split(//))
|
||||
when '^', ?^ # RELATIVE PLACEMENT (increase rowspan)
|
||||
params.push('^')
|
||||
when /^\^+$/ # RELATIVE PLACEMENT (increase rowspan)
|
||||
params.concat(win.to_s.split(//))
|
||||
when 'x', :x, ?x, nil, '' # RELATIVE PLACEMENT (empty column)
|
||||
params.push('x')
|
||||
when /^x+$/ # RELATIVE PLACEMENT (empty column)
|
||||
params.concat(win.to_s.split(//))
|
||||
else
|
||||
params.push(_epath(win))
|
||||
end
|
||||
}
|
||||
opts.each{|k, v|
|
||||
params.push("-#{k}")
|
||||
params.push(_epath(v)) # have to use 'epath' (hash_kv() is unavailable)
|
||||
}
|
||||
if Tk::TCL_MAJOR_VERSION < 8 ||
|
||||
(Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION <= 3)
|
||||
if params[0] == '-' || params[0] == 'x' || params[0] == '^'
|
||||
tk_call_without_enc('grid', *params)
|
||||
else
|
||||
tk_call_without_enc('grid', 'configure', *params)
|
||||
end
|
||||
else
|
||||
tk_call_without_enc('grid', 'configure', *params)
|
||||
end
|
||||
end
|
||||
alias grid configure
|
||||
|
||||
def columnconfigure(master, index, args)
|
||||
|
@ -61,12 +104,14 @@ module TkGrid
|
|||
tk_call_without_enc("grid", 'columnconfigure',
|
||||
master, index, *hash_kv(args))
|
||||
end
|
||||
alias column columnconfigure
|
||||
|
||||
def rowconfigure(master, index, args)
|
||||
# master = master.epath if master.kind_of?(TkObject)
|
||||
master = _epath(master)
|
||||
tk_call_without_enc("grid", 'rowconfigure', master, index, *hash_kv(args))
|
||||
end
|
||||
alias row rowconfigure
|
||||
|
||||
def columnconfiginfo(master, index, slot=nil)
|
||||
# master = master.epath if master.kind_of?(TkObject)
|
||||
|
@ -189,10 +234,10 @@ module TkGrid
|
|||
list(tk_call_without_enc('grid', 'slaves', master, *hash_kv(args)))
|
||||
end
|
||||
|
||||
module_function :bbox, :forget, :propagate, :info
|
||||
module_function :anchor, :bbox, :add, :forget, :propagate, :info
|
||||
module_function :remove, :size, :slaves, :location
|
||||
module_function :grid, :configure, :columnconfigure, :rowconfigure
|
||||
module_function :columnconfiginfo, :rowconfiginfo
|
||||
module_function :column, :row, :columnconfiginfo, :rowconfiginfo
|
||||
end
|
||||
=begin
|
||||
def TkGrid(win, *args)
|
||||
|
|
|
@ -156,7 +156,7 @@ class TkPhotoImage<TkImage
|
|||
self
|
||||
end
|
||||
|
||||
def cget(option)
|
||||
def cget_strict(option)
|
||||
case option.to_s
|
||||
when 'data', 'file'
|
||||
tk_send 'cget', '-' << option.to_s
|
||||
|
@ -164,6 +164,23 @@ class TkPhotoImage<TkImage
|
|||
tk_tcl2ruby(tk_send('cget', '-' << option.to_s))
|
||||
end
|
||||
end
|
||||
def cget(option)
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
cget_strict(option)
|
||||
else
|
||||
begin
|
||||
cget_strict(option)
|
||||
rescue => e
|
||||
if current_configinfo.has_key?(option.to_s)
|
||||
# error on known option
|
||||
fail e
|
||||
else
|
||||
# unknown option
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def copy(src, *opts)
|
||||
if opts.size == 0
|
||||
|
|
|
@ -8,6 +8,11 @@ require 'tk/itemfont.rb'
|
|||
module TkItemConfigOptkeys
|
||||
include TkUtil
|
||||
|
||||
def __item_optkey_aliases(id)
|
||||
{}
|
||||
end
|
||||
private :__item_optkey_aliases
|
||||
|
||||
def __item_numval_optkeys(id)
|
||||
[]
|
||||
end
|
||||
|
@ -165,6 +170,11 @@ module TkItemConfigMethod
|
|||
fail ArgumentError, "Invalid option `#{orig_opt.inspect}'"
|
||||
end
|
||||
|
||||
alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == option}
|
||||
if real_name
|
||||
option = real_name.to_s
|
||||
end
|
||||
|
||||
if ( method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[option] )
|
||||
optval = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
|
||||
begin
|
||||
|
@ -242,20 +252,35 @@ module TkItemConfigMethod
|
|||
__itemcget_core(tagOrId, option)
|
||||
rescue => e
|
||||
begin
|
||||
__itemconfiginfo_core(tagOrId)
|
||||
# not tag error -> option is unknown
|
||||
nil
|
||||
if __current_itemconfiginfo(tagOrId).has_key?(option.to_s)
|
||||
# not tag error & option is known -> error on known option
|
||||
fail e
|
||||
else
|
||||
# not tag error & option is unknown
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
def itemcget_strict(tagOrId, option)
|
||||
# never use TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
__itemcget_core(tagOrId, option)
|
||||
end
|
||||
|
||||
def __itemconfigure_core(tagOrId, slot, value=None)
|
||||
if slot.kind_of? Hash
|
||||
slot = _symbolkey2str(slot)
|
||||
|
||||
__item_optkey_aliases(tagid(tagOrId)).each{|alias_name, real_name|
|
||||
alias_name = alias_name.to_s
|
||||
if slot.has_key?(alias_name)
|
||||
slot[real_name.to_s] = slot.delete(alias_name)
|
||||
end
|
||||
}
|
||||
|
||||
__item_methodcall_optkeys(tagid(tagOrId)).each{|key, method|
|
||||
value = slot.delete(key.to_s)
|
||||
self.__send__(method, tagOrId, value) if value
|
||||
|
@ -292,6 +317,11 @@ module TkItemConfigMethod
|
|||
fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
|
||||
end
|
||||
|
||||
alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
if ( conf = __item_keyonly_optkeys(tagid(tagOrId)).find{|k, v| k.to_s == slot } )
|
||||
defkey, undefkey = conf
|
||||
if value
|
||||
|
@ -319,7 +349,8 @@ module TkItemConfigMethod
|
|||
|
||||
def __check_available_itemconfigure_options(tagOrId, keys)
|
||||
id = tagid(tagOrId)
|
||||
availables = self.current_itemconfiginfo(id).keys
|
||||
|
||||
availables = self.__current_itemconfiginfo(id).keys
|
||||
|
||||
# add non-standard keys
|
||||
availables |= __font_optkeys.map{|k|
|
||||
|
@ -329,6 +360,7 @@ module TkItemConfigMethod
|
|||
availables |= __item_keyonly_optkeys(id).keys.map{|k| k.to_s}
|
||||
|
||||
keys = _symbolkey2str(keys)
|
||||
|
||||
keys.delete_if{|k, v| !(availables.include?(k))}
|
||||
end
|
||||
|
||||
|
@ -340,7 +372,7 @@ module TkItemConfigMethod
|
|||
begin
|
||||
__itemconfigure_core(tagOrId, slot)
|
||||
rescue
|
||||
slot = __check_available_configure_options(tagOrId, slot)
|
||||
slot = __check_available_itemconfigure_options(tagOrId, slot)
|
||||
__itemconfigure_core(tagOrId, slot) unless slot.empty?
|
||||
end
|
||||
else
|
||||
|
@ -348,7 +380,13 @@ module TkItemConfigMethod
|
|||
__itemconfigure_core(tagOrId, slot, value)
|
||||
rescue => e
|
||||
begin
|
||||
__itemconfiginfo_core(tagOrId)
|
||||
if __current_itemconfiginfo(tagOrId).has_key?(slot.to_s)
|
||||
# not tag error & option is known -> error on known option
|
||||
fail e
|
||||
else
|
||||
# not tag error & option is unknown
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
|
@ -383,6 +421,12 @@ module TkItemConfigMethod
|
|||
else
|
||||
if slot
|
||||
slot = slot.to_s
|
||||
|
||||
alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
case slot
|
||||
when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
|
||||
method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
|
||||
|
@ -754,6 +798,12 @@ module TkItemConfigMethod
|
|||
else
|
||||
if slot
|
||||
slot = slot.to_s
|
||||
|
||||
alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
case slot
|
||||
when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
|
||||
method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
|
||||
|
@ -1125,7 +1175,7 @@ module TkItemConfigMethod
|
|||
end
|
||||
end
|
||||
|
||||
def current_itemconfiginfo(tagOrId, slot = nil)
|
||||
def __current_itemconfiginfo(tagOrId, slot = nil)
|
||||
if TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
if slot
|
||||
org_slot = slot
|
||||
|
@ -1147,6 +1197,7 @@ module TkItemConfigMethod
|
|||
ret[conf[0]] = conf[-1]
|
||||
end
|
||||
}
|
||||
|
||||
ret
|
||||
end
|
||||
else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
|
||||
|
@ -1157,4 +1208,8 @@ module TkItemConfigMethod
|
|||
ret
|
||||
end
|
||||
end
|
||||
|
||||
def current_itemconfiginfo(tagOrId, slot = nil)
|
||||
__current_itemconfiginfo(tagOrId, slot)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -94,7 +94,16 @@ module TkTreatItemFont
|
|||
*(__item_config_cmd(tagid(tagOrId)) << {}))
|
||||
next
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
|
||||
fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
|
||||
else
|
||||
begin
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
|
||||
rescue => e
|
||||
# ignore
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
next
|
||||
|
@ -147,7 +156,16 @@ module TkTreatItemFont
|
|||
elsif Tk::JAPANIZED_TK
|
||||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
|
||||
ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
|
||||
else
|
||||
begin
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
|
||||
rescue => e
|
||||
# ignore
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -198,7 +216,16 @@ module TkTreatItemFont
|
|||
elsif Tk::JAPANIZED_TK
|
||||
fobj = fontobj # create a new TkFont object
|
||||
else
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
|
||||
knj = hash_kv(knj) if knj.kind_of?(Hash)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
|
||||
else
|
||||
begin
|
||||
tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
|
||||
rescue => e
|
||||
# ignore
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
|
|
|
@ -34,12 +34,13 @@ module TkMenuEntryConfig
|
|||
private :__item_val2ruby_optkeys
|
||||
|
||||
alias entrycget itemcget
|
||||
alias entrycget_strict itemcget_strict
|
||||
alias entryconfigure itemconfigure
|
||||
alias entryconfiginfo itemconfiginfo
|
||||
alias current_entryconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
end
|
||||
|
||||
class Tk::Menu<TkWindow
|
||||
|
@ -518,7 +519,7 @@ class Tk::Menubutton<Tk::Label
|
|||
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||
keys = __check_available_configure_options(keys)
|
||||
unless keys.empty?
|
||||
tk_call_without_enc('destroy', @path)
|
||||
tk_call_without_enc('destroy', @path) rescue nil
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
*hash_kv(keys, true))
|
||||
end
|
||||
|
@ -642,6 +643,9 @@ class Tk::OptionMenubutton<Tk::Menubutton
|
|||
def menucget(key)
|
||||
@menu.cget(key)
|
||||
end
|
||||
def menucget_strict(key)
|
||||
@menu.cget_strict(key)
|
||||
end
|
||||
def menuconfigure(key, val=None)
|
||||
@menu.configure(key, val)
|
||||
self
|
||||
|
@ -655,6 +659,9 @@ class Tk::OptionMenubutton<Tk::Menubutton
|
|||
def entrycget(index, key)
|
||||
@menu.entrycget(index, key)
|
||||
end
|
||||
def entrycget_strict(index, key)
|
||||
@menu.entrycget_strict(index, key)
|
||||
end
|
||||
def entryconfigure(index, key, val=None)
|
||||
@menu.entryconfigure(index, key, val)
|
||||
self
|
||||
|
|
|
@ -155,15 +155,12 @@ module TkMenuSpec
|
|||
def _use_menubar?(parent)
|
||||
use_menubar = false
|
||||
if parent.kind_of?(Tk::Root) || parent.kind_of?(Tk::Toplevel)
|
||||
return true
|
||||
true
|
||||
elsif parent.current_configinfo.has_key?('menu')
|
||||
true
|
||||
else
|
||||
begin
|
||||
parent.cget('menu')
|
||||
return true
|
||||
rescue
|
||||
end
|
||||
false
|
||||
end
|
||||
false
|
||||
end
|
||||
private :_use_menubar?
|
||||
|
||||
|
@ -171,7 +168,7 @@ module TkMenuSpec
|
|||
#unless (mbar = parent.menu).kind_of?(TkMenu)
|
||||
# --> use current TkMenu class
|
||||
mbar = parent.menu
|
||||
unless parent.menu.kind_of?(Tk::Menu) || parent.menu.kind_of?(TkMenu)
|
||||
unless mbar.kind_of?(Tk::Menu) || mbar.kind_of?(TkMenu)
|
||||
#mbar = Tk::Menu.new(parent, :tearoff=>false)
|
||||
mbar = TkMenu.new(parent, :tearoff=>false)
|
||||
parent.menu(mbar)
|
||||
|
@ -198,7 +195,6 @@ module TkMenuSpec
|
|||
|
||||
if _use_menubar?(parent)
|
||||
# menubar by menu entries
|
||||
|
||||
mbar = _create_menu_for_menubar(parent)
|
||||
|
||||
menu_name = nil
|
||||
|
|
|
@ -83,6 +83,20 @@ class TkNamespace < TkObject
|
|||
super(slot)
|
||||
end
|
||||
end
|
||||
def cget_strict(slot)
|
||||
if slot == :namespace || slot == 'namespace'
|
||||
ns = super(slot)
|
||||
Tk_Namespace_ID_TBL.mutex.synchronize{
|
||||
if TkNamespace::Tk_Namespace_ID_TBL.key?(ns)
|
||||
TkNamespace::Tk_Namespace_ID_TBL[ns]
|
||||
else
|
||||
ns
|
||||
end
|
||||
}
|
||||
else
|
||||
super(slot)
|
||||
end
|
||||
end
|
||||
|
||||
def configinfo(slot = nil)
|
||||
if slot
|
||||
|
|
|
@ -9,6 +9,7 @@ module TkPack
|
|||
|
||||
TkCommandNames = ['pack'.freeze].freeze
|
||||
|
||||
=begin
|
||||
def configure(win, *args)
|
||||
if args[-1].kind_of?(Hash)
|
||||
opts = args.pop
|
||||
|
@ -29,6 +30,22 @@ module TkPack
|
|||
}
|
||||
tk_call_without_enc("pack", 'configure', *params)
|
||||
end
|
||||
=end
|
||||
def configure(*args)
|
||||
if args[-1].kind_of?(Hash)
|
||||
opts = args.pop
|
||||
else
|
||||
opts = {}
|
||||
end
|
||||
fail ArgumentError, 'no widget is given' if args.empty?
|
||||
params = []
|
||||
args.flatten(1).each{|win| params.push(_epath(win))}
|
||||
opts.each{|k, v|
|
||||
params.push("-#{k}")
|
||||
params.push(_epath(v)) # have to use 'epath' (hash_kv() is unavailable)
|
||||
}
|
||||
tk_call_without_enc("pack", 'configure', *params)
|
||||
end
|
||||
alias pack configure
|
||||
|
||||
def forget(*args)
|
||||
|
|
|
@ -15,7 +15,7 @@ module TkPalette
|
|||
].freeze
|
||||
|
||||
def TkPalette.set(*args)
|
||||
args = args.to_a.flatten if args.kind_of? Hash
|
||||
args = args[0].to_a.flatten if args[0].kind_of? Hash
|
||||
tk_call('tk_setPalette', *args)
|
||||
end
|
||||
def TkPalette.setPalette(*args)
|
||||
|
|
|
@ -76,11 +76,32 @@ class Tk::PanedWindow<TkWindow
|
|||
self
|
||||
end
|
||||
|
||||
def panecget(win, key)
|
||||
def panecget_strict(win, key)
|
||||
# win = win.epath if win.kind_of?(TkObject)
|
||||
win = _epath(win)
|
||||
tk_tcl2ruby(tk_send_without_enc('panecget', win, "-#{key}"))
|
||||
end
|
||||
def panecget(win, key)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
panecget_strict(win, key)
|
||||
else
|
||||
begin
|
||||
panecget_strict(win, key)
|
||||
rescue => e
|
||||
begin
|
||||
if current_paneconfiginfo(win).has_key?(option.to_s)
|
||||
# not tag error & option is known -> error on known option
|
||||
fail e
|
||||
else
|
||||
# not tag error & option is unknown
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def paneconfigure(win, key, value=nil)
|
||||
# win = win.epath if win.kind_of?(TkObject)
|
||||
|
|
|
@ -26,9 +26,16 @@ class Tk::Scale<TkWindow
|
|||
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||
keys = __check_available_configure_options(keys)
|
||||
unless keys.empty?
|
||||
tk_call_without_enc('destroy', @path)
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
*hash_kv(keys, true))
|
||||
begin
|
||||
tk_call_without_enc('destroy', @path)
|
||||
rescue
|
||||
# cannot destroy
|
||||
configure(keys)
|
||||
else
|
||||
# re-create widget
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
*hash_kv(keys, true))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,9 +31,16 @@ class Tk::Scrollbar<TkWindow
|
|||
tk_call_without_enc(self.class::TkCommandNames[0], @path)
|
||||
keys = __check_available_configure_options(keys)
|
||||
unless keys.empty?
|
||||
tk_call_without_enc('destroy', @path)
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
*hash_kv(keys, true))
|
||||
begin
|
||||
tk_call_without_enc('destroy', @path)
|
||||
rescue
|
||||
# cannot destroy
|
||||
configure(keys)
|
||||
else
|
||||
# re-create widget
|
||||
tk_call_without_enc(self.class::TkCommandNames[0], @path,
|
||||
*hash_kv(keys, true))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,6 +37,7 @@ class Tk::Spinbox<Tk::Entry
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -52,6 +53,7 @@ class Tk::Spinbox<Tk::Entry
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
|
|
@ -32,31 +32,37 @@ module TkTextTagConfig
|
|||
def tag_cget(tagOrId, option)
|
||||
itemcget(['tag', tagOrId], option)
|
||||
end
|
||||
def tag_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['tag', tagOrId], option)
|
||||
end
|
||||
def tag_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['tag', tagOrId], slot, value)
|
||||
end
|
||||
def tag_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['tag', tagOrId], slot)
|
||||
itemconfiginfo(['tag', tagOrId], slot)
|
||||
end
|
||||
def current_tag_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['tag', tagOrId], slot)
|
||||
current_itemconfiginfo(['tag', tagOrId], slot)
|
||||
end
|
||||
|
||||
def window_cget(tagOrId, option)
|
||||
itemcget(['window', tagOrId], option)
|
||||
end
|
||||
def window_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['window', tagOrId], option)
|
||||
end
|
||||
def window_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['window', tagOrId], slot, value)
|
||||
end
|
||||
def window_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['window', tagOrId], slot)
|
||||
itemconfiginfo(['window', tagOrId], slot)
|
||||
end
|
||||
def current_window_configinfo(tagOrId, slot=nil)
|
||||
itemconfigure(['window', tagOrId], slot)
|
||||
current_itemconfiginfo(['window', tagOrId], slot)
|
||||
end
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
end
|
||||
|
||||
class Tk::Text<TkTextWin
|
||||
|
@ -403,7 +409,7 @@ class Tk::Text<TkTextWin
|
|||
end
|
||||
alias previous_mark mark_previous
|
||||
|
||||
def image_cget(index, slot)
|
||||
def image_cget_strict(index, slot)
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
_fromUTF8(tk_send_without_enc('image', 'cget',
|
||||
|
@ -415,6 +421,28 @@ class Tk::Text<TkTextWin
|
|||
end
|
||||
end
|
||||
|
||||
def image_cget(index, slot)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
image_cget_strict(index, slot)
|
||||
else
|
||||
begin
|
||||
image_cget_strict(index, slot)
|
||||
rescue => e
|
||||
begin
|
||||
if current_image_configinfo(index).has_key?(slot.to_s)
|
||||
# not tag error & option is known -> error on known option
|
||||
fail e
|
||||
else
|
||||
# not tag error & option is unknown
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def image_configure(index, slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
_fromUTF8(tk_send_without_enc('image', 'configure',
|
||||
|
|
|
@ -52,6 +52,10 @@ class TkTextImage<TkObject
|
|||
@t.image_cget(@index, slot)
|
||||
end
|
||||
|
||||
def cget_strict(slot)
|
||||
@t.image_cget_strict(@index, slot)
|
||||
end
|
||||
|
||||
def configure(slot, value=None)
|
||||
@t.image_configure(@index, slot, value)
|
||||
self
|
||||
|
|
|
@ -132,6 +132,9 @@ class TkTextTag<TkObject
|
|||
def cget(key)
|
||||
@t.tag_cget @id, key
|
||||
end
|
||||
def cget_strict(key)
|
||||
@t.tag_cget_strict @id, key
|
||||
end
|
||||
=begin
|
||||
def cget(key)
|
||||
case key.to_s
|
||||
|
|
|
@ -72,6 +72,9 @@ class TkTextWindow<TkObject
|
|||
def cget(slot)
|
||||
@t.window_cget(@index, slot)
|
||||
end
|
||||
def cget_strict(slot)
|
||||
@t.window_cget_strict(@index, slot)
|
||||
end
|
||||
|
||||
def configure(slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
|
|
|
@ -111,7 +111,8 @@ class TkTimer
|
|||
if @running == false || @proc_max == 0 || @do_loop == 0
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
return
|
||||
end
|
||||
if @current_pos >= @proc_max
|
||||
|
@ -120,7 +121,8 @@ class TkTimer
|
|||
else
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -151,6 +153,8 @@ class TkTimer
|
|||
|
||||
@wait_var = TkVariable.new(0)
|
||||
|
||||
@at_end_proc = nil
|
||||
|
||||
@cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback))
|
||||
|
||||
@set_next = true
|
||||
|
@ -210,6 +214,12 @@ class TkTimer
|
|||
|
||||
attr_accessor :loop_exec
|
||||
|
||||
def __at_end__
|
||||
@at_end_proc.call(self) if @at_end_proc
|
||||
@wait_var.value = 0 # for wait
|
||||
end
|
||||
private :__at_end__
|
||||
|
||||
def cb_call
|
||||
@cb_cmd.call
|
||||
end
|
||||
|
@ -427,7 +437,8 @@ class TkTimer
|
|||
|
||||
def cancel
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
tk_call 'after', 'cancel', @after_id if @after_id
|
||||
@after_id = nil
|
||||
|
||||
|
@ -471,6 +482,21 @@ class TkTimer
|
|||
end
|
||||
end
|
||||
|
||||
def at_end(*arg, &b)
|
||||
if arg.empty?
|
||||
if b
|
||||
@at_end_proc = b
|
||||
else
|
||||
# no proc
|
||||
return @at_end_proc
|
||||
end
|
||||
else
|
||||
fail ArgumentError, "wrong number of arguments" if arg.length != 1 || b
|
||||
@at_end_proc = arg[0]
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def wait(on_thread = true, check_root = false)
|
||||
if $SAFE >= 4
|
||||
fail SecurityError, "can't wait timer at $SAFE >= 4"
|
||||
|
@ -569,7 +595,8 @@ class TkRTTimer < TkTimer
|
|||
if @running == false || @proc_max == 0 || @do_loop == 0
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
return
|
||||
end
|
||||
if @current_pos >= @proc_max
|
||||
|
@ -578,7 +605,8 @@ class TkRTTimer < TkTimer
|
|||
else
|
||||
Tk_CBTBL.delete(@id) ;# for GC
|
||||
@running = false
|
||||
@wait_var.value = 0
|
||||
# @wait_var.value = 0
|
||||
__at_end__
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
|
@ -72,7 +72,7 @@ class Tk::Toplevel<TkWindow
|
|||
|
||||
conf_methods = _symbolkey2str(__methodcall_optkeys())
|
||||
|
||||
keys.each{|k,v|
|
||||
keys.each{|k,v| # k is a String
|
||||
if conf_methods.key?(k)
|
||||
wm_cmds[conf_methods[k]] = v
|
||||
elsif Wm.method_defined?(k)
|
||||
|
|
|
@ -50,7 +50,8 @@ module Tk
|
|||
key2class.each{|key, klass|
|
||||
if keys[key].kind_of?(Array)
|
||||
cmd, *args = keys[key]
|
||||
keys[key] = klass.new(cmd, args.join(' '))
|
||||
#keys[key] = klass.new(cmd, args.join(' '))
|
||||
keys[key] = klass.new(cmd, *args)
|
||||
# elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
|
||||
elsif TkComm._callback_entry?(keys[key])
|
||||
keys[key] = klass.new(keys[key])
|
||||
|
@ -151,7 +152,8 @@ module Tk
|
|||
key2class.each{|key, klass|
|
||||
if keys[key].kind_of?(Array)
|
||||
cmd, *args = keys[key]
|
||||
keys[key] = klass.new(cmd, args.join(' '))
|
||||
#keys[key] = klass.new(cmd, args.join(' '))
|
||||
keys[key] = klass.new(cmd, *args)
|
||||
# elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
|
||||
elsif TkComm._callback_entry?(keys[key])
|
||||
keys[key] = klass.new(keys[key])
|
||||
|
@ -249,6 +251,7 @@ class TkValidateCommand
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -264,6 +267,7 @@ class TkValidateCommand
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -293,6 +297,7 @@ class TkValidateCommand
|
|||
extra_args_tbl = klass._get_extra_args_tbl
|
||||
|
||||
if args.compact.size > 0
|
||||
args.map!{|arg| klass._sym2subst(arg)}
|
||||
args = args.join(' ')
|
||||
keys = klass._get_subst_key(args)
|
||||
if cmd.kind_of?(String)
|
||||
|
|
|
@ -362,7 +362,7 @@ module Tk
|
|||
end
|
||||
end
|
||||
def overrideredirect(mode=TkComm::None)
|
||||
Wm.overrideredirect(self, mode=TkComm::None)
|
||||
Wm.overrideredirect(self, mode)
|
||||
end
|
||||
alias wm_overrideredirect overrideredirect
|
||||
TOPLEVEL_METHODCALL_OPTKEYS['overrideredirect'] = 'overrideredirect'
|
||||
|
@ -545,7 +545,7 @@ module Tk
|
|||
module Wm_for_General
|
||||
Wm.instance_methods.each{|m|
|
||||
if (m = m.to_s) =~ /^wm_(.*)$/
|
||||
eval "def #{m}(*args); Tk::Wm.#{$1}(self, *args); end"
|
||||
eval "def #{m}(*args, &b); Tk::Wm.#{$1}(self, *args, &b); end"
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
@ -85,6 +85,9 @@ module Tk::BLT
|
|||
def axis_cget(id, option)
|
||||
ret = itemcget(['axis', tagid(id)], option)
|
||||
end
|
||||
def axis_cget_strict(id, option)
|
||||
ret = itemcget_strict(['axis', tagid(id)], option)
|
||||
end
|
||||
def axis_configure(*args)
|
||||
slot = args.pop
|
||||
if slot.kind_of?(Hash)
|
||||
|
@ -118,6 +121,9 @@ module Tk::BLT
|
|||
def crosshairs_cget(option)
|
||||
itemcget('crosshairs', option)
|
||||
end
|
||||
def crosshairs_cget_strict(option)
|
||||
itemcget_strict('crosshairs', option)
|
||||
end
|
||||
def crosshairs_configure(slot, value=None)
|
||||
itemconfigure('crosshairs', slot, value)
|
||||
end
|
||||
|
@ -131,6 +137,9 @@ module Tk::BLT
|
|||
def element_cget(id, option)
|
||||
itemcget(['element', tagid(id)], option)
|
||||
end
|
||||
def element_cget_strict(id, option)
|
||||
itemcget_strict(['element', tagid(id)], option)
|
||||
end
|
||||
def element_configure(*args)
|
||||
slot = args.pop
|
||||
if slot.kind_of?(Hash)
|
||||
|
@ -152,6 +161,9 @@ module Tk::BLT
|
|||
def bar_cget(id, option)
|
||||
itemcget(['bar', tagid(id)], option)
|
||||
end
|
||||
def bar_cget_strict(id, option)
|
||||
itemcget_strict(['bar', tagid(id)], option)
|
||||
end
|
||||
def bar_configure(*args)
|
||||
slot = args.pop
|
||||
if slot.kind_of?(Hash)
|
||||
|
@ -173,6 +185,9 @@ module Tk::BLT
|
|||
def line_cget(id, option)
|
||||
itemcget(['line', tagid(id)], option)
|
||||
end
|
||||
def line_cget_strict(id, option)
|
||||
itemcget_strict(['line', tagid(id)], option)
|
||||
end
|
||||
def line_configure(*args)
|
||||
slot = args.pop
|
||||
if slot.kind_of?(Hash)
|
||||
|
@ -194,6 +209,9 @@ module Tk::BLT
|
|||
def gridline_cget(option)
|
||||
itemcget('grid', option)
|
||||
end
|
||||
def gridline_cget_strict(option)
|
||||
itemcget_strict('grid', option)
|
||||
end
|
||||
def gridline_configure(slot, value=None)
|
||||
itemconfigure('grid', slot, value)
|
||||
end
|
||||
|
@ -207,6 +225,9 @@ module Tk::BLT
|
|||
def legend_cget(option)
|
||||
itemcget('legend', option)
|
||||
end
|
||||
def legend_cget_strict(option)
|
||||
itemcget_strict('legend', option)
|
||||
end
|
||||
def legend_configure(slot, value=None)
|
||||
itemconfigure('legend', slot, value)
|
||||
end
|
||||
|
@ -220,6 +241,9 @@ module Tk::BLT
|
|||
def pen_cget(id, option)
|
||||
itemcget(['pen', tagid(id)], option)
|
||||
end
|
||||
def pen_cget_strict(id, option)
|
||||
itemcget_strict(['pen', tagid(id)], option)
|
||||
end
|
||||
def pen_configure(*args)
|
||||
slot = args.pop
|
||||
if slot.kind_of?(Hash)
|
||||
|
@ -241,6 +265,9 @@ module Tk::BLT
|
|||
def postscript_cget(option)
|
||||
itemcget('postscript', option)
|
||||
end
|
||||
def postscript_cget_strict(option)
|
||||
itemcget_strict('postscript', option)
|
||||
end
|
||||
def postscript_configure(slot, value=None)
|
||||
itemconfigure('postscript', slot, value)
|
||||
end
|
||||
|
@ -254,6 +281,9 @@ module Tk::BLT
|
|||
def marker_cget(id, option)
|
||||
itemcget(['marker', tagid(id)], option)
|
||||
end
|
||||
def marker_cget_strict(id, option)
|
||||
itemcget_strict(['marker', tagid(id)], option)
|
||||
end
|
||||
def marker_configure(*args)
|
||||
slot = args.pop
|
||||
if slot.kind_of?(Hash)
|
||||
|
@ -273,11 +303,12 @@ module Tk::BLT
|
|||
end
|
||||
|
||||
alias __itemcget itemcget
|
||||
alias __itemcget_strict itemcget_strict
|
||||
alias __itemconfiginfo itemconfiginfo
|
||||
alias __current_itemconfiginfo current_itemconfiginfo
|
||||
private :__itemcget, :__itemconfiginfo, :__current_itemconfiginfo
|
||||
|
||||
def itemcget(tagOrId, option)
|
||||
def itemcget_strict(tagOrId, option)
|
||||
ret = __itemcget(tagid(tagOrId), option)
|
||||
if option == 'bindtags' || option == :bindtags
|
||||
ret.collect{|tag| TkBindTag.id2obj(tag)}
|
||||
|
@ -285,6 +316,27 @@ module Tk::BLT
|
|||
ret
|
||||
end
|
||||
end
|
||||
def itemcget(tagOrId, option)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
itemcget_strict(tagOrId, option)
|
||||
else
|
||||
begin
|
||||
itemcget_strict(tagOrId, option)
|
||||
rescue => e
|
||||
begin
|
||||
if current_itemconfiginfo(tagOrId).has_key?(option.to_s)
|
||||
# error on known option
|
||||
fail e
|
||||
else
|
||||
# unknown option
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
def itemconfiginfo(tagOrId, slot = nil)
|
||||
ret = __itemconfiginfo(tagid(tagOrId), slot)
|
||||
|
||||
|
@ -321,8 +373,8 @@ module Tk::BLT
|
|||
ret
|
||||
end
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
#################
|
||||
|
||||
|
@ -428,6 +480,9 @@ module Tk::BLT
|
|||
def cget(option)
|
||||
@chart.axis_cget(@id, option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@chart.axis_cget_strict(@id, option)
|
||||
end
|
||||
def configure(key, value=None)
|
||||
@chart.axis_configure(@id, key, value)
|
||||
self
|
||||
|
@ -530,6 +585,9 @@ module Tk::BLT
|
|||
def cget(option)
|
||||
@chart.crosshair_cget(option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@chart.crosshair_cget_strict(option)
|
||||
end
|
||||
def configure(key, value=None)
|
||||
@chart.crosshair_configure(key, value)
|
||||
self
|
||||
|
@ -675,6 +733,9 @@ module Tk::BLT
|
|||
# @chart.element_cget(@id, option)
|
||||
@chart.__send__(@typename + '_cget', @id, option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@chart.__send__(@typename + '_cget_strict', @id, option)
|
||||
end
|
||||
def configure(key, value=None)
|
||||
# @chart.element_configure(@id, key, value)
|
||||
@chart.__send__(@typename + '_configure', @id, key, value)
|
||||
|
@ -775,6 +836,9 @@ module Tk::BLT
|
|||
def cget(option)
|
||||
@chart.gridline_cget(option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@chart.gridline_cget_strict(option)
|
||||
end
|
||||
def configure(key, value=None)
|
||||
@chart.gridline_configure(key, value)
|
||||
self
|
||||
|
@ -846,6 +910,9 @@ module Tk::BLT
|
|||
def cget(option)
|
||||
@chart.legend_cget(option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@chart.legend_cget_strict(option)
|
||||
end
|
||||
def configure(key, value=None)
|
||||
@chart.legend_configure(key, value)
|
||||
self
|
||||
|
@ -972,6 +1039,9 @@ module Tk::BLT
|
|||
def cget(option)
|
||||
@chart.pen_cget(@id, option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@chart.pen_cget_strict(@id, option)
|
||||
end
|
||||
def configure(key, value=None)
|
||||
@chart.pen_configure(@id, key, value)
|
||||
self
|
||||
|
@ -1039,6 +1109,9 @@ module Tk::BLT
|
|||
def cget(option)
|
||||
@chart.postscript_cget(option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@chart.postscript_cget_strict(option)
|
||||
end
|
||||
def configure(key, value=None)
|
||||
@chart.postscript_configure(key, value)
|
||||
self
|
||||
|
@ -1117,6 +1190,13 @@ module Tk::BLT
|
|||
fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
|
||||
}
|
||||
|
||||
__item_optkey_aliases(nil).each{|alias_name, real_name|
|
||||
alias_name = alias_name.to_s
|
||||
if keys.has_key?(alias_name)
|
||||
keys[real_name.to_s] = keys.delete(alias_name)
|
||||
end
|
||||
}
|
||||
|
||||
__item_methodcall_optkeys(nil).each{|key|
|
||||
key = key.to_s
|
||||
methodkeys[key] = keys.delete(key) if keys.key?(key)
|
||||
|
@ -1192,6 +1272,9 @@ module Tk::BLT
|
|||
def cget(option)
|
||||
@chart.marker_cget(@id, option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@chart.marker_cget_strict(@id, option)
|
||||
end
|
||||
def configure(key, value=None)
|
||||
@chart.marker_configure(@id, key, value)
|
||||
self
|
||||
|
@ -1774,6 +1857,9 @@ module Tk::BLT
|
|||
def xaxis_cget(option)
|
||||
itemcget('xaxis', option)
|
||||
end
|
||||
def xaxis_cget_strict(option)
|
||||
itemcget_strict('xaxis', option)
|
||||
end
|
||||
def xaxis_configure(slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
slot = _symbolkey2str(slot)
|
||||
|
@ -1843,6 +1929,9 @@ module Tk::BLT
|
|||
def x2axis_cget(option)
|
||||
itemcget('x2axis', option)
|
||||
end
|
||||
def x2axis_cget_strict(option)
|
||||
itemcget_strict('x2axis', option)
|
||||
end
|
||||
def x2axis_configure(slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
slot = _symbolkey2str(slot)
|
||||
|
@ -1912,6 +2001,9 @@ module Tk::BLT
|
|||
def yaxis_cget(option)
|
||||
itemcget('yaxis', option)
|
||||
end
|
||||
def yaxis_cget_strict(option)
|
||||
itemcget_strict('yaxis', option)
|
||||
end
|
||||
def yaxis_configure(slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
slot = _symbolkey2str(slot)
|
||||
|
@ -1981,6 +2073,9 @@ module Tk::BLT
|
|||
def y2axis_cget(option)
|
||||
itemcget('y2axis', option)
|
||||
end
|
||||
def y2axis_cget_strict(option)
|
||||
itemcget_strict('y2axis', option)
|
||||
end
|
||||
def y2axis_configure(slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
slot = _symbolkey2str(slot)
|
||||
|
|
|
@ -81,6 +81,7 @@ module Tk::BLT
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -96,6 +97,7 @@ module Tk::BLT
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL)
|
||||
|
||||
|
@ -123,6 +125,7 @@ module Tk::BLT
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -138,6 +141,7 @@ module Tk::BLT
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL)
|
||||
|
||||
|
@ -177,6 +181,7 @@ module Tk::BLT
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -192,6 +197,7 @@ module Tk::BLT
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL)
|
||||
end
|
||||
|
|
|
@ -22,6 +22,7 @@ module Tk::BLT
|
|||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
alias window_cget itemcget
|
||||
alias window_cget_strict itemcget_strict
|
||||
alias window_configure itemconfigure
|
||||
alias window_configuinfo itemconfiginfo
|
||||
alias current_window_configuinfo current_itemconfiginfo
|
||||
|
|
|
@ -29,6 +29,9 @@ module Tk::BLT
|
|||
def blt_table_cget(*args)
|
||||
Tk::BLT::Table.cget(self, *args)
|
||||
end
|
||||
def blt_table_cget_strict(*args)
|
||||
Tk::BLT::Table.cget_strict(self, *args)
|
||||
end
|
||||
|
||||
def blt_table_configure(*args)
|
||||
Tk::BLT::Table.configure(self, *args)
|
||||
|
@ -92,6 +95,9 @@ module Tk::BLT
|
|||
def blt_table_itemcget(*args)
|
||||
Tk::BLT::Table.itemcget(self, *args)
|
||||
end
|
||||
def blt_table_itemcget_strict(*args)
|
||||
Tk::BLT::Table.itemcget_strict(self, *args)
|
||||
end
|
||||
|
||||
def blt_table_itemconfigure(*args)
|
||||
Tk::BLT::Table.itemconfigure(self, *args)
|
||||
|
@ -136,12 +142,13 @@ class << Tk::BLT::Table
|
|||
private :__item_pathname
|
||||
|
||||
alias __itemcget itemcget
|
||||
alias __itemcget_strict itemcget_strict
|
||||
alias __itemconfigure itemconfigure
|
||||
alias __itemconfiginfo itemconfiginfo
|
||||
alias __current_itemconfiginfo current_itemconfiginfo
|
||||
|
||||
private :__itemcget, :__itemconfigure
|
||||
private :__itemconfiginfo, :__current_itemconfiginfo
|
||||
private :__itemcget, :__itemcget_strict
|
||||
private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
|
||||
|
||||
def __boolval_optkeys
|
||||
super() << 'propagate'
|
||||
|
@ -176,6 +183,9 @@ class << Tk::BLT::Table
|
|||
def cget(container, option)
|
||||
__itemcget([container], option)
|
||||
end
|
||||
def cget_strict(container, option)
|
||||
__itemcget_strict([container], option)
|
||||
end
|
||||
|
||||
def configure(container, *args)
|
||||
__itemconfigure([container], *args)
|
||||
|
@ -192,6 +202,9 @@ class << Tk::BLT::Table
|
|||
def itemcget(container, item, option)
|
||||
__itemcget([container, tagid(item)], option)
|
||||
end
|
||||
def itemcget_strict(container, item, option)
|
||||
__itemcget_strict([container, tagid(item)], option)
|
||||
end
|
||||
|
||||
def itemconfigure(container, *args)
|
||||
if args[-1].kind_of?(Hash)
|
||||
|
|
|
@ -128,6 +128,9 @@ module Tk::BLT
|
|||
def cget(*args)
|
||||
@t.tab_cget(@id, *args)
|
||||
end
|
||||
def cget_strict(*args)
|
||||
@t.tab_cget_strict(@id, *args)
|
||||
end
|
||||
def configure(*args)
|
||||
@t.tab_configure(@id, *args)
|
||||
end
|
||||
|
@ -240,6 +243,7 @@ module Tk::BLT
|
|||
private :__item_pathname
|
||||
|
||||
alias tab_cget itemcget
|
||||
alias tab_cget_strict itemcget_strict
|
||||
alias tab_configure itemconfigure
|
||||
alias tab_configinfo itemconfiginfo
|
||||
alias current_tab_configinfo current_itemconfiginfo
|
||||
|
|
|
@ -30,11 +30,14 @@ module Tk::BLT
|
|||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
def cget(master, option)
|
||||
itemconfigure(master, slot, value)
|
||||
itemcget(master, option)
|
||||
end
|
||||
def cget_strict(master, option)
|
||||
itemcget_strict(master, option)
|
||||
end
|
||||
def configure(master, slot, value=None)
|
||||
itemconfigure(master, slot, value)
|
||||
|
|
|
@ -98,6 +98,9 @@ module Tk::BLT::Treeview::ConfigMethod
|
|||
def column_cget(name, option)
|
||||
itemcget(['column', name], option)
|
||||
end
|
||||
def column_cget_strict(name, option)
|
||||
itemcget_strict(['column', name], option)
|
||||
end
|
||||
def column_configure(name, slot, value=None)
|
||||
itemconfigure(['column', name], slot, value)
|
||||
end
|
||||
|
@ -111,6 +114,9 @@ module Tk::BLT::Treeview::ConfigMethod
|
|||
def button_cget(option)
|
||||
itemcget('button', option)
|
||||
end
|
||||
def button_cget_strict(option)
|
||||
itemcget_strict('button', option)
|
||||
end
|
||||
def button_configure(slot, value=None)
|
||||
itemconfigure('button', slot, value)
|
||||
end
|
||||
|
@ -129,6 +135,14 @@ module Tk::BLT::Treeview::ConfigMethod
|
|||
ret
|
||||
end
|
||||
end
|
||||
def entry_cget_strict(option)
|
||||
ret = itemcget_strict('entry', option)
|
||||
if option == 'bindtags' || option == :bindtags
|
||||
ret.collect{|tag| TkBindTag.id2obj(tag)}
|
||||
else
|
||||
ret
|
||||
end
|
||||
end
|
||||
def entry_configure(slot, value=None)
|
||||
itemconfigure('entry', slot, value)
|
||||
end
|
||||
|
@ -170,6 +184,9 @@ module Tk::BLT::Treeview::ConfigMethod
|
|||
def sort_cget(option)
|
||||
itemcget('sort', option)
|
||||
end
|
||||
def sort_cget_strict(option)
|
||||
itemcget_strict('sort', option)
|
||||
end
|
||||
def sort_configure(slot, value=None)
|
||||
itemconfigure('sort', slot, value)
|
||||
end
|
||||
|
@ -183,6 +200,9 @@ module Tk::BLT::Treeview::ConfigMethod
|
|||
def text_cget(option)
|
||||
itemcget('text', option)
|
||||
end
|
||||
def text_cget_strict(option)
|
||||
itemcget_strict('text', option)
|
||||
end
|
||||
def text_configure(slot, value=None)
|
||||
itemconfigure('text', slot, value)
|
||||
end
|
||||
|
@ -193,8 +213,8 @@ module Tk::BLT::Treeview::ConfigMethod
|
|||
current_itemconfiginfo('text', slot)
|
||||
end
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
end
|
||||
|
||||
class Tk::BLT::Treeview
|
||||
|
@ -239,6 +259,7 @@ class Tk::BLT::Treeview
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -254,6 +275,7 @@ class Tk::BLT::Treeview
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -492,6 +514,7 @@ class Tk::BLT::Treeview
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -507,6 +530,7 @@ class Tk::BLT::Treeview
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -523,7 +547,8 @@ class Tk::BLT::Treeview
|
|||
def _find_exec_flag_value(val)
|
||||
if val.kind_of?(Array)
|
||||
cmd, *args = val
|
||||
FindExecFlagValue.new(cmd, args.join(' '))
|
||||
#FindExecFlagValue.new(cmd, args.join(' '))
|
||||
FindExecFlagValue.new(cmd, *args)
|
||||
elsif TkComm._callback_entry?(val)
|
||||
FindExecFlagValue.new(val)
|
||||
else
|
||||
|
|
|
@ -30,11 +30,14 @@ module Tk::BLT
|
|||
end
|
||||
private :__item_config_cmd
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
def cget(win, option)
|
||||
itemconfigure(['cget', win], slot, value)
|
||||
itemcget(['cget', win], option)
|
||||
end
|
||||
def cget_strict(win, option)
|
||||
itemcget_strict(['cget', win], option)
|
||||
end
|
||||
def configure(win, slot, value=None)
|
||||
itemconfigure(['configure', win], slot, value)
|
||||
|
@ -46,8 +49,11 @@ module Tk::BLT
|
|||
current_itemconfiginfo(['configure', win], slot)
|
||||
end
|
||||
|
||||
def tokwn_cget(win, option)
|
||||
itemconfigure(['token', 'cget', win], slot, value)
|
||||
def token_cget(win, option)
|
||||
itemcget(['token', 'cget', win], option)
|
||||
end
|
||||
def token_cget_strict(win, option)
|
||||
itemcget_strict(['token', 'cget', win], option)
|
||||
end
|
||||
def token_configure(win, slot, value=None)
|
||||
itemconfigure(['token', 'configure', win], slot, value)
|
||||
|
|
|
@ -146,7 +146,7 @@ module Tk::BLT
|
|||
end
|
||||
end
|
||||
end
|
||||
def cget(key)
|
||||
def cget_strict(key)
|
||||
key = key.to_s
|
||||
begin
|
||||
info.assoc(key)[1]
|
||||
|
@ -154,5 +154,22 @@ module Tk::BLT
|
|||
fail ArgumentError, "unknown option '#{key}'"
|
||||
end
|
||||
end
|
||||
def cget(key)
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
cget_strict(key)
|
||||
else
|
||||
begin
|
||||
cget_strict(key)
|
||||
rescue => e
|
||||
if current_configinfo.has_key?(key.to_s)
|
||||
# error on known option
|
||||
fail e
|
||||
else
|
||||
# unknown option
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -59,6 +59,13 @@ class Tk::BWidget::Dialog
|
|||
end
|
||||
end
|
||||
|
||||
def cget_strict(slot)
|
||||
if slot.to_s == 'relative'
|
||||
super('parent')
|
||||
else
|
||||
super(slot)
|
||||
end
|
||||
end
|
||||
def cget(slot)
|
||||
if slot.to_s == 'relative'
|
||||
super('parent')
|
||||
|
|
|
@ -34,6 +34,13 @@ module Tk::BWidget::DynamicHelp
|
|||
['DynamicHelp::configure']
|
||||
end
|
||||
|
||||
def self.cget_strict(slot)
|
||||
slot = slot.to_s
|
||||
info = {}
|
||||
self.current_configinfo.each{|k,v| info[k.to_s] = v if k.to_s == slot}
|
||||
fail RuntimeError, "unknown option \"-#{slot}\"" if info.empty?
|
||||
info.values[0]
|
||||
end
|
||||
def self.cget(slot)
|
||||
self.current_configinfo(slot).values[0]
|
||||
end
|
||||
|
|
|
@ -297,6 +297,9 @@ class Tk::BWidget::ListBox::Item
|
|||
def cget(key)
|
||||
@listbox.itemcget(@id, key)
|
||||
end
|
||||
def cget_strict(key)
|
||||
@listbox.itemcget_strict(@id, key)
|
||||
end
|
||||
|
||||
def configure(key, val=None)
|
||||
@listbox.itemconfigure(@id, key, val)
|
||||
|
|
|
@ -65,6 +65,17 @@ class Tk::BWidget::MessageDlg
|
|||
end
|
||||
@keys[slot]
|
||||
end
|
||||
def cget_strict(slot)
|
||||
slot = slot.to_s
|
||||
if slot == 'relative'
|
||||
slot = 'parent'
|
||||
end
|
||||
if winfo_exist?
|
||||
val = super(slot)
|
||||
@keys[slot] = val
|
||||
end
|
||||
@keys[slot]
|
||||
end
|
||||
|
||||
def configure(slot, value=None)
|
||||
if winfo_exist?
|
||||
|
|
|
@ -358,6 +358,9 @@ class Tk::BWidget::Tree::Node
|
|||
def cget(key)
|
||||
@tree.itemcget(@id, key)
|
||||
end
|
||||
def cget_strict(key)
|
||||
@tree.itemcget_strict(@id, key)
|
||||
end
|
||||
|
||||
def configure(key, val=None)
|
||||
@tree.itemconfigure(@id, key, val)
|
||||
|
|
|
@ -29,6 +29,13 @@ module Tk::BWidget::Widget
|
|||
['Widget::configure']
|
||||
end
|
||||
|
||||
def self.cget_strict(slot)
|
||||
slot = slot.to_s
|
||||
info = {}
|
||||
self.current_configinfo.each{|k,v| info[k.to_s] = v if k.to_s == slot}
|
||||
fail RuntimeError, "unknown option \"-#{slot}\"" if info.empty?
|
||||
info.values[0]
|
||||
end
|
||||
def self.cget(slot)
|
||||
self.current_configinfo(slot).values[0]
|
||||
end
|
||||
|
@ -105,9 +112,12 @@ module Tk::BWidget::Widget
|
|||
tk_call('Widget::setoption', win, option, value)
|
||||
end
|
||||
|
||||
def self.sub_cget(win, subwidget)
|
||||
def self.sub_cget_strict(win, subwidget)
|
||||
tk_call('Widget::subcget', win, subwidget)
|
||||
end
|
||||
def self.sub_cget(win, subwidget)
|
||||
self.sub_cget_strict(win, subwidget)
|
||||
end
|
||||
|
||||
def self.sync_options(klass, subclass, subpath, options)
|
||||
tk_call('Widget::syncoptions', klass, subclass, subpath, options)
|
||||
|
|
|
@ -47,12 +47,13 @@ class Tk::Iwidgets::Buttonbox
|
|||
end
|
||||
|
||||
alias buttoncget itemcget
|
||||
alias buttoncget_strict itemcget_strict
|
||||
alias buttonconfigure itemconfigure
|
||||
alias buttonconfiginfo itemconfiginfo
|
||||
alias current_buttonconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ class Tk::Iwidgets::Calendar
|
|||
KEY_TBL = [ [?d, ?s, :date], nil ]
|
||||
PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -61,6 +62,7 @@ class Tk::Iwidgets::Calendar
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
|
|
@ -47,12 +47,13 @@ class Tk::Iwidgets::Checkbox
|
|||
end
|
||||
|
||||
alias buttoncget itemcget
|
||||
alias buttoncget_strict itemcget_strict
|
||||
alias buttonconfigure itemconfigure
|
||||
alias buttonconfiginfo itemconfiginfo
|
||||
alias current_buttonconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -47,12 +47,13 @@ class Tk::Iwidgets::Dialogshell
|
|||
end
|
||||
|
||||
alias buttoncget itemcget
|
||||
alias buttoncget_strict itemcget_strict
|
||||
alias buttonconfigure itemconfigure
|
||||
alias buttonconfiginfo itemconfiginfo
|
||||
alias current_buttonconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ class Tk::Iwidgets::Entryfield
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -58,6 +59,7 @@ class Tk::Iwidgets::Entryfield
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
end
|
||||
|
|
|
@ -31,6 +31,7 @@ class Tk::Iwidgets::Hierarchy
|
|||
KEY_TBL = [ [?n, ?s, :node], nil ]
|
||||
PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -46,6 +47,7 @@ class Tk::Iwidgets::Hierarchy
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -74,6 +76,7 @@ class Tk::Iwidgets::Hierarchy
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -89,6 +92,7 @@ class Tk::Iwidgets::Hierarchy
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -112,6 +116,7 @@ class Tk::Iwidgets::Hierarchy
|
|||
]
|
||||
PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -127,6 +132,7 @@ class Tk::Iwidgets::Hierarchy
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
|
|
@ -62,12 +62,13 @@ class Tk::Iwidgets::Menubar
|
|||
end
|
||||
|
||||
alias menucget itemcget
|
||||
alias menucget_strict itemcget_strict
|
||||
alias menuconfigure itemconfigure
|
||||
alias menuconfiginfo itemconfiginfo
|
||||
alias current_menuconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -47,12 +47,13 @@ class Tk::Iwidgets::Messagebox
|
|||
private :__item_boolval_optkeys
|
||||
|
||||
alias typecget itemcget
|
||||
alias typecget_strict itemcget_strict
|
||||
alias typeconfigure itemconfigure
|
||||
alias typeconfiginfo itemconfiginfo
|
||||
alias current_typeconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -42,12 +42,13 @@ class Tk::Iwidgets::Notebook
|
|||
end
|
||||
|
||||
alias pagecget itemcget
|
||||
alias pagecget_strict itemcget_strict
|
||||
alias pageconfigure itemconfigure
|
||||
alias pageconfiginfo itemconfiginfo
|
||||
alias current_pageconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -42,12 +42,13 @@ class Tk::Iwidgets::Panedwindow
|
|||
end
|
||||
|
||||
alias panecget itemcget
|
||||
alias panecget_strict itemcget_strict
|
||||
alias paneconfigure itemconfigure
|
||||
alias paneconfiginfo itemconfiginfo
|
||||
alias current_paneconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -47,12 +47,13 @@ class Tk::Iwidgets::Radiobox
|
|||
end
|
||||
|
||||
alias buttoncget itemcget
|
||||
alias buttoncget_strict itemcget_strict
|
||||
alias buttonconfigure itemconfigure
|
||||
alias buttonconfiginfo itemconfiginfo
|
||||
alias current_buttonconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class Tk::Iwidgets::Scrolledcanvas
|
|||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @canvas.methods.include?(id.id2name)
|
||||
if @canvas.respond_to?(id)
|
||||
@canvas.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
|
|
|
@ -42,7 +42,7 @@ class Tk::Iwidgets::Scrolledlistbox
|
|||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @listbox.methods.include?(id.id2name)
|
||||
if @listbox.respond_to?(id)
|
||||
@listbox.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
|
|
|
@ -37,7 +37,7 @@ class Tk::Iwidgets::Scrolledtext
|
|||
end
|
||||
|
||||
def method_missing(id, *args)
|
||||
if @text.methods.include?(id.id2name)
|
||||
if @text.respond_to?(id)
|
||||
@text.__send__(id, *args)
|
||||
else
|
||||
super(id, *args)
|
||||
|
@ -116,7 +116,7 @@ class Tk::Iwidgets::Scrolledtext
|
|||
get('-displaychars', *index)
|
||||
end
|
||||
|
||||
def image_cget(index, slot)
|
||||
def image_cget_strict(index, slot)
|
||||
case slot.to_s
|
||||
when 'text', 'label', 'show', 'data', 'file'
|
||||
_fromUTF8(tk_send_without_enc('image', 'cget',
|
||||
|
@ -127,6 +127,27 @@ class Tk::Iwidgets::Scrolledtext
|
|||
"-#{slot}")))
|
||||
end
|
||||
end
|
||||
def image_cget(index, slot)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
image_cget_strict(index, slot)
|
||||
else
|
||||
begin
|
||||
image_cget_strict(index, slot)
|
||||
rescue => e
|
||||
begin
|
||||
if current_image_configinfo.has_key?(slot.to_s)
|
||||
# error on known option
|
||||
fail e
|
||||
else
|
||||
# unknown option
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def image_configure(index, slot, value=None)
|
||||
if slot.kind_of? Hash
|
||||
|
|
|
@ -38,6 +38,7 @@ class Tk::Iwidgets::Spinner
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -53,6 +54,7 @@ class Tk::Iwidgets::Spinner
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
end
|
||||
|
|
|
@ -47,12 +47,13 @@ class Tk::Iwidgets::Tabnotebook
|
|||
end
|
||||
|
||||
alias pagecget itemcget
|
||||
alias pagecget_strict itemcget_strict
|
||||
alias pageconfigure itemconfigure
|
||||
alias pageconfiginfo itemconfiginfo
|
||||
alias current_pageconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -42,12 +42,13 @@ class Tk::Iwidgets::Tabset
|
|||
end
|
||||
|
||||
alias tabcget itemcget
|
||||
alias tabcget_strict itemcget_strict
|
||||
alias tabconfigure itemconfigure
|
||||
alias tabconfiginfo itemconfiginfo
|
||||
alias current_tabconfiginfo current_itemconfiginfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
|
||||
####################################
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class Tk::Tcllib::GetString_Dialog
|
|||
@variable.value
|
||||
end
|
||||
|
||||
def cget(slot)
|
||||
def cget_strict(slot)
|
||||
slot = slot.to_s
|
||||
if slot == 'text'
|
||||
@text
|
||||
|
@ -95,6 +95,9 @@ class Tk::Tcllib::GetString_Dialog
|
|||
@keys[slot]
|
||||
end
|
||||
end
|
||||
def cget(slot)
|
||||
cget_strict(slot)
|
||||
end
|
||||
|
||||
def configure(slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
|
|
|
@ -90,7 +90,7 @@ class Tk::Tcllib::Swaplist_Dialog
|
|||
end
|
||||
alias selected value
|
||||
|
||||
def cget(slot)
|
||||
def cget_strict(slot)
|
||||
slot = slot.to_s
|
||||
if slot == 'complete_list'
|
||||
@complete_list
|
||||
|
@ -100,6 +100,9 @@ class Tk::Tcllib::Swaplist_Dialog
|
|||
@keys[slot]
|
||||
end
|
||||
end
|
||||
def cget(slot)
|
||||
cget_strict(slot)
|
||||
end
|
||||
|
||||
def configure(slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
|
|
|
@ -70,6 +70,9 @@ module Tk::Tcllib::TablelistItemConfig
|
|||
def cell_cget(tagOrId, option)
|
||||
itemcget(['cell', tagOrId], option)
|
||||
end
|
||||
def cell_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['cell', tagOrId], option)
|
||||
end
|
||||
def cell_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['cell', tagOrId], slot, value)
|
||||
end
|
||||
|
@ -80,6 +83,7 @@ module Tk::Tcllib::TablelistItemConfig
|
|||
current_itemconfiginfo(['cell', tagOrId], slot)
|
||||
end
|
||||
alias cellcget cell_cget
|
||||
alias cellcget_strict cell_cget_strict
|
||||
alias cellconfigure cell_configure
|
||||
alias cellconfiginfo cell_configinfo
|
||||
alias current_cellconfiginfo current_cell_configinfo
|
||||
|
@ -87,6 +91,9 @@ module Tk::Tcllib::TablelistItemConfig
|
|||
def column_cget(tagOrId, option)
|
||||
itemcget(['column', tagOrId], option)
|
||||
end
|
||||
def column_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['column', tagOrId], option)
|
||||
end
|
||||
def column_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['column', tagOrId], slot, value)
|
||||
end
|
||||
|
@ -97,6 +104,7 @@ module Tk::Tcllib::TablelistItemConfig
|
|||
current_itemconfiginfo(['column', tagOrId], slot)
|
||||
end
|
||||
alias columncget column_cget
|
||||
alias columncget_strict column_cget_strict
|
||||
alias columnconfigure column_configure
|
||||
alias columnconfiginfo column_configinfo
|
||||
alias current_columnconfiginfo current_column_configinfo
|
||||
|
@ -104,6 +112,9 @@ module Tk::Tcllib::TablelistItemConfig
|
|||
def row_cget(tagOrId, option)
|
||||
itemcget(['row', tagOrId], option)
|
||||
end
|
||||
def row_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['row', tagOrId], option)
|
||||
end
|
||||
def row_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['row', tagOrId], slot, value)
|
||||
end
|
||||
|
@ -114,12 +125,13 @@ module Tk::Tcllib::TablelistItemConfig
|
|||
current_itemconfiginfo(['row', tagOrId], slot)
|
||||
end
|
||||
alias rowcget row_cget
|
||||
alias rowcget_strict row_cget_strict
|
||||
alias rowconfigure row_configure
|
||||
alias rowconfiginfo row_configinfo
|
||||
alias current_rowconfiginfo current_row_configinfo
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
end
|
||||
|
||||
class Tk::Tcllib::Tablelist
|
||||
|
|
|
@ -133,7 +133,11 @@ module Tk
|
|||
ns_list.each{|ns|
|
||||
cmd = "#{ns}::#{proc_name}"
|
||||
unless Tk.info(:commands, cmd).empty?
|
||||
fail RuntimeError, "can't define '#{cmd}' command (already exist)"
|
||||
#fail RuntimeError, "can't define '#{cmd}' command (already exist)"
|
||||
|
||||
# do nothing !!!
|
||||
warn "Warning: can't define '#{cmd}' command (already exist)" if $DEBUG
|
||||
next
|
||||
end
|
||||
TkNamespace.eval(ns){
|
||||
TkCore::INTERP.add_tk_procs(proc_name, 'imgdir {patterns {*.gif}}',
|
||||
|
@ -197,6 +201,38 @@ module Tk
|
|||
args.map!{|arg| TkComm._get_eval_string(arg)}.join('.')
|
||||
end
|
||||
|
||||
def self.themes(glob_ptn = nil)
|
||||
if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::themes').empty?
|
||||
fail RuntimeError, 'not support glob option' if glob_ptn
|
||||
cmd = ['::tile::availableThemes']
|
||||
else
|
||||
glob_ptn = '*' unless glob_ptn
|
||||
cmd = ['::ttk::themes', glob_ptn]
|
||||
end
|
||||
|
||||
begin
|
||||
TkComm.simplelist(Tk.tk_call_without_enc(*cmd))
|
||||
rescue
|
||||
TkComm.simplelist(Tk.tk_call('lsearch', '-all', '-inline',
|
||||
Tk::Tile::Style.theme_names,
|
||||
glob_ptn))
|
||||
end
|
||||
end
|
||||
|
||||
def self.set_theme(theme)
|
||||
if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::setTheme').empty?
|
||||
cmd = '::tile::setTheme'
|
||||
else
|
||||
cmd = '::ttk::setTheme'
|
||||
end
|
||||
|
||||
begin
|
||||
Tk.tk_call_without_enc(cmd, theme)
|
||||
rescue
|
||||
Tk::Tile::Style.theme_use(theme)
|
||||
end
|
||||
end
|
||||
|
||||
module KeyNav
|
||||
if Tk::Tile::TILE_SPEC_VERSION_ID < 8
|
||||
def self.enableMnemonics(w)
|
||||
|
@ -328,12 +364,16 @@ module Tk
|
|||
|
||||
autoload :TLabelframe, 'tkextlib/tile/tlabelframe'
|
||||
autoload :Labelframe, 'tkextlib/tile/tlabelframe'
|
||||
autoload :TLabelFrame, 'tkextlib/tile/tlabelframe'
|
||||
autoload :LabelFrame, 'tkextlib/tile/tlabelframe'
|
||||
|
||||
autoload :TLabel, 'tkextlib/tile/tlabel'
|
||||
autoload :Label, 'tkextlib/tile/tlabel'
|
||||
|
||||
autoload :TMenubutton, 'tkextlib/tile/tmenubutton'
|
||||
autoload :Menubutton, 'tkextlib/tile/tmenubutton'
|
||||
autoload :TMenuButton, 'tkextlib/tile/tmenubutton'
|
||||
autoload :MenuButton, 'tkextlib/tile/tmenubutton'
|
||||
|
||||
autoload :TNotebook, 'tkextlib/tile/tnotebook'
|
||||
autoload :Notebook, 'tkextlib/tile/tnotebook'
|
||||
|
|
|
@ -54,9 +54,21 @@ class Tk::Tile::Dialog
|
|||
window(tk_call_without_enc('::ttk::dialog::clientframe', @path))
|
||||
end
|
||||
|
||||
def cget(slot)
|
||||
@keys[slot]
|
||||
def cget_strict(slot)
|
||||
@keys[slot.to_s]
|
||||
end
|
||||
def cget(slot)
|
||||
@keys[slot.to_s]
|
||||
end
|
||||
=begin
|
||||
def cget(slot)
|
||||
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
cget_strict(slot)
|
||||
else
|
||||
cget_strict(slot) rescue nil
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
||||
def configure(slot, value=None)
|
||||
if slot.kind_of?(Hash)
|
||||
|
|
|
@ -33,9 +33,15 @@ class << Tk::Tile::Style
|
|||
# conflict with some definitions on Tcl/Tk scripts.
|
||||
if Tk::Tile::TILE_SPEC_VERSION_ID < 7
|
||||
def __define_wrapper_proc_for_compatibility__!
|
||||
__define_themes_and_setTheme_proc__!
|
||||
|
||||
unless Tk.info(:commands, '::ttk::style').empty?
|
||||
fail RuntimeError,
|
||||
"can't define ':ttk::style' command (already exist)"
|
||||
# fail RuntimeError,
|
||||
# "can't define '::ttk::style' command (already exist)"
|
||||
|
||||
# do nothing !!!
|
||||
warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
|
||||
return
|
||||
end
|
||||
TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
|
||||
if [string equal [lrange $args 0 1] {element create}] {
|
||||
|
@ -55,9 +61,15 @@ class << Tk::Tile::Style
|
|||
end
|
||||
else ### TILE_SPEC_VERSION_ID == 7
|
||||
def __define_wrapper_proc_for_compatibility__!
|
||||
__define_themes_and_setTheme_proc__!
|
||||
|
||||
unless Tk.info(:commands, '::ttk::style').empty?
|
||||
fail RuntimeError,
|
||||
"can't define ':ttk::style' command (already exist)"
|
||||
# fail RuntimeError,
|
||||
# "can't define '::ttk::style' command (already exist)"
|
||||
|
||||
# do nothing !!!
|
||||
warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
|
||||
return
|
||||
end
|
||||
TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
|
||||
if [string equal [lrange $args 0 1] {element create}] {
|
||||
|
@ -83,8 +95,14 @@ class << Tk::Tile::Style
|
|||
TkCommandNames = ['::ttk::style'.freeze].freeze
|
||||
|
||||
def __define_wrapper_proc_for_compatibility__!
|
||||
__define_themes_and_setTheme_proc__!
|
||||
|
||||
unless Tk.info(:commands, '::style').empty?
|
||||
fail RuntimeError, "can't define '::style' command (already exist)"
|
||||
# fail RuntimeError, "can't define '::style' command (already exist)"
|
||||
|
||||
# do nothing !!!
|
||||
warn "Warning: can't define '::style' command (already exist)" if $DEBUG
|
||||
return
|
||||
end
|
||||
TkCore::INTERP.add_tk_procs('::style', 'args', <<-'EOS')
|
||||
if [string equal [lrange $args 0 1] {element create}] {
|
||||
|
@ -108,6 +126,36 @@ class << Tk::Tile::Style
|
|||
end
|
||||
end
|
||||
|
||||
def __define_themes_and_setTheme_proc__!
|
||||
TkCore::INTERP.add_tk_procs('::ttk::themes', '{ptn *}', <<-'EOS')
|
||||
#set themes [list]
|
||||
set themes [::ttk::style theme names]
|
||||
foreach pkg [lsearch -inline -all -glob [package names] ttk::theme::$ptn] {
|
||||
set theme [namespace tail $pkg]
|
||||
if {[lsearch -exact $themes $theme] < 0} {
|
||||
lappend themes $theme
|
||||
}
|
||||
}
|
||||
foreach pkg [lsearch -inline -all -glob [package names] tile::theme::$ptn] {
|
||||
set theme [namespace tail $pkg]
|
||||
if {[lsearch -exact $themes $theme] < 0} {
|
||||
lappend themes $theme
|
||||
}
|
||||
}
|
||||
return $themes
|
||||
EOS
|
||||
#########################
|
||||
TkCore::INTERP.add_tk_procs('::ttk::setTheme', 'theme', <<-'EOS')
|
||||
variable currentTheme
|
||||
if {[lsearch -exact [::ttk::style theme names] $theme] < 0} {
|
||||
package require [lsearch -inline -regexp [package names] (ttk|tile)::theme::$theme]
|
||||
}
|
||||
::ttk::style theme use $theme
|
||||
set currentTheme $theme
|
||||
EOS
|
||||
end
|
||||
private :__define_themes_and_setTheme_proc__!
|
||||
|
||||
def configure(style=nil, keys=nil)
|
||||
if style.kind_of?(Hash)
|
||||
keys = style
|
||||
|
|
|
@ -27,6 +27,11 @@ class Tk::Tile::TEntry < Tk::Entry
|
|||
WidgetClassName = 'TEntry'.freeze
|
||||
WidgetClassNames[WidgetClassName] = self
|
||||
|
||||
def __optkey_aliases
|
||||
{:vcmd=>:validatecommand, :invcmd=>:invalidcommand}
|
||||
end
|
||||
private :__optkey_aliases
|
||||
|
||||
def __boolval_optkeys
|
||||
super() << 'exportselection'
|
||||
end
|
||||
|
|
|
@ -41,13 +41,35 @@ class Tk::Tile::TNotebook < TkWindow
|
|||
private :__item_methodcall_optkeys
|
||||
|
||||
#alias tabcget itemcget
|
||||
#alias tabcget_strict itemcget_strict
|
||||
alias tabconfigure itemconfigure
|
||||
alias tabconfiginfo itemconfiginfo
|
||||
alias current_tabconfiginfo current_itemconfiginfo
|
||||
|
||||
def tabcget(tagOrId, option)
|
||||
def tabcget_strict(tagOrId, option)
|
||||
tabconfigure(tagOrId, option)[-1]
|
||||
end
|
||||
def tabcget(tagOrId, option)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
tabcget_strict(tagOrId, option)
|
||||
else
|
||||
begin
|
||||
tabcget_strict(tagOrId, option)
|
||||
rescue => e
|
||||
begin
|
||||
if current_tabconfiginfo(tagOrId).has_key?(option.to_s)
|
||||
# not tag error & option is known -> error on known option
|
||||
fail e
|
||||
else
|
||||
# not tag error & option is unknown
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
################################
|
||||
|
||||
include Tk::Tile::TileWidget
|
||||
|
@ -77,9 +99,9 @@ class Tk::Tile::TNotebook < TkWindow
|
|||
|
||||
def add(child, keys=nil)
|
||||
if keys && keys != None
|
||||
tk_send_without_enc('add', _epath(child), *hash_kv(keys))
|
||||
tk_send('add', _epath(child), *hash_kv(keys))
|
||||
else
|
||||
tk_send_without_enc('add', _epath(child))
|
||||
tk_send('add', _epath(child))
|
||||
end
|
||||
self
|
||||
end
|
||||
|
|
|
@ -36,9 +36,21 @@ class Tk::Tile::TPaned < TkWindow
|
|||
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
|
||||
end
|
||||
|
||||
def add(win, keys)
|
||||
win = _epath(win)
|
||||
tk_send_without_enc('add', win, *hash_kv(keys))
|
||||
def add(*args)
|
||||
keys = args.pop
|
||||
fail ArgumentError, "no window in arguments" unless keys
|
||||
|
||||
if keys && keys.kind_of?(Hash)
|
||||
fail ArgumentError, "no window in arguments" if args == []
|
||||
opts = hash_kv(keys)
|
||||
else
|
||||
args.push(keys) if keys
|
||||
opts = []
|
||||
end
|
||||
|
||||
args.each{|win|
|
||||
tk_send_without_enc('add', _epath(win), *opts)
|
||||
}
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -54,10 +66,33 @@ class Tk::Tile::TPaned < TkWindow
|
|||
self
|
||||
end
|
||||
|
||||
def panecget(pane, slot)
|
||||
def panecget_strict(pane, slot)
|
||||
pane = _epath(pane)
|
||||
tk_tcl2ruby(tk_send_without_enc('pane', pane, "-#{slot}"))
|
||||
end
|
||||
alias pane_cget_strict panecget_strict
|
||||
|
||||
def panecget(pane, slot)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
panecget_strict(pane, slot)
|
||||
else
|
||||
begin
|
||||
panecget_strict(pane, slot)
|
||||
rescue => e
|
||||
begin
|
||||
if current_paneconfiginfo(pane).has_key?(slot.to_s)
|
||||
# not tag error & option is known -> error on known option
|
||||
fail e
|
||||
else
|
||||
# not tag error & option is unknown
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
alias pane_cget panecget
|
||||
|
||||
def paneconfigure(pane, key, value=nil)
|
||||
|
|
|
@ -33,6 +33,12 @@ module Tk::Tile::TreeviewConfig
|
|||
else
|
||||
if slot
|
||||
slot = slot.to_s
|
||||
|
||||
alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
case slot
|
||||
when /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
|
||||
begin
|
||||
|
@ -198,6 +204,12 @@ module Tk::Tile::TreeviewConfig
|
|||
else
|
||||
if slot
|
||||
slot = slot.to_s
|
||||
|
||||
alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
|
||||
if real_name
|
||||
slot = real_name.to_s
|
||||
end
|
||||
|
||||
case slot
|
||||
when /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
|
||||
begin
|
||||
|
@ -508,17 +520,21 @@ module Tk::Tile::TreeviewConfig
|
|||
end
|
||||
|
||||
alias __itemcget itemcget
|
||||
alias __itemcget_strict itemcget_strict
|
||||
alias __itemconfigure itemconfigure
|
||||
alias __itemconfiginfo itemconfiginfo
|
||||
alias __current_itemconfiginfo current_itemconfiginfo
|
||||
|
||||
private :__itemcget, :__itemconfigure
|
||||
private :__itemconfiginfo, :__current_itemconfiginfo
|
||||
private :__itemcget, :__itemcget_strict
|
||||
private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
|
||||
|
||||
# Treeview Item
|
||||
def itemcget(tagOrId, option)
|
||||
__itemcget([:item, tagOrId], option)
|
||||
end
|
||||
def itemcget_strict(tagOrId, option)
|
||||
__itemcget_strict([:item, tagOrId], option)
|
||||
end
|
||||
def itemconfigure(tagOrId, slot, value=None)
|
||||
__itemconfigure([:item, tagOrId], slot, value)
|
||||
end
|
||||
|
@ -533,6 +549,9 @@ module Tk::Tile::TreeviewConfig
|
|||
def columncget(tagOrId, option)
|
||||
__itemcget([:column, tagOrId], option)
|
||||
end
|
||||
def columncget_strict(tagOrId, option)
|
||||
__itemcget_strict([:column, tagOrId], option)
|
||||
end
|
||||
def columnconfigure(tagOrId, slot, value=None)
|
||||
__itemconfigure([:column, tagOrId], slot, value)
|
||||
end
|
||||
|
@ -543,12 +562,13 @@ module Tk::Tile::TreeviewConfig
|
|||
__current_itemconfiginfo([:column, tagOrId], slot)
|
||||
end
|
||||
alias column_cget columncget
|
||||
alias column_cget_strict columncget_strict
|
||||
alias column_configure columnconfigure
|
||||
alias column_configinfo columnconfiginfo
|
||||
alias current_column_configinfo current_columnconfiginfo
|
||||
|
||||
# Treeview Heading
|
||||
def headingcget(tagOrId, option)
|
||||
def headingcget_strict(tagOrId, option)
|
||||
if __tile_specific_item_optkeys([:heading, tagOrId]).index(option.to_s)
|
||||
begin
|
||||
# On tile-0.7.{2-8}, 'state' options has no '-' at its head.
|
||||
|
@ -558,7 +578,28 @@ module Tk::Tile::TreeviewConfig
|
|||
tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{option}"))
|
||||
end
|
||||
else
|
||||
__itemcget([:heading, tagOrId], option)
|
||||
__itemcget_strict([:heading, tagOrId], option)
|
||||
end
|
||||
end
|
||||
def headingcget(tagOrId, option)
|
||||
unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
|
||||
headingcget_strict(tagOrId, option)
|
||||
else
|
||||
begin
|
||||
headingcget_strict(tagOrId, option)
|
||||
rescue => e
|
||||
begin
|
||||
if current_headingconfiginfo(tagOrId).has_key?(option.to_s)
|
||||
# not tag error & option is known -> error on known option
|
||||
fail e
|
||||
else
|
||||
# not tag error & option is unknown
|
||||
nil
|
||||
end
|
||||
rescue
|
||||
fail e # tag error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
def headingconfigure(tagOrId, slot, value=None)
|
||||
|
@ -590,6 +631,7 @@ module Tk::Tile::TreeviewConfig
|
|||
__current_itemconfiginfo([:heading, tagOrId], slot)
|
||||
end
|
||||
alias heading_cget headingcget
|
||||
alias heading_cget_strict headingcget_strict
|
||||
alias heading_configure headingconfigure
|
||||
alias heading_configinfo headingconfiginfo
|
||||
alias current_heading_configinfo current_headingconfiginfo
|
||||
|
@ -598,6 +640,9 @@ module Tk::Tile::TreeviewConfig
|
|||
def tagcget(tagOrId, option)
|
||||
__itemcget([:tag, tagOrId], option)
|
||||
end
|
||||
def tagcget_strict(tagOrId, option)
|
||||
__itemcget_strict([:tag, tagOrId], option)
|
||||
end
|
||||
def tagconfigure(tagOrId, slot, value=None)
|
||||
__itemconfigure([:tag, tagOrId], slot, value)
|
||||
end
|
||||
|
@ -608,6 +653,7 @@ module Tk::Tile::TreeviewConfig
|
|||
__current_itemconfiginfo([:tag, tagOrId], slot)
|
||||
end
|
||||
alias tag_cget tagcget
|
||||
alias tag_cget_strict tagcget_strict
|
||||
alias tag_configure tagconfigure
|
||||
alias tag_configinfo tagconfiginfo
|
||||
alias current_tag_configinfo current_tagconfiginfo
|
||||
|
@ -694,6 +740,9 @@ class Tk::Tile::Treeview::Item < TkObject
|
|||
def cget(option)
|
||||
@t.itemcget(@id, option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@t.itemcget_strict(@id, option)
|
||||
end
|
||||
|
||||
def configure(key, value=None)
|
||||
@t.itemconfigure(@id, key, value)
|
||||
|
@ -933,6 +982,9 @@ class Tk::Tile::Treeview::Tag < TkObject
|
|||
def cget(option)
|
||||
@t.tagcget(@id, option)
|
||||
end
|
||||
def cget_strict(option)
|
||||
@t.tagcget_strict(@id, option)
|
||||
end
|
||||
|
||||
def configure(key, value=None)
|
||||
@t.tagconfigure(@id, key, value)
|
||||
|
|
|
@ -11,15 +11,15 @@ require 'tkextlib/setup.rb'
|
|||
# call setup script
|
||||
require 'tkextlib/tkDND/setup.rb'
|
||||
|
||||
# TkPackage.require('shape', '0.3')
|
||||
TkPackage.require('shape')
|
||||
# TkPackage.require('Shape', '0.3')
|
||||
TkPackage.require('Shape')
|
||||
|
||||
module Tk
|
||||
module TkDND
|
||||
module Shape
|
||||
extend TkCore
|
||||
|
||||
PACKAGE_NAME = 'shape'.freeze
|
||||
PACKAGE_NAME = 'Shape'.freeze
|
||||
def self.package_name
|
||||
PACKAGE_NAME
|
||||
end
|
||||
|
@ -27,26 +27,28 @@ module Tk
|
|||
=begin
|
||||
def self.package_version
|
||||
begin
|
||||
TkPackage.require('shape')
|
||||
TkPackage.require('Shape')
|
||||
rescue
|
||||
''
|
||||
end
|
||||
end
|
||||
=end
|
||||
def self.package_version
|
||||
Tk.tk_call('set', 'shape_version')
|
||||
end
|
||||
alias shape_version package_version
|
||||
class << self
|
||||
def package_version
|
||||
Tk.tk_call('set', 'shape_version')
|
||||
end
|
||||
alias shape_version package_version
|
||||
|
||||
def self.package_patchlevel
|
||||
Tk.tk_call('set', 'shape_patchlevel')
|
||||
end
|
||||
alias shape_patchlevel package_patchlevel
|
||||
def package_patchlevel
|
||||
Tk.tk_call('set', 'shape_patchLevel')
|
||||
end
|
||||
alias shape_patchlevel package_patchlevel
|
||||
|
||||
def self.version
|
||||
tk_call('shape', 'version')
|
||||
def version
|
||||
tk_call('shape', 'version')
|
||||
end
|
||||
alias xshape_version version
|
||||
end
|
||||
alias xshape_version version
|
||||
|
||||
############################
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ module Tk
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -72,6 +73,7 @@ module Tk
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
# setup tables
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
|
|
@ -77,6 +77,9 @@ module Tk::TkTable::ConfigMethod
|
|||
def tag_cget(tagOrId, option)
|
||||
itemcget(['tag', tagid(tagOrId)], option)
|
||||
end
|
||||
def tag_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['tag', tagid(tagOrId)], option)
|
||||
end
|
||||
def tag_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['tag', tagid(tagOrId)], slot, value)
|
||||
end
|
||||
|
@ -90,6 +93,9 @@ module Tk::TkTable::ConfigMethod
|
|||
def window_cget(tagOrId, option)
|
||||
itemcget(['window', tagid(tagOrId)], option)
|
||||
end
|
||||
def window_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['window', tagid(tagOrId)], option)
|
||||
end
|
||||
def window_configure(tagOrId, slot, value=None)
|
||||
if slot == :window || slot == 'window'
|
||||
value = _epath(value)
|
||||
|
@ -108,8 +114,8 @@ module Tk::TkTable::ConfigMethod
|
|||
current_itemconfiginfo(['window', tagid(tagOrId)], slot)
|
||||
end
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
end
|
||||
|
||||
#####################################################
|
||||
|
@ -194,6 +200,9 @@ class Tk::TkTable::CellTag
|
|||
def cget(key)
|
||||
@t.tag_cget(@id, key)
|
||||
end
|
||||
def cget_strict(key)
|
||||
@t.tag_cget_strict(@id, key)
|
||||
end
|
||||
def configure(key, val=None)
|
||||
@t.tag_configure(@id, key, val)
|
||||
end
|
||||
|
@ -291,6 +300,7 @@ class Tk::TkTable
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -306,6 +316,7 @@ class Tk::TkTable
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -340,6 +351,7 @@ class Tk::TkTable
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -355,6 +367,7 @@ class Tk::TkTable
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -387,6 +400,7 @@ class Tk::TkTable
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -402,6 +416,7 @@ class Tk::TkTable
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -437,6 +452,7 @@ class Tk::TkTable
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -452,6 +468,7 @@ class Tk::TkTable
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
end
|
||||
|
|
|
@ -137,6 +137,7 @@ class Tk::TreeCtrl::NotifyEvent
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -152,6 +153,7 @@ class Tk::TreeCtrl::NotifyEvent
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
# setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
|
||||
#
|
||||
|
@ -415,6 +417,9 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
def column_cget(tagOrId, option)
|
||||
itemcget(['column', tagOrId], option)
|
||||
end
|
||||
def column_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['column', tagOrId], option)
|
||||
end
|
||||
def column_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['column', tagOrId], slot, value)
|
||||
end
|
||||
|
@ -428,6 +433,9 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
def column_dragcget(option)
|
||||
itemcget(['column', 'drag'], option)
|
||||
end
|
||||
def column_dragcget_strict(option)
|
||||
itemcget_strict(['column', 'drag'], option)
|
||||
end
|
||||
def column_dragconfigure(slot, value=None)
|
||||
itemconfigure(['column', 'drag'], slot, value)
|
||||
end
|
||||
|
@ -441,6 +449,9 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
def debug_cget(option)
|
||||
itemcget('debug', option)
|
||||
end
|
||||
def debug_cget_strict(option)
|
||||
itemcget_strict('debug', option)
|
||||
end
|
||||
def debug_configure(slot, value=None)
|
||||
itemconfigure('debug', slot, value)
|
||||
end
|
||||
|
@ -454,6 +465,9 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
def dragimage_cget(option)
|
||||
itemcget('dragimage', option)
|
||||
end
|
||||
def dragimage_cget_strict(option)
|
||||
itemcget_strict('dragimage', option)
|
||||
end
|
||||
def dragimage_configure(slot, value=None)
|
||||
itemconfigure('dragimage', slot, value)
|
||||
end
|
||||
|
@ -467,6 +481,9 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
def element_cget(tagOrId, option)
|
||||
itemcget(['element', tagOrId], option)
|
||||
end
|
||||
def element_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['element', tagOrId], option)
|
||||
end
|
||||
def element_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['element', tagOrId], slot, value)
|
||||
end
|
||||
|
@ -480,6 +497,9 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
def item_cget(tagOrId, option)
|
||||
itemcget(['item', tagOrId], option)
|
||||
end
|
||||
def item_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['item', tagOrId], option)
|
||||
end
|
||||
def item_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['item', tagOrId], slot, value)
|
||||
end
|
||||
|
@ -493,6 +513,9 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
def item_element_cget(item, column, elem, option)
|
||||
itemcget([['item', 'element'], [item, column, elem]], option)
|
||||
end
|
||||
def item_element_cget_strict(item, column, elem, option)
|
||||
itemcget_strict([['item', 'element'], [item, column, elem]], option)
|
||||
end
|
||||
def item_element_configure(item, column, elem, slot, value=None)
|
||||
itemconfigure([['item', 'element'], [item, column, elem]], slot, value)
|
||||
end
|
||||
|
@ -506,6 +529,9 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
def marquee_cget(option)
|
||||
itemcget('marquee', option)
|
||||
end
|
||||
def marquee_cget_strict(option)
|
||||
itemcget_strict('marquee', option)
|
||||
end
|
||||
def marquee_configure(slot, value=None)
|
||||
itemconfigure('marquee', slot, value)
|
||||
end
|
||||
|
@ -518,7 +544,19 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
|
||||
def notify_cget(win, pattern, option)
|
||||
pattern = "<#{pattern}>"
|
||||
itemconfigure(['notify', [win, pattern]], option)
|
||||
# "notify" doesn't have cget subcommand.
|
||||
current_itemconfiginfo(['notify', [win, pattern]])[option.to_s]
|
||||
end
|
||||
def notify_cget_strict(win, pattern, option)
|
||||
pattern = "<#{pattern}>"
|
||||
# "notify" doesn't have cget subcommand.
|
||||
info = current_itemconfiginfo(['notify', [win, pattern]])
|
||||
option = option.to_s
|
||||
unless info.has_key?(option)
|
||||
fail RuntimeError, "unknown option \"#{option}\""
|
||||
else
|
||||
info[option]
|
||||
end
|
||||
end
|
||||
def notify_configure(win, pattern, slot, value=None)
|
||||
pattern = "<#{pattern}>"
|
||||
|
@ -528,11 +566,17 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
pattern = "<#{pattern}>"
|
||||
itemconfiginfo(['notify', [win, pattern]], slot)
|
||||
end
|
||||
alias current_notify_configinfo notify_configinfo
|
||||
def current_notify_configinfo(tagOrId, slot=nil)
|
||||
pattern = "<#{pattern}>"
|
||||
current_itemconfiginfo(['notify', [win, pattern]], slot)
|
||||
end
|
||||
|
||||
def style_cget(tagOrId, option)
|
||||
itemcget(['style', tagOrId], option)
|
||||
end
|
||||
def style_cget_strict(tagOrId, option)
|
||||
itemcget_strict(['style', tagOrId], option)
|
||||
end
|
||||
def style_configure(tagOrId, slot, value=None)
|
||||
itemconfigure(['style', tagOrId], slot, value)
|
||||
end
|
||||
|
@ -543,8 +587,8 @@ module Tk::TreeCtrl::ConfigMethod
|
|||
current_itemconfiginfo(['style', tagOrId], slot)
|
||||
end
|
||||
|
||||
private :itemcget, :itemconfigure
|
||||
private :itemconfiginfo, :current_itemconfiginfo
|
||||
private :itemcget, :itemcget_strict
|
||||
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
|
||||
end
|
||||
|
||||
##############################################
|
||||
|
@ -1700,6 +1744,9 @@ class Tk::TreeCtrl::Column < TkObject
|
|||
def cget(opt)
|
||||
@tree.column_cget(@tree.column_index(@id), opt)
|
||||
end
|
||||
def cget_strict(opt)
|
||||
@tree.column_cget_strict(@tree.column_index(@id), opt)
|
||||
end
|
||||
|
||||
def configure(*args)
|
||||
@tree.column_configure(@tree.column_index(@id), *args)
|
||||
|
@ -1800,6 +1847,9 @@ class Tk::TreeCtrl::Element < TkObject
|
|||
def cget(opt)
|
||||
@tree.element_cget(@id, opt)
|
||||
end
|
||||
def cget_strict(opt)
|
||||
@tree.element_cget_strict(@id, opt)
|
||||
end
|
||||
|
||||
def configure(*args)
|
||||
@tree.element_configure(@id, *args)
|
||||
|
@ -1931,6 +1981,9 @@ class Tk::TreeCtrl::Item < TkObject
|
|||
def cget(opt)
|
||||
@tree.item_cget(@id, opt)
|
||||
end
|
||||
def cget_strict(opt)
|
||||
@tree.item_cget_strict(@id, opt)
|
||||
end
|
||||
|
||||
def configure(*args)
|
||||
@tree.item_configure(@id, *args)
|
||||
|
@ -1964,6 +2017,9 @@ class Tk::TreeCtrl::Item < TkObject
|
|||
def element_cget(opt)
|
||||
@tree.item_element_cget(@id, opt)
|
||||
end
|
||||
def element_cget_strict(opt)
|
||||
@tree.item_element_cget_strict(@id, opt)
|
||||
end
|
||||
|
||||
def element_configure(*args)
|
||||
@tree.item_element_configure(@id, *args)
|
||||
|
@ -2215,6 +2271,9 @@ class Tk::TreeCtrl::Style < TkObject
|
|||
def cget(opt)
|
||||
@tree.style_cget(@id, opt)
|
||||
end
|
||||
def cget_strict(opt)
|
||||
@tree.style_cget_strict(@id, opt)
|
||||
end
|
||||
|
||||
def configure(*args)
|
||||
@tree.style_configure(@id, *args)
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
# release date of tkextlib
|
||||
#
|
||||
module Tk
|
||||
Tkextlib_RELEASE_DATE = '2008-03-29'.freeze
|
||||
Tkextlib_RELEASE_DATE = '2008-05-23'.freeze
|
||||
end
|
||||
|
|
|
@ -177,6 +177,10 @@ class Tk::Vu::PieSlice
|
|||
@pie.itemcget(@id, slot)
|
||||
end
|
||||
|
||||
def cget_strict(slot)
|
||||
@pie.itemcget_strict(@id, slot)
|
||||
end
|
||||
|
||||
def configure(*args)
|
||||
@pie.itemconfigure(@id, *args)
|
||||
self
|
||||
|
|
|
@ -150,6 +150,7 @@ class Tk::Winico
|
|||
nil
|
||||
]
|
||||
|
||||
=begin
|
||||
# for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
|
||||
KEY_TBL.map!{|inf|
|
||||
if inf.kind_of?(Array)
|
||||
|
@ -165,6 +166,7 @@ class Tk::Winico
|
|||
end
|
||||
inf
|
||||
}
|
||||
=end
|
||||
|
||||
_setup_subst_table(KEY_TBL, PROC_TBL);
|
||||
|
||||
|
@ -185,7 +187,8 @@ class Tk::Winico
|
|||
Winico_callback._config_keys.each{|k|
|
||||
if keys[k].kind_of?(Array)
|
||||
cmd, *args = keys[k]
|
||||
keys[k] = Winico_callback.new(cmd, args.join(' '))
|
||||
#keys[k] = Winico_callback.new(cmd, args.join(' '))
|
||||
keys[k] = Winico_callback.new(cmd, *args)
|
||||
# elsif keys[k].kind_of?(Proc)
|
||||
elsif TkComm._callback_entry?(keys[k])
|
||||
keys[k] = Winico_callback.new(keys[k])
|
||||
|
@ -201,7 +204,8 @@ class Tk::Winico
|
|||
Winico_callback._config_keys.each{|k|
|
||||
if keys[k].kind_of?(Array)
|
||||
cmd, *args = keys[k]
|
||||
keys[k] = Winico_callback.new(cmd, args.join(' '))
|
||||
#keys[k] = Winico_callback.new(cmd, args.join(' '))
|
||||
keys[k] = Winico_callback.new(cmd, *args)
|
||||
# elsif keys[k].kind_of?(Proc)
|
||||
elsif TkComm._callback_entry?(keys[k])
|
||||
keys[k] = Winico_callback.new(keys[k])
|
||||
|
|
|
@ -15,8 +15,10 @@ $anilabel_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($anilabel_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
msg = TkLabel.new($anilabel_demo) {
|
||||
msg = TkLabel.new(base_frame) {
|
||||
font $font
|
||||
wraplength '4i'
|
||||
justify 'left'
|
||||
|
@ -25,7 +27,7 @@ msg = TkLabel.new($anilabel_demo) {
|
|||
msg.pack('side'=>'top')
|
||||
|
||||
# frame
|
||||
TkFrame.new($anilabel_demo) {|frame|
|
||||
TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -43,8 +45,8 @@ TkFrame.new($anilabel_demo) {|frame|
|
|||
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
||||
|
||||
# create frame for label demo
|
||||
f_left = TkLabelFrame.new($anilabel_demo, :text=>'Scrolling Texts')
|
||||
f_right = TkLabelFrame.new($anilabel_demo, :text=>'GIF Image')
|
||||
f_left = TkLabelFrame.new(base_frame, :text=>'Scrolling Texts')
|
||||
f_right = TkLabelFrame.new(base_frame, :text=>'GIF Image')
|
||||
Tk.pack(f_left, f_right, 'side'=>'left', 'expand'=>'yes', 'fill'=>'both',
|
||||
'padx'=>10, 'pady'=>10)
|
||||
|
||||
|
|
|
@ -16,8 +16,10 @@ $aniwave_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($aniwave_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# create label
|
||||
msg = TkLabel.new($aniwave_demo) {
|
||||
msg = TkLabel.new(base_frame) {
|
||||
font $font
|
||||
wraplength '4i'
|
||||
justify 'left'
|
||||
|
@ -26,7 +28,7 @@ msg = TkLabel.new($aniwave_demo) {
|
|||
msg.pack('side'=>'top')
|
||||
|
||||
# create frame
|
||||
TkFrame.new($aniwave_demo) {|frame|
|
||||
TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -58,6 +60,7 @@ class AnimatedWaveDemo
|
|||
@backupCoords = []
|
||||
n = 0
|
||||
(-10..300).step(5){|n| @waveCoords << [n, 100]; @backupCoords << [n, 100] }
|
||||
n = 305
|
||||
@waveCoords << [n, 0]; @backupCoords << [n, 0]
|
||||
@waveCoords << [n+5, 200]; @backupCoords << [n+5, 200]
|
||||
@coordsLen = @waveCoords.length
|
||||
|
@ -112,4 +115,4 @@ class AnimatedWaveDemo
|
|||
end
|
||||
|
||||
# Start the animation processing
|
||||
AnimatedWaveDemo.new($aniwave_demo, :left).move
|
||||
AnimatedWaveDemo.new(base_frame, :left).move
|
||||
|
|
|
@ -107,14 +107,16 @@ $arrow_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($arrow_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
TkLabel.new($arrow_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
|
||||
TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
|
||||
'text'=>"This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."){
|
||||
pack('side'=>'top')
|
||||
}
|
||||
|
||||
# frame
|
||||
$arrow_buttons = TkFrame.new($arrow_demo) {|frame|
|
||||
$arrow_buttons = TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -132,7 +134,7 @@ $arrow_buttons = TkFrame.new($arrow_demo) {|frame|
|
|||
$arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
||||
|
||||
# canvas
|
||||
$arrow_canvas = TkCanvas.new($arrow_demo, 'width'=>500, 'height'=>350,
|
||||
$arrow_canvas = TkCanvas.new(base_frame, 'width'=>500, 'height'=>350,
|
||||
'relief'=>'sunken', 'borderwidth'=>2)
|
||||
$arrow_canvas.pack('expand'=>'yes', 'fill'=>'both')
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@ $bind_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($bind_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# frame
|
||||
TkFrame.new($bind_demo) {|frame|
|
||||
TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -43,14 +45,14 @@ def tag_binding_for_bind_demo(tag, enter_style, leave_style)
|
|||
end
|
||||
|
||||
# text
|
||||
txt = TkText.new($bind_demo){|t|
|
||||
txt = TkText.new(base_frame){|t|
|
||||
#
|
||||
setgrid 'true'
|
||||
#width 60
|
||||
#height 24
|
||||
font $font
|
||||
wrap 'word'
|
||||
TkScrollbar.new($bind_demo) {|s|
|
||||
TkScrollbar.new(base_frame) {|s|
|
||||
pack('side'=>'right', 'fill'=>'y')
|
||||
command proc{|*args| t.yview(*args)}
|
||||
t.yscrollcommand proc{|first,last| s.set first,last}
|
||||
|
@ -94,32 +96,32 @@ txt = TkText.new($bind_demo){|t|
|
|||
}
|
||||
d1.bind('1',
|
||||
proc{
|
||||
eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`)
|
||||
eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`, 'items.rb')
|
||||
})
|
||||
d2.bind('1',
|
||||
proc{
|
||||
eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`)
|
||||
eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`, 'plot.rb')
|
||||
})
|
||||
d3.bind('1',
|
||||
proc{
|
||||
eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`)
|
||||
eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`, 'ctext.rb')
|
||||
})
|
||||
d4.bind('1',
|
||||
proc{
|
||||
eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`)
|
||||
eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`, 'arrow.rb')
|
||||
})
|
||||
d5.bind('1',
|
||||
proc{
|
||||
eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`)
|
||||
eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`, 'ruler.rb')
|
||||
})
|
||||
d6.bind('1',
|
||||
proc{
|
||||
eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`)
|
||||
eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`, 'cscroll.rb')
|
||||
})
|
||||
|
||||
TkTextMarkInsert.new(t, '0.0')
|
||||
configure('state','disabled')
|
||||
}
|
||||
|
||||
txt.width 60
|
||||
txt.width 24
|
||||
txt.width 60
|
||||
txt.height 24
|
||||
|
|
|
@ -21,7 +21,7 @@ def bitmapRow(w,*args)
|
|||
TkFrame.new(row){|base|
|
||||
pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c')
|
||||
TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom')
|
||||
TkLabel.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
|
||||
Tk::Label.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
|
||||
}
|
||||
end
|
||||
}
|
||||
|
@ -40,14 +40,16 @@ $bitmap_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($bitmap_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
TkLabel.new($bitmap_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
|
||||
TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
|
||||
'text'=>"This window displays all of Tk's built-in bitmaps, along with the names you can use for them in Tcl scripts."){
|
||||
pack('side'=>'top')
|
||||
}
|
||||
|
||||
# frame
|
||||
$bitmap_buttons = TkFrame.new($bitmap_demo) {|frame|
|
||||
$bitmap_buttons = TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -65,7 +67,7 @@ $bitmap_buttons = TkFrame.new($bitmap_demo) {|frame|
|
|||
$bitmap_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
||||
|
||||
# frame
|
||||
TkFrame.new($bitmap_demo){|f|
|
||||
TkFrame.new(base_frame){|f|
|
||||
bitmapRow(f,'error','gray25','gray50','hourglass')
|
||||
bitmapRow(f,'info','question','questhead','warning')
|
||||
pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
|
||||
|
|
|
@ -29,7 +29,7 @@ msg = TkLabel.new($button_demo) {
|
|||
msg.pack('side'=>'top')
|
||||
|
||||
# frame
|
||||
$button_buttons = TkFrame.new($button_demo) {|frame|
|
||||
$button_buttons = Tk::Frame.new($button_demo) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
|
|
@ -19,8 +19,10 @@ $check_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($check_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
msg = TkLabel.new($check_demo) {
|
||||
msg = TkLabel.new(base_frame) {
|
||||
font $font
|
||||
wraplength '4i'
|
||||
justify 'left'
|
||||
|
@ -34,7 +36,7 @@ brakes = TkVariable.new(0)
|
|||
sober = TkVariable.new(0)
|
||||
|
||||
# frame
|
||||
TkFrame.new($check_demo) {|frame|
|
||||
TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -54,7 +56,7 @@ TkFrame.new($check_demo) {|frame|
|
|||
TkButton.new(frame) {
|
||||
text 'See Variables'
|
||||
command proc{
|
||||
showVars($check_demo,
|
||||
showVars(base_frame,
|
||||
['wipers', wipers], ['brakes', brakes], ['sober', sober])
|
||||
}
|
||||
}.pack('side'=>'left', 'expand'=>'yes')
|
||||
|
@ -63,8 +65,8 @@ TkFrame.new($check_demo) {|frame|
|
|||
|
||||
|
||||
# checkbutton
|
||||
[ TkCheckButton.new($check_demo, 'text'=>'Wipers OK', 'variable'=>wipers),
|
||||
TkCheckButton.new($check_demo, 'text'=>'Brakes OK', 'variable'=>brakes),
|
||||
TkCheckButton.new($check_demo, 'text'=>'Driver Sober', 'variable'=>sober)
|
||||
[ TkCheckButton.new(base_frame, 'text'=>'Wipers OK', 'variable'=>wipers),
|
||||
TkCheckButton.new(base_frame, 'text'=>'Brakes OK', 'variable'=>brakes),
|
||||
TkCheckButton.new(base_frame, 'text'=>'Driver Sober', 'variable'=>sober)
|
||||
].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')}
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ $check2_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($check2_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
msg = TkLabel.new($check2_demo) {
|
||||
msg = TkLabel.new(base_frame) {
|
||||
font $font
|
||||
wraplength '4i'
|
||||
justify 'left'
|
||||
|
@ -31,7 +33,7 @@ brakes = TkVariable.new(0)
|
|||
sober = TkVariable.new(0)
|
||||
|
||||
# frame
|
||||
TkFrame.new($check2_demo) {|frame|
|
||||
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',
|
||||
|
@ -59,15 +61,15 @@ TkFrame.new($check2_demo) {|frame|
|
|||
|
||||
|
||||
# checkbutton
|
||||
TkCheckButton.new($check2_demo, :text=>'Safety Check', :variable=>safety,
|
||||
TkCheckButton.new(base_frame, :text=>'Safety Check', :variable=>safety,
|
||||
:relief=>:flat, :onvalue=>'all', :offvalue=>'none',
|
||||
:tristatevalue=>'partial'){
|
||||
pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
|
||||
}
|
||||
|
||||
[ TkCheckButton.new($check2_demo, 'text'=>'Wipers OK', 'variable'=>wipers),
|
||||
TkCheckButton.new($check2_demo, 'text'=>'Brakes OK', 'variable'=>brakes),
|
||||
TkCheckButton.new($check2_demo, 'text'=>'Driver Sober', 'variable'=>sober)
|
||||
[ TkCheckButton.new(base_frame, 'text'=>'Wipers OK', 'variable'=>wipers),
|
||||
TkCheckButton.new(base_frame, 'text'=>'Brakes OK', 'variable'=>brakes),
|
||||
TkCheckButton.new(base_frame, 'text'=>'Driver Sober', 'variable'=>sober)
|
||||
].each{|w|
|
||||
w.relief('flat')
|
||||
w.pack('side'=>'top', 'padx'=>15, 'pady'=>2, 'anchor'=>'w')
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#
|
||||
# widget demo prompts the user to select a color (called by 'widget')
|
||||
#
|
||||
# Note: don't support ttk_wrapper. work with standard widgets only.
|
||||
#
|
||||
|
||||
# toplevel widget
|
||||
if defined?($clrpick_demo) && $clrpick_demo
|
||||
|
@ -18,13 +20,18 @@ $clrpick_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($clrpick_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
|
||||
#TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
|
||||
Tk::Label.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
|
||||
'text'=>"Press the buttons below to choose the foreground and background colors for the widgets in this window.").pack('side'=>'top')
|
||||
|
||||
# frame
|
||||
TkFrame.new($clrpick_demo) {|frame|
|
||||
TkButton.new(frame) {
|
||||
#TkFrame.new($clrpick_demo) {|frame|
|
||||
Tk::Frame.new($clrpick_demo) {|frame|
|
||||
# TkButton.new(frame) {
|
||||
Tk::Button.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
tmppath = $clrpick_demo
|
||||
|
@ -33,20 +40,23 @@ TkFrame.new($clrpick_demo) {|frame|
|
|||
}
|
||||
}.pack('side'=>'left', 'expand'=>'yes')
|
||||
|
||||
TkButton.new(frame) {
|
||||
# TkButton.new(frame) {
|
||||
Tk::Button.new(frame) {
|
||||
text 'Show Code'
|
||||
command proc{showCode 'clrpick'}
|
||||
}.pack('side'=>'left', 'expand'=>'yes')
|
||||
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
||||
|
||||
# button
|
||||
TkButton.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
|
||||
# TkButton.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
|
||||
Tk::Button.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
|
||||
command(proc{setColor $clrpick_demo, b, 'background',
|
||||
['background', 'highlightbackground']})
|
||||
pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
|
||||
}
|
||||
|
||||
TkButton.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
|
||||
# TkButton.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
|
||||
Tk::Button.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
|
||||
command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']})
|
||||
pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
|
||||
}
|
||||
|
|
|
@ -20,8 +20,10 @@ $colors_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($colors_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
msg = TkLabel.new($colors_demo) {
|
||||
msg = TkLabel.new(base_frame) {
|
||||
font $font
|
||||
wraplength '4i'
|
||||
justify 'left'
|
||||
|
@ -30,7 +32,7 @@ msg = TkLabel.new($colors_demo) {
|
|||
msg.pack('side'=>'top')
|
||||
|
||||
# frame
|
||||
TkFrame.new($colors_demo) {|frame|
|
||||
TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -49,7 +51,7 @@ TkFrame.new($colors_demo) {|frame|
|
|||
|
||||
# frame
|
||||
colors_lbox = nil
|
||||
TkFrame.new($colors_demo, 'borderwidth'=>10) {|w|
|
||||
TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
|
||||
s = TkScrollbar.new(w)
|
||||
colors_lbox = TkListbox.new(w) {
|
||||
setgrid 1
|
||||
|
@ -62,7 +64,15 @@ TkFrame.new($colors_demo, 'borderwidth'=>10) {|w|
|
|||
colors_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
|
||||
}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
|
||||
|
||||
colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
|
||||
#colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
|
||||
colors_lbox.bind('Double-1', proc{
|
||||
begin
|
||||
TkPalette.setPalette TkSelection.get
|
||||
rescue => e
|
||||
p e
|
||||
Tk.tk_call_without_enc('destroy', '.___tk_set_palette')
|
||||
end
|
||||
})
|
||||
|
||||
ins_data = [
|
||||
'gray60','gray70','gray80','gray85','gray90','gray95',
|
||||
|
|
96
ext/tk/sample/demos-en/combo.rb
Normal file
96
ext/tk/sample/demos-en/combo.rb
Normal file
|
@ -0,0 +1,96 @@
|
|||
# combo.rb --
|
||||
#
|
||||
# This demonstration script creates several combobox widgets.
|
||||
#
|
||||
# based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
|
||||
|
||||
if defined?($combo_demo) && $combo_demo
|
||||
$combo_demo.destroy
|
||||
$combo_demo = nil
|
||||
end
|
||||
|
||||
$combo_demo = TkToplevel.new {|w|
|
||||
title("Combobox Demonstration")
|
||||
iconname("combo")
|
||||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($combo_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'5i', :justify=>:left,
|
||||
:text=><<EOL).pack(:side=>:top, :fill=>:x)
|
||||
Three different combo-boxes are displayed below. \
|
||||
You can add characters to the first \
|
||||
one by pointing, clicking and typing, just as with an entry; pressing \
|
||||
Return will cause the current value to be added to the list that is \
|
||||
selectable from the drop-down list, and you can choose other values \
|
||||
by pressing the Down key, using the arrow keys to pick another one, \
|
||||
and pressing Return again. The second combo-box is fixed to a \
|
||||
particular value, and cannot be modified at all. The third one only \
|
||||
allows you to select values from its drop-down list of Australian \
|
||||
cities.
|
||||
EOL
|
||||
|
||||
## variables
|
||||
firstValue = TkVariable.new
|
||||
secondValue = TkVariable.new
|
||||
ozCity = TkVariable.new
|
||||
|
||||
## See Code / Dismiss buttons
|
||||
Ttk::Frame.new(base_frame) {|frame|
|
||||
sep = Ttk::Separator.new(frame)
|
||||
Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
|
||||
TkGrid('x',
|
||||
Ttk::Button.new(frame, :text=>'See Variables',
|
||||
:image=>$image['view'], :compound=>:left,
|
||||
:command=>proc{
|
||||
showVars(base_frame,
|
||||
['firstVariable', firstValue],
|
||||
['secondVariable', secondValue],
|
||||
['ozCity', ozCity])
|
||||
}),
|
||||
Ttk::Button.new(frame, :text=>'See Code',
|
||||
:image=>$image['view'], :compound=>:left,
|
||||
:command=>proc{showCode 'combo'}),
|
||||
Ttk::Button.new(frame, :text=>'Dismiss',
|
||||
:image=>$image['delete'], :compound=>:left,
|
||||
:command=>proc{
|
||||
$combo_demo.destroy
|
||||
$combo_demo = nil
|
||||
}),
|
||||
:padx=>4, :pady=>4)
|
||||
grid_columnconfigure(0, :weight=>1)
|
||||
pack(:side=>:bottom, :fill=>:x)
|
||||
}
|
||||
|
||||
frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
australianCities = [
|
||||
'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide', 'Brisbane',
|
||||
'Hobart', 'Darwin', 'Alice Springs'
|
||||
]
|
||||
|
||||
|
||||
secondValue.value = 'unchangable'
|
||||
ozCity.value = 'Sydney'
|
||||
|
||||
Tk.pack(Ttk::Labelframe.new(frame, :text=>'Fully Editable'){|f|
|
||||
Ttk::Combobox.new(f, :textvariable=>firstValue){|b|
|
||||
b.bind('Return', '%W'){|w|
|
||||
w.values <<= w.value unless w.values.include?(w.value)
|
||||
}
|
||||
}.pack(:pady=>5, :padx=>10)
|
||||
},
|
||||
|
||||
Ttk::LabelFrame.new(frame, :text=>'Disabled'){|f|
|
||||
Ttk::Combobox.new(f, :textvariable=>secondValue, :state=>:disabled) .
|
||||
pack(:pady=>5, :padx=>10)
|
||||
},
|
||||
|
||||
Ttk::LabelFrame.new(frame, :text=>'Defined List Only'){|f|
|
||||
Ttk::Combobox.new(f, :textvariable=>ozCity, :state=>:readonly,
|
||||
:values=>australianCities) .
|
||||
pack(:pady=>5, :padx=>10)
|
||||
},
|
||||
|
||||
:side=>:top, :pady=>5, :padx=>10)
|
|
@ -19,14 +19,16 @@ $cscroll_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($cscroll_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
TkLabel.new($cscroll_demo, 'font'=>$font, 'wraplength'=>'4i',
|
||||
TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i',
|
||||
'justify'=>'left', 'text'=>"This window displays a canvas widget that can be scrolled either using the scrollbars or by dragging with button 2 in the canvas. If you click button 1 on one of the rectangles, its indices will be printed on stdout."){
|
||||
pack('side'=>'top')
|
||||
}
|
||||
|
||||
# frame
|
||||
$cscroll_buttons = TkFrame.new($cscroll_demo) {|frame|
|
||||
$cscroll_buttons = TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -45,7 +47,7 @@ $cscroll_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
|||
|
||||
# frame
|
||||
unless $tk_version =~ /^4\.[01]/
|
||||
$cscroll_grid = TkFrame.new($cscroll_demo) {
|
||||
$cscroll_grid = TkFrame.new(base_frame) {
|
||||
pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
|
||||
}
|
||||
TkGrid.rowconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
|
||||
|
@ -53,7 +55,7 @@ unless $tk_version =~ /^4\.[01]/
|
|||
end
|
||||
|
||||
# canvas
|
||||
$cscroll_canvas = TkCanvas.new($cscroll_demo,
|
||||
$cscroll_canvas = TkCanvas.new(base_frame,
|
||||
'relief'=>'sunken', 'borderwidth'=>2,
|
||||
'scrollregion'=>['-11c', '-11c', '50c', '20c']
|
||||
) {|c|
|
||||
|
@ -64,7 +66,7 @@ $cscroll_canvas = TkCanvas.new($cscroll_demo,
|
|||
'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
|
||||
end
|
||||
|
||||
TkScrollbar.new($cscroll_demo, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
|
||||
TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
|
||||
c.yscrollcommand(proc{|first,last| vs.set first,last})
|
||||
if $tk_version =~ /^4\.[01]/
|
||||
pack('side'=>'right', 'fill'=>'y')
|
||||
|
@ -74,7 +76,7 @@ $cscroll_canvas = TkCanvas.new($cscroll_demo,
|
|||
end
|
||||
}
|
||||
|
||||
TkScrollbar.new($cscroll_demo, 'orient'=>'horiz',
|
||||
TkScrollbar.new(base_frame, 'orient'=>'horiz',
|
||||
'command'=>proc{|*args| c.xview(*args)}) {|hs|
|
||||
c.xscrollcommand(proc{|first,last| hs.set first,last})
|
||||
if $tk_version =~ /^4\.[01]/
|
||||
|
|
|
@ -19,8 +19,10 @@ $ctext_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($ctext_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
|
||||
TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
|
||||
'text'=>"This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification. The text also supports the following simple bindings for editing:
|
||||
1. You can point, click, and type.
|
||||
2. You can also select with button 1.
|
||||
|
@ -33,7 +35,7 @@ TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
|
|||
}
|
||||
|
||||
# frame
|
||||
$ctext_buttons = TkFrame.new($ctext_demo) {|frame|
|
||||
$ctext_buttons = TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -51,7 +53,7 @@ $ctext_buttons = TkFrame.new($ctext_demo) {|frame|
|
|||
$ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
||||
|
||||
# canvas
|
||||
$ctext_canvas = TkCanvas.new($ctext_demo, 'relief'=>'flat',
|
||||
$ctext_canvas = TkCanvas.new(base_frame, 'relief'=>'flat',
|
||||
'borderwidth'=>0, 'width'=>500, 'height'=>350)
|
||||
$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ $entry1_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($entry1_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
msg = TkLabel.new($entry1_demo) {
|
||||
msg = TkLabel.new(base_frame) {
|
||||
font $font
|
||||
wraplength '5i'
|
||||
justify 'left'
|
||||
|
@ -25,7 +27,7 @@ msg = TkLabel.new($entry1_demo) {
|
|||
msg.pack('side'=>'top')
|
||||
|
||||
# frame
|
||||
TkFrame.new($entry1_demo) {|frame|
|
||||
TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -42,9 +44,9 @@ TkFrame.new($entry1_demo) {|frame|
|
|||
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
||||
|
||||
#
|
||||
e1 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
|
||||
e2 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
|
||||
e3 = TkEntry.new($entry1_demo, 'relief'=>'sunken')
|
||||
e1 = TkEntry.new(base_frame, 'relief'=>'sunken')
|
||||
e2 = TkEntry.new(base_frame, 'relief'=>'sunken')
|
||||
e3 = TkEntry.new(base_frame, 'relief'=>'sunken')
|
||||
[e1,e2,e3].each{|w| w.pack('side'=>'top', 'padx'=>10, 'pady'=>5, 'fill'=>'x')}
|
||||
|
||||
#
|
||||
|
|
|
@ -19,8 +19,10 @@ $entry2_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($entry2_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
msg = TkLabel.new($entry2_demo) {
|
||||
msg = TkLabel.new(base_frame) {
|
||||
font $font
|
||||
wraplength '5i'
|
||||
justify 'left'
|
||||
|
@ -29,7 +31,7 @@ msg = TkLabel.new($entry2_demo) {
|
|||
msg.pack('side'=>'top')
|
||||
|
||||
# frame
|
||||
TkFrame.new($entry2_demo) {|frame|
|
||||
TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -46,7 +48,7 @@ TkFrame.new($entry2_demo) {|frame|
|
|||
}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
|
||||
|
||||
# frame
|
||||
TkFrame.new($entry2_demo, 'borderwidth'=>10) {|w|
|
||||
TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
|
||||
# entry 1
|
||||
s1 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
|
||||
e1 = TkEntry.new(w, 'relief'=>'sunken') {
|
||||
|
|
|
@ -17,7 +17,9 @@ $entry3_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
TkLabel.new($entry3_demo,
|
||||
base_frame = TkFrame.new($entry3_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
TkLabel.new(base_frame,
|
||||
:font=>$font, :wraplength=>'5i', :justify=>:left,
|
||||
:text=><<EOL).pack(:side=>:top)
|
||||
Four different entries are displayed below. You can add characters \
|
||||
|
@ -34,7 +36,7 @@ characters (silently ignoring further ones), and displaying them as \
|
|||
asterisk characters.
|
||||
EOL
|
||||
|
||||
TkFrame.new($entry3_demo){|f|
|
||||
TkFrame.new(base_frame){|f|
|
||||
pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
|
||||
|
||||
TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
|
||||
|
@ -60,23 +62,41 @@ TkFrame.new($entry3_demo){|f|
|
|||
# count - Counter to control the number of times flashed
|
||||
def focusAndFlash(widget, fg, bg, count=5)
|
||||
return if count <= 0
|
||||
TkTimer.new(200, count,
|
||||
proc{widget.configure(:foreground=>bg, :background=>fg)},
|
||||
proc{widget.configure(:foreground=>fg, :background=>bg)}
|
||||
).start
|
||||
if fg && !fg.empty? && bg && !bg.empty?
|
||||
TkTimer.new(200, count,
|
||||
proc{widget.configure(:foreground=>bg, :background=>fg)},
|
||||
proc{widget.configure(:foreground=>fg, :background=>bg)}
|
||||
).start
|
||||
else
|
||||
# TkTimer.new(150, 3){Tk.bell}.start
|
||||
Tk.bell
|
||||
TkTimer.new(200, count,
|
||||
proc{widget.configure(:foreground=>'white',
|
||||
:background=>'black')},
|
||||
proc{widget.configure(:foreground=>'black',
|
||||
:background=>'white')}
|
||||
).at_end{begin
|
||||
widget.configure(:foreground=>fg,
|
||||
:background=>bg)
|
||||
rescue
|
||||
# ignore
|
||||
end}.start
|
||||
end
|
||||
widget.focus(true)
|
||||
end
|
||||
|
||||
l1 = TkLabelFrame.new($entry3_demo, :text=>"Integer Entry")
|
||||
l1 = TkLabelFrame.new(base_frame, :text=>"Integer Entry")
|
||||
TkEntry.new(l1, :validate=>:focus,
|
||||
:vcmd=>[
|
||||
proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
|
||||
]) {|e|
|
||||
invalidcommand [proc{|w| focusAndFlash(w, e.fg, e.bg)}, '%W']
|
||||
fg = e.foreground
|
||||
bg = e.background
|
||||
invalidcommand [proc{|w| focusAndFlash(w, fg, bg)}, '%W']
|
||||
pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
|
||||
}
|
||||
|
||||
l2 = TkLabelFrame.new($entry3_demo, :text=>"Length-Constrained Entry")
|
||||
l2 = TkLabelFrame.new(base_frame, :text=>"Length-Constrained Entry")
|
||||
TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell},
|
||||
:vcmd=>[proc{|s| s.length < 10}, '%P']
|
||||
).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
|
||||
|
@ -158,14 +178,14 @@ def validatePhoneChange(widget, vmode, idx, char)
|
|||
widget.insert(idx, $phoneNumberMap[char] || char)
|
||||
Tk.after_idle(proc{phoneSkipRight(widget, -1)})
|
||||
return true
|
||||
# Tk.update(true) # Don't work 'update' inter validation callback.
|
||||
# It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
|
||||
# Tk.update(true) # <- Don't work 'update' inter validation callback.
|
||||
# It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
l3 = TkLabelFrame.new($entry3_demo, :text=>"US Phone-Number Entry")
|
||||
l3 = TkLabelFrame.new(base_frame, :text=>"US Phone-Number Entry")
|
||||
TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
|
||||
:textvariable=>entry3content,
|
||||
:vcmd=>[
|
||||
|
@ -184,14 +204,14 @@ TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
|
|||
pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
|
||||
}
|
||||
|
||||
l4 = TkLabelFrame.new($entry3_demo, :text=>"Password Entry")
|
||||
l4 = TkLabelFrame.new(base_frame, :text=>"Password Entry")
|
||||
TkEntry.new(l4, :validate=>:key, :show=>'*',
|
||||
:vcmd=>[
|
||||
proc{|s| s.length <= 8},
|
||||
'%P'
|
||||
]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
|
||||
|
||||
TkFrame.new($entry3_demo){|f|
|
||||
TkFrame.new(base_frame){|f|
|
||||
lower
|
||||
TkGrid.configure(l1, l2, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
|
||||
TkGrid.configure(l3, l4, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
|
||||
|
|
|
@ -17,12 +17,14 @@ $filebox_demo = TkToplevel.new {|w|
|
|||
positionWindow(w)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($filebox_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
TkLabel.new($filebox_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
|
||||
TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
|
||||
'text'=>"Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog.").pack('side'=>'top')
|
||||
|
||||
# frame
|
||||
TkFrame.new($filebox_demo) {|frame|
|
||||
TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -40,7 +42,7 @@ TkFrame.new($filebox_demo) {|frame|
|
|||
|
||||
# frame
|
||||
['open', 'save'].each{|type|
|
||||
TkFrame.new($filebox_demo) {|f|
|
||||
TkFrame.new(base_frame) {|f|
|
||||
TkLabel.new(f, 'text'=>"Select a file to #{type}: ", 'anchor'=>'e')\
|
||||
.pack('side'=>'left')
|
||||
|
||||
|
@ -48,7 +50,7 @@ TkFrame.new($filebox_demo) {|frame|
|
|||
pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
|
||||
|
||||
TkButton.new(f, 'text'=>'Browse ...',
|
||||
'command'=>proc{fileDialog $filebox_demo,e,type})\
|
||||
'command'=>proc{fileDialog base_frame,e,type})\
|
||||
.pack('side'=>'left')
|
||||
}
|
||||
|
||||
|
@ -58,7 +60,7 @@ TkFrame.new($filebox_demo) {|frame|
|
|||
|
||||
$tk_strictMotif = TkVarAccess.new('tk_strictMotif')
|
||||
if ($tk_platform['platform'] == 'unix')
|
||||
TkCheckButton.new($filebox_demo,
|
||||
TkCheckButton.new(base_frame,
|
||||
'text'=>'Use Motif Style Dialog',
|
||||
'variable'=>$tk_strictMotif,
|
||||
'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c')
|
||||
|
@ -91,7 +93,10 @@ def fileDialog(w,ent,operation)
|
|||
if file != ""
|
||||
ent.delete 0, 'end'
|
||||
ent.insert 0, file
|
||||
ent.xview 'end'
|
||||
# ent.xview 'end'
|
||||
Tk.update_idletasks # need this for Tk::Tile::Entry
|
||||
# (to find right position of 'xview').
|
||||
ent.xview(ent.index('end'))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1590,14 +1590,16 @@ $floor_demo = TkToplevel.new {|w|
|
|||
minsize(100,100)
|
||||
}
|
||||
|
||||
base_frame = TkFrame.new($floor_demo).pack(:fill=>:both, :expand=>true)
|
||||
|
||||
# label
|
||||
TkLabel.new($floor_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
|
||||
TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
|
||||
'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){
|
||||
pack('side'=>'top')
|
||||
}
|
||||
|
||||
# frame
|
||||
$floor_buttons = TkFrame.new($floor_demo) {|frame|
|
||||
$floor_buttons = TkFrame.new(base_frame) {|frame|
|
||||
TkButton.new(frame) {
|
||||
text 'Dismiss'
|
||||
command proc{
|
||||
|
@ -1620,17 +1622,17 @@ $floorItems = {}
|
|||
|
||||
# canvas
|
||||
if $tk_version =~ /^4\.[01]/
|
||||
$floor_canvas_frame = TkFrame.new($floor_demo,'bd'=>2,'relief'=>'sunken',
|
||||
$floor_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
|
||||
'highlightthickness'=>2)
|
||||
$floor_canvas = TkCanvas.new($floor_canvas_frame,
|
||||
'width'=>900, 'height'=>500, 'borderwidth'=>0,
|
||||
'highlightthickness'=>0) {|c|
|
||||
TkScrollbar.new($floor_demo, 'orient'=>'horiz',
|
||||
TkScrollbar.new(base_frame, 'orient'=>'horiz',
|
||||
'command'=>proc{|*args| c.xview(*args)}){|hs|
|
||||
c.xscrollcommand(proc{|first,last| hs.set first,last})
|
||||
pack('side'=>'bottom', 'fill'=>'x')
|
||||
}
|
||||
TkScrollbar.new($floor_demo, 'command'=>proc{|*args| c.yview(*args)}){|vs|
|
||||
TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
|
||||
c.yscrollcommand(proc{|first,last| vs.set first,last})
|
||||
pack('side'=>'right', 'fill'=>'y')
|
||||
}
|
||||
|
@ -1639,7 +1641,7 @@ if $tk_version =~ /^4\.[01]/
|
|||
$floor_canvas.pack('expand'=>'yes', 'fill'=>'both')
|
||||
|
||||
else
|
||||
TkFrame.new($floor_demo) {|f|
|
||||
TkFrame.new(base_frame) {|f|
|
||||
pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
|
||||
|
||||
h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue