* ext/tk/extconf.rb: New strategy for searching Tcl/Tk libraries.

* ext/tk/*: Support new features of Tcl/Tk8.6b1 and minor bug fixes.
     ( [KNOWN BUG] Ruby/Tk on Ruby 1.9 will not work on Cygwin. )
* ext/tk/*: Unify sources between Ruby 1.8 & 1.9.
            Improve default_widget_set handling.
* ext/tk/*: Multi-TkInterpreter (multi-tk.rb) works on Ruby 1.8 & 1.9.
     ( [KNOWN BUG] On Ruby 1.8, join to a long term Thread on Tk
       callbacks may freeze. On Ruby 1.9, cannot create a second 
       master interpreter (creating slaves are OK); supported master
       interpreter is the default master interpreter only. )
* ext/tk/lib/tkextlib/*: Update supported versions of Tk extensions.
         Tcllib 1.8/Tklib 0.4.1  ==>  Tcllib 1.11.1/Tklib 0.5
         BWidgets 1.7            ==>  BWidgets 1.8
         TkTable 2.9             ==>  TkTable 2.10
         TkTreeCtrl 2005-12-02   ==>  TkTreeCtrl 2.2.9
         Tile 0.8.0/8.5.1        ==>  Tile 0.8.3/8.6b1
         IncrTcl 2005-02-14      ==>  IncrTcl 2008-12-15
         TclX 2005-02-07         ==>  TclX 2008-12-15
         Trofs 0.4.3             ==>  Trofs 0.4.4


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@24064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2009-07-12 23:09:52 +00:00
parent 4e94c36f3d
commit 41b74c6e20
535 changed files with 16499 additions and 10067 deletions

View file

@ -1,3 +1,29 @@
Mon Jul 13 08:01:00 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/extconf.rb: New strategy for searching Tcl/Tk libraries.
* ext/tk/*: Support new features of Tcl/Tk8.6b1 and minor bug fixes.
( [KNOWN BUG] Ruby/Tk on Ruby 1.9 will not work on Cygwin. )
* ext/tk/*: Unify sources between Ruby 1.8 & 1.9.
Improve default_widget_set handling.
* ext/tk/*: Multi-TkInterpreter (multi-tk.rb) works on Ruby 1.8 & 1.9.
( [KNOWN BUG] On Ruby 1.8, join to a long term Thread on Tk
callbacks may freeze. On Ruby 1.9, cannot create a second
master interpreter (creating slaves are OK); supported master
interpreter is the default master interpreter only. )
* ext/tk/lib/tkextlib/*: Update supported versions of Tk extensions.
Tcllib 1.8/Tklib 0.4.1 ==> Tcllib 1.11.1/Tklib 0.5
BWidgets 1.7 ==> BWidgets 1.8
TkTable 2.9 ==> TkTable 2.10
TkTreeCtrl 2005-12-02 ==> TkTreeCtrl 2.2.9
Tile 0.8.0/8.5.1 ==> Tile 0.8.3/8.6b1
IncrTcl 2005-02-14 ==> IncrTcl 2008-12-15
TclX 2005-02-07 ==> TclX 2008-12-15
Trofs 0.4.3 ==> Trofs 0.4.4
Mon Jul 13 01:18:46 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Mon Jul 13 01:18:46 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* time.c (time_timeval): rounds subsecond toward zero. * time.c (time_timeval): rounds subsecond toward zero.

View file

@ -1,3 +1,17 @@
2009-07-12 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/*: update release.
Tcllib 1.8/Tklib 0.4.1 ==> Tcllib 1.11.1/Tklib 0.5
BWidgets 1.7 ==> BWidgets 1.8
TkTable 2.9 ==> TkTable 2.10
TkTreeCtrl 2005-12-02 ==> TkTreeCtrl 2.2.9
Tile 0.8.0/8.5.1 ==> Tile 0.8.3/8.6b1
IncrTcl 2005-02-14 ==> IncrTcl 2008-12-15
TclX 2005-02-07 ==> TclX 2008-12-15
Trofs 0.4.3 ==> Trofs 0.4.4
--------------< ... some bug fixes ... >------------------
Tue Nov 25 03:37:42 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> Tue Nov 25 03:37:42 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/blt/tabset.rb, * ext/tk/lib/tkextlib/blt/tabset.rb,

View file

@ -140,8 +140,7 @@ module TclTklib
[module methods] [module methods]
get_version() get_version()
: return an array of major, minor, release-type number, : return an array of major, minor, release-type number,
: number, release-type name, and patchlevel of current : and patchlevel of current Tcl/Tk library.
: Tcl/Tk library.
mainloop(check_root = true) mainloop(check_root = true)
: Starts the eventloop. If 'check_root' is true, this method : Starts the eventloop. If 'check_root' is true, this method
@ -354,6 +353,11 @@ class TclTkIp
: to _eval and regist the command once, after that, the : to _eval and regist the command once, after that, the
: command can be called by _invoke. : command can be called by _invoke.
_cancel_eval(str)
_cancel_eval_unwind(str)
: (Tcl/Tk8.6 or later)
: Call Tcl_CancelEval() function, and cancel evaluation.
_toUTF8(str, encoding=nil) _toUTF8(str, encoding=nil)
_fromUTF8(str, encoding=nil) _fromUTF8(str, encoding=nil)
: Call the function (which is internal function of Tcl/Tk) to : Call the function (which is internal function of Tcl/Tk) to

View file

@ -235,8 +235,8 @@ require "tcltklib"
モジュールメソッド モジュールメソッド
get_version() get_version()
: Tcl/Tk の major, minor, release-type 番号, release-type 名, : Tcl/Tk の major, minor, release-type 番号, patchlevel を
: patchlevel を配列にして返す. : 配列にして返す.
mainloop(check_root = true) mainloop(check_root = true)
: イベントループを起動するcheck_root が true であれば, : イベントループを起動するcheck_root が true であれば,
@ -464,6 +464,11 @@ require "tcltklib"
: して登録に成功しさえすれば,以降は _invoke でも利用で : して登録に成功しさえすれば,以降は _invoke でも利用で
: きるようになる. : きるようになる.
_cancel_eval(str)
_cancel_eval_unwind(str)
: (Tcl/Tk8.6 or later)
: Tcl_CancelEval() 関数を呼び出しeval の実行を打ち切る.
_toUTF8(str, encoding=nil) _toUTF8(str, encoding=nil)
_fromUTF8(str, encoding=nil) _fromUTF8(str, encoding=nil)
: Tcl/Tk が内蔵している UTF8 変換処理を呼び出す. : Tcl/Tk が内蔵している UTF8 変換処理を呼び出す.

View file

@ -3,9 +3,22 @@ ActiveTcl is ActiveState's quality-assured distribution of Tcl.
# see <http://www.activestate.com/Products/ActiveTcl/> # see <http://www.activestate.com/Products/ActiveTcl/>
# <http://www.tcl.tk/> # <http://www.tcl.tk/>
First of all, please try to configure without any options.
"extconf.rb" searches ActiveTcl as default action.
If you have ActiveTcl and standard (or your own) Tcl/Tk on your
environment and don't want to use ActiveTcl on your Ruby/Tk, please
use --without-ActiveTcl option.
When "extconf.rb" fails to find your ActiveTcl libraries, please try
the followings.
If you want to use ActiveTcl binary package as the Tcl/Tk libraries, If you want to use ActiveTcl binary package as the Tcl/Tk libraries,
please use the following configure options. please use the following configure options.
--with-ActiveTcl=<ActiveTcl_root>
( When without argument; no <ActiveTcl_root>; only '--with-ActiveTcl',
it same to '--with-ActiveTcl=/opt/ActiveTcl*/lib' )
--with-tcl-dir=<ActiveTcl_root> --with-tcl-dir=<ActiveTcl_root>
--with-tk-dir=<ActiveTcl_root> --with-tk-dir=<ActiveTcl_root>

View file

@ -1,18 +1,53 @@
To compile 'tcltklib', you must have Tcl/Tk libraries on your environment. To compile 'tcltklib', you must have Tcl/Tk libraries on your environment.
Although 'extconf.rb' script searches Tcl/Tk libraries and header files, Although 'extconf.rb' script searches Tcl/Tk libraries and header files
(as default, searches tclConfig.sh/tkConfig.sh and use the defintions on
those; ActiveTcl has high priority on searching unless --without-ActiveTcl),
sometimes fails to find them. And then, 'tcltklib' cannot be compiled. If sometimes fails to find them. And then, 'tcltklib' cannot be compiled. If
Tcl/Tk libraries or header files are installed but are not found, you can 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 give the information by arguments of the 'configure' script. Please give
some or all of the following options. some or all of the following options.
--with-tk-old-extconf use old "extconf.rb" (default: false).
If current extconf.rb doesn't work properly
(or your install process is based on old
documant about Ruby/Tk install), please try
this option.
--with-ActiveTcl / --without-ActiveTcl
--with-ActiveTcl=<dir> search ActiveTcl libraries (default: true).
When true, try to find installed ActiveTcl.
When <dir> is given, use it as the ActiveTcl's
top directory (use <dir>/lib, and so on).
Old "extconf.rb" doesn't support this option.
--with-tk-shlib-search-path=<paths>
teach the paths for loading shared-libraries
to linker.
<paths> is a path list with the same format
as PATH environment variable.
This option may be experimental.
Old "extconf.rb" doesn't support this option.
--with-tcltkversion=<version> --with-tcltkversion=<version>
force version of Tcl/Tk libaray force version of Tcl/Tk libaray
(e.g. libtcl8.4g.so ==> --with-tcltkversion=8.4g) (e.g. libtcl8.4g.so ==> --with-tcltkversion=8.4g)
--without-tcl-config / --without-tk-config
--with-tclConfig-dir=<dir>
--with-tkConfig-dir=<dir> the directory contains 'tclConfig.sh' and
'tkConfig.sh'.
Current "extconf.rb" uses the information
on tclConfig.sh/tkConfig.rb, if possible.
Old "extconf.rb" doesn't support this option.
--with-tcllib=<libname> (e.g. libtcl8.4.so ==> --with-tcllib=tcl8.4) --with-tcllib=<libname> (e.g. libtcl8.4.so ==> --with-tcllib=tcl8.4)
--with-tklib=<libname> (e.g. libtk8.4.so ==> --with-tklib=tk8.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)
On old "extconf.rb", default is false.
On current "extconf.rb", default is true when
tclConfig.sh/tkConfig.sh have TCL_STUB_LIB_SPEC
/TK_STUB_LIB_SPEC, else default is false.
--with-tcl-dir=<path> --with-tcl-dir=<path>
equal to "--with-tcl-include=<path>/include --with-tcl-lib=<path>/lib" equal to "--with-tcl-include=<path>/include --with-tcl-lib=<path>/lib"
@ -36,6 +71,12 @@ some or all of the following options.
When this option is given, it is assumed that When this option is given, it is assumed that
--enable-tcltk-framework option is given also. --enable-tcltk-framework option is given also.
--with-tcl-framework-dir=<dir>
Tcl framework directory (e.g. "/Library/Frameworks/Tcl.framework")
--with-tk-framework-dir=<dir>
Tk framework directory (e.g. "/Library/Frameworks/Tk.framework")
--with-tcl-framework-header=<dir> --with-tcl-framework-header=<dir>
Tcl framework headers directory Tcl framework headers directory
(e.g. "/Library/Frameworks/Tcl.framework/Headers") (e.g. "/Library/Frameworks/Tcl.framework/Headers")

35
ext/tk/config_list.in Normal file
View file

@ -0,0 +1,35 @@
##############################################
# configure options for Ruby/Tk
# release date: 2009-07-12
##############################################
with tk-old-extconf
with ActiveTcl
with tk-shlib-search-path
with tcltkversion
with tcl-config
with tk-config
with tclConfig-dir
with tkConfig-dir
with tcllib
with tklib
enable tcltk-stubs
with tcl-dir
with tk-dir
with tcl-include
with tcl-lib
with tcl-lib
with tk-lib
enable mac-tcltk-framework
enable tcltk-framework
with tcltk-framework
with tcl-framework-dir
with tk-framework-dir
with tcl-framework-header
with tk-framework-header
with X11
with X11-dir
with X11-include
with X11-lib
enable pthread
enable tcl-thread
with tclConfig-file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -10,8 +10,8 @@ class MultiTkIp; end
class RemoteTkIp < MultiTkIp; end class RemoteTkIp < MultiTkIp; end
class MultiTkIp class MultiTkIp
@@IP_TABLE = {}.taint unless defined?(@@IP_TABLE) @@IP_TABLE = TkUtil.untrust({}) unless defined?(@@IP_TABLE)
@@TK_TABLE_LIST = [].taint unless defined?(@@TK_TABLE_LIST) @@TK_TABLE_LIST = TkUtil.untrust([]) unless defined?(@@TK_TABLE_LIST)
def self._IP_TABLE; @@IP_TABLE; end def self._IP_TABLE; @@IP_TABLE; end
def self._TK_TABLE_LIST; @@TK_TABLE_LIST; end def self._TK_TABLE_LIST; @@TK_TABLE_LIST; end
@ -88,10 +88,14 @@ class RemoteTkIp
@slave_ip_tbl = {} @slave_ip_tbl = {}
@slave_ip_top = {} @slave_ip_top = {}
@tk_windows.taint unless @tk_windows.tainted? @force_default_encoding ||= TkUtil.untrust([false])
@tk_table_list.taint unless @tk_table_list.tainted? @encoding ||= TkUtil.untrust([nil])
@slave_ip_tbl.taint unless @slave_ip_tbl.tainted? def @encoding.to_s; self.join(nil); end
@slave_ip_top.taint unless @slave_ip_top.tainted?
TkUtil.untrust(@tk_windows) unless @tk_windows.tainted?
TkUtil.untrust(@tk_table_list) unless @tk_table_list.tainted?
TkUtil.untrust(@slave_ip_tbl) unless @slave_ip_tbl.tainted?
TkUtil.untrust(@slave_ip_top) unless @slave_ip_top.tainted?
@system = Object.new @system = Object.new
@ -114,8 +118,8 @@ class RemoteTkIp
@@DEFAULT_MASTER.assign_receiver_and_watchdog(self) @@DEFAULT_MASTER.assign_receiver_and_watchdog(self)
@@IP_TABLE[@threadgroup] = self @@IP_TABLE[@threadgroup] = self
@@TK_TABLE_LIST.size.times{ @@TK_TABLE_LIST.size.times{
(tbl = {}).tainted? || tbl.taint (tbl = {}).tainted? || TkUtil.untrust(tbl)
@tk_table_list << tbl @tk_table_list << tbl
} }
@ -154,13 +158,13 @@ class RemoteTkIp
return nil if timeout < 1 return nil if timeout < 1
@ret_val.value = '' @ret_val.value = ''
@interp._invoke('send', '-async', @remote, @interp._invoke('send', '-async', @remote,
'send', '-async', Tk.appname, 'send', '-async', Tk.appname,
"set #{@ret_val.id} ready") "set #{@ret_val.id} ready")
Tk.update Tk.update
if @ret_val != 'ready' if @ret_val != 'ready'
(1..(timeout*5)).each{ (1..(timeout*5)).each{
sleep 0.2 sleep 0.2
Tk.update Tk.update
break if @ret_val == 'ready' break if @ret_val == 'ready'
} }
@ -204,10 +208,10 @@ class RemoteTkIp
cmds = @interp._merge_tklist(*TkUtil::_conv_args([], enc_mode, *cmds)) cmds = @interp._merge_tklist(*TkUtil::_conv_args([], enc_mode, *cmds))
if @displayof if @displayof
if async if async
@interp.__invoke('send', '-async', '-displayof', @displayof, @interp.__invoke('send', '-async', '-displayof', @displayof,
'--', @remote, *cmds) '--', @remote, *cmds)
else else
@interp.__invoke('send', '-displayof', @displayof, @interp.__invoke('send', '-displayof', @displayof,
'--', @remote, *cmds) '--', @remote, *cmds)
end end
else else
@ -229,7 +233,7 @@ class RemoteTkIp
def is_rubytk? def is_rubytk?
return false if _appsend(false, false, 'info', 'command', 'ruby') == "" return false if _appsend(false, false, 'info', 'command', 'ruby') == ""
[ _appsend(false, false, 'ruby', 'RUBY_VERSION'), [ _appsend(false, false, 'ruby', 'RUBY_VERSION'),
_appsend(false, false, 'set', 'tk_patchLevel') ] _appsend(false, false, 'set', 'tk_patchLevel') ]
end end
@ -298,7 +302,7 @@ class RemoteTkIp
raise SecurityError, "no permission to manipulate" unless self.manipulable? raise SecurityError, "no permission to manipulate" unless self.manipulable?
if @displayof if @displayof
lst = @interp._invoke_without_enc('winfo', 'interps', lst = @interp._invoke_without_enc('winfo', 'interps',
'-displayof', @displayof) '-displayof', @displayof)
else else
lst = @interp._invoke_without_enc('winfo', 'interps') lst = @interp._invoke_without_enc('winfo', 'interps')

View file

@ -84,7 +84,7 @@ end
# class TclTkInterpreter: tcl/tk interpreter # class TclTkInterpreter: tcl/tk interpreter
class TclTkInterpreter class TclTkInterpreter
# initialize(): # initialize():
def initialize() def initialize()
# generate interpreter object # generate interpreter object
@ip = TclTkIp.new() @ip = TclTkIp.new()
@ -181,7 +181,7 @@ end
# class TclTkObject: base class of the tcl/tk objects # class TclTkObject: base class of the tcl/tk objects
class TclTkObject class TclTkObject
# initialize(ip, exp): # initialize(ip, exp):
# ip: interpreter(TclTkIp) # ip: interpreter(TclTkIp)
# exp: tcl/tk representation # exp: tcl/tk representation
def initialize(ip, exp) def initialize(ip, exp)
@ -211,7 +211,7 @@ end
# class TclTkLibCommand: tcl/tk commands in the library # class TclTkLibCommand: tcl/tk commands in the library
class TclTkLibCommand < TclTkCommand class TclTkLibCommand < TclTkCommand
# initialize(ip, name): # initialize(ip, name):
# ip: interpreter(TclTkInterpreter) # ip: interpreter(TclTkInterpreter)
# name: command name (String) # name: command name (String)
def initialize(ip, name) def initialize(ip, name)
@ -222,7 +222,7 @@ end
# class TclTkVariable: tcl/tk variable # class TclTkVariable: tcl/tk variable
class TclTkVariable < TclTkObject class TclTkVariable < TclTkObject
# initialize(interp, dat): # initialize(interp, dat):
# interp: interpreter(TclTkInterpreter) # interp: interpreter(TclTkInterpreter)
# dat: the value to set(String) # dat: the value to set(String)
# if nil, not initialize variable # if nil, not initialize variable
@ -255,7 +255,7 @@ end
# class TclTkWidget: tcl/tk widget # class TclTkWidget: tcl/tk widget
class TclTkWidget < TclTkCommand class TclTkWidget < TclTkCommand
# initialize(*args): # initialize(*args):
# *args: parameters # *args: parameters
def initialize(*args) def initialize(*args)
if args[0].kind_of?(TclTkIp) if args[0].kind_of?(TclTkIp)
@ -281,7 +281,7 @@ class TclTkWidget < TclTkCommand
# interp: interpreter(TclTkInterpreter) # interp: interpreter(TclTkInterpreter)
# parent: parent widget # parent: parent widget
# command: widget generating tk command(label Åù) # command: widget generating tk command(label Åù)
# *args: argument to the command # *args: argument to the command
interp, parent, command, *args = args interp, parent, command, *args = args
# generate widget name # generate widget name
@ -303,14 +303,14 @@ end
# class TclTkCallback: tcl/tk callbacks # class TclTkCallback: tcl/tk callbacks
class TclTkCallback < TclTkObject class TclTkCallback < TclTkObject
# initialize(interp, pr, arg): # initialize(interp, pr, arg):
# interp: interpreter(TclTkInterpreter) # interp: interpreter(TclTkInterpreter)
# pr: callback procedure(Proc) # pr: callback procedure(Proc)
# arg: string to pass as block parameters of pr # arg: string to pass as block parameters of pr
# bind command of tcl/tk uses % replacement for parameters # bind command of tcl/tk uses % replacement for parameters
# pr can receive replaced data using block parameter # pr can receive replaced data using block parameter
# its format is specified by arg string # its format is specified by arg string
# You should not specify arg for the command like # You should not specify arg for the command like
# scrollbar with -command option, which receives parameters # scrollbar with -command option, which receives parameters
# without specifying any replacement # without specifying any replacement
def initialize(interp, pr, arg = nil) def initialize(interp, pr, arg = nil)
@ -347,7 +347,7 @@ end
# class TclTkImage: tcl/tk images # class TclTkImage: tcl/tk images
class TclTkImage < TclTkCommand class TclTkImage < TclTkCommand
# initialize(interp, t, *args): # initialize(interp, t, *args):
# generating image is done by TclTkImage.new() # generating image is done by TclTkImage.new()
# destrying is done by image delete (inconsistent, sigh) # destrying is done by image delete (inconsistent, sigh)
# interp: interpreter(TclTkInterpreter) # interp: interpreter(TclTkInterpreter)

File diff suppressed because it is too large Load diff

View file

@ -27,6 +27,8 @@ def TkPlace(*args); TkPlace.configure(*args); end
############################################ ############################################
# classes on Tk module # classes on Tk module
module Tk module Tk
autoload :Busy, 'tk/busy'
autoload :Button, 'tk/button' autoload :Button, 'tk/button'
autoload :Canvas, 'tk/canvas' autoload :Canvas, 'tk/canvas'
@ -250,78 +252,85 @@ autoload :TkXIM, 'tk/xim'
module Tk module Tk
@TOPLEVEL_ALIAS_TABLE = {} @TOPLEVEL_ALIAS_TABLE = {}
@TOPLEVEL_ALIAS_TABLE[:Tk] = { @TOPLEVEL_ALIAS_TABLE[:Tk] = {
:TkButton => 'tk/button', :TkButton => 'tk/button',
:TkCanvas => 'tk/canvas', :TkCanvas => 'tk/canvas',
:TkCheckButton => 'tk/checkbutton', :TkCheckButton => 'tk/checkbutton',
:TkCheckbutton => 'tk/checkbutton', :TkCheckbutton => 'tk/checkbutton',
# :TkDialog => 'tk/dialog', # :TkDialog => 'tk/dialog',
# :TkDialog2 => 'tk/dialog', # :TkDialog2 => 'tk/dialog',
# :TkDialogObj => 'tk/dialog', # :TkDialogObj => 'tk/dialog',
# :TkWarning => 'tk/dialog', # :TkWarning => 'tk/dialog',
# :TkWarning2 => 'tk/dialog', # :TkWarning2 => 'tk/dialog',
# :TkWarningObj => 'tk/dialog', # :TkWarningObj => 'tk/dialog',
:TkEntry => 'tk/entry', :TkEntry => 'tk/entry',
:TkFrame => 'tk/frame', :TkFrame => 'tk/frame',
:TkLabel => 'tk/label', :TkLabel => 'tk/label',
:TkLabelFrame => 'tk/labelframe', :TkLabelFrame => 'tk/labelframe',
:TkLabelframe => 'tk/labelframe', :TkLabelframe => 'tk/labelframe',
:TkListbox => 'tk/listbox', :TkListbox => 'tk/listbox',
:TkMacResource => 'tk/macpkg', :TkMacResource => 'tk/macpkg',
:TkMenu => 'tk/menu', :TkMenu => 'tk/menu',
:TkMenuClone => 'tk/menu', :TkMenuClone => 'tk/menu',
:TkCloneMenu => 'tk/menu', :TkCloneMenu => 'tk/menu',
# :TkSystemMenu => 'tk/menu', # :TkSystemMenu => 'tk/menu',
:TkSysMenu_Help => 'tk/menu', :TkSysMenu_Help => 'tk/menu',
:TkSysMenu_System => 'tk/menu', :TkSysMenu_System => 'tk/menu',
:TkSysMenu_Apple => 'tk/menu', :TkSysMenu_Apple => 'tk/menu',
:TkMenubutton => 'tk/menu', :TkMenubutton => 'tk/menu',
:TkMenuButton => 'tk/menu', :TkMenuButton => 'tk/menu',
:TkOptionMenubutton => 'tk/menu', :TkOptionMenubutton => 'tk/menu',
:TkOptionMenuButton => 'tk/menu', :TkOptionMenuButton => 'tk/menu',
:TkMessage => 'tk/message', :TkMessage => 'tk/message',
:TkPanedWindow => 'tk/panedwindow', :TkPanedWindow => 'tk/panedwindow',
:TkPanedwindow => 'tk/panedwindow', :TkPanedwindow => 'tk/panedwindow',
:TkRadioButton => 'tk/radiobutton', :TkRadioButton => 'tk/radiobutton',
:TkRadiobutton => 'tk/radiobutton', :TkRadiobutton => 'tk/radiobutton',
# :TkRoot => 'tk/root', # :TkRoot => 'tk/root',
:TkScale => 'tk/scale', :TkScale => 'tk/scale',
:TkScrollbar => 'tk/scrollbar', :TkScrollbar => 'tk/scrollbar',
:TkXScrollbar => 'tk/scrollbar', :TkXScrollbar => 'tk/scrollbar',
:TkYScrollbar => 'tk/scrollbar', :TkYScrollbar => 'tk/scrollbar',
:TkSpinbox => 'tk/spinbox', :TkSpinbox => 'tk/spinbox',
:TkText => 'tk/text', :TkText => 'tk/text',
:TkToplevel => 'tk/toplevel', :TkToplevel => 'tk/toplevel',
:TkWinDDE => 'tk/winpkg', :TkWinDDE => 'tk/winpkg',
:TkWinRegistry => 'tk/winpkg', :TkWinRegistry => 'tk/winpkg',
} }
@TOPLEVEL_ALIAS_OWNER = {} @TOPLEVEL_ALIAS_OWNER = {}
@TOPLEVEL_ALIAS_SETUP_PROC = {} @TOPLEVEL_ALIAS_SETUP_PROC = {}
@AUTOLOAD_FILE_SYM_TABLE = Hash.new{|h,k| h[k]={}} # TABLE[file][sym] -> obj
@current_default_widget_set = nil @current_default_widget_set = nil
module TOPLEVEL_ALIASES; end
end end
class Object
include Tk::TOPLEVEL_ALIASES
end
############################################ ############################################
# methods to control default widget set # methods to control default widget set
@ -343,50 +352,387 @@ class << Tk
_replace_toplevel_aliases(target) _replace_toplevel_aliases(target)
end end
def __set_toplevel_aliases__(target, obj, *symbols) def widget_set_symbols
@TOPLEVEL_ALIAS_TABLE.keys
end
def toplevel_aliases_on_widget_set(widget_set)
if (tbl = @TOPLEVEL_ALIAS_TABLE[widget_set.to_sym])
tbl.collect{|k, v| (v.nil?)? nil: k}.compact
else
fail ArgumentError, "unknown widget_set #{widget_set.to_sym.inspect}"
end
end
def __toplevel_alias_setup_proc__(*target_list, &cmd)
target_list.each{|target| @TOPLEVEL_ALIAS_SETUP_PROC[target.to_sym] = cmd}
end
def topobj_defined?(sym) #=> alias_filename or object or false
Object.autoload?(sym) ||
(Object.const_defined?(sym) && Object.const_get(sym))
end
def topalias_defined?(sym) #=> alias_filename or object or false
Tk::TOPLEVEL_ALIASES.autoload?(sym) ||
(Tk::TOPLEVEL_ALIASES.const_defined?(sym) &&
Tk::TOPLEVEL_ALIASES.const_get(sym))
end
def define_topobj(sym, obj)
if obj.kind_of? String
# obj is an autoload path
Object.autoload(sym, obj)
unless Object.autoload?(sym)
# file is autoloaded?
if @AUTOLOAD_FILE_SYM_TABLE.has_key?(obj) &&
(loaded_obj = @AUTOLOAD_FILE_SYM_TABLE[obj][sym])
Object.const_set(sym, loaded_obj)
else
fail ArgumentError, "cannot define autoload file (already loaded?)"
end
end
else
# object
Object.const_set(sym, obj)
end
end
def define_topalias(sym, obj)
if obj.kind_of? String
# obj is an autoload path
Tk::TOPLEVEL_ALIASES.autoload(sym, obj)
unless Tk::TOPLEVEL_ALIASES.autoload?(sym)
# file is autoloaded?
if @AUTOLOAD_FILE_SYM_TABLE.has_key?(obj) &&
(loaded_obj = @AUTOLOAD_FILE_SYM_TABLE[obj][sym])
Tk::TOPLEVEL_ALIASES.const_set(sym, loaded_obj)
else
fail ArgumentError, "cannot define autoload file (already loaded?)"
end
end
else
# object
Tk::TOPLEVEL_ALIASES.const_set(sym, obj)
end
end
def replace_topobj(sym, obj) #=> old_obj (alias_filename or object) or nil
if old_obj = topobj_defined?(sym)
Object.class_eval{remove_const sym} rescue nil # ignore err
end
define_topobj(sym, obj)
old_obj
end
def replace_topalias(sym, obj) #=> old_obj (alias_filename or object) or nil
if old_obj = topalias_defined?(sym)
Tk::TOPLEVEL_ALIASES.module_eval{remove_const sym} rescue nil #ignore err
end
define_topalias(sym, obj)
old_obj
end
private :topobj_defined?, :topalias_defined?
private :define_topobj, :define_topalias
private :replace_topobj, :replace_topalias
def __regist_toplevel_aliases__(target, obj, *symbols)
# initial regist
@TOPLEVEL_ALIAS_TABLE[target = target.to_sym] ||= {} @TOPLEVEL_ALIAS_TABLE[target = target.to_sym] ||= {}
symbols.each{|sym| symbols.each{|sym|
@TOPLEVEL_ALIAS_TABLE[target][sym = sym.to_sym] = obj @TOPLEVEL_ALIAS_TABLE[target][sym = sym.to_sym] = obj
# if @current_default_widget_set == target if !topalias_defined?(sym) || target == @current_default_widget_set
if @TOPLEVEL_ALIAS_OWNER[sym] == target @TOPLEVEL_ALIAS_OWNER[sym] = target
Object.class_eval{remove_const sym} if Object.const_defined?(sym) replace_topalias(sym, obj)
Object.const_set(sym, obj) replace_topobj(sym, obj) unless obj.kind_of?(String) # NOT autoload
end end
} }
end end
################################### def regist_sym_for_loaded_file(auto, obj, sym)
private @AUTOLOAD_FILE_SYM_TABLE[auto][sym] = obj
def _replace_toplevel_aliases(target)
# check already autoloaded reg = /^#{Regexp.quote(auto)}(\.rb|\.so|)$/
if (table = @TOPLEVEL_ALIAS_TABLE[current = @current_default_widget_set]) @TOPLEVEL_ALIAS_TABLE.each_key{|set|
table.each{|sym, file| if @TOPLEVEL_ALIAS_TABLE[set][sym] =~ reg
if !Object.autoload?(sym) && Object.const_defined?(sym) && @TOPLEVEL_ALIAS_TABLE[set][sym] = obj
@TOPLEVEL_ALIAS_TABLE[current][sym].kind_of?(String) if @TOPLEVEL_ALIAS_OWNER[sym].nil? || @TOPLEVEL_ALIAS_OWNER[sym] == set
# autoload -> class replace_topalias(sym, obj)
@TOPLEVEL_ALIAS_TABLE[current][sym] = Object.const_get(sym) replace_topobj(sym, obj) if set == @current_default_widget_set
end end
} end
}
if (f = Object.autoload?(sym)) && f =~ reg
replace_topobj(sym, obj)
end
if (f = Tk::TOPLEVEL_ALIASES.autoload?(sym)) && f =~ reg
replace_topalias(sym, obj)
end
end
private :regist_sym_for_loaded_file
def set_topalias(target, obj, sym)
# obj is a kind of String : define autoload path
# Class : use the class object
if target == @current_default_widget_set
case @TOPLEVEL_ALIAS_OWNER[sym]
when false
# Object::sym is out of control. --> not change
# Make ALIAS::sym under control, because target widget set is current.
# Keep OWNER[sym]
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
when target
if current_obj = topobj_defined?(sym)
if current_obj == obj
# Make current_obj under control.
# Keep Object::sym.
# Keep OWNER[sym].
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
else # current_obj != obj
if current_obj == topalias_defined?(sym)
# Change controlled object
# Keep OWNER[sym].
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
replace_topobj(sym, obj)
else # current_obj != topalias_defined?(sym)
# Maybe current_obj is defined by user. --> OWNER[sym] = faise
# Keep Object::sym.
@TOPLEVEL_ALIAS_OWNER[sym] = false
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
end
end
else # NOT topobj_defined?(sym)
# New definition for sym at target.
# Keep OWNER[sym].
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
define_topobj(sym, obj)
end
when nil
# New definition for sym at target.
@TOPLEVEL_ALIAS_OWNER[sym] = target
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
else # others
# Maybe planning to make sym under control.
@TOPLEVEL_ALIAS_OWNER[sym] = target
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
replace_topobj(sym, obj)
end
else # target != @current_default_widget_set
case @TOPLEVEL_ALIAS_OWNER[sym]
when false
# Object::sym is out of control. --> not change
if topalias_defined?(sym)
# ALIAS[sym] may be defined by other widget set.
# Keep Object::sym (even if it is not defined)
# Keep ALIAS[sym].
# Keep OWNER[sym].
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
else # NOT topalias_defined?(sym)
# Nobody controls ALIAS[sym].
# At leaset, current widget set doesn't control ALIAS[sym].
# Keep Object::sym (even if it is not defined)
# Keep OWNER[sym].
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
define_topalias(sym, obj)
end
when target
# Maybe change controlled object, because Object::sym is under control.
# Keep OWNER[sym].
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
replace_topobj(sym, obj)
when nil
# New definition for sym
@TOPLEVEL_ALIAS_OWNER[sym] = target
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
replace_topalias(sym, obj)
replace_topobj(sym, obj)
else # others
# An other widget set controls sym.
# Keep Object::sym (even if it is not defined)
# Keep ALIAS[sym].
# Keep OWNER[sym].
@TOPLEVEL_ALIAS_TABLE[target][sym] = obj
end
end end
# setup autoloads sym
@TOPLEVEL_ALIAS_TABLE[target].each{|sym, file| end
Object.class_eval{remove_const sym} if Object.const_defined?(sym) private :set_topalias
if file.kind_of?(String)
# file => autoload target file def __set_toplevel_aliases__(target, obj, *symbols)
Object.autoload(sym, file) # obj is a kind of String : define autoload path
else # Class : use the class object
# file => loaded class object target = target.to_sym
Object.const_set(sym, file) symbols.each{|sym| set_topalias(target, obj, sym.to_sym)}
end
def __set_loaded_toplevel_aliases__(autopath, target, obj, *symbols)
# autopath is an autoload file
# Currently, this method doesn't support that autoload loads
# different toplevels between <basename>.rb and <basename>.so extension.
shortpath = (autopath =~ /^(.*)(.rb|.so)$/)? $1: autopath
target = target.to_sym
symbols.map!{|sym| sym.to_sym}
symbols.each{|sym| regist_sym_for_loaded_file(shortpath, obj, sym) }
symbols.each{|sym| set_topalias(target, obj, sym)}
end
def backup_current_topdef(sym)
return if (current = @current_default_widget_set).nil?
case @TOPLEVEL_ALIAS_OWNER[sym]
when false
# Object::sym is out of control.
if (cur_alias = topalias_defined?(sym)) && ! cur_alias.kind_of?(String)
@TOPLEVEL_ALIAS_TABLE[current][sym] = cur_alias
end end
@TOPLEVEL_ALIAS_OWNER[sym] = target
when current
if cur_obj = topobj_defined?(sym)
if ! cur_obj.kind_of?(String) && (cur_alias = topalias_defined?(sym))
if cur_alias.kind_of?(String)
# Mayby, user replaced Object::sym.
# Make Object::sym out of control.
@TOPLEVEL_ALIAS_OWNER[sym] = false
elsif cur_obj == cur_alias
# Possibley, defined normally. Backup it
@TOPLEVEL_ALIAS_TABLE[current][sym] = cur_alias
else
# Mayby, user replaced Object::sym.
# Make Object::sym out of control.
@TOPLEVEL_ALIAS_OWNER[sym] = false
end
end
else
# Mayby, user replaced Object::sym.
# Make Object::sym out of control.
@TOPLEVEL_ALIAS_OWNER[sym] = false
end
when nil
# Object::sym is out of control.
if (cur_alias = topalias_defined?(sym)) && ! cur_alias.kind_of?(String)
# Possibley, defined normally. Backup it.
@TOPLEVEL_ALIAS_TABLE[current][sym] = cur_alias
end
else
# No authority to control Object::sym and ALIASES::sym.
# Do nothing.
end
end
private :backup_current_topdef
def _replace_toplevel_aliases(target)
# backup
@TOPLEVEL_ALIAS_TABLE[target].each_key{|sym|
backup_current_topdef(sym)
} }
# update current alias # replace
@TOPLEVEL_ALIAS_TABLE[target].each_key{|sym|
next if (obj = @TOPLEVEL_ALIAS_TABLE[target][sym]).nil?
if @TOPLEVEL_ALIAS_OWNER[sym] == false
# Object::sym is out of control. --> not change
# Keep OWNER[sym].
replace_topalias(sym, obj)
else
# New definition
@TOPLEVEL_ALIAS_OWNER[sym] = target
replace_topalias(sym, obj)
replace_topobj(sym, obj)
end
}
# change default_widget_set
@current_default_widget_set = target @current_default_widget_set = target
end end
private :_replace_toplevel_aliases
def __import_toplevel_aliases__(target, *symbols)
current = @current_default_widget_set
symbols.each{|sym|
sym = sym.to_sym
if (obj = @TOPLEVEL_ALIAS_TABLE[target][sym]).nil?
# remove
@TOPLEVEL_ALIAS_TABLE[current].delete(sym)
@TOPLEVEL_ALIAS_OWNER.delete(sym)
Tk::TOPLEVEL_ALIASES.module_eval{remove_const sym} if topalias_defined?(sym)
Object.class_eval{remove_const sym} if topobj_defined?(sym)
elsif obj == false
# remove, but OWNER[sym] <- false and not treat Object::sym
@TOPLEVEL_ALIAS_TABLE[current].delete(sym)
@TOPLEVEL_ALIAS_OWNER[sym] = false
Tk::TOPLEVEL_ALIASES.module_eval{remove_const sym} if topalias_defined?(sym)
elsif @TOPLEVEL_ALIAS_OWNER[sym] == false
# Object::sym is out of control. --> not change
# Keep OWNER[sym].
@TOPLEVEL_ALIAS_TABLE[current][sym] = obj
replace_topalias(sym, obj)
else
# new definition under control
@TOPLEVEL_ALIAS_OWNER[sym] = current
@TOPLEVEL_ALIAS_TABLE[current][sym] = obj
replace_topalias(sym, obj)
replace_topobj(sym, obj)
end
}
end
def __remove_toplevel_aliases__(*symbols)
# remove toplevel aliases of current widget set
current = @current_default_widget_set
symbols.each{|sym|
sym = sym.to_sym
@TOPLEVEL_ALIAS_TABLE[current].delete(sym)
@TOPLEVEL_ALIAS_OWNER.delete(sym)
Tk::TOPLEVEL_ALIASES.module_eval{remove_const sym} if topalias_defined?(sym)
Object.class_eval{remove_const sym} if topobj_defined?(sym)
}
end
def __reset_toplevel_owner__(*symbols)
symbols.each{|sym| @TOPLEVEL_ALIAS_OWNER.delete(sym.to_sym)}
end
def __disable_toplevel_control__(*symbols)
symbols.each{|sym| @TOPLEVEL_ALIAS_OWNER[sym.to_sym] = false}
end
def __create_widget_set__(new_set, src_set={})
new_set = new_set.to_sym
if @TOPLEVEL_ALIAS_TABLE[new_set]
fail RuntimeError, "A widget-set #{new_set.inspect} is already exist."
end
if src_set.kind_of?(Symbol)
# new_set is an alias name of existed widget set.
@TOPLEVEL_ALIAS_TABLE[new_set] = @TOPLEVEL_ALIAS_TABLE[src_set]
else
@TOPLEVEL_ALIAS_TABLE[new_set] = {}
src_set.each{|sym, obj| set_topalias(new_set, obj, sym.to_sym) }
end
end
end end
############################################ ############################################
# setup default widget set => :Tk # setup default widget set => :Tk
Tk.default_widget_set = :Tk Tk.default_widget_set = :Tk
@ -394,14 +740,14 @@ Tk.default_widget_set = :Tk
############################################ ############################################
# depend on the version of Tcl/Tk # depend on the version of Tcl/Tk
# major, minor, type, type_name, patchlevel = TclTkLib.get_version # major, minor, type, patchlevel = TclTkLib.get_version
############################################ ############################################
# Ttk (Tile) support # Ttk (Tile) support
=begin =begin
if major > 8 || if major > 8 ||
(major == 8 && minor > 5) || (major == 8 && minor > 5) ||
(major == 8 && minor == 5 && type >= TclTkLib::RELEASE_TYPE::BETA) (major == 8 && minor == 5 && type >= TclTkLib::RELEASE_TYPE::BETA)
# Tcl/Tk 8.5 beta or later # Tcl/Tk 8.5 beta or later
Object.autoload :Ttk, 'tkextlib/tile' Object.autoload :Ttk, 'tkextlib/tile'
Tk.autoload :Tile, 'tkextlib/tile' Tk.autoload :Tile, 'tkextlib/tile'

View file

@ -9,7 +9,7 @@ class TkBindTag
#BTagID_TBL = {} #BTagID_TBL = {}
BTagID_TBL = TkCore::INTERP.create_table BTagID_TBL = TkCore::INTERP.create_table
(Tk_BINDTAG_ID = ["btag".freeze, "00000".taint]).instance_eval{ (Tk_BINDTAG_ID = ["btag".freeze, TkUtil.untrust("00000")]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze

118
ext/tk/lib/tk/busy.rb Normal file
View file

@ -0,0 +1,118 @@
#
# tk/busy.rb: support 'tk busy' command (Tcl/Tk8.6 or later)
#
require 'tk'
module Tk::Busy
include TkCore
extend TkCore
extend TkItemConfigMethod
end
class << Tk::Busy
def __item_cget_cmd(win)
# maybe need to override
['tk', 'busy', 'cget', win.path]
end
private :__item_cget_cmd
def __item_config_cmd(win)
# maybe need to override
['tk', 'busy', 'configure', win.path]
end
private :__item_config_cmd
def __item_confinfo_cmd(win)
# maybe need to override
__item_config_cmd(win)
end
private :__item_confinfo_cmd
alias cget_tkstring itemcget_tkstring
alias cget itemcget
alias cget_strict itemcget_strict
alias configure itemconfigure
alias configinfo itemconfiginfo
alias current_configinfo current_itemconfiginfo
private :itemcget_tkstring, :itemcget, :itemcget_strict
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
def method_missing(id, *args)
name = id.id2name
case args.length
when 1
if name[-1] == ?=
configure name[0..-2], args[0]
args[0]
else
configure name, args[0]
self
end
when 0
begin
cget(name)
rescue
super(id, *args)
end
else
super(id, *args)
end
end
def hold(win, keys={})
tk_call_without_enc('tk', 'busy', 'hold', win, *hash_kv(keys))
win
end
def forget(*wins)
tk_call_without_enc('tk', 'busy', 'forget', *wins)
self
end
def current(pat=None)
list(tk_call('tk', 'busy', 'current', pat))
end
def status(win)
bool(tk_call_without_enc('tk', 'busy', 'status', win))
end
end
module Tk::Busy
def busy_configinfo(option=nil)
Tk::Busy.configinfo(self, option)
end
def busy_current_configinfo(option=nil)
Tk::Busy.current_configinfo(self, option)
end
def busy_configure(option, value=None)
Tk::Busy.configure(self, option, value)
self
end
def busy_cget(option)
Tk::Busy.configure(self, option)
end
def busy(keys={})
Tk::Busy.hold(self, keys)
self
end
alias busy_hold busy
def busy_forget
Tk::Busy.forget(self)
self
end
def busy_current?
! Tk::Busy.current(self.path).empty?
end
def busy_status
Tk::Busy.status(self)
end
end

View file

@ -7,7 +7,7 @@ require 'tk/label'
class Tk::Button<Tk::Label class Tk::Button<Tk::Label
TkCommandNames = ['button'.freeze].freeze TkCommandNames = ['button'.freeze].freeze
WidgetClassName = 'Button'.freeze WidgetClassName = 'Button'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
# tk_call_without_enc('button', @path, *hash_kv(keys, true)) # tk_call_without_enc('button', @path, *hash_kv(keys, true))
@ -27,4 +27,5 @@ class Tk::Button<Tk::Label
end end
#TkButton = Tk::Button unless Object.const_defined? :TkButton #TkButton = Tk::Button unless Object.const_defined? :TkButton
Tk.__set_toplevel_aliases__(:Tk, Tk::Button, :TkButton) #Tk.__set_toplevel_aliases__(:Tk, Tk::Button, :TkButton)
Tk.__set_loaded_toplevel_aliases__('tk/button.rb', :Tk, Tk::Button, :TkButton)

View file

@ -13,7 +13,7 @@ module TkCanvasItemConfig
def __item_strval_optkeys(id) def __item_strval_optkeys(id)
# maybe need to override # maybe need to override
super(id) + [ super(id) + [
'fill', 'activefill', 'disabledfill', 'fill', 'activefill', 'disabledfill',
'outline', 'activeoutline', 'disabledoutline' 'outline', 'activeoutline', 'disabledoutline'
] ]
end end
@ -45,7 +45,7 @@ class Tk::Canvas<TkWindow
TkCommandNames = ['canvas'.freeze].freeze TkCommandNames = ['canvas'.freeze].freeze
WidgetClassName = 'Canvas'.freeze WidgetClassName = 'Canvas'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def __destroy_hook__ def __destroy_hook__
TkcItem::CItemID_TBL.delete(@path) TkcItem::CItemID_TBL.delete(@path)
@ -117,7 +117,7 @@ class Tk::Canvas<TkWindow
end end
def bbox(tagOrId, *tags) def bbox(tagOrId, *tags)
list(tk_send_without_enc('bbox', tagid(tagOrId), list(tk_send_without_enc('bbox', tagid(tagOrId),
*tags.collect{|t| tagid(t)})) *tags.collect{|t| tagid(t)}))
end end
@ -181,7 +181,7 @@ class Tk::Canvas<TkWindow
end end
def dchars(tag, first, last=None) def dchars(tag, first, last=None)
tk_send_without_enc('dchars', tagid(tag), tk_send_without_enc('dchars', tagid(tag),
_get_eval_enc_str(first), _get_eval_enc_str(last)) _get_eval_enc_str(first), _get_eval_enc_str(last))
self self
end end
@ -214,7 +214,7 @@ class Tk::Canvas<TkWindow
alias deltag dtag alias deltag dtag
def find(mode, *args) def find(mode, *args)
list(tk_send_without_enc('find', mode, *args)).collect!{|id| list(tk_send_without_enc('find', mode, *args)).collect!{|id|
TkcItem.id2obj(self, id) TkcItem.id2obj(self, id)
} }
end end
@ -265,12 +265,18 @@ class Tk::Canvas<TkWindow
self self
end end
def imove(tagOrId, idx, x, y)
tk_send_without_enc('imove', tagid(tagOrId), idx, x, y)
self
end
alias i_move imove
def index(tagOrId, idx) def index(tagOrId, idx)
number(tk_send_without_enc('index', tagid(tagOrId), idx)) number(tk_send_without_enc('index', tagid(tagOrId), idx))
end end
def insert(tagOrId, index, string) def insert(tagOrId, index, string)
tk_send_without_enc('insert', tagid(tagOrId), index, tk_send_without_enc('insert', tagid(tagOrId), index,
_get_eval_enc_str(string)) _get_eval_enc_str(string))
self self
end end
@ -300,7 +306,7 @@ class Tk::Canvas<TkWindow
fnt fnt
end end
else else
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId), tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
"-#{option}"))) "-#{option}")))
end end
end end
@ -315,16 +321,16 @@ class Tk::Canvas<TkWindow
|| key['latinfont'] || key['asciifont'] ) || key['latinfont'] || key['asciifont'] )
tagfont_configure(tagid(tagOrId), key.dup) tagfont_configure(tagid(tagOrId), key.dup)
else else
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
*hash_kv(key, true))) *hash_kv(key, true)))
end end
else else
if ( key == 'coords' || key == :coords ) if ( key == 'coords' || key == :coords )
self.coords(tagOrId, value) self.coords(tagOrId, value)
elsif ( key == 'font' || key == :font || elsif ( key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont || key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont || key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont ) key == 'asciifont' || key == :asciifont )
if value == None if value == None
tagfontobj(tagid(tagOrId)) tagfontobj(tagid(tagOrId))
@ -332,7 +338,7 @@ class Tk::Canvas<TkWindow
tagfont_configure(tagid(tagOrId), {key=>value}) tagfont_configure(tagid(tagOrId), {key=>value})
end end
else else
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
"-#{key}", _get_eval_enc_str(value))) "-#{key}", _get_eval_enc_str(value)))
end end
end end
@ -389,16 +395,16 @@ class Tk::Canvas<TkWindow
else else
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
if conf[4] if conf[4]
if conf[4].index('{') if conf[4].index('{')
conf[4] = tk_split_list(conf[4]) conf[4] = tk_split_list(conf[4])
else else
conf[4] = tk_tcl2ruby(conf[4]) conf[4] = tk_tcl2ruby(conf[4])
end end
end end
end end
@ -421,8 +427,8 @@ class Tk::Canvas<TkWindow
when 'coords' when 'coords'
{'coords' => ['', '', '', self.coords(tagOrId)]} {'coords' => ['', '', '', self.coords(tagOrId)]}
when 'dash', 'activedash', 'disableddash' when 'dash', 'activedash', 'disableddash'
conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
tagid(tagOrId), tagid(tagOrId),
"-#{key}")) "-#{key}"))
if conf[3] && conf[3] =~ /^[0-9]/ if conf[3] && conf[3] =~ /^[0-9]/
conf[3] = list(conf[3]) conf[3] = list(conf[3])
@ -457,16 +463,16 @@ class Tk::Canvas<TkWindow
else else
if conf[2] if conf[2]
if conf[2].index('{') if conf[2].index('{')
conf[2] = tk_split_list(conf[2]) conf[2] = tk_split_list(conf[2])
else else
conf[2] = tk_tcl2ruby(conf[2]) conf[2] = tk_tcl2ruby(conf[2])
end end
end end
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
end end
@ -523,11 +529,18 @@ class Tk::Canvas<TkWindow
self self
end end
def move(tag, x, y) def move(tag, dx, dy)
tk_send_without_enc('move', tagid(tag), x, y) tk_send_without_enc('move', tagid(tag), dx, dy)
self self
end end
def moveto(tag, x, y)
# Tcl/Tk 8.6 or later
tk_send_without_enc('moveto', tagid(tag), x, y)
self
end
alias move_to moveto
def postscript(keys) def postscript(keys)
tk_send("postscript", *hash_kv(keys)) tk_send("postscript", *hash_kv(keys))
end end
@ -541,6 +554,15 @@ class Tk::Canvas<TkWindow
self self
end end
def rchars(tag, first, last, str_or_coords)
# Tcl/Tk 8.6 or later
str_or_coords = str_or_coords.flatten if str_or_coords.kinad_of? Array
tk_send_without_enc('rchars', tagid(tag), first, last, str_or_coords)
self
end
alias replace_chars rchars
alias replace_coords rchars
def scale(tag, x, y, xs, ys) def scale(tag, x, y, xs, ys)
tk_send_without_enc('scale', tagid(tag), x, y, xs, ys) tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
self self
@ -581,7 +603,8 @@ class Tk::Canvas<TkWindow
end end
#TkCanvas = Tk::Canvas unless Object.const_defined? :TkCanvas #TkCanvas = Tk::Canvas unless Object.const_defined? :TkCanvas
Tk.__set_toplevel_aliases__(:Tk, Tk::Canvas, :TkCanvas) #Tk.__set_toplevel_aliases__(:Tk, Tk::Canvas, :TkCanvas)
Tk.__set_loaded_toplevel_aliases__('tk/canvas.rb', :Tk, Tk::Canvas, :TkCanvas)
class TkcItem<TkObject class TkcItem<TkObject
@ -676,7 +699,7 @@ class TkcItem<TkObject
fail RuntimeError, "#{self} is an abstract class" fail RuntimeError, "#{self} is an abstract class"
end end
args, fontkeys = _parse_create_args(args) args, fontkeys = _parse_create_args(args)
idnum = tk_call_without_enc(canvas.path, 'create', idnum = tk_call_without_enc(canvas.path, 'create',
self::CItemTypeName, *args) self::CItemTypeName, *args)
canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty? canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty?
idnum.to_i # 'canvas item id' is an integer number idnum.to_i # 'canvas item id' is an integer number

View file

@ -60,6 +60,9 @@ module TkcTagAccess
@c.itembindinfo(@id, seq) @c.itembindinfo(@id, seq)
end end
def cget_tkstring(option)
@c.itemcget_tkstring(@id, option)
end
def cget(option) def cget(option)
@c.itemcget(@id, option) @c.itemcget(@id, option)
end end
@ -116,6 +119,13 @@ module TkcTagAccess
self self
end end
def imove(idx, x, y)
# Tcl/Tk 8.6 or later
@c.imove(@id, idx, x, y)
self
end
alias i_move imove
def index(idx) def index(idx)
@c.index(@id, idx) @c.index(@id, idx)
end end
@ -135,6 +145,13 @@ module TkcTagAccess
self self
end end
def moveto(x, y)
# Tcl/Tk 8.6 or later
@c.moveto(@id, x, y)
self
end
alias move_to moveto
def raise(abovethis=None) def raise(abovethis=None)
@c.raise(@id, abovethis) @c.raise(@id, abovethis)
self self
@ -145,6 +162,14 @@ module TkcTagAccess
self self
end end
def rchars(first, last, str_or_coords)
# Tcl/Tk 8.6 or later
@c.rchars(@id, first, last, str_or_coords)
self
end
alias replace_chars rchars
alias replace_coords rchars
def select_adjust(index) def select_adjust(index)
@c.select('adjust', @id, index) @c.select('adjust', @id, index)
self self
@ -203,7 +228,7 @@ class TkcTag<TkObject
CTagID_TBL = TkCore::INTERP.create_table CTagID_TBL = TkCore::INTERP.create_table
(Tk_CanvasTag_ID = ['ctag'.freeze, '00000'.taint]).instance_eval{ (Tk_CanvasTag_ID = ['ctag'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -218,7 +243,7 @@ class TkcTag<TkObject
CTagID_TBL.mutex.synchronize{ CTagID_TBL.mutex.synchronize{
if CTagID_TBL[cpath] if CTagID_TBL[cpath]
CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
else else
id id
end end
} }
@ -389,7 +414,7 @@ class TkcTagCurrent<TkcTagString
end end
class TkcGroup<TkcTag class TkcGroup<TkcTag
(Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint]).instance_eval{ (Tk_cGroup_ID = ['tkcg'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -414,7 +439,7 @@ class TkcGroup<TkcTag
include(*args) if args != [] include(*args) if args != []
end end
#private :create_self #private :create_self
def include(*tags) def include(*tags)
for i in tags for i in tags
#i.addtag(@id) #i.addtag(@id)

View file

@ -7,7 +7,7 @@ require 'tk/radiobutton'
class Tk::CheckButton<Tk::RadioButton class Tk::CheckButton<Tk::RadioButton
TkCommandNames = ['checkbutton'.freeze].freeze TkCommandNames = ['checkbutton'.freeze].freeze
WidgetClassName = 'Checkbutton'.freeze WidgetClassName = 'Checkbutton'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
# tk_call_without_enc('checkbutton', @path, *hash_kv(keys, true)) # tk_call_without_enc('checkbutton', @path, *hash_kv(keys, true))
@ -26,5 +26,7 @@ end
Tk::Checkbutton = Tk::CheckButton Tk::Checkbutton = Tk::CheckButton
#TkCheckButton = Tk::CheckButton unless Object.const_defined? :TkCheckButton #TkCheckButton = Tk::CheckButton unless Object.const_defined? :TkCheckButton
#TkCheckbutton = Tk::Checkbutton unless Object.const_defined? :TkCheckbutton #TkCheckbutton = Tk::Checkbutton unless Object.const_defined? :TkCheckbutton
Tk.__set_toplevel_aliases__(:Tk, Tk::CheckButton, #Tk.__set_toplevel_aliases__(:Tk, Tk::CheckButton,
:TkCheckButton, :TkCheckbutton) # :TkCheckButton, :TkCheckbutton)
Tk.__set_loaded_toplevel_aliases__('tk/checkbutton.rb', :Tk, Tk::CheckButton,
:TkCheckButton, :TkCheckbutton)

View file

@ -1,5 +1,5 @@
# #
# tk/composite.rb : # tk/composite.rb :
# #
require 'tk' require 'tk'
@ -145,16 +145,34 @@ module TkComposite
str.chop << ' @epath=' << @epath.inspect << '>' str.chop << ' @epath=' << @epath.inspect << '>'
end end
def _get_opt_method_list(arg)
m_set, m_cget, m_info = arg
m_set = m_set.to_s
m_cget = m_set if !m_cget && self.method(m_set).arity == -1
m_cget = m_cget.to_s if m_cget
m_info = m_info.to_s if m_info
[m_set, m_cget, m_info]
end
private :_get_opt_method_list
def option_methods(*opts) def option_methods(*opts)
opts.each{|m_set, m_cget, m_info| if opts.size == 1 && opts[0].kind_of?(Hash)
m_set = m_set.to_s # {name => [m_set, m_cget, m_info], name => method} style
m_cget = m_set if !m_cget && self.method(m_set).arity == -1 opts[0].each{|name, arg|
m_cget = m_cget.to_s if m_cget m_set, m_cget, m_info = _get_opt_method_list(arg)
m_info = m_info.to_s if m_info @option_methods[name.to_s] = {
@option_methods[m_set] = { :set => m_set, :cget => m_cget, :info => m_info
:set => m_set, :cget => m_cget, :info => m_info }
} }
} else
# [m_set, m_cget, m_info] or method style
opts.each{|arg|
m_set, m_cget, m_info = _get_opt_method_list(arg)
@option_methods[m_set] = {
:set => m_set, :cget => m_cget, :info => m_info
}
}
end
end end
def delegate_alias(alias_opt, option, *wins) def delegate_alias(alias_opt, option, *wins)
@ -215,6 +233,14 @@ module TkComposite
end end
private :__cget_delegates private :__cget_delegates
def cget_tkstring(slot)
if (ret = __cget_delegates(slot)) == None
super(slot)
else
_get_eval_string(ret)
end
end
def cget(slot) def cget(slot)
if (ret = __cget_delegates(slot)) == None if (ret = __cget_delegates(slot)) == None
super(slot) super(slot)
@ -358,7 +384,7 @@ module TkComposite
opt, wins = tbl[0] opt, wins = tbl[0]
next unless wins && wins[-1] next unless wins && wins[-1]
if slot == opt if slot == opt
info_list.delete_if{|i| i[0] == slot} << info_list.delete_if{|i| i[0] == slot} <<
wins[-1].configinfo(slot) wins[-1].configinfo(slot)
else else
info = wins[-1].configinfo(opt) info = wins[-1].configinfo(opt)
@ -367,7 +393,7 @@ module TkComposite
end end
else else
opt, wins = tbl[-1] opt, wins = tbl[-1]
info_list.delete_if{|i| i[0] == slot} << info_list.delete_if{|i| i[0] == slot} <<
[slot, '', '', '', wins[-1].cget(opt)] [slot, '', '', '', wins[-1].cget(opt)]
end end
} }

View file

@ -28,7 +28,7 @@ module TkConsole
# supports a Tcl script only # supports a Tcl script only
# I have no idea to support a Ruby script seamlessly. # I have no idea to support a Ruby script seamlessly.
# #
_fromUTF8(tk_call_without_enc('console', 'eval', _fromUTF8(tk_call_without_enc('console', 'eval',
_get_eval_enc_str(tcl_script))) _get_eval_enc_str(tcl_script)))
end end
def self.maininterp_eval(tcl_script) def self.maininterp_eval(tcl_script)
@ -36,7 +36,7 @@ module TkConsole
# supports a Tcl script only # supports a Tcl script only
# I have no idea to support a Ruby script seamlessly. # I have no idea to support a Ruby script seamlessly.
# #
_fromUTF8(tk_call_without_enc('consoleinterp', 'eval', _fromUTF8(tk_call_without_enc('consoleinterp', 'eval',
_get_eval_enc_str(tcl_script))) _get_eval_enc_str(tcl_script)))
end end
@ -45,7 +45,7 @@ module TkConsole
# supports a Tcl script only # supports a Tcl script only
# I have no idea to support a Ruby script seamlessly. # I have no idea to support a Ruby script seamlessly.
# #
_fromUTF8(tk_call_without_enc('consoleinterp', 'record', _fromUTF8(tk_call_without_enc('consoleinterp', 'record',
_get_eval_enc_str(tcl_script))) _get_eval_enc_str(tcl_script)))
end end

View file

@ -18,11 +18,11 @@ class TkDialogObj < TkWindow
def _set_button_config(configs) def _set_button_config(configs)
set_config = proc{|c,i| set_config = proc{|c,i|
if $VERBOSE && (c.has_key?('command') || c.has_key?(:command)) if $VERBOSE && (c.has_key?('command') || c.has_key?(:command))
STDERR.print("Warning: cannot give a command option " + STDERR.print("Warning: cannot give a command option " +
"to the dialog button#{i}. It was removed.\n") "to the dialog button#{i}. It was removed.\n")
end end
c.delete('command'); c.delete(:command) c.delete('command'); c.delete(:command)
# @config << Kernel.format("%s.button%s configure %s; ", # @config << Kernel.format("%s.button%s configure %s; ",
# @path, i, hash_kv(c).join(' ')) # @path, i, hash_kv(c).join(' '))
# @config << @path+'.button'+i.to_s+' configure '+hash_kv(c).join(' ')+'; ' # @config << @path+'.button'+i.to_s+' configure '+hash_kv(c).join(' ')+'; '
@config << @path+'.button'+i.to_s+' configure '+ @config << @path+'.button'+i.to_s+' configure '+
@ -103,7 +103,7 @@ class TkDialogObj < TkWindow
#end #end
if @buttons.kind_of?(Array) if @buttons.kind_of?(Array)
_set_button_config(@buttons.collect{|cfg| _set_button_config(@buttons.collect{|cfg|
(cfg.kind_of? Array)? cfg[1]: nil}) (cfg.kind_of? Array)? cfg[1]: nil})
@buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg} @buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg}
end end
@ -127,7 +127,7 @@ class TkDialogObj < TkWindow
=end =end
if @message_config.kind_of?(Hash) if @message_config.kind_of?(Hash)
# @config << Kernel.format("%s.msg configure %s;", # @config << Kernel.format("%s.msg configure %s;",
# @path, hash_kv(@message_config).join(' ')) # @path, hash_kv(@message_config).join(' '))
# @config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';' # @config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';'
@config << @path+'.msg configure '+ @config << @path+'.msg configure '+
@ -135,7 +135,7 @@ class TkDialogObj < TkWindow
end end
if @msgframe_config.kind_of?(Hash) if @msgframe_config.kind_of?(Hash)
# @config << Kernel.format("%s.top configure %s;", # @config << Kernel.format("%s.top configure %s;",
# @path, hash_kv(@msgframe_config).join(' ')) # @path, hash_kv(@msgframe_config).join(' '))
# @config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';' # @config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';'
@config << @path+'.top configure '+ @config << @path+'.top configure '+
@ -143,7 +143,7 @@ class TkDialogObj < TkWindow
end end
if @btnframe_config.kind_of?(Hash) if @btnframe_config.kind_of?(Hash)
# @config << Kernel.format("%s.bot configure %s;", # @config << Kernel.format("%s.bot configure %s;",
# @path, hash_kv(@btnframe_config).join(' ')) # @path, hash_kv(@btnframe_config).join(' '))
# @config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';' # @config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';'
@config << @path+'.bot configure '+ @config << @path+'.bot configure '+
@ -151,7 +151,7 @@ class TkDialogObj < TkWindow
end end
if @bitmap_config.kind_of?(Hash) if @bitmap_config.kind_of?(Hash)
# @config << Kernel.format("%s.bitmap configure %s;", # @config << Kernel.format("%s.bitmap configure %s;",
# @path, hash_kv(@bitmap_config).join(' ')) # @path, hash_kv(@bitmap_config).join(' '))
# @config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';' # @config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';'
@config << @path+'.bitmap configure '+ @config << @path+'.bitmap configure '+
@ -176,19 +176,19 @@ class TkDialogObj < TkWindow
# default_button = '{}' if default_button == nil # default_button = '{}' if default_button == nil
default_button = '' if default_button == nil default_button = '' if default_button == nil
#Tk.ip_eval('eval {global '+@var.id+';'+@config+ #Tk.ip_eval('eval {global '+@var.id+';'+@config+
# 'set '+@var.id+' [tk_dialog '+ # 'set '+@var.id+' [tk_dialog '+
# @path+" "+@title+" {#{@message}} "+@bitmap+" "+ # @path+" "+@title+" {#{@message}} "+@bitmap+" "+
# String(default_button)+" "+@buttons.join(' ')+']}') # String(default_button)+" "+@buttons.join(' ')+']}')
Tk.ip_eval(@config) Tk.ip_eval(@config)
# @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title + # @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title +
# ' {' + @message + '} ' + @bitmap + ' ' + # ' {' + @message + '} ' + @bitmap + ' ' +
# String(default_button) + ' ' + @buttons.join(' ')).to_i # String(default_button) + ' ' + @buttons.join(' ')).to_i
# @val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' + # @val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' +
# @title + ' {' + @message + '} ' + @bitmap + ' ' + # @title + ' {' + @message + '} ' + @bitmap + ' ' +
# String(default_button) + ' ' + @buttons.join(' ')).to_i # String(default_button) + ' ' + @buttons.join(' ')).to_i
@val = Tk.ip_eval(array2tk_list([ @val = Tk.ip_eval(array2tk_list([
self.class::TkCommandNames[0], self.class::TkCommandNames[0],
@path, @title, @message, @bitmap, @path, @title, @message, @bitmap,
String(default_button) String(default_button)
].concat(@buttons))).to_i ].concat(@buttons))).to_i
end end
@ -226,7 +226,7 @@ class TkDialogObj < TkWindow
return nil return nil
end end
def bitmap def bitmap
# returns a bitmap name or a bitmap file path # returns a bitmap name or a bitmap file path
# (@ + path ; e.g. '@/usr/share/bitmap/sample.xbm') # (@ + path ; e.g. '@/usr/share/bitmap/sample.xbm')
return "info" return "info"
end end

View file

@ -67,11 +67,11 @@ module Tk
def initialize(str, enc = nil) def initialize(str, enc = nil)
super(str) super(str)
# @encoding = ( enc || # @encoding = ( enc ||
# ((self.class::Encoding)? # ((self.class::Encoding)?
# self.class::Encoding : Tk.encoding_system) ) # self.class::Encoding : Tk.encoding_system) )
enc ||= (self.class::Encoding)? enc ||= (self.class::Encoding)?
self.class::Encoding : self.class::Encoding :
((Tk.encoding)? Tk.encoding : Tk.encoding_system) ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
if TkCore::WITH_ENCODING if TkCore::WITH_ENCODING
unless encobj = Tk::Encoding::ENCODING_TABLE.get_obj(enc) unless encobj = Tk::Encoding::ENCODING_TABLE.get_obj(enc)

View file

@ -13,7 +13,7 @@ class Tk::Entry<Tk::Label
TkCommandNames = ['entry'.freeze].freeze TkCommandNames = ['entry'.freeze].freeze
WidgetClassName = 'Entry'.freeze WidgetClassName = 'Entry'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# super(__conv_vcmd_on_hash_kv(keys)) # super(__conv_vcmd_on_hash_kv(keys))
@ -116,4 +116,5 @@ class Tk::Entry<Tk::Label
end end
#TkEntry = Tk::Entry unless Object.const_defined? :TkEntry #TkEntry = Tk::Entry unless Object.const_defined? :TkEntry
Tk.__set_toplevel_aliases__(:Tk, Tk::Entry, :TkEntry) #Tk.__set_toplevel_aliases__(:Tk, Tk::Entry, :TkEntry)
Tk.__set_loaded_toplevel_aliases__('tk/entry.rb', :Tk, Tk::Entry, :TkEntry)

View file

@ -8,7 +8,7 @@ end
######################## ########################
require 'tkutil' require 'tkutil'
require 'tk' require 'tk' unless Object.const_defined? :TkComm
######################## ########################
@ -53,39 +53,39 @@ module TkEvent
#-----+-------------------+------------------+-----------------------# #-----+-------------------+------------------+-----------------------#
# ID | const | group_flag | context_name # # ID | const | group_flag | context_name #
#-----+-------------------+------------------+-----------------------# #-----+-------------------+------------------+-----------------------#
[ 2, :KeyPress, Grp::KEY, 'KeyPress', 'Key' ], [ 2, :KeyPress, Grp::KEY, 'KeyPress', 'Key' ],
[ 3, :KeyRelease, Grp::KEY, 'KeyRelease' ], [ 3, :KeyRelease, Grp::KEY, 'KeyRelease' ],
[ 4, :ButtonPress, Grp::BUTTON, 'ButtonPress', 'Button' ], [ 4, :ButtonPress, Grp::BUTTON, 'ButtonPress', 'Button' ],
[ 5, :ButtonRelease, Grp::BUTTON, 'ButtonRelease' ], [ 5, :ButtonRelease, Grp::BUTTON, 'ButtonRelease' ],
[ 6, :MotionNotify, Grp::MOTION, 'Motion' ], [ 6, :MotionNotify, Grp::MOTION, 'Motion' ],
[ 7, :EnterNotify, Grp::CROSSING, 'Enter' ], [ 7, :EnterNotify, Grp::CROSSING, 'Enter' ],
[ 8, :LeaveNotify, Grp::CROSSING, 'Leave' ], [ 8, :LeaveNotify, Grp::CROSSING, 'Leave' ],
[ 9, :FocusIn, Grp::FOCUS, 'FocusIn' ], [ 9, :FocusIn, Grp::FOCUS, 'FocusIn' ],
[ 10, :FocusOut, Grp::FOCUS, 'FocusOut' ], [ 10, :FocusOut, Grp::FOCUS, 'FocusOut' ],
[ 11, :KeymapNotify, 0, ], [ 11, :KeymapNotify, 0, ],
[ 12, :Expose, Grp::EXPOSE, 'Expose' ], [ 12, :Expose, Grp::EXPOSE, 'Expose' ],
[ 13, :GraphicsExpose, Grp::EXPOSE, ], [ 13, :GraphicsExpose, Grp::EXPOSE, ],
[ 14, :NoExpose, 0, ], [ 14, :NoExpose, 0, ],
[ 15, :VisibilityNotify, Grp::VISIBILITY, 'Visibility' ], [ 15, :VisibilityNotify, Grp::VISIBILITY, 'Visibility' ],
[ 16, :CreateNotify, Grp::CREATE, 'Create' ], [ 16, :CreateNotify, Grp::CREATE, 'Create' ],
[ 17, :DestroyNotify, Grp::DESTROY, 'Destroy' ], [ 17, :DestroyNotify, Grp::DESTROY, 'Destroy' ],
[ 18, :UnmapNotify, Grp::UNMAP, 'Unmap' ], [ 18, :UnmapNotify, Grp::UNMAP, 'Unmap' ],
[ 19, :MapNotify, Grp::MAP, 'Map' ], [ 19, :MapNotify, Grp::MAP, 'Map' ],
[ 20, :MapRequest, Grp::MAPREQ, 'MapRequest' ], [ 20, :MapRequest, Grp::MAPREQ, 'MapRequest' ],
[ 21, :ReparentNotify, Grp::REPARENT, 'Reparent' ], [ 21, :ReparentNotify, Grp::REPARENT, 'Reparent' ],
[ 22, :ConfigureNotify, Grp::CONFIG, 'Configure' ], [ 22, :ConfigureNotify, Grp::CONFIG, 'Configure' ],
[ 23, :ConfigureRequest, Grp::CONFIGREQ, 'ConfigureRequest' ], [ 23, :ConfigureRequest, Grp::CONFIGREQ, 'ConfigureRequest' ],
[ 24, :GravityNotify, Grp::GRAVITY, 'Gravity' ], [ 24, :GravityNotify, Grp::GRAVITY, 'Gravity' ],
[ 25, :ResizeRequest, Grp::RESIZEREQ, 'ResizeRequest' ], [ 25, :ResizeRequest, Grp::RESIZEREQ, 'ResizeRequest' ],
[ 26, :CirculateNotify, Grp::CIRC, 'Circulate' ], [ 26, :CirculateNotify, Grp::CIRC, 'Circulate' ],
[ 27, :CirculateRequest, 0, 'CirculateRequest' ], [ 27, :CirculateRequest, 0, 'CirculateRequest' ],
[ 28, :PropertyNotify, Grp::PROP, 'Property' ], [ 28, :PropertyNotify, Grp::PROP, 'Property' ],
[ 29, :SelectionClear, 0, ], [ 29, :SelectionClear, 0, ],
[ 30, :SelectionRequest, 0, ], [ 30, :SelectionRequest, 0, ],
[ 31, :SelectionNotify, 0, ], [ 31, :SelectionNotify, 0, ],
[ 32, :ColormapNotify, Grp::COLORMAP, 'Colormap' ], [ 32, :ColormapNotify, Grp::COLORMAP, 'Colormap' ],
[ 33, :ClientMessage, 0, ], [ 33, :ClientMessage, 0, ],
[ 34, :MappingNotify, 0, ], [ 34, :MappingNotify, 0, ],
[ 35, :VirtualEvent, Grp::VIRTUAL, ], [ 35, :VirtualEvent, Grp::VIRTUAL, ],
[ 36, :ActivateNotify, Grp::ACTIVATE, 'Activate' ], [ 36, :ActivateNotify, Grp::ACTIVATE, 'Activate' ],
[ 37, :DeactivateNotify, Grp::ACTIVATE, 'Deactivate' ], [ 37, :DeactivateNotify, Grp::ACTIVATE, 'Deactivate' ],
@ -153,12 +153,12 @@ module TkEvent
FIELD_FLAG = { FIELD_FLAG = {
# key => flag # key => flag
'above' => Grp::CONFIG, 'above' => Grp::CONFIG,
'borderwidth' => (Grp::CREATE|Grp::CONFIG), 'borderwidth' => (Grp::CREATE|Grp::CONFIG),
'button' => Grp::BUTTON, 'button' => Grp::BUTTON,
'count' => Grp::EXPOSE, 'count' => Grp::EXPOSE,
'data' => (Grp::VIRTUAL|Grp::STRING_DATA), 'data' => (Grp::VIRTUAL|Grp::STRING_DATA),
'delta' => Grp::MWHEEL, 'delta' => Grp::MWHEEL,
'detail' => (Grp::FOCUS|Grp::CROSSING), 'detail' => (Grp::FOCUS|Grp::CROSSING),
'focus' => Grp::CROSSING, 'focus' => Grp::CROSSING,
'height' => (Grp::EXPOSE|Grp::CONFIG), 'height' => (Grp::EXPOSE|Grp::CONFIG),
@ -191,23 +191,23 @@ module TkEvent
} }
FIELD_OPERATION = { FIELD_OPERATION = {
'root' => proc{|val| 'root' => proc{|val|
begin begin
Tk.tk_call_without_enc('winfo', 'pathname', val) Tk.tk_call_without_enc('winfo', 'pathname', val)
val val
rescue rescue
nil nil
end end
}, },
'subwindow' => proc{|val| 'subwindow' => proc{|val|
begin begin
Tk.tk_call_without_enc('winfo', 'pathname', val) Tk.tk_call_without_enc('winfo', 'pathname', val)
val val
rescue rescue
nil nil
end end
}, },
'window' => proc{|val| nil} 'window' => proc{|val| nil}
} }
@ -280,7 +280,7 @@ module TkEvent
Tk.event_generate(win, type_name, opts) Tk.event_generate(win, type_name, opts)
else else
# If type is KEY event, focus should be set to target widget. # If type is KEY event, focus should be set to target widget.
# If not set, original widget will get the same event. # If not set, original widget will get the same event.
# That will make infinite loop. # That will make infinite loop.
w = Tk.tk_call_without_enc('focus') w = Tk.tk_call_without_enc('focus')
begin begin
@ -296,58 +296,58 @@ module TkEvent
# [ <'%' subst-key char>, <proc type char>, <instance var (accessor) name>] # [ <'%' subst-key char>, <proc type char>, <instance var (accessor) name>]
KEY_TBL = [ KEY_TBL = [
[ ?#, ?n, :serial ], [ ?#, ?n, :serial ],
[ ?a, ?s, :above ], [ ?a, ?s, :above ],
[ ?b, ?n, :num ], [ ?b, ?n, :num ],
[ ?c, ?n, :count ], [ ?c, ?n, :count ],
[ ?d, ?s, :detail ], [ ?d, ?s, :detail ],
# ?e # ?e
[ ?f, ?b, :focus ], [ ?f, ?b, :focus ],
# ?g # ?g
[ ?h, ?n, :height ], [ ?h, ?n, :height ],
[ ?i, ?s, :win_hex ], [ ?i, ?s, :win_hex ],
# ?j # ?j
[ ?k, ?n, :keycode ], [ ?k, ?n, :keycode ],
# ?l # ?l
[ ?m, ?s, :mode ], [ ?m, ?s, :mode ],
# ?n # ?n
[ ?o, ?b, :override ], [ ?o, ?b, :override ],
[ ?p, ?s, :place ], [ ?p, ?s, :place ],
# ?q # ?q
# ?r # ?r
[ ?s, ?x, :state ], [ ?s, ?x, :state ],
[ ?t, ?n, :time ], [ ?t, ?n, :time ],
# ?u # ?u
[ ?v, ?n, :value_mask ], [ ?v, ?n, :value_mask ],
[ ?w, ?n, :width ], [ ?w, ?n, :width ],
[ ?x, ?n, :x ], [ ?x, ?n, :x ],
[ ?y, ?n, :y ], [ ?y, ?n, :y ],
# ?z # ?z
[ ?A, ?s, :char ], [ ?A, ?s, :char ],
[ ?B, ?n, :borderwidth ], [ ?B, ?n, :borderwidth ],
# ?C # ?C
[ ?D, ?n, :wheel_delta ], [ ?D, ?n, :wheel_delta ],
[ ?E, ?b, :send_event ], [ ?E, ?b, :send_event ],
# ?F # ?F
# ?G # ?G
# ?H # ?H
# ?I # ?I
# ?J # ?J
[ ?K, ?s, :keysym ], [ ?K, ?s, :keysym ],
# ?L # ?L
# ?M # ?M
[ ?N, ?n, :keysym_num ], [ ?N, ?n, :keysym_num ],
# ?O # ?O
[ ?P, ?s, :property ], [ ?P, ?s, :property ],
# ?Q # ?Q
[ ?R, ?s, :rootwin_id ], [ ?R, ?s, :rootwin_id ],
[ ?S, ?s, :subwindow ], [ ?S, ?s, :subwindow ],
[ ?T, ?n, :type ], [ ?T, ?n, :type ],
# ?U # ?U
# ?V # ?V
[ ?W, ?w, :widget ], [ ?W, ?w, :widget ],
[ ?X, ?n, :x_root ], [ ?X, ?n, :x_root ],
[ ?Y, ?n, :y_root ], [ ?Y, ?n, :y_root ],
# ?Z # ?Z
nil nil
] ]
@ -356,16 +356,16 @@ module TkEvent
# the subst-key string will be converted to a bytecode (128+idx). # the subst-key string will be converted to a bytecode (128+idx).
LONGKEY_TBL = [ LONGKEY_TBL = [
# for example, for %CTT and %CST subst-key on tkdnd-2.0 # for example, for %CTT and %CST subst-key on tkdnd-2.0
# ['CTT', ?l, :drop_target_type], # ['CTT', ?l, :drop_target_type],
# ['CST', ?l, :drop_source_type], # ['CST', ?l, :drop_source_type],
] ]
# [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>] # [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
PROC_TBL = [ PROC_TBL = [
[ ?n, TkComm.method(:num_or_str) ], [ ?n, TkComm.method(:num_or_str) ],
[ ?s, TkComm.method(:string) ], [ ?s, TkComm.method(:string) ],
[ ?b, TkComm.method(:bool) ], [ ?b, TkComm.method(:bool) ],
[ ?w, TkComm.method(:window) ], [ ?w, TkComm.method(:window) ],
[ ?x, proc{|val| [ ?x, proc{|val|
begin begin
@ -374,7 +374,7 @@ module TkEvent
val val
end end
} }
], ],
nil nil
] ]
@ -399,25 +399,25 @@ module TkEvent
# setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys # setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
# #
# _get_subst_key() and _get_all_subst_keys() generates key-string # _get_subst_key() and _get_all_subst_keys() generates key-string
# which describe how to convert callback arguments to ruby objects. # which describe how to convert callback arguments to ruby objects.
# When binding parameters are given, use _get_subst_key(). # When binding parameters are given, use _get_subst_key().
# But when no parameters are given, use _get_all_subst_keys() to # But when no parameters are given, use _get_all_subst_keys() to
# create a Event class object as a callback parameter. # create a Event class object as a callback parameter.
# #
# scan_args() is used when doing callback. It convert arguments # scan_args() is used when doing callback. It convert arguments
# ( which are Tcl strings ) to ruby objects based on the key string # ( which are Tcl strings ) to ruby objects based on the key string
# that is generated by _get_subst_key() or _get_all_subst_keys(). # 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 # _setup_subst_table(KEY_TBL, LONGKEY_TBL, PROC_TBL) # if use longname-keys
# #
# NOTE: The order of parameters which passed to callback procedure is # NOTE: The order of parameters which passed to callback procedure is
# <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ... # <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
# #
# If you need support extra arguments given by Tcl/Tk, # If you need support extra arguments given by Tcl/Tk,
# please override _get_extra_args_tbl # please override _get_extra_args_tbl
# #
#def self._get_extra_args_tbl #def self._get_extra_args_tbl
@ -436,15 +436,15 @@ module TkEvent
alias sendevent send_event alias sendevent send_event
=end =end
ALIAS_TBL = { ALIAS_TBL = {
:button => :num, :button => :num,
:data => :detail, :data => :detail,
:delta => :wheel_delta, :delta => :wheel_delta,
:root => :rootwin_id, :root => :rootwin_id,
:rootx => :x_root, :rootx => :x_root,
:root_x => :x_root, :root_x => :x_root,
:rooty => :y_root, :rooty => :y_root,
:root_y => :y_root, :root_y => :y_root,
:sendevent => :send_event, :sendevent => :send_event,
:window => :widget :window => :widget
} }
@ -482,6 +482,26 @@ module TkEvent
end end
}) })
end end
elsif cmd.respond_to?(:arity) && cmd.arity == 0 # args.size == 0
args = ''
if cmd.kind_of?(String)
id = cmd
elsif cmd.kind_of?(TkCallbackEntry)
id = install_cmd(cmd)
else
id = install_cmd(proc{
begin
TkUtil.eval_cmd(cmd)
rescue Exception=>e
if TkCore::INTERP.kind_of?(TclTkIp)
fail e
else
# MultiTkIp
fail Exception, "#{e.class}: #{e.message.dup}"
end
end
})
end
else else
keys, args = klass._get_all_subst_keys keys, args = klass._get_all_subst_keys

View file

@ -11,7 +11,7 @@ class TkFont
TkCommandNames = ['font'.freeze].freeze TkCommandNames = ['font'.freeze].freeze
(Tk_FontID = ["@font".freeze, "00000".taint]).instance_eval{ (Tk_FontID = ["@font".freeze, TkUtil.untrust("00000")]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -20,7 +20,7 @@ class TkFont
Tk_FontNameTBL = TkCore::INTERP.create_table Tk_FontNameTBL = TkCore::INTERP.create_table
Tk_FontUseTBL = TkCore::INTERP.create_table Tk_FontUseTBL = TkCore::INTERP.create_table
TkCore::INTERP.init_ip_env{ TkCore::INTERP.init_ip_env{
Tk_FontNameTBL.mutex.synchronize{ Tk_FontNameTBL.clear } Tk_FontNameTBL.mutex.synchronize{ Tk_FontNameTBL.clear }
Tk_FontUseTBL.mutex.synchronize{ Tk_FontUseTBL.clear } Tk_FontUseTBL.mutex.synchronize{ Tk_FontUseTBL.clear }
} }
@ -66,8 +66,8 @@ class TkFont
knj = 'defaultgui' knj = 'defaultgui'
when /Mincho:Helvetica-Bold-12/ when /Mincho:Helvetica-Bold-12/
# Tcl/Tk-JP for UNIX/X # Tcl/Tk-JP for UNIX/X
ltn, knj = tk_split_simplelist(tk_call('font', 'configure', ltn, knj = tk_split_simplelist(tk_call('font', 'configure',
'Mincho:Helvetica-Bold-12', 'Mincho:Helvetica-Bold-12',
'-compound')) '-compound'))
else else
# unknown Tcl/Tk-JP # unknown Tcl/Tk-JP
@ -75,7 +75,7 @@ class TkFont
platform = Tk::PLATFORM['platform'] platform = Tk::PLATFORM['platform']
case platform case platform
when 'unix' when 'unix'
ltn = {'family'=>'Helvetica'.freeze, ltn = {'family'=>'Helvetica'.freeze,
'size'=>-12, 'weight'=>'bold'.freeze} 'size'=>-12, 'weight'=>'bold'.freeze}
#knj = 'k14' #knj = 'k14'
#knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0' #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0'
@ -102,7 +102,7 @@ class TkFont
platform = Tk::PLATFORM['platform'] platform = Tk::PLATFORM['platform']
case platform case platform
when 'unix' when 'unix'
ltn = {'family'=>'Helvetica'.freeze, ltn = {'family'=>'Helvetica'.freeze,
'size'=>-12, 'weight'=>'bold'.freeze} 'size'=>-12, 'weight'=>'bold'.freeze}
when 'windows' when 'windows'
ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
@ -211,7 +211,7 @@ class TkFont
end end
end end
def TkFont.actual_hash(fnt, option=nil) def TkFont.actual_hash(fnt, option=nil)
Hash[TkFont.actual_hash(fnt, option)] Hash[TkFont.actual(fnt, option)]
end end
def TkFont.actual_displayof(fnt, win, option=nil) def TkFont.actual_displayof(fnt, win, option=nil)
@ -224,7 +224,7 @@ class TkFont
end end
end end
def TkFont.actual_hash_displayof(fnt, option=nil) def TkFont.actual_hash_displayof(fnt, option=nil)
Hash[TkFont.actual_hash_displayof(fnt, option)] Hash[TkFont.actual_displayof(fnt, option)]
end end
def TkFont.configure(fnt, slot, value=None) def TkFont.configure(fnt, slot, value=None)
@ -294,7 +294,7 @@ class TkFont
end end
h = Hash[TkFont.metrics(fnt)] h = Hash[TkFont.metrics(fnt)]
h.keys.each{|k| h.keys.each{|k|
case TkFont::MetricsType[k.to_s] case TkFont::MetricsType[k.to_s]
when ?n when ?n
h[k] = TkComm::num_or_str(h[k]) h[k] = TkComm::num_or_str(h[k])
@ -331,7 +331,7 @@ class TkFont
end end
h = Hash[TkFont.metrics_displayof(fnt, win, option)] h = Hash[TkFont.metrics_displayof(fnt, win, option)]
h.keys.each{|k| h.keys.each{|k|
case TkFont::MetricsType[k.to_s] case TkFont::MetricsType[k.to_s]
when ?n when ?n
h[k] = TkComm::num_or_str(h[k]) h[k] = TkComm::num_or_str(h[k])
@ -459,7 +459,7 @@ class TkFont
else else
begin begin
compound = tk_split_simplelist( compound = tk_split_simplelist(
Hash[*tk_split_simplelist(tk_call('font', 'configure', Hash[*tk_split_simplelist(tk_call('font', 'configure',
fnt))].collect{|k,v| fnt))].collect{|k,v|
[k[1..-1], v] [k[1..-1], v]
}.assoc('compound')[1]) }.assoc('compound')[1])
@ -473,7 +473,7 @@ class TkFont
TkFont.new(fnt).call_font_configure([path, key], *args) TkFont.new(fnt).call_font_configure([path, key], *args)
end end
else else
TkFont.new(compound[0], TkFont.new(compound[0],
compound[1]).call_font_configure([path, key], *args) compound[1]).call_font_configure([path, key], *args)
end end
end end
@ -570,7 +570,7 @@ class TkFont
if JAPANIZED_TK if JAPANIZED_TK
tk_call('font', 'create', @latinfont, '-charset', 'iso8859') tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983') tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
tk_call('font', 'create', @compoundfont, tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont]) '-compound', [@latinfont, @kanjifont])
else else
tk_call('font', 'create', @latinfont) tk_call('font', 'create', @latinfont)
@ -614,7 +614,7 @@ class TkFont
# compound font check # compound font check
if Tk::TK_VERSION == '8.0' && JAPANIZED_TK if Tk::TK_VERSION == '8.0' && JAPANIZED_TK
begin begin
compound = tk_split_simplelist(tk_call('font', 'configure', compound = tk_split_simplelist(tk_call('font', 'configure',
ltn, '-compound')) ltn, '-compound'))
if knj == nil if knj == nil
if compound != [] if compound != []
@ -624,7 +624,7 @@ class TkFont
if compound != [] if compound != []
ltn = compound[0] ltn = compound[0]
end end
compound = tk_split_simplelist(tk_call('font', 'configure', compound = tk_split_simplelist(tk_call('font', 'configure',
knj, '-compound')) knj, '-compound'))
if compound != [] if compound != []
knj = compound[1] knj = compound[1]
@ -639,7 +639,7 @@ class TkFont
if Tk::TK_VERSION =~ /^4..*/ if Tk::TK_VERSION =~ /^4..*/
knj = DEFAULT_KANJI_FONT_NAME knj = DEFAULT_KANJI_FONT_NAME
else else
knj = ltn knj = ltn
end end
end end
else else
@ -806,7 +806,7 @@ class TkFont
if font[:charset] || font['charset'] if font[:charset] || font['charset']
tk_call('font', 'create', @latinfont, *hash_kv(font)) tk_call('font', 'create', @latinfont, *hash_kv(font))
else else
tk_call('font', 'create', @latinfont, tk_call('font', 'create', @latinfont,
'-charset', 'iso8859', *hash_kv(font)) '-charset', 'iso8859', *hash_kv(font))
end end
elsif font.kind_of? Array elsif font.kind_of? Array
@ -815,7 +815,7 @@ class TkFont
elsif font.kind_of? TkFont elsif font.kind_of? TkFont
tk_call('font', 'create', @latinfont, '-copy', font.latin_font) tk_call('font', 'create', @latinfont, '-copy', font.latin_font)
elsif font elsif font
tk_call('font', 'create', @latinfont, '-copy', font, tk_call('font', 'create', @latinfont, '-copy', font,
'-charset', 'iso8859') '-charset', 'iso8859')
else else
tk_call('font', 'create', @latinfont, '-charset', 'iso8859') tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
@ -851,7 +851,7 @@ class TkFont
if font[:charset] || font['charset'] if font[:charset] || font['charset']
tk_call('font', 'create', @kanjifont, *hash_kv(font)) tk_call('font', 'create', @kanjifont, *hash_kv(font))
else else
tk_call('font', 'create', @kanjifont, tk_call('font', 'create', @kanjifont,
'-charset', 'jisx0208.1983', *hash_kv(font)) '-charset', 'jisx0208.1983', *hash_kv(font))
end end
elsif font.kind_of? Array elsif font.kind_of? Array
@ -860,7 +860,7 @@ class TkFont
elsif font.kind_of? TkFont elsif font.kind_of? TkFont
tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font_id) tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font_id)
elsif font elsif font
tk_call('font', 'create', @kanjifont, '-copy', font, tk_call('font', 'create', @kanjifont, '-copy', font,
'-charset', 'jisx0208.1983') '-charset', 'jisx0208.1983')
else else
tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983') tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
@ -922,7 +922,7 @@ class TkFont
@fontslot = {'font'=>@compoundfont} @fontslot = {'font'=>@compoundfont}
# @fontslot['font'] = @compoundfont # @fontslot['font'] = @compoundfont
begin begin
tk_call('font', 'create', @compoundfont, tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys)) '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
rescue RuntimeError => e rescue RuntimeError => e
if ltn == knj if ltn == knj
@ -930,7 +930,7 @@ class TkFont
tk_call('font', 'delete', @latinfont) tk_call('font', 'delete', @latinfont)
create_latinfont(DEFAULT_LATIN_FONT_NAME) create_latinfont(DEFAULT_LATIN_FONT_NAME)
opts = [] opts = []
Hash[*(tk_split_simplelist(tk_call('font', 'configure', Hash[*(tk_split_simplelist(tk_call('font', 'configure',
@kanjifont)))].each{|k,v| @kanjifont)))].each{|k,v|
case k case k
when '-size', '-weight', '-slant', '-underline', '-overstrike' when '-size', '-weight', '-slant', '-underline', '-overstrike'
@ -938,14 +938,14 @@ class TkFont
end end
} }
tk_call('font', 'configure', @latinfont, *opts) tk_call('font', 'configure', @latinfont, *opts)
tk_call('font', 'create', @compoundfont, tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys)) '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
elsif e.message =~ /ascii font .* specified/ elsif e.message =~ /ascii font .* specified/
tk_call('font', 'delete', @kanjifont) tk_call('font', 'delete', @kanjifont)
create_kanjifont(DEFAULT_KANJI_FONT_NAME) create_kanjifont(DEFAULT_KANJI_FONT_NAME)
opts = [] opts = []
Hash[*(tk_split_simplelist(tk_call('font', 'configure', Hash[*(tk_split_simplelist(tk_call('font', 'configure',
@latinfont)))].each{|k,v| @latinfont)))].each{|k,v|
case k case k
when '-size', '-weight', '-slant', '-underline', '-overstrike' when '-size', '-weight', '-slant', '-underline', '-overstrike'
@ -953,7 +953,7 @@ class TkFont
end end
} }
tk_call('font', 'configure', @kanjifont, *opts) tk_call('font', 'configure', @kanjifont, *opts)
tk_call('font', 'create', @compoundfont, tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys)) '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
else else
@ -1392,7 +1392,7 @@ class TkFont
end end
h = Hash[metrics(option)] h = Hash[metrics(option)]
h.keys.each{|k| h.keys.each{|k|
case TkFont::MetricsType[k.to_s] case TkFont::MetricsType[k.to_s]
when ?n when ?n
h[k] = TkComm::num_or_str(h[k]) h[k] = TkComm::num_or_str(h[k])
@ -1424,7 +1424,7 @@ class TkFont
end end
h = Hash[metrics_displayof(win, option)] h = Hash[metrics_displayof(win, option)]
h.keys.each{|k| h.keys.each{|k|
case TkFont::MetricsType[k.to_s] case TkFont::MetricsType[k.to_s]
when ?n when ?n
h[k] = TkComm::num_or_str(h[k]) h[k] = TkComm::num_or_str(h[k])
@ -1459,7 +1459,7 @@ class TkFont
end end
h = Hash[latin_metrics(option)] h = Hash[latin_metrics(option)]
h.keys.each{|k| h.keys.each{|k|
case TkFont::MetricsType[k.to_s] case TkFont::MetricsType[k.to_s]
when ?n when ?n
h[k] = TkComm::num_or_str(h[k]) h[k] = TkComm::num_or_str(h[k])
@ -1495,7 +1495,7 @@ class TkFont
end end
h = Hash[latin_metrics_displayof(win, option)] h = Hash[latin_metrics_displayof(win, option)]
h.keys.each{|k| h.keys.each{|k|
case TkFont::MetricsType[k.to_s] case TkFont::MetricsType[k.to_s]
when ?n when ?n
h[k] = TkComm::num_or_str(h[k]) h[k] = TkComm::num_or_str(h[k])
@ -1532,7 +1532,7 @@ class TkFont
end end
h = Hash[kanji_metrics(option)] h = Hash[kanji_metrics(option)]
h.keys.each{|k| h.keys.each{|k|
case TkFont::MetricsType[k.to_s] case TkFont::MetricsType[k.to_s]
when ?n when ?n
h[k] = TkComm::num_or_str(h[k]) h[k] = TkComm::num_or_str(h[k])
@ -1570,7 +1570,7 @@ class TkFont
end end
h = Hash[kanji_metrics_displayof(win, option)] h = Hash[kanji_metrics_displayof(win, option)]
h.keys.each{|k| h.keys.each{|k|
case TkFont::MetricsType[k.to_s] case TkFont::MetricsType[k.to_s]
when ?n when ?n
h[k] = TkComm::num_or_str(h[k]) h[k] = TkComm::num_or_str(h[k])
@ -1586,7 +1586,7 @@ class TkFont
def reset_pointadjust def reset_pointadjust
begin begin
if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
configure('pointadjust' => latin_actual.assoc('size')[1].to_f / configure('pointadjust' => latin_actual.assoc('size')[1].to_f /
kanji_actual.assoc('size')[1].to_f ) kanji_actual.assoc('size')[1].to_f )
end end
rescue rescue
@ -1659,8 +1659,8 @@ module TkFont::CoreMethods
'' ''
end end
else else
[['family',''], ['size',0], ['weight',''], ['slant',''], [['family',''], ['size',0], ['weight',''], ['slant',''],
['underline',false], ['overstrike',false], ['charset',''], ['underline',false], ['overstrike',false], ['charset',''],
['pointadjust',0]] ['pointadjust',0]]
end end
end end
@ -1672,7 +1672,7 @@ module TkFont::CoreMethods
"" ""
elsif option elsif option
if win if win
val = tk_call('font', 'actual', font, val = tk_call('font', 'actual', font,
"-displayof", win, "-#{option}") "-displayof", win, "-#{option}")
else else
val = tk_call('font', 'actual', font, "-#{option}") val = tk_call('font', 'actual', font, "-#{option}")
@ -1687,7 +1687,7 @@ module TkFont::CoreMethods
end end
else else
l = tk_split_simplelist(if win l = tk_split_simplelist(if win
tk_call('font', 'actual', font, tk_call('font', 'actual', font,
"-displayof", win) "-displayof", win)
else else
tk_call('font', 'actual', font) tk_call('font', 'actual', font)
@ -1733,8 +1733,8 @@ module TkFont::CoreMethods
'' ''
end end
else else
[['family',''], ['size',0], ['weight',''], ['slant',''], [['family',''], ['size',0], ['weight',''], ['slant',''],
['underline',false], ['overstrike',false], ['charset',''], ['underline',false], ['overstrike',false], ['charset',''],
['pointadjust',1.0]] ['pointadjust',1.0]]
end end
else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
@ -1753,8 +1753,8 @@ module TkFont::CoreMethods
'' ''
end end
else else
{'family'=>'', 'size'=>0, 'weight'=>'', 'slant'=>'', {'family'=>'', 'size'=>0, 'weight'=>'', 'slant'=>'',
'underline'=>false, 'overstrike'=>false, 'underline'=>false, 'overstrike'=>false,
'charset'=>false, 'pointadjust'=>1.0} 'charset'=>false, 'pointadjust'=>1.0}
end end
end end
@ -1775,20 +1775,20 @@ module TkFont::CoreMethods
configure_core_tk8x(font, 'family', slot.delete('family')) configure_core_tk8x(font, 'family', slot.delete('family'))
end end
if ((slot.key?('size') || slot.key?(:size)) && if ((slot.key?('size') || slot.key?(:size)) &&
padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust)) padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust))
tk_call('font', 'configure', font, tk_call('font', 'configure', font,
'-pointadjust', padjust, *hash_kv(slot)) '-pointadjust', padjust, *hash_kv(slot))
else else
tk_call('font', 'configure', font, *hash_kv(slot)) tk_call('font', 'configure', font, *hash_kv(slot))
end end
elsif (slot == 'size' || slot == :size) && padjust != nil elsif (slot == 'size' || slot == :size) && padjust != nil
tk_call('font', 'configure', font, tk_call('font', 'configure', font,
"-#{slot}", value, '-pointadjust', padjust) "-#{slot}", value, '-pointadjust', padjust)
elsif JAPANIZED_TK && (slot == 'family' || slot == :family) elsif JAPANIZED_TK && (slot == 'family' || slot == :family)
# coumpund font? # coumpund font?
begin begin
compound = tk_split_simplelist(tk_call('font', 'configure', compound = tk_split_simplelist(tk_call('font', 'configure',
font, '-compound')) font, '-compound'))
rescue rescue
tk_call('font', 'configure', font, '-family', value) tk_call('font', 'configure', font, '-family', value)
@ -1819,7 +1819,7 @@ module TkFont::CoreMethods
ensure ensure
tk_call('font', 'delete', kfnt) if kfnt != '' tk_call('font', 'delete', kfnt) if kfnt != ''
end end
else else
tk_call('font', 'configure', font, "-#{slot}", value) tk_call('font', 'configure', font, "-#{slot}", value)
end end
@ -2044,7 +2044,7 @@ module TkFont::CoreMethods
keys = self.configinfo keys = self.configinfo
tk_call('font', 'delete', @compoundfont) tk_call('font', 'delete', @compoundfont)
begin begin
tk_call('font', 'create', @compoundfont, tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys)) '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
=begin =begin
latinkeys = {} latinkeys = {}
@ -2061,7 +2061,7 @@ module TkFont::CoreMethods
tk_call('font', 'delete', @latinfont) tk_call('font', 'delete', @latinfont)
if fnt_bup && fnt_bup != '' if fnt_bup && fnt_bup != ''
tk_call('font', 'create', @latinfont, '-copy', fnt_bup) tk_call('font', 'create', @latinfont, '-copy', fnt_bup)
tk_call('font', 'create', @compoundfont, tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys)) '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
tk_call('font', 'delete', fnt_bup) tk_call('font', 'delete', fnt_bup)
else else
@ -2082,7 +2082,7 @@ module TkFont::CoreMethods
# not exist? (deleted?) -> create font # not exist? (deleted?) -> create font
tk_call('font', 'create', @compoundfont, *hash_kv(latinkeys)) tk_call('font', 'create', @compoundfont, *hash_kv(latinkeys))
end end
end end
self self
end end
@ -2112,20 +2112,20 @@ module TkFont::CoreMethods
keys = self.configinfo keys = self.configinfo
tk_call('font', 'delete', @compoundfont) tk_call('font', 'delete', @compoundfont)
begin begin
tk_call('font', 'create', @compoundfont, tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys)) '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
rescue RuntimeError => e rescue RuntimeError => e
tk_call('font', 'delete', @kanjifont) tk_call('font', 'delete', @kanjifont)
if fnt_bup && fnt_bup != '' if fnt_bup && fnt_bup != ''
tk_call('font', 'create', @kanjifont, '-copy', fnt_bup) tk_call('font', 'create', @kanjifont, '-copy', fnt_bup)
tk_call('font', 'create', @compoundfont, tk_call('font', 'create', @compoundfont,
'-compound', [@latinfont, @kanjifont], *hash_kv(keys)) '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
tk_call('font', 'delete', fnt_bup) tk_call('font', 'delete', fnt_bup)
else else
fail e fail e
end end
end end
end end
self self
end end
@ -2137,7 +2137,7 @@ module TkFont::CoreMethods
font = '{}' if font == '' font = '{}' if font == ''
if win if win
number(tk_call('font', 'measure', font, number(tk_call('font', 'measure', font,
'-displayof', win, text)) '-displayof', win, text))
else else
number(tk_call('font', 'measure', font, text)) number(tk_call('font', 'measure', font, text))
@ -2158,7 +2158,7 @@ module TkFont::CoreMethods
if option if option
if win if win
number(tk_call('font', 'metrics', font, number(tk_call('font', 'metrics', font,
"-displayof", win, "-#{option}")) "-displayof", win, "-#{option}"))
else else
number(tk_call('font', 'metrics', font, "-#{option}")) number(tk_call('font', 'metrics', font, "-#{option}"))
@ -2199,7 +2199,7 @@ module TkFont::CoreMethods
alias measure_core measure_core_tk4x alias measure_core measure_core_tk4x
alias metrics_core metrics_core_tk4x alias metrics_core metrics_core_tk4x
when /^8\.[0-5]/ when /^8\.[0-9]/
alias actual_core actual_core_tk8x alias actual_core actual_core_tk8x
alias configure_core configure_core_tk8x alias configure_core configure_core_tk8x
alias configinfo_core configinfo_core_tk8x alias configinfo_core configinfo_core_tk8x
@ -2304,12 +2304,12 @@ end
####################################### #######################################
# define system font names # define system font names
####################################### #######################################
if Tk::TCL_MAJOR_VERSION > 8 || if Tk::TCL_MAJOR_VERSION > 8 ||
(Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5) (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
# add standard fonts of Tcl/Tk 8.5+ # add standard fonts of Tcl/Tk 8.5+
TkFont::SYSTEM_FONT_NAMES.add [ TkFont::SYSTEM_FONT_NAMES.add [
'TkDefaultFont', 'TkTextFont', 'TkFixedFont', 'TkMenuFont', 'TkDefaultFont', 'TkTextFont', 'TkFixedFont', 'TkMenuFont',
'TkHeadingFont', 'TkCaptionFont', 'TkSmallCaptionFont', 'TkHeadingFont', 'TkCaptionFont', 'TkSmallCaptionFont',
'TkIconFont', 'TkTooltipFont' 'TkIconFont', 'TkTooltipFont'
] ]
end end
@ -2323,22 +2323,29 @@ TkFont::SYSTEM_FONT_NAMES.add [
# -- macintosh, macosx # -- macintosh, macosx
TkFont::SYSTEM_FONT_NAMES.add ['system', 'application'] TkFont::SYSTEM_FONT_NAMES.add ['system', 'application']
if Tk::TCL_MAJOR_VERSION > 8 || if Tk::TCL_MAJOR_VERSION > 8 ||
(Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5) (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
TkFont::SYSTEM_FONT_NAMES.add ['menu'] TkFont::SYSTEM_FONT_NAMES.add ['menu']
end end
# -- macosx (Aqua theme) # -- macosx (Aqua theme)
if Tk::TCL_MAJOR_VERSION > 8 || if Tk::TCL_MAJOR_VERSION > 8 ||
(Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5) (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
TkFont::SYSTEM_FONT_NAMES.add [ TkFont::SYSTEM_FONT_NAMES.add [
'systemSystemFont', 'systemEmphasizedSystemFont', 'systemSystemFont', 'systemEmphasizedSystemFont',
'systemSmallSystemFont', 'systemSmallEmphasizedSystemFont', 'systemSmallSystemFont', 'systemSmallEmphasizedSystemFont',
'systemApplicationFont', 'systemLabelFont', 'systemViewsFont', 'systemApplicationFont', 'systemLabelFont', 'systemViewsFont',
'systemMenuTitleFont', 'systemMenuItemFont', 'systemMenuItemMarkFont', 'systemMenuTitleFont', 'systemMenuItemFont', 'systemMenuItemMarkFont',
'systemMenuItemCmdKeyFont', 'systemWindowTitleFont', 'systemMenuItemCmdKeyFont', 'systemWindowTitleFont',
'systemPushButtonFont', 'systemUtilityWindowTitleFont', 'systemPushButtonFont', 'systemUtilityWindowTitleFont',
'systemAlertHeaderFont', 'systemToolbarFont', 'systemMiniSystemFont', 'systemAlertHeaderFont', 'systemToolbarFont', 'systemMiniSystemFont',
'systemDetailSystemFont', 'systemDetailEmphasizedSystemFont' 'systemDetailSystemFont', 'systemDetailEmphasizedSystemFont'
] ]
end end
#######################################
# autoload
#######################################
class TkFont
autoload :Chooser, 'tk/fontchooser'
end

View file

@ -0,0 +1,166 @@
#
# tk/fontchooser.rb -- "tk fontchooser" support (Tcl/Tk8.6 or later)
#
require 'tk'
require 'tk/font'
module TkFont::Chooser
extend TkCore
end
class << TkFont::Chooser
def method_missing(id, *args)
name = id.id2name
case args.length
when 1
if name[-1] == ?=
configure name[0..-2], args[0]
args[0]
else
configure name, args[0]
self
end
when 0
begin
cget(name)
rescue
super(id, *args)
end
else
super(id, *args)
end
end
def __conviginfo_value(key, val)
case key
when 'parent'
window(val)
when 'title'
val
when 'font'
if (lst = tk_split_simplelist(val)).size == 1
lst[0]
else
lst.map{|elem| num_or_str(elem)}
end
when 'command'
tk_tcl2ruby(val)
when 'visible'
bool(val)
else # unkown
val
end
end
private :__conviginfo_value
def configinfo(option=nil)
if !option && TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
lst = tk_split_simplelist(tk_call('tk', 'fontchooser', 'configure'))
ret = []
TkComm.slice_ary(lst, 2){|k, v|
k = k[1..-1]
ret << [k, __conviginfo_value(k, v)]
}
ret
else
current_configinfo(option)
end
end
def current_configinfo(option=nil)
if option
opt = option.to_s
fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.empty?
__conviginfo_value(option.to_s, tk_call('tk','fontchooser',
'configure',"-#{opt}"))
else
lst = tk_split_simplelist(tk_call('tk', 'fontchooser', 'configure'))
ret = {}
TkComm.slice_ary(lst, 2){|k, v|
k = k[1..-1]
ret[k] = __conviginfo_value(k, v)
}
ret
end
end
def configure(option, value=None)
if option.kind_of? Hash
tk_call('tk', 'fontchooser', 'configure',
*hash_kv(_symbolkey2str(option)))
else
opt = option.to_s
fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.empty?
tk_call('tk', 'fontchooser', 'configure', "-#{opt}", value)
end
self
end
def configure_cmd(slot, value)
configure(slot, install_cmd(value))
end
def command(cmd=nil, &b)
if cmd
configure_cmd('command', cmd)
elsif b
configure_cmd('command', Proc.new(&b))
else
cget('command')
end
end
def cget(slot)
configinfo slot
end
def [](slot)
cget slot
end
def []=(slot, val)
configure slot, val
val
end
def show
tk_call('tk', 'fontchooser', 'show')
self
end
def hide
tk_call('tk', 'fontchooser', 'hide')
self
end
def toggle
cget(:visible) ? hide: show
self
end
def set_for(target, title="Font")
if target.kind_of? TkFont
configs = {
:font=>target.actual_hash,
:command=>proc{|fnt, *args|
target.configure(TkFont.actual_hash(fnt))
}
}
else
configs = {
:font=>target.cget_tkstring(:font),
:command=>proc{|fnt, *args|
target.font = TkFont.actual_hash_displayof(fnt, target)
}
}
end
configs[:title] = title if title
configure(configs)
target
end
def unset
configure(:command, nil)
end
end

View file

@ -6,7 +6,7 @@ require 'tk'
class Tk::Frame<TkWindow class Tk::Frame<TkWindow
TkCommandNames = ['frame'.freeze].freeze TkCommandNames = ['frame'.freeze].freeze
WidgetClassName = 'Frame'.freeze WidgetClassName = 'Frame'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
################# old version ################# old version
# def initialize(parent=nil, keys=nil) # def initialize(parent=nil, keys=nil)
@ -128,4 +128,5 @@ class Tk::Frame<TkWindow
end end
#TkFrame = Tk::Frame unless Object.const_defined? :TkFrame #TkFrame = Tk::Frame unless Object.const_defined? :TkFrame
Tk.__set_toplevel_aliases__(:Tk, Tk::Frame, :TkFrame) #Tk.__set_toplevel_aliases__(:Tk, Tk::Frame, :TkFrame)
Tk.__set_loaded_toplevel_aliases__('tk/frame.rb', :Tk, Tk::Frame, :TkFrame)

View file

@ -101,7 +101,7 @@ module TkGrid
def columnconfigure(master, index, args) def columnconfigure(master, index, args)
# master = master.epath if master.kind_of?(TkObject) # master = master.epath if master.kind_of?(TkObject)
master = _epath(master) master = _epath(master)
tk_call_without_enc("grid", 'columnconfigure', tk_call_without_enc("grid", 'columnconfigure',
master, index, *hash_kv(args)) master, index, *hash_kv(args))
end end
alias column columnconfigure alias column columnconfigure
@ -119,15 +119,15 @@ module TkGrid
if slot if slot
case slot case slot
when 'uniform', :uniform when 'uniform', :uniform
tk_call_without_enc('grid', 'columnconfigure', tk_call_without_enc('grid', 'columnconfigure',
master, index, "-#{slot}") master, index, "-#{slot}")
else else
num_or_str(tk_call_without_enc('grid', 'columnconfigure', num_or_str(tk_call_without_enc('grid', 'columnconfigure',
master, index, "-#{slot}")) master, index, "-#{slot}"))
end end
else else
#ilist = list(tk_call_without_enc('grid','columnconfigure',master,index)) #ilist = list(tk_call_without_enc('grid','columnconfigure',master,index))
ilist = simplelist(tk_call_without_enc('grid', 'columnconfigure', ilist = simplelist(tk_call_without_enc('grid', 'columnconfigure',
master, index)) master, index))
info = {} info = {}
while key = ilist.shift while key = ilist.shift
@ -148,15 +148,15 @@ module TkGrid
if slot if slot
case slot case slot
when 'uniform', :uniform when 'uniform', :uniform
tk_call_without_enc('grid', 'rowconfigure', tk_call_without_enc('grid', 'rowconfigure',
master, index, "-#{slot}") master, index, "-#{slot}")
else else
num_or_str(tk_call_without_enc('grid', 'rowconfigure', num_or_str(tk_call_without_enc('grid', 'rowconfigure',
master, index, "-#{slot}")) master, index, "-#{slot}"))
end end
else else
#ilist = list(tk_call_without_enc('grid', 'rowconfigure', master, index)) #ilist = list(tk_call_without_enc('grid', 'rowconfigure', master, index))
ilist = simplelist(tk_call_without_enc('grid', 'rowconfigure', ilist = simplelist(tk_call_without_enc('grid', 'rowconfigure',
master, index)) master, index))
info = {} info = {}
while key = ilist.shift while key = ilist.shift

View file

@ -11,7 +11,7 @@ class TkImage<TkObject
Tk_IMGTBL = TkCore::INTERP.create_table Tk_IMGTBL = TkCore::INTERP.create_table
(Tk_Image_ID = ['i'.freeze, '00000'.taint]).instance_eval{ (Tk_Image_ID = ['i'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -45,7 +45,7 @@ class TkImage<TkObject
keys.delete('imagename') keys.delete('imagename')
keys.delete('without_creating') keys.delete('without_creating')
obj.instance_eval{ obj.instance_eval{
tk_call_without_enc('image', 'create', tk_call_without_enc('image', 'create',
@type, @path, *hash_kv(keys, true)) @type, @path, *hash_kv(keys, true))
} }
end end
@ -78,7 +78,7 @@ class TkImage<TkObject
} }
end end
unless without_creating unless without_creating
tk_call_without_enc('image', 'create', tk_call_without_enc('image', 'create',
@type, @path, *hash_kv(keys, true)) @type, @path, *hash_kv(keys, true))
end end
end end

View file

@ -31,10 +31,10 @@ module TkItemConfigOptkeys
def __item_strval_optkeys(id) def __item_strval_optkeys(id)
# maybe need to override # maybe need to override
[ [
'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile', 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile',
'activebackground', 'activeforeground', 'background', 'activebackground', 'activeforeground', 'background',
'disabledforeground', 'disabledbackground', 'foreground', 'disabledforeground', 'disabledbackground', 'foreground',
'highlightbackground', 'highlightcolor', 'insertbackground', 'highlightbackground', 'highlightcolor', 'insertbackground',
'selectbackground', 'selectforeground', 'troughcolor' 'selectbackground', 'selectforeground', 'troughcolor'
] ]
end end
@ -148,7 +148,7 @@ module TkItemConfigMethod
def __item_configinfo_struct(id) def __item_configinfo_struct(id)
# maybe need to override # maybe need to override
{:key=>0, :alias=>1, :db_name=>1, :db_class=>2, {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
:default_value=>3, :current_value=>4} :default_value=>3, :current_value=>4}
end end
private :__item_configinfo_struct private :__item_configinfo_struct
@ -162,6 +162,13 @@ module TkItemConfigMethod
################################################ ################################################
def itemcget_tkstring(tagOrId, option)
opt = option.to_s
fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.length == 0
tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{opt}"))
end
def __itemcget_core(tagOrId, option) def __itemcget_core(tagOrId, option)
orig_opt = option orig_opt = option
option = option.to_s option = option.to_s
@ -402,7 +409,7 @@ module TkItemConfigMethod
fontkey = $2 fontkey = $2
# conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}")))) # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}")), false, true) conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}")), false, true)
conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
|| conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
@ -414,7 +421,7 @@ module TkItemConfigMethod
elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
end end
conf conf
@ -464,7 +471,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
@ -472,7 +479,7 @@ module TkItemConfigMethod
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
@ -485,11 +492,11 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -500,7 +507,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
@ -508,7 +515,7 @@ module TkItemConfigMethod
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
@ -521,11 +528,11 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -536,12 +543,12 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -574,13 +581,13 @@ module TkItemConfigMethod
# conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))) # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
conf = tk_split_list(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), 0, false, true) conf = tk_split_list(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), 0, false, true)
end end
conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
end end
@ -591,7 +598,7 @@ module TkItemConfigMethod
# conf = tk_split_simplelist(conflist) # conf = tk_split_simplelist(conflist)
ret = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false).collect{|conflist| ret = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false).collect{|conflist|
conf = tk_split_simplelist(conflist, false, true) conf = tk_split_simplelist(conflist, false, true)
conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
optkey = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] optkey = conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
@ -627,7 +634,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
@ -635,7 +642,7 @@ module TkItemConfigMethod
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
@ -645,11 +652,11 @@ module TkItemConfigMethod
when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -657,7 +664,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
@ -665,7 +672,7 @@ module TkItemConfigMethod
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
@ -675,11 +682,11 @@ module TkItemConfigMethod
when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -687,12 +694,12 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -719,20 +726,20 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
else else
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
end end
if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
else else
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
end end
end end
@ -740,7 +747,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- ) && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
end end
@ -774,7 +781,7 @@ module TkItemConfigMethod
fontkey = $2 fontkey = $2
# conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}")))) # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}")), false, true) conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}")), false, true)
conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
@ -788,7 +795,7 @@ module TkItemConfigMethod
elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
end end
{ conf[0] => conf[1] } { conf[0] => conf[1] }
@ -841,7 +848,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
@ -849,7 +856,7 @@ module TkItemConfigMethod
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
@ -862,11 +869,11 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -877,7 +884,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
@ -885,7 +892,7 @@ module TkItemConfigMethod
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
@ -898,11 +905,11 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -913,12 +920,12 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -951,13 +958,13 @@ module TkItemConfigMethod
# conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))) # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
conf = tk_split_list(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), 0, false, true) conf = tk_split_list(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), 0, false, true)
end end
conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
end end
{ conf[0] => conf[1] } { conf[0] => conf[1] }
@ -971,7 +978,7 @@ module TkItemConfigMethod
# conf = tk_split_simplelist(conflist) # conf = tk_split_simplelist(conflist)
tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false).each{|conflist| tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false).each{|conflist|
conf = tk_split_simplelist(conflist, false, true) conf = tk_split_simplelist(conflist, false, true)
conf[__item_configinfo_struct(tagid(tagOrId))[:key]] = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
optkey = conf[__item_configinfo_struct(tagid(tagOrId))[:key]] optkey = conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
@ -1007,7 +1014,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
@ -1015,7 +1022,7 @@ module TkItemConfigMethod
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
@ -1025,11 +1032,11 @@ module TkItemConfigMethod
when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -1037,7 +1044,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
@ -1045,7 +1052,7 @@ module TkItemConfigMethod
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
begin begin
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
rescue rescue
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
@ -1055,11 +1062,11 @@ module TkItemConfigMethod
when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] ) if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -1067,12 +1074,12 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ ) && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
@ -1099,19 +1106,19 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
&& conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] ) && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{') if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
else else
conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]) tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
end end
end end
if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{') if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
else else
conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]) tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
end end
end end
@ -1120,7 +1127,7 @@ module TkItemConfigMethod
if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
&& conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 ) && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1] conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
end end
ret[conf[0]] = conf[1] ret[conf[0]] = conf[1]
@ -1187,7 +1194,7 @@ module TkItemConfigMethod
end end
slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]]
end while(org_slot != slot) end while(org_slot != slot)
fail RuntimeError, fail RuntimeError,
"there is a configure alias loop about '#{org_slot}'" "there is a configure alias loop about '#{org_slot}'"
else else
ret = {} ret = {}

View file

@ -32,22 +32,22 @@ module TkTreatItemFont
if key if key
pathname = [win, tag, key].join(';') pathname = [win, tag, key].join(';')
TkFont.used_on(pathname) || TkFont.used_on(pathname) ||
TkFont.init_widget_font(pathname, TkFont.init_widget_font(pathname,
*(__item_confinfo_cmd(tagid(tagOrId)))) *(__item_confinfo_cmd(tagid(tagOrId))))
elsif optkeys.size == 1 elsif optkeys.size == 1
pathname = [win, tag, optkeys[0]].join(';') pathname = [win, tag, optkeys[0]].join(';')
TkFont.used_on(pathname) || TkFont.used_on(pathname) ||
TkFont.init_widget_font(pathname, TkFont.init_widget_font(pathname,
*(__item_confinfo_cmd(tagid(tagOrId)))) *(__item_confinfo_cmd(tagid(tagOrId))))
else else
fonts = {} fonts = {}
optkeys.each{|key| optkeys.each{|key|
key = key.to_s key = key.to_s
pathname = [win, tag, key].join(';') pathname = [win, tag, key].join(';')
fonts[key] = fonts[key] =
TkFont.used_on(pathname) || TkFont.used_on(pathname) ||
TkFont.init_widget_font(pathname, TkFont.init_widget_font(pathname,
*(__item_confinfo_cmd(tagid(tagOrId)))) *(__item_confinfo_cmd(tagid(tagOrId))))
} }
fonts fonts
@ -73,13 +73,13 @@ module TkTreatItemFont
slot.delete(a_optkey) slot.delete(a_optkey)
slot.delete(k_optkey) slot.delete(k_optkey)
fnt.call_font_configure([pathname, optkey], fnt.call_font_configure([pathname, optkey],
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
next next
else else
if fnt if fnt
if (slot.key?(l_optkey) || if (slot.key?(l_optkey) ||
slot.key?(a_optkey) || slot.key?(a_optkey) ||
slot.key?(k_optkey)) slot.key?(k_optkey))
fnt = TkFont.new(fnt) fnt = TkFont.new(fnt)
@ -90,7 +90,7 @@ module TkTreatItemFont
fnt.latin_replace(lfnt) if lfnt fnt.latin_replace(lfnt) if lfnt
fnt.kanji_replace(kfnt) if kfnt fnt.kanji_replace(kfnt) if kfnt
fnt.call_font_configure([pathname, optkey], fnt.call_font_configure([pathname, optkey],
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
next next
else else
@ -115,7 +115,7 @@ module TkTreatItemFont
kfnt = slot.delete(k_optkey) kfnt = slot.delete(k_optkey)
if lfnt && kfnt if lfnt && kfnt
TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey], TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
elsif lfnt elsif lfnt
latintagfont_configure([lfnt, optkey]) latintagfont_configure([lfnt, optkey])
@ -264,10 +264,10 @@ module TkTreatItemFont
end end
if targetkey if targetkey
fnt.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey], fnt.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
else else
fnt.call_font_configure(__item_pathname(tagid(tagOrId)), fnt.call_font_configure(__item_pathname(tagid(tagOrId)),
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
end end
self self
@ -276,10 +276,10 @@ module TkTreatItemFont
def latintagfont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil) def latintagfont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
if targetkey if targetkey
fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey], fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
else else
fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)), fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
end end
@ -302,10 +302,10 @@ module TkTreatItemFont
def kanjifont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil) def kanjifont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
if targetkey if targetkey
fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey], fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
else else
fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)), fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
*(__item_config_cmd(tagid(tagOrId)) << {})) *(__item_config_cmd(tagid(tagOrId)) << {}))
end end

View file

@ -8,8 +8,8 @@ module TkKinput
extend Tk extend Tk
TkCommandNames = [ TkCommandNames = [
'kinput_start'.freeze, 'kinput_start'.freeze,
'kinput_send_spot'.freeze, 'kinput_send_spot'.freeze,
'kanjiInput'.freeze 'kanjiInput'.freeze
].freeze ].freeze
@ -47,7 +47,7 @@ module TkKinput
def TkKinput.attribute_info(win, slot=nil) def TkKinput.attribute_info(win, slot=nil)
if slot if slot
conf = tk_split_list(tk_call('kanjiInput', 'attribute', conf = tk_split_list(tk_call('kanjiInput', 'attribute',
win, "-#{slot}")) win, "-#{slot}"))
conf[0] = conf[0][1..-1] conf[0] = conf[0][1..-1]
conf conf

View file

@ -6,7 +6,7 @@ require 'tk'
class Tk::Label<TkWindow class Tk::Label<TkWindow
TkCommandNames = ['label'.freeze].freeze TkCommandNames = ['label'.freeze].freeze
WidgetClassName = 'Label'.freeze WidgetClassName = 'Label'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
# tk_call_without_enc('label', @path, *hash_kv(keys, true)) # tk_call_without_enc('label', @path, *hash_kv(keys, true))
@ -18,4 +18,5 @@ class Tk::Label<TkWindow
end end
#TkLabel = Tk::Label unless Object.const_defined? :TkLabel #TkLabel = Tk::Label unless Object.const_defined? :TkLabel
Tk.__set_toplevel_aliases__(:Tk, Tk::Label, :TkLabel) #Tk.__set_toplevel_aliases__(:Tk, Tk::Label, :TkLabel)
Tk.__set_loaded_toplevel_aliases__('tk/label.rb', :Tk, Tk::Label, :TkLabel)

View file

@ -7,7 +7,7 @@ require 'tk/frame'
class Tk::LabelFrame<Tk::Frame class Tk::LabelFrame<Tk::Frame
TkCommandNames = ['labelframe'.freeze].freeze TkCommandNames = ['labelframe'.freeze].freeze
WidgetClassName = 'Labelframe'.freeze WidgetClassName = 'Labelframe'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
# tk_call_without_enc('labelframe', @path, *hash_kv(keys, true)) # tk_call_without_enc('labelframe', @path, *hash_kv(keys, true))
@ -26,4 +26,6 @@ end
Tk::Labelframe = Tk::LabelFrame Tk::Labelframe = Tk::LabelFrame
#TkLabelFrame = Tk::LabelFrame unless Object.const_defined? :TkLabelFrame #TkLabelFrame = Tk::LabelFrame unless Object.const_defined? :TkLabelFrame
#TkLabelframe = Tk::Labelframe unless Object.const_defined? :TkLabelframe #TkLabelframe = Tk::Labelframe unless Object.const_defined? :TkLabelframe
Tk.__set_toplevel_aliases__(:Tk, Tk::LabelFrame, :TkLabelFrame, :TkLabelframe) #Tk.__set_toplevel_aliases__(:Tk, Tk::LabelFrame, :TkLabelFrame, :TkLabelframe)
Tk.__set_loaded_toplevel_aliases__('tk/labelframe.rb', :Tk, Tk::LabelFrame,
:TkLabelFrame, :TkLabelframe)

View file

@ -21,7 +21,7 @@ class Tk::Listbox<TkTextWin
TkCommandNames = ['listbox'.freeze].freeze TkCommandNames = ['listbox'.freeze].freeze
WidgetClassName = 'Listbox'.freeze WidgetClassName = 'Listbox'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
@ -92,7 +92,7 @@ class Tk::Listbox<TkTextWin
fail ArgumentError, 'an Array is expected' fail ArgumentError, 'an Array is expected'
end end
tk_send_without_enc('delete', '0', 'end') tk_send_without_enc('delete', '0', 'end')
tk_send_without_enc('insert', '0', tk_send_without_enc('insert', '0',
*(vals.collect{|v| _get_eval_enc_str(v)})) *(vals.collect{|v| _get_eval_enc_str(v)}))
vals vals
end end
@ -110,7 +110,7 @@ class Tk::Listbox<TkTextWin
_fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}")) _fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}"))
when 'font', 'kanjifont' when 'font', 'kanjifont'
#fnt = tk_tcl2ruby(tk_send('itemcget', index, "-#{key}")) #fnt = tk_tcl2ruby(tk_send('itemcget', index, "-#{key}"))
fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index, fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index,
'-font'))) '-font')))
unless fnt.kind_of?(TkFont) unless fnt.kind_of?(TkFont)
fnt = tagfontobj(index, fnt) fnt = tagfontobj(index, fnt)
@ -127,9 +127,9 @@ class Tk::Listbox<TkTextWin
end end
def itemconfigure(index, key, val=None) def itemconfigure(index, key, val=None)
if key.kind_of? Hash if key.kind_of? Hash
if (key['font'] || key[:font] || if (key['font'] || key[:font] ||
key['kanjifont'] || key[:kanjifont] || key['kanjifont'] || key[:kanjifont] ||
key['latinfont'] || key[:latinfont] || key['latinfont'] || key[:latinfont] ||
key['asciifont'] || key[:asciifont] ) key['asciifont'] || key[:asciifont] )
tagfont_configure(index, _symbolkey2str(key)) tagfont_configure(index, _symbolkey2str(key))
else else
@ -137,9 +137,9 @@ class Tk::Listbox<TkTextWin
end end
else else
if (key == 'font' || key == :font || if (key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont || key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont || key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont ) key == 'asciifont' || key == :asciifont )
if val == None if val == None
tagfontobj(index) tagfontobj(index)
@ -176,16 +176,16 @@ class Tk::Listbox<TkTextWin
else else
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
if conf[4] if conf[4]
if conf[4].index('{') if conf[4].index('{')
conf[4] = tk_split_list(conf[4]) conf[4] = tk_split_list(conf[4])
else else
conf[4] = tk_tcl2ruby(conf[4]) conf[4] = tk_tcl2ruby(conf[4])
end end
end end
end end
@ -224,16 +224,16 @@ class Tk::Listbox<TkTextWin
else else
if conf[2] if conf[2]
if conf[2].index('{') if conf[2].index('{')
conf[2] = tk_split_list(conf[2]) conf[2] = tk_split_list(conf[2])
else else
conf[2] = tk_tcl2ruby(conf[2]) conf[2] = tk_tcl2ruby(conf[2])
end end
end end
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
end end
@ -279,4 +279,6 @@ class Tk::Listbox<TkTextWin
end end
#TkListbox = Tk::Listbox unless Object.const_defined? :TkListbox #TkListbox = Tk::Listbox unless Object.const_defined? :TkListbox
Tk.__set_toplevel_aliases__(:Tk, Tk::Listbox, :TkListbox) #Tk.__set_toplevel_aliases__(:Tk, Tk::Listbox, :TkListbox)
Tk.__set_loaded_toplevel_aliases__('tk/listbox.rb', :Tk, Tk::Listbox,
:TkListbox)

View file

@ -23,7 +23,9 @@ end
module Tk::MacResource module Tk::MacResource
end end
#TkMacResource = Tk::MacResource #TkMacResource = Tk::MacResource
Tk.__set_toplevel_aliases__(:Tk, Tk::MacResource, :TkMacResource) #Tk.__set_toplevel_aliases__(:Tk, Tk::MacResource, :TkMacResource)
Tk.__set_loaded_toplevel_aliases__('tk/macpkg.rb', :Tk, Tk::MacResource,
:TkMacResource)
module Tk::MacResource module Tk::MacResource
extend Tk extend Tk

View file

@ -33,13 +33,14 @@ module TkMenuEntryConfig
end end
private :__item_val2ruby_optkeys private :__item_val2ruby_optkeys
alias entrycget_tkstring itemcget_tkstring
alias entrycget itemcget alias entrycget itemcget
alias entrycget_strict itemcget_strict alias entrycget_strict itemcget_strict
alias entryconfigure itemconfigure alias entryconfigure itemconfigure
alias entryconfiginfo itemconfiginfo alias entryconfiginfo itemconfiginfo
alias current_entryconfiginfo current_itemconfiginfo alias current_entryconfiginfo current_itemconfiginfo
private :itemcget, :itemcget_strict private :itemcget_tkstring, :itemcget, :itemcget_strict
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end end
@ -50,7 +51,7 @@ class Tk::Menu<TkWindow
TkCommandNames = ['menu'.freeze].freeze TkCommandNames = ['menu'.freeze].freeze
WidgetClassName = 'Menu'.freeze WidgetClassName = 'Menu'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
@ -155,13 +156,13 @@ class Tk::Menu<TkWindow
_fromUTF8(tk_send_without_enc('invoke', _get_eval_enc_str(index))) _fromUTF8(tk_send_without_enc('invoke', _get_eval_enc_str(index)))
end end
def insert(index, type, keys=nil) def insert(index, type, keys=nil)
tk_send_without_enc('insert', _get_eval_enc_str(index), tk_send_without_enc('insert', _get_eval_enc_str(index),
type, *hash_kv(keys, true)) type, *hash_kv(keys, true))
self self
end end
def delete(first, last=nil) def delete(first, last=nil)
if last if last
tk_send_without_enc('delete', _get_eval_enc_str(first), tk_send_without_enc('delete', _get_eval_enc_str(first),
_get_eval_enc_str(last)) _get_eval_enc_str(last))
else else
tk_send_without_enc('delete', _get_eval_enc_str(first)) tk_send_without_enc('delete', _get_eval_enc_str(first))
@ -170,7 +171,7 @@ class Tk::Menu<TkWindow
end end
def popup(x, y, index=nil) def popup(x, y, index=nil)
if index if index
tk_call_without_enc('tk_popup', path, x, y, tk_call_without_enc('tk_popup', path, x, y,
_get_eval_enc_str(index)) _get_eval_enc_str(index))
else else
tk_call_without_enc('tk_popup', path, x, y) tk_call_without_enc('tk_popup', path, x, y)
@ -214,7 +215,7 @@ class Tk::Menu<TkWindow
def entrycget(index, key) def entrycget(index, key)
case key.to_s case key.to_s
when 'text', 'label', 'show' when 'text', 'label', 'show'
_fromUTF8(tk_send_without_enc('entrycget', _fromUTF8(tk_send_without_enc('entrycget',
_get_eval_enc_str(index), "-#{key}")) _get_eval_enc_str(index), "-#{key}"))
when 'font', 'kanjifont' when 'font', 'kanjifont'
#fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}")) #fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}"))
@ -234,20 +235,20 @@ class Tk::Menu<TkWindow
end end
def entryconfigure(index, key, val=None) def entryconfigure(index, key, val=None)
if key.kind_of? Hash if key.kind_of? Hash
if (key['font'] || key[:font] || if (key['font'] || key[:font] ||
key['kanjifont'] || key[:kanjifont] || key['kanjifont'] || key[:kanjifont] ||
key['latinfont'] || key[:latinfont] || key['latinfont'] || key[:latinfont] ||
key['asciifont'] || key[:asciifont]) key['asciifont'] || key[:asciifont])
tagfont_configure(index, _symbolkey2str(key)) tagfont_configure(index, _symbolkey2str(key))
else else
tk_send_without_enc('entryconfigure', _get_eval_enc_str(index), tk_send_without_enc('entryconfigure', _get_eval_enc_str(index),
*hash_kv(key, true)) *hash_kv(key, true))
end end
else else
if (key == 'font' || key == :font || if (key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont || key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont || key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont ) key == 'asciifont' || key == :asciifont )
if val == None if val == None
tagfontobj(index) tagfontobj(index)
@ -284,16 +285,16 @@ class Tk::Menu<TkWindow
else else
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
if conf[4] if conf[4]
if conf[4].index('{') if conf[4].index('{')
conf[4] = tk_split_list(conf[4]) conf[4] = tk_split_list(conf[4])
else else
conf[4] = tk_tcl2ruby(conf[4]) conf[4] = tk_tcl2ruby(conf[4])
end end
end end
end end
@ -331,16 +332,16 @@ class Tk::Menu<TkWindow
else else
if conf[2] if conf[2]
if conf[2].index('{') if conf[2].index('{')
conf[2] = tk_split_list(conf[2]) conf[2] = tk_split_list(conf[2])
else else
conf[2] = tk_tcl2ruby(conf[2]) conf[2] = tk_tcl2ruby(conf[2])
end end
end end
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
end end
@ -386,9 +387,33 @@ class Tk::Menu<TkWindow
end end
#TkMenu = Tk::Menu unless Object.const_defined? :TkMenu #TkMenu = Tk::Menu unless Object.const_defined? :TkMenu
Tk.__set_toplevel_aliases__(:Tk, Tk::Menu, :TkMenu) #Tk.__set_toplevel_aliases__(:Tk, Tk::Menu, :TkMenu)
Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::Menu, :TkMenu)
module Tk::Menu::TkInternalFunction; end
class << Tk::Menu::TkInternalFunction
# These methods calls internal functions of Tcl/Tk.
# So, They may not work on your Tcl/Tk.
def next_menu(menu, dir='next')
dir = dir.to_s
case dir
when 'next', 'forward', 'down'
dir = 'right'
when 'previous', 'backward', 'up'
dir = 'left'
end
Tk.tk_call('::tk::MenuNextMenu', menu, dir)
end
def next_entry(menu, delta)
# delta is increment value of entry index.
# For example, +1 denotes 'next entry' and -1 denotes 'previous entry'.
Tk.tk_call('::tk::MenuNextEntry', menu, delta)
end
end
class Tk::MenuClone<Tk::Menu class Tk::MenuClone<Tk::Menu
=begin =begin
def initialize(parent, type=None) def initialize(parent, type=None)
@ -446,7 +471,9 @@ end
Tk::CloneMenu = Tk::MenuClone Tk::CloneMenu = Tk::MenuClone
#TkMenuClone = Tk::MenuClone unless Object.const_defined? :TkMenuClone #TkMenuClone = Tk::MenuClone unless Object.const_defined? :TkMenuClone
#TkCloneMenu = Tk::CloneMenu unless Object.const_defined? :TkCloneMenu #TkCloneMenu = Tk::CloneMenu unless Object.const_defined? :TkCloneMenu
Tk.__set_toplevel_aliases__(:Tk, Tk::MenuClone, :TkMenuClone, :TkCloneMenu) #Tk.__set_toplevel_aliases__(:Tk, Tk::MenuClone, :TkMenuClone, :TkCloneMenu)
Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::MenuClone,
:TkMenuClone, :TkCloneMenu)
module Tk::SystemMenu module Tk::SystemMenu
def initialize(parent, keys=nil) def initialize(parent, keys=nil)
@ -480,7 +507,9 @@ class Tk::SysMenu_Help<Tk::Menu
SYSMENU_NAME = 'help' SYSMENU_NAME = 'help'
end end
#TkSysMenu_Help = Tk::SysMenu_Help unless Object.const_defined? :TkSysMenu_Help #TkSysMenu_Help = Tk::SysMenu_Help unless Object.const_defined? :TkSysMenu_Help
Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Help, :TkSysMenu_Help) #Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Help, :TkSysMenu_Help)
Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_Help,
:TkSysMenu_Help)
class Tk::SysMenu_System<Tk::Menu class Tk::SysMenu_System<Tk::Menu
@ -489,7 +518,9 @@ class Tk::SysMenu_System<Tk::Menu
SYSMENU_NAME = 'system' SYSMENU_NAME = 'system'
end end
#TkSysMenu_System = Tk::SysMenu_System unless Object.const_defined? :TkSysMenu_System #TkSysMenu_System = Tk::SysMenu_System unless Object.const_defined? :TkSysMenu_System
Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_System, :TkSysMenu_System) #Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_System, :TkSysMenu_System)
Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_System,
:TkSysMenu_System)
class Tk::SysMenu_Apple<Tk::Menu class Tk::SysMenu_Apple<Tk::Menu
@ -498,29 +529,31 @@ class Tk::SysMenu_Apple<Tk::Menu
SYSMENU_NAME = 'apple' SYSMENU_NAME = 'apple'
end end
#TkSysMenu_Apple = Tk::SysMenu_Apple unless Object.const_defined? :TkSysMenu_Apple #TkSysMenu_Apple = Tk::SysMenu_Apple unless Object.const_defined? :TkSysMenu_Apple
Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Apple, :TkSysMenu_Apple) #Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Apple, :TkSysMenu_Apple)
Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_Apple,
:TkSysMenu_Apple)
class Tk::Menubutton<Tk::Label class Tk::Menubutton<Tk::Label
TkCommandNames = ['menubutton'.freeze].freeze TkCommandNames = ['menubutton'.freeze].freeze
WidgetClassName = 'Menubutton'.freeze WidgetClassName = 'Menubutton'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def create_self(keys) def create_self(keys)
if keys and keys != None if keys and keys != None
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
# tk_call_without_enc('menubutton', @path, *hash_kv(keys, true)) # tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
else else
begin begin
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
rescue rescue
tk_call_without_enc(self.class::TkCommandNames[0], @path) tk_call_without_enc(self.class::TkCommandNames[0], @path)
keys = __check_available_configure_options(keys) keys = __check_available_configure_options(keys)
unless keys.empty? unless keys.empty?
tk_call_without_enc('destroy', @path) rescue nil tk_call_without_enc('destroy', @path) rescue nil
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
end end
end end
@ -541,7 +574,9 @@ end
Tk::MenuButton = Tk::Menubutton Tk::MenuButton = Tk::Menubutton
#TkMenubutton = Tk::Menubutton unless Object.const_defined? :TkMenubutton #TkMenubutton = Tk::Menubutton unless Object.const_defined? :TkMenubutton
#TkMenuButton = Tk::MenuButton unless Object.const_defined? :TkMenuButton #TkMenuButton = Tk::MenuButton unless Object.const_defined? :TkMenuButton
Tk.__set_toplevel_aliases__(:Tk, Tk::Menubutton, :TkMenubutton, :TkMenuButton) #Tk.__set_toplevel_aliases__(:Tk, Tk::Menubutton, :TkMenubutton, :TkMenuButton)
Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::Menubutton,
:TkMenubutton, :TkMenuButton)
class Tk::OptionMenubutton<Tk::Menubutton class Tk::OptionMenubutton<Tk::Menubutton
@ -571,7 +606,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
parent = nil parent = nil
if !args.empty? && (args[0].kind_of?(TkWindow) || args[0] == nil) if !args.empty? && (args[0].kind_of?(TkWindow) || args[0] == nil)
keys.delete('parent') # ignore keys.delete('parent') # ignore
parent = args.shift parent = args.shift
else else
parent = keys.delete('parent') parent = keys.delete('parent')
end end
@ -579,7 +614,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
@variable = nil @variable = nil
if !args.empty? && (args[0].kind_of?(TkVariable) || args[0] == nil) if !args.empty? && (args[0].kind_of?(TkVariable) || args[0] == nil)
keys.delete('variable') # ignore keys.delete('variable') # ignore
@variable = args.shift @variable = args.shift
else else
@variable = keys.delete('variable') @variable = keys.delete('variable')
end end
@ -593,7 +628,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
end end
install_win(if parent then parent.path end) install_win(if parent then parent.path end)
@menu = OptionMenu.new(tk_call('tk_optionMenu', @menu = OptionMenu.new(tk_call('tk_optionMenu',
@path, @variable.id, *args)) @path, @variable.id, *args))
configure(keys) if keys configure(keys) if keys
@ -612,7 +647,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
self self
end end
def add(value) def add(value)
@menu.add('radiobutton', 'variable'=>@variable, @menu.add('radiobutton', 'variable'=>@variable,
'label'=>value, 'value'=>value) 'label'=>value, 'value'=>value)
self self
end end
@ -623,7 +658,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
@menu.invoke(index) @menu.invoke(index)
end end
def insert(index, value) def insert(index, value)
@menu.insert(index, 'radiobutton', 'variable'=>@variable, @menu.insert(index, 'radiobutton', 'variable'=>@variable,
'label'=>value, 'value'=>value) 'label'=>value, 'value'=>value)
self self
end end
@ -677,5 +712,7 @@ end
Tk::OptionMenuButton = Tk::OptionMenubutton Tk::OptionMenuButton = Tk::OptionMenubutton
#TkOptionMenubutton = Tk::OptionMenubutton unless Object.const_defined? :TkOptionMenubutton #TkOptionMenubutton = Tk::OptionMenubutton unless Object.const_defined? :TkOptionMenubutton
#TkOptionMenuButton = Tk::OptionMenuButton unless Object.const_defined? :TkOptionMenuButton #TkOptionMenuButton = Tk::OptionMenuButton unless Object.const_defined? :TkOptionMenuButton
Tk.__set_toplevel_aliases__(:Tk, Tk::OptionMenubutton, #Tk.__set_toplevel_aliases__(:Tk, Tk::OptionMenubutton,
:TkOptionMenubutton, :TkOptionMenuButton) # :TkOptionMenubutton, :TkOptionMenuButton)
Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::OptionMenubutton,
:TkOptionMenubutton, :TkOptionMenuButton)

View file

@ -2,7 +2,7 @@
# tk/menubar.rb # tk/menubar.rb
# #
# Original version: # Original version:
# Copyright (C) 1998 maeda shugo. All rights reserved. # Copyright (C) 1998 maeda shugo. All rights reserved.
# This file can be distributed under the terms of the Ruby. # This file can be distributed under the terms of the Ruby.
# Usage: # Usage:
@ -52,18 +52,18 @@
# {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0}, # {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
# '---', # '---',
# ['Check_A', TkVariable.new(true), 6], # ['Check_A', TkVariable.new(true), 6],
# {:type=>'checkbutton', :label=>'Check_B', # {:type=>'checkbutton', :label=>'Check_B',
# :variable=>TkVariable.new, :underline=>6}, # :variable=>TkVariable.new, :underline=>6},
# '---', # '---',
# ['Radio_X', [radio_var, 'x'], 6], # ['Radio_X', [radio_var, 'x'], 6],
# ['Radio_Y', [radio_var, 'y'], 6], # ['Radio_Y', [radio_var, 'y'], 6],
# ['Radio_Z', [radio_var, 'z'], 6], # ['Radio_Z', [radio_var, 'z'], 6],
# '---', # '---',
# ['cascade', [ # ['cascade', [
# ['sss', proc{p 'sss'}, 0], # ['sss', proc{p 'sss'}, 0],
# ['ttt', proc{p 'ttt'}, 0], # ['ttt', proc{p 'ttt'}, 0],
# ['uuu', proc{p 'uuu'}, 0], # ['uuu', proc{p 'uuu'}, 0],
# ['vvv', proc{p 'vvv'}, 0], # ['vvv', proc{p 'vvv'}, 0],
# ], 0], # ], 0],
# '---', # '---',
# ['Quit', proc{exit}, 0]], # ['Quit', proc{exit}, 0]],
@ -92,25 +92,31 @@ require 'tk/menuspec'
class TkMenubar<Tk::Frame class TkMenubar<Tk::Frame
include TkComposite include TkComposite
include TkMenuSpec include TkMenuSpec
def initialize(parent = nil, spec = nil, options = nil) def initialize(parent = nil, spec = nil, options = {})
if parent.kind_of? Hash if parent.kind_of? Hash
options = _symbolkey2str(parent) options = parent
spec = options.delete('spec') parent = nil
super(options) spec = (options.has_key?('spec'))? options.delete('spec'): nil
else
super(parent, options)
end end
_symbolkey2str(options)
menuspec_opt = {}
TkMenuSpec::MENUSPEC_OPTKEYS.each{|key|
menuspec_opt[key] = options.delete(key) if options.has_key?(key)
}
super(parent, options)
@menus = [] @menus = []
spec.each{|info| add_menu(info)} if spec spec.each{|info| add_menu(info, menuspec_opt)} if spec
options.each{|key, value| configure(key, value)} if options options.each{|key, value| configure(key, value)} if options
end end
def add_menu(menu_info) def add_menu(menu_info, menuspec_opt={})
mbtn, menu = _create_menubutton(@frame, menu_info) mbtn, menu = _create_menubutton(@frame, menu_info, menuspec_opt)
submenus = _get_cascade_menus(menu).flatten submenus = _get_cascade_menus(menu).flatten
@ -124,7 +130,7 @@ class TkMenubar<Tk::Frame
delegate('font', mbtn, menu, *submenus) delegate('font', mbtn, menu, *submenus)
delegate('kanjifont', mbtn, menu, *submenus) delegate('kanjifont', mbtn, menu, *submenus)
end end
def [](index) def [](index)
return @menus[index] return @menus[index]
end end

View file

@ -3,35 +3,50 @@
# Hidethoshi NAGAI (nagai@ai.kyutech.ac.jp) # Hidethoshi NAGAI (nagai@ai.kyutech.ac.jp)
# #
# based on tkmenubar.rb : # based on tkmenubar.rb :
# Copyright (C) 1998 maeda shugo. All rights reserved. # Copyright (C) 1998 maeda shugo. All rights reserved.
# This file can be distributed under the terms of the Ruby. # This file can be distributed under the terms of the Ruby.
# #
# The format of the menu_spec is: # The format of the menu_spec is:
# [ menu_info, menu_info, ... ] # [ menubutton_info, menubutton_info, ... ]
# #
# And the format of the menu_info is: # The format of the menubutton_info is:
# [ menubutton_info, entry_info, entry_info, ... ]
#
# And each format of *_info is:
# [ # [
# [text, underline, configs], # menu button/entry (*1) # [text, underline, configs], # menu button/entry (*1)
# [label, command, underline, accelerator, configs], # command entry # [label, command, underline, accelerator, configs], # command entry
# [label, TkVar_obj, underline, accelerator, configs], # checkbutton entry # [label, TkVar_obj, underline, accelerator, configs], # checkbutton entry
# [label, [TkVar_obj, value], # [label, [TkVar_obj, value],
# underline, accelerator, configs], # radiobutton entry # underline, accelerator, configs], # radiobutton entry
# [label, [[...menu_info...], [...menu_info...], ...], # [label, [[...menu_info...], [...menu_info...], ...],
# underline, accelerator, configs], # cascade entry (*2) # underline, accelerator, configs], # cascade entry (*2)
# '---', # separator # '---', # separator
# ... # ...
# ] # ]
# #
# underline, accelerator, and configs are optional pearameters. # A menu_info is an array of menu entries:
# Hashes are OK instead of Arrays. Then the entry type ('command', # [ entry_info, entry_info, ... ]
#
#
# underline, accelerator, and configs are optional pearameters.
# Hashes are OK instead of Arrays. Then the entry type ('command',
# 'checkbutton', 'radiobutton' or 'cascade') is given by 'type' key # 'checkbutton', 'radiobutton' or 'cascade') is given by 'type' key
# (e.g. :type=>'cascade'). When type is 'cascade', an array of menu_info # (e.g. :type=>'cascade'). When type is 'cascade', an array of menu_info
# is acceptable for 'menu' key (then, create sub-menu). # is acceptable for 'menu' key (then, create sub-menu).
# #
# If the value of underline is true instead of an integer,
# check whether the text/label string contains a '&' character.
# When includes, the first '&' is removed and its following character is
# converted the corresponding 'underline' option (first '&' is removed).
# Else if the value of underline is a String or a Regexp,
# use the result of label.index(underline) as the index of underline
# (don't remove matched substring).
#
# NOTE: (*1) # NOTE: (*1)
# If you want to make special menus (*.help for UNIX, *.system for Win, # If you want to make special menus (*.help for UNIX, *.system for Win,
# and *.apple for Mac), append 'menu_name'=>name (name is 'help' for UNIX, # and *.apple for Mac), append 'menu_name'=>name (name is 'help' for UNIX,
# 'system' for Win, and 'apple' for Mac) option to the configs hash of # 'system' for Win, and 'apple' for Mac) option to the configs hash of
# menu button/entry information. # menu button/entry information.
# #
# NOTE: (*2) # NOTE: (*2)
@ -39,7 +54,11 @@
# to the configs of the cascade entry. # to the configs of the cascade entry.
module TkMenuSpec module TkMenuSpec
def _create_menu(parent, menu_info, menu_name = nil, extend TkMenuSpec
MENUSPEC_OPTKEYS = [ 'layout_proc' ]
def _create_menu(parent, menu_info, menu_name = nil,
tearoff = false, default_opts = nil) tearoff = false, default_opts = nil)
if tearoff.kind_of?(Hash) if tearoff.kind_of?(Hash)
default_opts = tearoff default_opts = tearoff
@ -59,6 +78,7 @@ module TkMenuSpec
end end
tearoff = orig_opts.delete('tearoff') if orig_opts.key?('tearoff') tearoff = orig_opts.delete('tearoff') if orig_opts.key?('tearoff')
tearoff = false unless tearoff # nil --> false
if menu_name if menu_name
#menu = Tk::Menu.new(parent, :widgetname=>menu_name, :tearoff=>tearoff) #menu = Tk::Menu.new(parent, :widgetname=>menu_name, :tearoff=>tearoff)
@ -80,10 +100,27 @@ module TkMenuSpec
menu_opts.update(_symbolkey2str(options.delete('menu_config') || {})) menu_opts.update(_symbolkey2str(options.delete('menu_config') || {}))
if item_type == 'cascade' && options['menu'].kind_of?(Array) if item_type == 'cascade' && options['menu'].kind_of?(Array)
# create cascade menu # create cascade menu
submenu = _create_menu(menu, options['menu'], menu_name, submenu = _create_menu(menu, options['menu'], menu_name,
tearoff, menu_opts) tearoff, menu_opts)
options['menu'] = submenu options['menu'] = submenu
end end
case options['underline']
when String, Regexp
if options['label'] &&
(idx = options['label'].index(options['underline']))
options['underline'] = idx
else
options['underline'] = -1
end
when true
if options['label'] && (idx = options['label'].index('&'))
options['label'] = options['label'].dup
options['label'][idx] = ''
options['underline'] = idx
else
options['underline'] = -1
end
end
menu.add(item_type, options) menu.add(item_type, options)
elsif item_info.kind_of?(Array) elsif item_info.kind_of?(Array)
@ -117,7 +154,7 @@ module TkMenuSpec
menu_config = opts.delete('menu_config') || {} menu_config = opts.delete('menu_config') || {}
menu_opts.update(_symbolkey2str(menu_config)) menu_opts.update(_symbolkey2str(menu_config))
end end
submenu = _create_menu(menu, item_info[1], menu_name, submenu = _create_menu(menu, item_info[1], menu_name,
tearoff, menu_opts) tearoff, menu_opts)
options['menu'] = submenu options['menu'] = submenu
end end
@ -138,6 +175,25 @@ module TkMenuSpec
end end
options.update(opts) options.update(opts)
end end
case options['underline']
when String, Regexp
if options['label'] &&
(idx = options['label'].index(options['underline']))
options['underline'] = idx
else
options['underline'] = -1
end
when true
if options['label'] && (idx = options['label'].index('&'))
options['label'] = options['label'].dup
options['label'][idx] = ''
options['underline'] = idx
else
options['underline'] = -1
end
end
menu.add(item_type, options) menu.add(item_type, options)
elsif /^-+$/ =~ item_info elsif /^-+$/ =~ item_info
@ -155,7 +211,7 @@ module TkMenuSpec
def _use_menubar?(parent) def _use_menubar?(parent)
use_menubar = false use_menubar = false
if parent.kind_of?(Tk::Root) || parent.kind_of?(Tk::Toplevel) if parent.kind_of?(Tk::Root) || parent.kind_of?(Tk::Toplevel)
true true
elsif parent.current_configinfo.has_key?('menu') elsif parent.current_configinfo.has_key?('menu')
true true
else else
@ -177,7 +233,7 @@ module TkMenuSpec
end end
private :_create_menu_for_menubar private :_create_menu_for_menubar
def _create_menubutton(parent, menu_info, tearoff=false, default_opts = nil) def _create_menubutton(parent, menu_info, tearoff=false, default_opts = {})
btn_info = menu_info[0] btn_info = menu_info[0]
if tearoff.kind_of?(Hash) if tearoff.kind_of?(Hash)
@ -186,14 +242,49 @@ module TkMenuSpec
end end
if default_opts.kind_of?(Hash) if default_opts.kind_of?(Hash)
keys = _symbolkey2str(default_opts) default_opts = _symbolkey2str(default_opts)
else
keys = {} if default_opts.has_key?('layout_proc')
layout_proc = default_opts.delete('layout_proc')
end
_vertical_mbar_bind_proc = proc{|m, dir|
Tk::Menu::TkInternalFunction.next_menu(m, dir) rescue nil
# ignore error when the internal function doesn't exist
}
case layout_proc
when :vertical, 'vertical', :vertical_left, 'vertical_left'
layout_proc = proc{|_parent, _mbtn|
_mbtn.direction :right
_mbtn.pack(:side=>:top, :fill=>:x)
menu = _mbtn.menu
menu.bind('Tab', _vertical_mbar_bind_proc, :widget, 'forward')
menu.bind('Alt-Tab', _vertical_mbar_bind_proc, :widget, 'backward')
}
when :vertical_right, 'vertical_right'
layout_proc = proc{|_parent, _mbtn|
_mbtn.direction :left
_mbtn.pack(:side=>:top, :fill=>:x)
menu = _mbtn.menu
menu.bind('Tab', _vertical_mbar_bind_proc, :widget, 'forward')
menu.bind('Alt-Tab', _vertical_mbar_bind_proc, :widget, 'backward')
}
when :horizontal, 'horizontal'
layout_proc = proc{|_parent, _mbtn| _mbtn.pack(:side=>:left)}
else
# do nothing
end
end end
tearoff = keys.delete('tearoff') if keys.key?('tearoff') keys = default_opts.dup
if _use_menubar?(parent) tearoff = keys.delete('tearoff') if keys.key?('tearoff')
tearoff = false unless tearoff # nil --> false
if _use_menubar?(parent) && ! layout_proc
# menubar by menu entries # menubar by menu entries
mbar = _create_menu_for_menubar(parent) mbar = _create_menu_for_menubar(parent)
@ -202,19 +293,57 @@ module TkMenuSpec
if btn_info.kind_of?(Hash) if btn_info.kind_of?(Hash)
keys.update(_symbolkey2str(btn_info)) keys.update(_symbolkey2str(btn_info))
menu_name = keys.delete('menu_name') menu_name = keys.delete('menu_name')
keys['label'] = keys.delete('text') if keys.key?('text') keys['label'] = keys.delete('text') || ''
case keys['underline']
when String, Regexp
if idx = keys['label'].index(keys['underline'])
keys['underline'] = idx
else
keys['underline'] = -1
end
when true
if idx = keys['label'].index('&')
keys['label'] = keys['label'].dup
keys['label'][idx] = ''
keys['underline'] = idx
else
keys['underline'] = -1
end
end
elsif btn_info.kind_of?(Array) elsif btn_info.kind_of?(Array)
keys['label'] = btn_info[0] if btn_info[0] keys['label'] = btn_info[0] if btn_info[0]
keys['underline'] = btn_info[1] if btn_info[1]
case btn_info[1]
when Integer
keys['underline'] = btn_info[1]
when String, Regexp
if idx = keys['label'].index(btn_info[1])
keys['underline'] = idx
else
keys['underline'] = -1
end
when true
if idx = keys['label'].index('&')
keys['label'] = keys['label'].dup
keys['label'][idx] = ''
keys['underline'] = idx
else
keys['underline'] = -1
end
end
if btn_info[2]&&btn_info[2].kind_of?(Hash) if btn_info[2]&&btn_info[2].kind_of?(Hash)
keys.update(_symbolkey2str(btn_info[2])) keys.update(_symbolkey2str(btn_info[2]))
menu_name = keys.delete('menu_name') menu_name = keys.delete('menu_name')
end end
else else
keys = {:label=>btn_info} keys = {:label=>btn_info}
end end
menu = _create_menu(mbar, menu_info[1..-1], menu_name, menu = _create_menu(mbar, menu_info[1..-1], menu_name,
tearoff, default_opts) tearoff, default_opts)
menu.tearoff(tearoff) menu.tearoff(tearoff)
@ -234,9 +363,42 @@ module TkMenuSpec
if btn_info.kind_of?(Hash) if btn_info.kind_of?(Hash)
keys.update(_symbolkey2str(btn_info)) keys.update(_symbolkey2str(btn_info))
menu_name = keys.delete('menu_name') menu_name = keys.delete('menu_name')
keys['text'] = keys.delete('label') if keys.key?('label') keys['text'] = keys.delete('label') || ''
case keys['underline']
when String, Regexp
if idx = keys['text'].index(keys['underline'])
keys['underline'] = idx
else
keys['underline'] = -1
end
when true
if idx = keys['text'].index('&')
keys['text'] = keys['text'].dup
keys['text'][idx] = ''
keys['underline'] = idx
else
keys['underline'] = -1
end
end
mbtn.configure(keys) mbtn.configure(keys)
elsif btn_info.kind_of?(Array) elsif btn_info.kind_of?(Array)
case btn_info[1]
when String, Regexp
if btn_info[0] && (idx = btn_info[0].index(btn_info[1]))
btn_info[1] = idx
else
btn_info[1] = -1
end
when true
if btn_info[0] && (idx = btn_info[0].index('&'))
btn_info[0] = btn_info[0].dup
btn_info[0][idx] = ''
btn_info[1] = idx
else
btn_info[1] = -1
end
end
mbtn.configure('text', btn_info[0]) if btn_info[0] mbtn.configure('text', btn_info[0]) if btn_info[0]
mbtn.configure('underline', btn_info[1]) if btn_info[1] mbtn.configure('underline', btn_info[1]) if btn_info[1]
# mbtn.configure('accelerator', btn_info[2]) if btn_info[2] # mbtn.configure('accelerator', btn_info[2]) if btn_info[2]
@ -245,22 +407,41 @@ module TkMenuSpec
menu_name = keys.delete('menu_name') menu_name = keys.delete('menu_name')
mbtn.configure(keys) mbtn.configure(keys)
end end
else else
mbtn.configure('text', btn_info) mbtn.configure('text', btn_info)
end end
mbtn.pack('side' => 'left') menu = _create_menu(mbtn, menu_info[1..-1], menu_name,
menu = _create_menu(mbtn, menu_info[1..-1], menu_name,
tearoff, default_opts) tearoff, default_opts)
mbtn.menu(menu) mbtn.menu(menu)
if layout_proc.kind_of?(Proc) || layout_proc.kind_of?(Method)
# e.g. make a vertical menubar
# :layout_proc => proc{|parent, btn| btn.pack(:side=>:top, :fill=>:x)}
layout_proc.call(parent, mbtn)
else
mbtn.pack('side' => 'left')
end
[mbtn, menu] [mbtn, menu]
end end
end end
private :_create_menubutton private :_create_menubutton
def _create_menubar(parent, menu_spec, tearoff = false, opts = nil)
if tearoff.kind_of?(Hash)
opts = tearoff
tearoff = false
end
tearoff = false unless tearoff # nil --> false
menu_spec.each{|menu_info|
_create_menubutton(parent, menu_info, tearoff, opts)
}
parent
end
private :_create_menubar
def _get_cascade_menus(menu) def _get_cascade_menus(menu)
menus = [] menus = []
(0..(menu.index('last'))).each{|idx| (0..(menu.index('last'))).each{|idx|

View file

@ -7,7 +7,7 @@ require 'tk/label'
class Tk::Message<Tk::Label class Tk::Message<Tk::Label
TkCommandNames = ['message'.freeze].freeze TkCommandNames = ['message'.freeze].freeze
WidgetClassName = 'Message'.freeze WidgetClassName = 'Message'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
# tk_call_without_enc('message', @path, *hash_kv(keys, true)) # tk_call_without_enc('message', @path, *hash_kv(keys, true))
@ -19,4 +19,6 @@ class Tk::Message<Tk::Label
end end
#TkMessage = Tk::Message unless Object.const_defined? :TkMessage #TkMessage = Tk::Message unless Object.const_defined? :TkMessage
Tk.__set_toplevel_aliases__(:Tk, Tk::Message, :TkMessage) #Tk.__set_toplevel_aliases__(:Tk, Tk::Message, :TkMessage)
Tk.__set_loaded_toplevel_aliases__('tk/message.rb', :Tk, Tk::Message,
:TkMessage)

View file

@ -8,8 +8,8 @@ module TkManageFocus
extend Tk extend Tk
TkCommandNames = [ TkCommandNames = [
'tk_focusFollowMouse'.freeze, 'tk_focusFollowMouse'.freeze,
'tk_focusNext'.freeze, 'tk_focusNext'.freeze,
'tk_focusPrev'.freeze 'tk_focusPrev'.freeze
].freeze ].freeze

View file

@ -11,13 +11,13 @@ class TkMsgCatalog < TkObject
#extend TkMsgCatalog #extend TkMsgCatalog
TkCommandNames = [ TkCommandNames = [
'::msgcat::mc'.freeze, '::msgcat::mc'.freeze,
'::msgcat::mcmax'.freeze, '::msgcat::mcmax'.freeze,
'::msgcat::mclocale'.freeze, '::msgcat::mclocale'.freeze,
'::msgcat::mcpreferences'.freeze, '::msgcat::mcpreferences'.freeze,
'::msgcat::mcload'.freeze, '::msgcat::mcload'.freeze,
'::msgcat::mcset'.freeze, '::msgcat::mcset'.freeze,
'::msgcat::mcmset'.freeze, '::msgcat::mcmset'.freeze,
'::msgcat::mcunknown'.freeze '::msgcat::mcunknown'.freeze
].freeze ].freeze
@ -36,7 +36,7 @@ class TkMsgCatalog < TkObject
MSGCAT_EXT = '.msg' MSGCAT_EXT = '.msg'
UNKNOWN_CBTBL = Hash.new{|hash,key| hash[key] = {}}.taint UNKNOWN_CBTBL = TkUtil.untrust(Hash.new{|hash,key| hash[key] = {}})
TkCore::INTERP.add_tk_procs('::msgcat::mcunknown', 'args', <<-'EOL') TkCore::INTERP.add_tk_procs('::msgcat::mcunknown', 'args', <<-'EOL')
if {[set st [catch {eval {ruby_cmd TkMsgCatalog callback} [namespace current] $args} ret]] != 0} { if {[set st [catch {eval {ruby_cmd TkMsgCatalog callback} [namespace current] $args} ret]] != 0} {
@ -69,10 +69,10 @@ class TkMsgCatalog < TkObject
exit!(1) exit!(1)
rescue Exception => e rescue Exception => e
begin begin
msg = _toUTF8(e.class.inspect) + ': ' + msg = _toUTF8(e.class.inspect) + ': ' +
_toUTF8(e.message) + "\n" + _toUTF8(e.message) + "\n" +
"\n---< backtrace of Ruby side >-----\n" + "\n---< backtrace of Ruby side >-----\n" +
_toUTF8(e.backtrace.join("\n")) + _toUTF8(e.backtrace.join("\n")) +
"\n---< backtrace of Tk side >-------" "\n---< backtrace of Tk side >-------"
if TkCore::WITH_ENCODING if TkCore::WITH_ENCODING
msg.force_encoding('utf-8') msg.force_encoding('utf-8')
@ -80,9 +80,9 @@ class TkMsgCatalog < TkObject
msg.instance_variable_set(:@encoding, 'utf-8') msg.instance_variable_set(:@encoding, 'utf-8')
end end
rescue Exception rescue Exception
msg = e.class.inspect + ': ' + e.message + "\n" + msg = e.class.inspect + ': ' + e.message + "\n" +
"\n---< backtrace of Ruby side >-----\n" + "\n---< backtrace of Ruby side >-----\n" +
e.backtrace.join("\n") + e.backtrace.join("\n") +
"\n---< backtrace of Tk side >-------" "\n---< backtrace of Tk side >-------"
end end
fail(e, msg) fail(e, msg)
@ -153,7 +153,7 @@ class TkMsgCatalog < TkObject
end end
def translate(*args) def translate(*args)
dst = args.collect{|src| dst = args.collect{|src|
@namespace.eval{tk_call_without_enc('::msgcat::mc', @namespace.eval{tk_call_without_enc('::msgcat::mc',
_get_eval_string(src, true))} _get_eval_string(src, true))}
} }
Tk.UTF8_String(sprintf(*dst)) Tk.UTF8_String(sprintf(*dst))
@ -229,29 +229,29 @@ class TkMsgCatalog < TkObject
def self.set_translation(locale, src_str, trans_str=None, enc='utf-8') def self.set_translation(locale, src_str, trans_str=None, enc='utf-8')
if trans_str && trans_str != None if trans_str && trans_str != None
trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc)) trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset', Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset',
locale, locale,
_get_eval_string(src_str, true), _get_eval_string(src_str, true),
trans_str)) trans_str))
else else
Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset', Tk.UTF8_String(tk_call_without_enc('::msgcat::mcset',
locale, locale,
_get_eval_string(src_str, true))) _get_eval_string(src_str, true)))
end end
end end
def set_translation(locale, src_str, trans_str=None, enc='utf-8') def set_translation(locale, src_str, trans_str=None, enc='utf-8')
if trans_str && trans_str != None if trans_str && trans_str != None
trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc)) trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
Tk.UTF8_String(@namespace.eval{ Tk.UTF8_String(@namespace.eval{
tk_call_without_enc('::msgcat::mcset', tk_call_without_enc('::msgcat::mcset',
locale, locale,
_get_eval_string(src_str, true), _get_eval_string(src_str, true),
trans_str) trans_str)
}) })
else else
Tk.UTF8_String(@namespace.eval{ Tk.UTF8_String(@namespace.eval{
tk_call_without_enc('::msgcat::mcset', tk_call_without_enc('::msgcat::mcset',
locale, locale,
_get_eval_string(src_str, true))}) _get_eval_string(src_str, true))})
end end
end end
@ -261,7 +261,7 @@ class TkMsgCatalog < TkObject
list = [] list = []
trans_list.each{|src, trans| trans_list.each{|src, trans|
if trans && trans != None if trans && trans != None
list << _get_eval_string(src, true) list << _get_eval_string(src, true)
list << Tk.UTF8_Stirng(_toUTF8(trans, enc)) list << Tk.UTF8_Stirng(_toUTF8(trans, enc))
else else
list << _get_eval_string(src, true) << '' list << _get_eval_string(src, true) << ''
@ -274,7 +274,7 @@ class TkMsgCatalog < TkObject
list = [] list = []
trans_list.each{|src, trans| trans_list.each{|src, trans|
if trans && trans != None if trans && trans != None
list << _get_eval_string(src, true) list << _get_eval_string(src, true)
list << Tk.UTF8_String(_toUTF8(trans, enc)) list << Tk.UTF8_String(_toUTF8(trans, enc))
else else
list << _get_eval_string(src, true) << '' list << _get_eval_string(src, true) << ''

View file

@ -8,12 +8,12 @@ class TkNamespace < TkObject
extend Tk extend Tk
TkCommandNames = [ TkCommandNames = [
'namespace'.freeze, 'namespace'.freeze,
].freeze ].freeze
Tk_Namespace_ID_TBL = TkCore::INTERP.create_table Tk_Namespace_ID_TBL = TkCore::INTERP.create_table
(Tk_Namespace_ID = ["ns".freeze, "00000".taint]).instance_eval{ (Tk_Namespace_ID = ["ns".freeze, TkUtil.untrust("00000")]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -46,7 +46,7 @@ class TkNamespace < TkObject
private :__config_cmd private :__config_cmd
def __configinfo_struct def __configinfo_struct
{:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil, {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
:default_value=>nil, :current_value=>2} :default_value=>nil, :current_value=>2}
end end
private :__configinfo_struct private :__configinfo_struct
@ -122,8 +122,8 @@ class TkNamespace < TkObject
if TkComm::GET_CONFIGINFO_AS_ARRAY if TkComm::GET_CONFIGINFO_AS_ARRAY
Tk_Namespace_ID_TBL.mutex.synchronize{ Tk_Namespace_ID_TBL.mutex.synchronize{
info.map!{|inf| info.map!{|inf|
if inf[0] == 'namespace' && if inf[0] == 'namespace' &&
TkNamespace::Tk_Namespace_ID_TBL.key?(inf[-1]) TkNamespace::Tk_Namespace_ID_TBL.key?(inf[-1])
[inf[0], TkNamespace::Tk_Namespace_ID_TBL[inf[-1]]] [inf[0], TkNamespace::Tk_Namespace_ID_TBL[inf[-1]]]
else else
@ -160,19 +160,19 @@ class TkNamespace < TkObject
def tk_call(*args) def tk_call(*args)
#super('namespace', 'eval', @namespace, *args) #super('namespace', 'eval', @namespace, *args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''} args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @namespace, super('namespace', 'eval', @namespace,
TkCore::INTERP._merge_tklist(*args)) TkCore::INTERP._merge_tklist(*args))
end end
def tk_call_without_enc(*args) def tk_call_without_enc(*args)
#super('namespace', 'eval', @namespace, *args) #super('namespace', 'eval', @namespace, *args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''} args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @namespace, super('namespace', 'eval', @namespace,
TkCore::INTERP._merge_tklist(*args)) TkCore::INTERP._merge_tklist(*args))
end end
def tk_call_with_enc(*args) def tk_call_with_enc(*args)
#super('namespace', 'eval', @namespace, *args) #super('namespace', 'eval', @namespace, *args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''} args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @namespace, super('namespace', 'eval', @namespace,
TkCore::INTERP._merge_tklist(*args)) TkCore::INTERP._merge_tklist(*args))
end end
@ -223,19 +223,19 @@ class TkNamespace < TkObject
def tk_call(*args) def tk_call(*args)
#super('namespace', 'eval', @fullname, *args) #super('namespace', 'eval', @fullname, *args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''} args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname, super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args)) TkCore::INTERP._merge_tklist(*args))
end end
def tk_call_without_enc(*args) def tk_call_without_enc(*args)
#super('namespace', 'eval', @fullname, *args) #super('namespace', 'eval', @fullname, *args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''} args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname, super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args)) TkCore::INTERP._merge_tklist(*args))
end end
def tk_call_with_enc(*args) def tk_call_with_enc(*args)
#super('namespace', 'eval', @fullname, *args) #super('namespace', 'eval', @fullname, *args)
args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''} args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
super('namespace', 'eval', @fullname, super('namespace', 'eval', @fullname,
TkCore::INTERP._merge_tklist(*args)) TkCore::INTERP._merge_tklist(*args))
end end
alias ns_tk_call tk_call alias ns_tk_call tk_call
@ -318,7 +318,7 @@ class TkNamespace < TkObject
else else
fail ArgumentError, "String or Proc is expected" fail ArgumentError, "String or Proc is expected"
end end
TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code', TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
_get_eval_string(cmd, false))) _get_eval_string(cmd, false)))
end end
=end =end
@ -350,8 +350,8 @@ class TkNamespace < TkObject
else else
fail ArgumentError, "String or Proc is expected" fail ArgumentError, "String or Proc is expected"
end end
TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code', TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
_get_eval_string(cmd, false)), _get_eval_string(cmd, false)),
true) true)
end end

View file

@ -8,7 +8,7 @@ module TkOptionDB
extend Tk extend Tk
TkCommandNames = ['option'.freeze].freeze TkCommandNames = ['option'.freeze].freeze
(CmdClassID = ['CMD_CLASS'.freeze, '00000'.taint]).instance_eval{ (CmdClassID = ['CMD_CLASS'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -44,7 +44,7 @@ module TkOptionDB
def read_entries(file, f_enc=nil) def read_entries(file, f_enc=nil)
if TkCore::INTERP.safe? if TkCore::INTERP.safe?
fail SecurityError, fail SecurityError,
"can't call 'TkOptionDB.read_entries' on a safe interpreter" "can't call 'TkOptionDB.read_entries' on a safe interpreter"
end end
@ -86,7 +86,7 @@ module TkOptionDB
ent ent
end end
module_function :read_entries module_function :read_entries
def read_with_encoding(file, f_enc=nil, pri=None) def read_with_encoding(file, f_enc=nil, pri=None)
# try to read the file as an OptionDB file # try to read the file as an OptionDB file
read_entries(file, f_enc).each{|pat, val| read_entries(file, f_enc).each{|pat, val|
@ -136,7 +136,7 @@ module TkOptionDB
@@resource_proc_class.const_set(:CARRIER, '.'.freeze) @@resource_proc_class.const_set(:CARRIER, '.'.freeze)
@@resource_proc_class.instance_variable_set('@method_tbl', @@resource_proc_class.instance_variable_set('@method_tbl',
TkCore::INTERP.create_table) TkCore::INTERP.create_table)
@@resource_proc_class.instance_variable_set('@add_method', false) @@resource_proc_class.instance_variable_set('@add_method', false)
@@resource_proc_class.instance_variable_set('@safe_mode', 4) @@resource_proc_class.instance_variable_set('@safe_mode', 4)
@ -144,7 +144,7 @@ module TkOptionDB
class << @@resource_proc_class class << @@resource_proc_class
private :new private :new
=begin =begin
CARRIER = '.'.freeze CARRIER = '.'.freeze
METHOD_TBL = TkCore::INTERP.create_table METHOD_TBL = TkCore::INTERP.create_table
ADD_METHOD = false ADD_METHOD = false
@ -171,7 +171,7 @@ module TkOptionDB
def __check_proc_string__(str) def __check_proc_string__(str)
# If you want to check the proc_string, do it in this method. # If you want to check the proc_string, do it in this method.
# Please define this in the block given to 'new_proc_class' method. # Please define this in the block given to 'new_proc_class' method.
str str
end end
@ -186,20 +186,20 @@ module TkOptionDB
unless TkComm._callback_entry?(res_proc) unless TkComm._callback_entry?(res_proc)
#if id == :new || !(self::METHOD_TBL.has_key?(id) || self::ADD_METHOD) #if id == :new || !(self::METHOD_TBL.has_key?(id) || self::ADD_METHOD)
if id == :new || !(@method_tbl.has_key?(id) || @add_method) if id == :new || !(@method_tbl.has_key?(id) || @add_method)
raise NoMethodError, raise NoMethodError,
"not support resource-proc '#{id.id2name}' for #{self.name}" "not support resource-proc '#{id.id2name}' for #{self.name}"
end end
proc_str = proc_source proc_str = proc_source
proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str
#proc_str = __closed_block_check__(proc_str) #proc_str = __closed_block_check__(proc_str)
proc_str = __check_proc_string__(proc_str) proc_str = __check_proc_string__(proc_str)
res_proc = proc{ res_proc = proc{
begin begin
#eval("$SAFE = #{self::SAFE_MODE};\nProc.new" + proc_str) #eval("$SAFE = #{self::SAFE_MODE};\nProc.new" + proc_str)
eval("$SAFE = #{@safe_mode};\nProc.new" + proc_str) eval("$SAFE = #{@safe_mode};\nProc.new" + proc_str)
rescue SyntaxError=>err rescue SyntaxError=>err
raise SyntaxError, raise SyntaxError,
TkCore::INTERP._toUTF8(err.message.gsub(/\(eval\):\d:/, TkCore::INTERP._toUTF8(err.message.gsub(/\(eval\):\d:/,
"(#{id.id2name}):")) "(#{id.id2name}):"))
end end
}.call }.call
@ -291,7 +291,7 @@ module TkOptionDB
cmd_klass.instance_variable_set('@method_tbl', TkCore::INTERP.create_table) cmd_klass.instance_variable_set('@method_tbl', TkCore::INTERP.create_table)
cmd_klass.instance_variable_set('@add_method', add) cmd_klass.instance_variable_set('@add_method', add)
cmd_klass.instance_variable_set('@safe_mode', safe) cmd_klass.instance_variable_set('@safe_mode', safe)
func.each{|f| func.each{|f|
cmd_klass.instance_variable_get('@method_tbl')[f.to_s.intern] = nil cmd_klass.instance_variable_get('@method_tbl')[f.to_s.intern] = nil
} }
=begin =begin
@ -310,14 +310,14 @@ module TkOptionDB
# for security, make these methods invalid # for security, make these methods invalid
class << klass class << klass
def __null_method(*args); nil; end def __null_method(*args); nil; end
[ :class_eval, :name, :superclass, :clone, :dup, :autoload, :autoload?, [ :class_eval, :name, :superclass, :clone, :dup, :autoload, :autoload?,
:ancestors, :const_defined?, :const_get, :const_set, :const_missing, :ancestors, :const_defined?, :const_get, :const_set, :const_missing,
:class_variables, :constants, :included_modules, :instance_methods, :class_variables, :constants, :included_modules, :instance_methods,
:method_defined?, :module_eval, :private_instance_methods, :method_defined?, :module_eval, :private_instance_methods,
:protected_instance_methods, :public_instance_methods, :protected_instance_methods, :public_instance_methods,
:singleton_methods, :remove_const, :remove_method, :undef_method, :singleton_methods, :remove_const, :remove_method, :undef_method,
:to_s, :inspect, :display, :method, :methods, :respond_to?, :to_s, :inspect, :display, :method, :methods, :respond_to?,
:instance_variable_get, :instance_variable_set, :instance_method, :instance_variable_get, :instance_variable_set, :instance_method,
:instance_eval, :instance_exec, :instance_variables, :kind_of?, :is_a?, :instance_eval, :instance_exec, :instance_variables, :kind_of?, :is_a?,
:private_methods, :protected_methods, :public_methods ].each{|m| :private_methods, :protected_methods, :public_methods ].each{|m|
alias_method(m, :__null_method) alias_method(m, :__null_method)
@ -331,7 +331,7 @@ module TkOptionDB
RAND_BASE_HEAD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' RAND_BASE_HEAD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
RAND_BASE_CHAR = RAND_BASE_HEAD + 'abcdefghijklmnopqrstuvwxyz0123456789_' RAND_BASE_CHAR = RAND_BASE_HEAD + 'abcdefghijklmnopqrstuvwxyz0123456789_'
def __get_random_basename def __get_random_basename
name = '%s%03d' % [RAND_BASE_HEAD[rand(RAND_BASE_HEAD.size),1], name = '%s%03d' % [RAND_BASE_HEAD[rand(RAND_BASE_HEAD.size),1],
RAND_BASE_CNT[0]] RAND_BASE_CNT[0]]
len = RAND_BASE_CHAR.size len = RAND_BASE_CHAR.size
(6+rand(10)).times{ (6+rand(10)).times{
@ -344,9 +344,9 @@ module TkOptionDB
private_class_method :__get_random_basename private_class_method :__get_random_basename
# define new proc class : # define new proc class :
# If you want to modify the new class or create a new subclass, # If you want to modify the new class or create a new subclass,
# you must do such operation in the block parameter. # you must do such operation in the block parameter.
# Because the created class is flozen after evaluating the block. # Because the created class is flozen after evaluating the block.
def new_proc_class(klass, func, safe = 4, add = false, parent = nil, &b) def new_proc_class(klass, func, safe = 4, add = false, parent = nil, &b)
new_klass = __create_new_class(klass, func, safe, add, parent) new_klass = __create_new_class(klass, func, safe, add, parent)
new_klass.class_eval(&b) if block_given? new_klass.class_eval(&b) if block_given?
@ -357,7 +357,7 @@ module TkOptionDB
module_function :new_proc_class module_function :new_proc_class
def eval_under_random_base(parent = nil, &b) def eval_under_random_base(parent = nil, &b)
new_klass = __create_new_class(__get_random_basename(), new_klass = __create_new_class(__get_random_basename(),
[], 4, false, parent) [], 4, false, parent)
ret = new_klass.class_eval(&b) if block_given? ret = new_klass.class_eval(&b) if block_given?
__remove_methods_of_proc_class(new_klass) __remove_methods_of_proc_class(new_klass)

View file

@ -1,10 +1,10 @@
# #
# tk/optionobj.rb : control options for a group of widgets # tk/optionobj.rb : control options for a group of widgets
# #
# NOTE: If you want to use key-only option (no value), # NOTE: If you want to use key-only option (no value),
# use Tk::None for the value of the key-only option. # use Tk::None for the value of the key-only option.
# #
# e.g. hash_kv({'aaa'=>1, 'bbb'=>Tk::None, 'ccc'=>3}) # e.g. hash_kv({'aaa'=>1, 'bbb'=>Tk::None, 'ccc'=>3})
# => ["-aaa", 1, "-bbb", "-ccc", 3] # => ["-aaa", 1, "-bbb", "-ccc", 3]
# #
require 'tk' require 'tk'
@ -36,7 +36,7 @@ module Tk
def _remove_win(win) def _remove_win(win)
if win.kind_of?(Array) if win.kind_of?(Array)
widget, method = win widget, method = win
@observ.delete_if{|x| @observ.delete_if{|x|
if x.kind_of?(Array) if x.kind_of?(Array)
x[0] == widget x[0] == widget
else else
@ -56,15 +56,15 @@ module Tk
private :_remove_win private :_remove_win
def assign(*wins) def assign(*wins)
# win := # win :=
# widget #==> call widget.configure(hash) # widget #==> call widget.configure(hash)
# [widget] #==> call widget.configure(hash) # [widget] #==> call widget.configure(hash)
# [widget, nil, {src=>target, ... }] # [widget, nil, {src=>target, ... }]
# #==> call widget.configure(hash) # #==> call widget.configure(hash)
# with converting hash-key # with converting hash-key
# [widget, method] #==> call widget.method(hash) # [widget, method] #==> call widget.method(hash)
# [widget, method, {src=>target, ... }] # [widget, method, {src=>target, ... }]
# #==> call widget.method(hash) # #==> call widget.method(hash)
# with converting hash-key # with converting hash-key
# [widget [receiver, method, arg, ... ]] # [widget [receiver, method, arg, ... ]]
# #==> call receiver.method(arg, ... , hash) # #==> call receiver.method(arg, ... , hash)
@ -74,7 +74,7 @@ module Tk
# #
# src := option_name_on_optobj # src := option_name_on_optobj
# #
# target := # target :=
# nil #==> not use the src # nil #==> not use the src
# option_name_on_target_widget # option_name_on_target_widget
# [ option_name_on_target_widget, ... ] # [ option_name_on_target_widget, ... ]
@ -123,7 +123,7 @@ module Tk
next unless key next unless key
if key.kind_of?(Array) if key.kind_of?(Array)
key.each{|k| hash[k] = val} key.each{|k| hash[k] = val}
else else
hash[key] = val hash[key] = val
end end
} }

View file

@ -9,8 +9,8 @@ module TkPalette
extend Tk extend Tk
TkCommandNames = [ TkCommandNames = [
'tk_setPalette'.freeze, 'tk_setPalette'.freeze,
'tk_bisque'.freeze, 'tk_bisque'.freeze,
'tkDarken'.freeze 'tkDarken'.freeze
].freeze ].freeze

View file

@ -6,7 +6,7 @@ require 'tk'
class Tk::PanedWindow<TkWindow class Tk::PanedWindow<TkWindow
TkCommandNames = ['panedwindow'.freeze].freeze TkCommandNames = ['panedwindow'.freeze].freeze
WidgetClassName = 'Panedwindow'.freeze WidgetClassName = 'Panedwindow'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
# tk_call_without_enc('panedwindow', @path, *hash_kv(keys, true)) # tk_call_without_enc('panedwindow', @path, *hash_kv(keys, true))
@ -128,10 +128,10 @@ class Tk::PanedWindow<TkWindow
# win = win.epath if win.kind_of?(TkObject) # win = win.epath if win.kind_of?(TkObject)
win = _epath(win) win = _epath(win)
if key if key
#conf = tk_split_list(tk_send_without_enc('paneconfigure', #conf = tk_split_list(tk_send_without_enc('paneconfigure',
# win, "-#{key}")) # win, "-#{key}"))
conf = tk_split_list(tk_send_without_enc('paneconfigure', conf = tk_split_list(tk_send_without_enc('paneconfigure',
win, "-#{key}"), win, "-#{key}"),
false, true) false, true)
conf[0] = conf[0][1..-1] conf[0] = conf[0][1..-1]
if conf[0] == 'hide' if conf[0] == 'hide'
@ -140,10 +140,10 @@ class Tk::PanedWindow<TkWindow
end end
conf conf
else else
#tk_split_simplelist(tk_send_without_enc('paneconfigure', #tk_split_simplelist(tk_send_without_enc('paneconfigure',
# win)).collect{|conflist| # win)).collect{|conflist|
# conf = tk_split_simplelist(conflist) # conf = tk_split_simplelist(conflist)
tk_split_simplelist(tk_send_without_enc('paneconfigure', win), tk_split_simplelist(tk_send_without_enc('paneconfigure', win),
false, false).collect{|conflist| false, false).collect{|conflist|
conf = tk_split_simplelist(conflist, false, true) conf = tk_split_simplelist(conflist, false, true)
conf[0] = conf[0][1..-1] conf[0] = conf[0][1..-1]
@ -151,18 +151,18 @@ class Tk::PanedWindow<TkWindow
if conf[0] == 'hide' if conf[0] == 'hide'
conf[3] = bool(conf[3]) unless conf[3].empty? conf[3] = bool(conf[3]) unless conf[3].empty?
elsif conf[3].index('{') elsif conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
if conf[4] if conf[4]
if conf[0] == 'hide' if conf[0] == 'hide'
conf[4] = bool(conf[4]) unless conf[4].empty? conf[4] = bool(conf[4]) unless conf[4].empty?
elsif conf[4].index('{') elsif conf[4].index('{')
conf[4] = tk_split_list(conf[4]) conf[4] = tk_split_list(conf[4])
else else
conf[4] = tk_tcl2ruby(conf[4]) conf[4] = tk_tcl2ruby(conf[4])
end end
end end
conf[1] = conf[1][1..-1] if conf.size == 2 # alias info conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
@ -173,10 +173,10 @@ class Tk::PanedWindow<TkWindow
# win = win.epath if win.kind_of?(TkObject) # win = win.epath if win.kind_of?(TkObject)
win = _epath(win) win = _epath(win)
if key if key
#conf = tk_split_list(tk_send_without_enc('paneconfigure', #conf = tk_split_list(tk_send_without_enc('paneconfigure',
# win, "-#{key}")) # win, "-#{key}"))
conf = tk_split_list(tk_send_without_enc('paneconfigure', conf = tk_split_list(tk_send_without_enc('paneconfigure',
win, "-#{key}"), win, "-#{key}"),
false, true) false, true)
key = conf.shift[1..-1] key = conf.shift[1..-1]
if key == 'hide' if key == 'hide'
@ -186,10 +186,10 @@ class Tk::PanedWindow<TkWindow
{ key => conf } { key => conf }
else else
ret = {} ret = {}
#tk_split_simplelist(tk_send_without_enc('paneconfigure', #tk_split_simplelist(tk_send_without_enc('paneconfigure',
# win)).each{|conflist| # win)).each{|conflist|
# conf = tk_split_simplelist(conflist) # conf = tk_split_simplelist(conflist)
tk_split_simplelist(tk_send_without_enc('paneconfigure', win), tk_split_simplelist(tk_send_without_enc('paneconfigure', win),
false, false).each{|conflist| false, false).each{|conflist|
conf = tk_split_simplelist(conflist, false, true) conf = tk_split_simplelist(conflist, false, true)
key = conf.shift[1..-1] key = conf.shift[1..-1]
@ -197,18 +197,18 @@ class Tk::PanedWindow<TkWindow
if key == 'hide' if key == 'hide'
conf[2] = bool(conf[2]) unless conf[2].empty? conf[2] = bool(conf[2]) unless conf[2].empty?
elsif conf[2].index('{') elsif conf[2].index('{')
conf[2] = tk_split_list(conf[2]) conf[2] = tk_split_list(conf[2])
else else
conf[2] = tk_tcl2ruby(conf[2]) conf[2] = tk_tcl2ruby(conf[2])
end end
end end
if conf[3] if conf[3]
if key == 'hide' if key == 'hide'
conf[3] = bool(conf[3]) unless conf[3].empty? conf[3] = bool(conf[3]) unless conf[3].empty?
elsif conf[3].index('{') elsif conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
if conf.size == 1 if conf.size == 1
@ -254,5 +254,7 @@ end
Tk::Panedwindow = Tk::PanedWindow Tk::Panedwindow = Tk::PanedWindow
#TkPanedWindow = Tk::PanedWindow unless Object.const_defined? :TkPanedWindow #TkPanedWindow = Tk::PanedWindow unless Object.const_defined? :TkPanedWindow
#TkPanedwindow = Tk::Panedwindow unless Object.const_defined? :TkPanedwindow #TkPanedwindow = Tk::Panedwindow unless Object.const_defined? :TkPanedwindow
Tk.__set_toplevel_aliases__(:Tk, Tk::PanedWindow, #Tk.__set_toplevel_aliases__(:Tk, Tk::PanedWindow,
:TkPanedWindow, :TkPanedwindow) # :TkPanedWindow, :TkPanedwindow)
Tk.__set_loaded_toplevel_aliases__('tk/panedwindow.rb', :Tk, Tk::PanedWindow,
:TkPanedWindow, :TkPanedwindow)

View file

@ -35,9 +35,9 @@ module TkPlace
# win = win.epath if win.kind_of?(TkObject) # win = win.epath if win.kind_of?(TkObject)
win = _epath(win) win = _epath(win)
if slot if slot
#conf = tk_split_list(tk_call_without_enc('place', 'configure', #conf = tk_split_list(tk_call_without_enc('place', 'configure',
# win, "-#{slot}") ) # win, "-#{slot}") )
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure', conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
win, "-#{slot}") ) win, "-#{slot}") )
conf[0] = conf[0][1..-1] conf[0] = conf[0][1..-1]
conf[1] = tk_tcl2ruby(conf[1]) conf[1] = tk_tcl2ruby(conf[1])
@ -46,7 +46,7 @@ module TkPlace
conf[4] = tk_tcl2ruby(conf[1]) conf[4] = tk_tcl2ruby(conf[1])
conf conf
else else
tk_split_simplelist(tk_call_without_enc('place', 'configure', tk_split_simplelist(tk_call_without_enc('place', 'configure',
win)).collect{|conflist| win)).collect{|conflist|
#conf = list(conflist) #conf = list(conflist)
conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)} conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)}
@ -63,16 +63,16 @@ module TkPlace
# win = win.epath if win.kind_of?(TkObject) # win = win.epath if win.kind_of?(TkObject)
win = _epath(win) win = _epath(win)
if slot if slot
#conf = tk_split_list(tk_call_without_enc('place', 'configure', #conf = tk_split_list(tk_call_without_enc('place', 'configure',
# win, "-#{slot}") ) # win, "-#{slot}") )
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure', conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
win, "-#{slot}") ) win, "-#{slot}") )
# { conf[0][1..-1] => conf[1] } # { conf[0][1..-1] => conf[1] }
{ conf[0][1..-1] => tk_tcl2ruby(conf[4]) } { conf[0][1..-1] => tk_tcl2ruby(conf[4]) }
else else
ret = {} ret = {}
#tk_split_list(tk_call_without_enc('place','configure',win)).each{|conf| #tk_split_list(tk_call_without_enc('place','configure',win)).each{|conf|
tk_split_simplelist(tk_call_without_enc('place', 'configure', tk_split_simplelist(tk_call_without_enc('place', 'configure',
win)).each{|conf_list| win)).each{|conf_list|
#ret[conf[0][1..-1]] = conf[1] #ret[conf[0][1..-1]] = conf[1]
conf = simplelist(conf_list) conf = simplelist(conf_list)

View file

@ -7,7 +7,7 @@ require 'tk/button'
class Tk::RadioButton<Tk::Button class Tk::RadioButton<Tk::Button
TkCommandNames = ['radiobutton'.freeze].freeze TkCommandNames = ['radiobutton'.freeze].freeze
WidgetClassName = 'Radiobutton'.freeze WidgetClassName = 'Radiobutton'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys) #def create_self(keys)
# if keys and keys != None # if keys and keys != None
# tk_call_without_enc('radiobutton', @path, *hash_kv(keys, true)) # tk_call_without_enc('radiobutton', @path, *hash_kv(keys, true))
@ -67,5 +67,7 @@ end
Tk::Radiobutton = Tk::RadioButton Tk::Radiobutton = Tk::RadioButton
#TkRadioButton = Tk::RadioButton unless Object.const_defined? :TkRadioButton #TkRadioButton = Tk::RadioButton unless Object.const_defined? :TkRadioButton
#TkRadiobutton = Tk::Radiobutton unless Object.const_defined? :TkRadiobutton #TkRadiobutton = Tk::Radiobutton unless Object.const_defined? :TkRadiobutton
Tk.__set_toplevel_aliases__(:Tk, Tk::RadioButton, #Tk.__set_toplevel_aliases__(:Tk, Tk::RadioButton,
:TkRadioButton, :TkRadiobutton) # :TkRadioButton, :TkRadiobutton)
Tk.__set_loaded_toplevel_aliases__('tk/radiobutton.rb', :Tk, Tk::RadioButton,
:TkRadioButton, :TkRadiobutton)

View file

@ -16,7 +16,7 @@ class Tk::Root<TkWindow
def Root.new(keys=nil, &b) def Root.new(keys=nil, &b)
unless TkCore::INTERP.tk_windows['.'] unless TkCore::INTERP.tk_windows['.']
TkCore::INTERP.tk_windows['.'] = TkCore::INTERP.tk_windows['.'] =
super(:without_creating=>true, :widgetname=>'.'){} super(:without_creating=>true, :widgetname=>'.'){}
end end
root = TkCore::INTERP.tk_windows['.'] root = TkCore::INTERP.tk_windows['.']
@ -52,7 +52,7 @@ class Tk::Root<TkWindow
end end
WidgetClassName = 'Tk'.freeze WidgetClassName = 'Tk'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def self.to_eval def self.to_eval
# self::WidgetClassName # self::WidgetClassName
@ -70,8 +70,8 @@ class Tk::Root<TkWindow
def add_menu(menu_info, tearoff=false, opts=nil) def add_menu(menu_info, tearoff=false, opts=nil)
# See tk/menuspec.rb for menu_info. # See tk/menuspec.rb for menu_info.
# opts is a hash of default configs for all of cascade menus. # opts is a hash of default configs for all of cascade menus.
# Configs of menu_info can override it. # Configs of menu_info can override it.
if tearoff.kind_of?(Hash) if tearoff.kind_of?(Hash)
opts = tearoff opts = tearoff
tearoff = false tearoff = false
@ -82,7 +82,7 @@ class Tk::Root<TkWindow
def add_menubar(menu_spec, tearoff=false, opts=nil) def add_menubar(menu_spec, tearoff=false, opts=nil)
# See tk/menuspec.rb for menu_spec. # See tk/menuspec.rb for menu_spec.
# opts is a hash of default configs for all of cascade menus. # opts is a hash of default configs for all of cascade menus.
# Configs of menu_spec can override it. # Configs of menu_spec can override it.
menu_spec.each{|info| add_menu(info, tearoff, opts)} menu_spec.each{|info| add_menu(info, tearoff, opts)}
self.menu self.menu
end end

View file

@ -6,7 +6,7 @@ require 'tk'
class Tk::Scale<TkWindow class Tk::Scale<TkWindow
TkCommandNames = ['scale'.freeze].freeze TkCommandNames = ['scale'.freeze].freeze
WidgetClassName = 'Scale'.freeze WidgetClassName = 'Scale'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def create_self(keys) def create_self(keys)
if keys and keys != None if keys and keys != None
@ -16,11 +16,11 @@ class Tk::Scale<TkWindow
end end
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
#tk_call_without_enc('scale', @path, *hash_kv(keys, true)) #tk_call_without_enc('scale', @path, *hash_kv(keys, true))
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
else else
begin begin
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
rescue rescue
tk_call_without_enc(self.class::TkCommandNames[0], @path) tk_call_without_enc(self.class::TkCommandNames[0], @path)
@ -33,7 +33,7 @@ class Tk::Scale<TkWindow
configure(keys) configure(keys)
else else
# re-create widget # re-create widget
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
end end
end end
@ -69,7 +69,7 @@ class Tk::Scale<TkWindow
def configure(slot, value=None) def configure(slot, value=None)
if (slot == 'command' || slot == :command) if (slot == 'command' || slot == :command)
configure('command'=>value) configure('command'=>value)
elsif slot.kind_of?(Hash) && elsif slot.kind_of?(Hash) &&
(slot.key?('command') || slot.key?(:command)) (slot.key?('command') || slot.key?(:command))
slot = _symbolkey2str(slot) slot = _symbolkey2str(slot)
slot['command'] = _wrap_command_arg(slot.delete('command')) slot['command'] = _wrap_command_arg(slot.delete('command'))
@ -108,4 +108,5 @@ class Tk::Scale<TkWindow
end end
#TkScale = Tk::Scale unless Object.const_defined? :TkScale #TkScale = Tk::Scale unless Object.const_defined? :TkScale
Tk.__set_toplevel_aliases__(:Tk, Tk::Scale, :TkScale) #Tk.__set_toplevel_aliases__(:Tk, Tk::Scale, :TkScale)
Tk.__set_loaded_toplevel_aliases__('tk/scale.rb', :Tk, Tk::Scale, :TkScale)

View file

@ -6,11 +6,11 @@ require 'tk'
class Tk::Scrollbar<TkWindow class Tk::Scrollbar<TkWindow
TkCommandNames = ['scrollbar'.freeze].freeze TkCommandNames = ['scrollbar'.freeze].freeze
WidgetClassName = 'Scrollbar'.freeze WidgetClassName = 'Scrollbar'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def create_self(keys) def create_self(keys)
@assigned = [] @assigned = []
@scroll_proc = proc{|*args| @scroll_proc = proc{|*args|
if self.orient == 'horizontal' if self.orient == 'horizontal'
@assigned.each{|w| w.xview(*args)} @assigned.each{|w| w.xview(*args)}
else # 'vertical' else # 'vertical'
@ -21,11 +21,11 @@ class Tk::Scrollbar<TkWindow
if keys and keys != None if keys and keys != None
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
#tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true)) #tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
else else
begin begin
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
rescue rescue
tk_call_without_enc(self.class::TkCommandNames[0], @path) tk_call_without_enc(self.class::TkCommandNames[0], @path)
@ -38,7 +38,7 @@ class Tk::Scrollbar<TkWindow
configure(keys) configure(keys)
else else
# re-create widget # re-create widget
tk_call_without_enc(self.class::TkCommandNames[0], @path, tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true)) *hash_kv(keys, true))
end end
end end
@ -148,7 +148,9 @@ class Tk::Scrollbar<TkWindow
end end
#TkScrollbar = Tk::Scrollbar unless Object.const_defined? :TkScrollbar #TkScrollbar = Tk::Scrollbar unless Object.const_defined? :TkScrollbar
Tk.__set_toplevel_aliases__(:Tk, Tk::Scrollbar, :TkScrollbar) #Tk.__set_toplevel_aliases__(:Tk, Tk::Scrollbar, :TkScrollbar)
Tk.__set_loaded_toplevel_aliases__('tk/scrollbar.rb', :Tk, Tk::Scrollbar,
:TkScrollbar)
class Tk::XScrollbar<Tk::Scrollbar class Tk::XScrollbar<Tk::Scrollbar
@ -161,7 +163,9 @@ class Tk::XScrollbar<Tk::Scrollbar
end end
#TkXScrollbar = Tk::XScrollbar unless Object.const_defined? :TkXScrollbar #TkXScrollbar = Tk::XScrollbar unless Object.const_defined? :TkXScrollbar
Tk.__set_toplevel_aliases__(:Tk, Tk::XScrollbar, :TkXScrollbar) #Tk.__set_toplevel_aliases__(:Tk, Tk::XScrollbar, :TkXScrollbar)
Tk.__set_loaded_toplevel_aliases__('tk/scrollbar.rb', :Tk, Tk::XScrollbar,
:TkXScrollbar)
class Tk::YScrollbar<Tk::Scrollbar class Tk::YScrollbar<Tk::Scrollbar
@ -174,4 +178,6 @@ class Tk::YScrollbar<Tk::Scrollbar
end end
#TkYScrollbar = Tk::YScrollbar unless Object.const_defined? :TkYScrollbar #TkYScrollbar = Tk::YScrollbar unless Object.const_defined? :TkYScrollbar
Tk.__set_toplevel_aliases__(:Tk, Tk::YScrollbar, :TkYScrollbar) #Tk.__set_toplevel_aliases__(:Tk, Tk::YScrollbar, :TkYScrollbar)
Tk.__set_loaded_toplevel_aliases__('tk/scrollbar.rb', :Tk, Tk::YScrollbar,
:TkYScrollbar)

View file

@ -18,7 +18,7 @@ module TkSelection
end end
def self.clear_on_display(win, sel=nil) def self.clear_on_display(win, sel=nil)
if sel if sel
tk_call_without_enc('selection', 'clear', tk_call_without_enc('selection', 'clear',
'-displayof', win, '-selection', sel) '-displayof', win, '-selection', sel)
else else
tk_call_without_enc('selection', 'clear', '-displayof', win) tk_call_without_enc('selection', 'clear', '-displayof', win)
@ -35,7 +35,7 @@ module TkSelection
end end
def self.get_on_display(win, keys=nil) def self.get_on_display(win, keys=nil)
#tk_call('selection', 'get', '-displayof', win, *hash_kv(keys)) #tk_call('selection', 'get', '-displayof', win, *hash_kv(keys))
_fromUTF8(tk_call_without_enc('selection', 'get', '-displayof', _fromUTF8(tk_call_without_enc('selection', 'get', '-displayof',
win, *hash_kv(keys))) win, *hash_kv(keys)))
end end
def get(keys=nil) def get(keys=nil)
@ -65,7 +65,7 @@ module TkSelection
end end
def self.get_owner_on_display(win, sel=nil) def self.get_owner_on_display(win, sel=nil)
if sel if sel
window(tk_call_without_enc('selection', 'own', window(tk_call_without_enc('selection', 'own',
'-displayof', win, '-selection', sel)) '-displayof', win, '-selection', sel))
else else
window(tk_call_without_enc('selection', 'own', '-displayof', win)) window(tk_call_without_enc('selection', 'own', '-displayof', win))

View file

@ -8,20 +8,20 @@ require 'tk/entry'
class Tk::Spinbox<Tk::Entry class Tk::Spinbox<Tk::Entry
TkCommandNames = ['spinbox'.freeze].freeze TkCommandNames = ['spinbox'.freeze].freeze
WidgetClassName = 'Spinbox'.freeze WidgetClassName = 'Spinbox'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
class SpinCommand < TkValidateCommand class SpinCommand < TkValidateCommand
class ValidateArgs < TkUtil::CallbackSubst class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [ KEY_TBL = [
[ ?d, ?s, :direction ], [ ?d, ?s, :direction ],
[ ?s, ?e, :current ], [ ?s, ?e, :current ],
[ ?W, ?w, :widget ], [ ?W, ?w, :widget ],
nil nil
] ]
PROC_TBL = [ PROC_TBL = [
[ ?s, TkComm.method(:string) ], [ ?s, TkComm.method(:string) ],
[ ?w, TkComm.method(:window) ], [ ?w, TkComm.method(:window) ],
[ ?e, proc{|val| [ ?e, proc{|val|
#enc = Tk.encoding #enc = Tk.encoding
@ -32,7 +32,7 @@ class Tk::Spinbox<Tk::Entry
TkComm::string(val) TkComm::string(val)
end end
} }
], ],
nil nil
] ]
@ -100,13 +100,36 @@ class Tk::Spinbox<Tk::Entry
tk_send_without_enc('identify', x, y) tk_send_without_enc('identify', x, y)
end end
def invoke(elem)
tk_send_without_enc('invoke', elem)
self
end
def spinup def spinup
tk_send_without_enc('invoke', 'spinup') begin
tk_send_without_enc('invoke', 'buttonup')
rescue RuntimeError => e
# old version of element?
begin
tk_send_without_enc('invoke', 'spinup')
rescue
fail e
end
end
self self
end end
def spindown def spindown
tk_send_without_enc('invoke', 'spindown') begin
tk_send_without_enc('invoke', 'buttondown')
rescue RuntimeError => e
# old version of element?
begin
tk_send_without_enc('invoke', 'spinup')
rescue
fail e
end
end
self self
end end
@ -116,4 +139,6 @@ class Tk::Spinbox<Tk::Entry
end end
#TkSpinbox = Tk::Spinbox unless Object.const_defined? :TkSpinbox #TkSpinbox = Tk::Spinbox unless Object.const_defined? :TkSpinbox
Tk.__set_toplevel_aliases__(:Tk, Tk::Spinbox, :TkSpinbox) #Tk.__set_toplevel_aliases__(:Tk, Tk::Spinbox, :TkSpinbox)
Tk.__set_loaded_toplevel_aliases__('tk/spinbox.rb', :Tk, Tk::Spinbox,
:TkSpinbox)

View file

@ -29,6 +29,9 @@ module TkTextTagConfig
end end
private :__item_pathname private :__item_pathname
def tag_cget_tkstring(tagOrId, option)
itemcget_tkstring(['tag', tagOrId], option)
end
def tag_cget(tagOrId, option) def tag_cget(tagOrId, option)
itemcget(['tag', tagOrId], option) itemcget(['tag', tagOrId], option)
end end
@ -45,6 +48,9 @@ module TkTextTagConfig
current_itemconfiginfo(['tag', tagOrId], slot) current_itemconfiginfo(['tag', tagOrId], slot)
end end
def window_cget_tkstring(tagOrId, option)
itemcget_tkstring(['window', tagOrId], option)
end
def window_cget(tagOrId, option) def window_cget(tagOrId, option)
itemcget(['window', tagOrId], option) itemcget(['window', tagOrId], option)
end end
@ -61,7 +67,7 @@ module TkTextTagConfig
current_itemconfiginfo(['window', tagOrId], slot) current_itemconfiginfo(['window', tagOrId], slot)
end end
private :itemcget, :itemcget_strict private :itemcget_tkstring, :itemcget, :itemcget_strict
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end end
@ -251,7 +257,7 @@ class Tk::Text<TkTextWin
TkCommandNames = ['text'.freeze].freeze TkCommandNames = ['text'.freeze].freeze
WidgetClassName = 'Text'.freeze WidgetClassName = 'Text'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def self.new(*args, &block) def self.new(*args, &block)
obj = super(*args){} obj = super(*args){}
@ -281,7 +287,7 @@ class Tk::Text<TkTextWin
def create_self(keys) def create_self(keys)
#if keys and keys != None #if keys and keys != None
# #tk_call_without_enc('text', @path, *hash_kv(keys, true)) # #tk_call_without_enc('text', @path, *hash_kv(keys, true))
# tk_call_without_enc(self.class::TkCommandNames[0], @path, # tk_call_without_enc(self.class::TkCommandNames[0], @path,
# *hash_kv(keys, true)) # *hash_kv(keys, true))
#else #else
# #tk_call_without_enc('text', @path) # #tk_call_without_enc('text', @path)
@ -306,7 +312,7 @@ class Tk::Text<TkTextWin
end end
def index(idx) def index(idx)
Tk::Text::IndexString.new(tk_send_without_enc('index', Tk::Text::IndexString.new(tk_send_without_enc('index',
_get_eval_enc_str(idx))) _get_eval_enc_str(idx)))
end end
@ -375,7 +381,7 @@ class Tk::Text<TkTextWin
def mark_gravity(mark, direction=nil) def mark_gravity(mark, direction=nil)
if direction if direction
tk_send_without_enc('mark', 'gravity', tk_send_without_enc('mark', 'gravity',
_get_eval_enc_str(mark), direction) _get_eval_enc_str(mark), direction)
self self
else else
@ -384,27 +390,27 @@ class Tk::Text<TkTextWin
end end
def mark_set(mark, index) def mark_set(mark, index)
tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark), tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
_get_eval_enc_str(index)) _get_eval_enc_str(index))
self self
end end
alias set_mark mark_set alias set_mark mark_set
def mark_unset(*marks) def mark_unset(*marks)
tk_send_without_enc('mark', 'unset', tk_send_without_enc('mark', 'unset',
*(marks.collect{|mark| _get_eval_enc_str(mark)})) *(marks.collect{|mark| _get_eval_enc_str(mark)}))
self self
end end
alias unset_mark mark_unset alias unset_mark mark_unset
def mark_next(index) def mark_next(index)
tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next', tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
_get_eval_enc_str(index)))) _get_eval_enc_str(index))))
end end
alias next_mark mark_next alias next_mark mark_next
def mark_previous(index) def mark_previous(index)
tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous', tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
_get_eval_enc_str(index)))) _get_eval_enc_str(index))))
end end
alias previous_mark mark_previous alias previous_mark mark_previous
@ -412,11 +418,11 @@ class Tk::Text<TkTextWin
def image_cget_strict(index, slot) def image_cget_strict(index, slot)
case slot.to_s case slot.to_s
when 'text', 'label', 'show', 'data', 'file' when 'text', 'label', 'show', 'data', 'file'
_fromUTF8(tk_send_without_enc('image', 'cget', _fromUTF8(tk_send_without_enc('image', 'cget',
_get_eval_enc_str(index), "-#{slot}")) _get_eval_enc_str(index), "-#{slot}"))
else else
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget', tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
_get_eval_enc_str(index), _get_eval_enc_str(index),
"-#{slot}"))) "-#{slot}")))
end end
end end
@ -445,13 +451,13 @@ class Tk::Text<TkTextWin
def image_configure(index, slot, value=None) def image_configure(index, slot, value=None)
if slot.kind_of?(Hash) if slot.kind_of?(Hash)
_fromUTF8(tk_send_without_enc('image', 'configure', _fromUTF8(tk_send_without_enc('image', 'configure',
_get_eval_enc_str(index), _get_eval_enc_str(index),
*hash_kv(slot, true))) *hash_kv(slot, true)))
else else
_fromUTF8(tk_send_without_enc('image', 'configure', _fromUTF8(tk_send_without_enc('image', 'configure',
_get_eval_enc_str(index), _get_eval_enc_str(index),
"-#{slot}", "-#{slot}",
_get_eval_enc_str(value))) _get_eval_enc_str(value)))
end end
self self
@ -481,16 +487,16 @@ class Tk::Text<TkTextWin
else else
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
if conf[4] if conf[4]
if conf[4].index('{') if conf[4].index('{')
conf[4] = tk_split_list(conf[4]) conf[4] = tk_split_list(conf[4])
else else
conf[4] = tk_tcl2ruby(conf[4]) conf[4] = tk_tcl2ruby(conf[4])
end end
end end
end end
@ -522,16 +528,16 @@ class Tk::Text<TkTextWin
else else
if conf[2] if conf[2]
if conf[2].index('{') if conf[2].index('{')
conf[2] = tk_split_list(conf[2]) conf[2] = tk_split_list(conf[2])
else else
conf[2] = tk_tcl2ruby(conf[2]) conf[2] = tk_tcl2ruby(conf[2])
end end
end end
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
end end
@ -620,7 +626,7 @@ class Tk::Text<TkTextWin
end end
def compare(idx1, op, idx2) def compare(idx1, op, idx2)
bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1), bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
op, _get_eval_enc_str(idx2))) op, _get_eval_enc_str(idx2)))
end end
@ -643,7 +649,7 @@ class Tk::Text<TkTextWin
def count_info(idx1, idx2, update=true) def count_info(idx1, idx2, update=true)
# Tk8.5 feature # Tk8.5 feature
opts = [ opts = [
:chars, :displaychars, :displayindices, :displaylines, :chars, :displaychars, :displayindices, :displaylines,
:indices, :lines, :xpixels, :ypixels :indices, :lines, :xpixels, :ypixels
] ]
if update if update
@ -737,8 +743,8 @@ class Tk::Text<TkTextWin
end end
def tag_add(tag, index1, index2=None) def tag_add(tag, index1, index2=None)
tk_send_without_enc('tag', 'add', _get_eval_enc_str(tag), tk_send_without_enc('tag', 'add', _get_eval_enc_str(tag),
_get_eval_enc_str(index1), _get_eval_enc_str(index1),
_get_eval_enc_str(index2)) _get_eval_enc_str(index2))
self self
end end
@ -746,15 +752,15 @@ class Tk::Text<TkTextWin
alias add_tag tag_add alias add_tag tag_add
def tag_delete(*tags) def tag_delete(*tags)
tk_send_without_enc('tag', 'delete', tk_send_without_enc('tag', 'delete',
*(tags.collect{|tag| _get_eval_enc_str(tag)})) *(tags.collect{|tag| _get_eval_enc_str(tag)}))
TkTextTag::TTagID_TBL.mutex.synchronize{ TkTextTag::TTagID_TBL.mutex.synchronize{
if TkTextTag::TTagID_TBL[@path] if TkTextTag::TTagID_TBL[@path]
tags.each{|tag| tags.each{|tag|
if tag.kind_of?(TkTextTag) if tag.kind_of?(TkTextTag)
TkTextTag::TTagID_TBL[@path].delete(tag.id) TkTextTag::TTagID_TBL[@path].delete(tag.id)
else else
TkTextTag::TTagID_TBL[@path].delete(tag) TkTextTag::TTagID_TBL[@path].delete(tag)
end end
} }
end end
@ -807,7 +813,7 @@ class Tk::Text<TkTextWin
def tag_cget(tag, key) def tag_cget(tag, key)
case key.to_s case key.to_s
when 'text', 'label', 'show', 'data', 'file' when 'text', 'label', 'show', 'data', 'file'
tk_call_without_enc(@path, 'tag', 'cget', tk_call_without_enc(@path, 'tag', 'cget',
_get_eval_enc_str(tag), "-#{key}") _get_eval_enc_str(tag), "-#{key}")
when 'font', 'kanjifont' when 'font', 'kanjifont'
#fnt = tk_tcl2ruby(tk_send('tag', 'cget', tag, "-#{key}")) #fnt = tk_tcl2ruby(tk_send('tag', 'cget', tag, "-#{key}"))
@ -833,14 +839,14 @@ class Tk::Text<TkTextWin
|| key['latinfont'] || key['asciifont'] ) || key['latinfont'] || key['asciifont'] )
tagfont_configure(tag, key) tagfont_configure(tag, key)
else else
tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag), tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag),
*hash_kv(key, true)) *hash_kv(key, true))
end end
else else
if key == 'font' || key == :font || if key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont || key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont || key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont key == 'asciifont' || key == :asciifont
if val == None if val == None
tagfontobj(tag) tagfontobj(tag)
@ -848,7 +854,7 @@ class Tk::Text<TkTextWin
tagfont_configure(tag, {key=>val}) tagfont_configure(tag, {key=>val})
end end
else else
tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag), tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag),
"-#{key}", _get_eval_enc_str(val)) "-#{key}", _get_eval_enc_str(val))
end end
end end
@ -878,16 +884,16 @@ class Tk::Text<TkTextWin
else else
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
if conf[4] if conf[4]
if conf[4].index('{') if conf[4].index('{')
conf[4] = tk_split_list(conf[4]) conf[4] = tk_split_list(conf[4])
else else
conf[4] = tk_tcl2ruby(conf[4]) conf[4] = tk_tcl2ruby(conf[4])
end end
end end
end end
@ -926,16 +932,16 @@ class Tk::Text<TkTextWin
else else
if conf[2] if conf[2]
if conf[2].index('{') if conf[2].index('{')
conf[2] = tk_split_list(conf[2]) conf[2] = tk_split_list(conf[2])
else else
conf[2] = tk_tcl2ruby(conf[2]) conf[2] = tk_tcl2ruby(conf[2])
end end
end end
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
end end
@ -980,19 +986,19 @@ class Tk::Text<TkTextWin
=end =end
def tag_raise(tag, above=None) def tag_raise(tag, above=None)
tk_send_without_enc('tag', 'raise', _get_eval_enc_str(tag), tk_send_without_enc('tag', 'raise', _get_eval_enc_str(tag),
_get_eval_enc_str(above)) _get_eval_enc_str(above))
self self
end end
def tag_lower(tag, below=None) def tag_lower(tag, below=None)
tk_send_without_enc('tag', 'lower', _get_eval_enc_str(tag), tk_send_without_enc('tag', 'lower', _get_eval_enc_str(tag),
_get_eval_enc_str(below)) _get_eval_enc_str(below))
self self
end end
def tag_remove(tag, *indices) def tag_remove(tag, *indices)
tk_send_without_enc('tag', 'remove', _get_eval_enc_str(tag), tk_send_without_enc('tag', 'remove', _get_eval_enc_str(tag),
*(indices.collect{|idx| _get_eval_enc_str(idx)})) *(indices.collect{|idx| _get_eval_enc_str(idx)}))
self self
end end
@ -1001,7 +1007,7 @@ class Tk::Text<TkTextWin
#l = tk_split_simplelist(tk_send_without_enc('tag', 'ranges', #l = tk_split_simplelist(tk_send_without_enc('tag', 'ranges',
# _get_eval_enc_str(tag))) # _get_eval_enc_str(tag)))
l = tk_split_simplelist(tk_send_without_enc('tag', 'ranges', l = tk_split_simplelist(tk_send_without_enc('tag', 'ranges',
_get_eval_enc_str(tag)), _get_eval_enc_str(tag)),
false, true) false, true)
r = [] r = []
while key=l.shift while key=l.shift
@ -1011,18 +1017,18 @@ class Tk::Text<TkTextWin
end end
def tag_nextrange(tag, first, last=None) def tag_nextrange(tag, first, last=None)
simplelist(tk_send_without_enc('tag', 'nextrange', simplelist(tk_send_without_enc('tag', 'nextrange',
_get_eval_enc_str(tag), _get_eval_enc_str(tag),
_get_eval_enc_str(first), _get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx| _get_eval_enc_str(last))).collect{|idx|
Tk::Text::IndexString.new(idx) Tk::Text::IndexString.new(idx)
} }
end end
def tag_prevrange(tag, first, last=None) def tag_prevrange(tag, first, last=None)
simplelist(tk_send_without_enc('tag', 'prevrange', simplelist(tk_send_without_enc('tag', 'prevrange',
_get_eval_enc_str(tag), _get_eval_enc_str(tag),
_get_eval_enc_str(first), _get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx| _get_eval_enc_str(last))).collect{|idx|
Tk::Text::IndexString.new(idx) Tk::Text::IndexString.new(idx)
} }
@ -1032,7 +1038,7 @@ class Tk::Text<TkTextWin
def window_cget(index, slot) def window_cget(index, slot)
case slot.to_s case slot.to_s
when 'text', 'label', 'show', 'data', 'file' when 'text', 'label', 'show', 'data', 'file'
_fromUTF8(tk_send_without_enc('window', 'cget', _fromUTF8(tk_send_without_enc('window', 'cget',
_get_eval_enc_str(index), "-#{slot}")) _get_eval_enc_str(index), "-#{slot}"))
when 'font', 'kanjifont' when 'font', 'kanjifont'
#fnt = tk_tcl2ruby(tk_send('window', 'cget', index, "-#{slot}")) #fnt = tk_tcl2ruby(tk_send('window', 'cget', index, "-#{slot}"))
@ -1076,12 +1082,12 @@ class Tk::Text<TkTextWin
slot['create'] = install_cmd(proc{_epath(p_create.call)}) slot['create'] = install_cmd(proc{_epath(p_create.call)})
end end
end end
tk_send_without_enc('window', 'configure', tk_send_without_enc('window', 'configure',
_get_eval_enc_str(index), _get_eval_enc_str(index),
*hash_kv(slot, true)) *hash_kv(slot, true))
else else
if slot == 'window' || slot == :window if slot == 'window' || slot == :window
# id = value # id = value
# value = id.epath if id.kind_of?(TkWindow) # value = id.epath if id.kind_of?(TkWindow)
value = _epath(value) value = _epath(value)
end end
@ -1101,8 +1107,8 @@ class Tk::Text<TkTextWin
value = install_cmd(proc{_epath(p_create.call)}) value = install_cmd(proc{_epath(p_create.call)})
end end
end end
tk_send_without_enc('window', 'configure', tk_send_without_enc('window', 'configure',
_get_eval_enc_str(index), _get_eval_enc_str(index),
"-#{slot}", _get_eval_enc_str(value)) "-#{slot}", _get_eval_enc_str(value))
end end
end end
@ -1129,16 +1135,16 @@ class Tk::Text<TkTextWin
else else
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
if conf[4] if conf[4]
if conf[4].index('{') if conf[4].index('{')
conf[4] = tk_split_list(conf[4]) conf[4] = tk_split_list(conf[4])
else else
conf[4] = tk_tcl2ruby(conf[4]) conf[4] = tk_tcl2ruby(conf[4])
end end
end end
end end
@ -1166,16 +1172,16 @@ class Tk::Text<TkTextWin
else else
if conf[2] if conf[2]
if conf[2].index('{') if conf[2].index('{')
conf[2] = tk_split_list(conf[2]) conf[2] = tk_split_list(conf[2])
else else
conf[2] = tk_tcl2ruby(conf[2]) conf[2] = tk_tcl2ruby(conf[2])
end end
end end
if conf[3] if conf[3]
if conf[3].index('{') if conf[3].index('{')
conf[3] = tk_split_list(conf[3]) conf[3] = tk_split_list(conf[3])
else else
conf[3] = tk_tcl2ruby(conf[3]) conf[3] = tk_tcl2ruby(conf[3])
end end
end end
end end
@ -1231,11 +1237,11 @@ class Tk::Text<TkTextWin
# $KCODE == 'NONE' # $KCODE == 'NONE'
if JAPANIZED_TK if JAPANIZED_TK
tk_call_without_enc('kstring', 'length', tk_call_without_enc('kstring', 'length',
_get_eval_enc_str(txt)).to_i _get_eval_enc_str(txt)).to_i
else else
begin begin
tk_call_without_enc('encoding', 'convertto', 'ascii', tk_call_without_enc('encoding', 'convertto', 'ascii',
_get_eval_enc_str(txt)).length _get_eval_enc_str(txt)).length
rescue StandardError, NameError rescue StandardError, NameError
# sorry, I have no plan # sorry, I have no plan
@ -1324,11 +1330,11 @@ class Tk::Text<TkTextWin
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
if pat.kind_of?(String) if pat.kind_of?(String)
#return [index(start + " + #{pos} chars"), pat.split('').length] #return [index(start + " + #{pos} chars"), pat.split('').length]
return [index(start + " + #{pos} chars"), return [index(start + " + #{pos} chars"),
_ktext_length(pat), pat.dup] _ktext_length(pat), pat.dup]
else else
#return [index(start + " + #{pos} chars"), $&.split('').length] #return [index(start + " + #{pos} chars"), $&.split('').length]
return [index(start + " + #{pos} chars"), return [index(start + " + #{pos} chars"),
_ktext_length(match), match] _ktext_length(match), match]
end end
else else
@ -1342,11 +1348,11 @@ class Tk::Text<TkTextWin
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
if pat.kind_of?(String) if pat.kind_of?(String)
#return [index(start + " + #{pos} chars"), pat.split('').length] #return [index(start + " + #{pos} chars"), pat.split('').length]
return [index(start + " + #{pos} chars"), return [index(start + " + #{pos} chars"),
_ktext_length(pat), pat.dup] _ktext_length(pat), pat.dup]
else else
#return [index(start + " + #{pos} chars"), $&.split('').length] #return [index(start + " + #{pos} chars"), $&.split('').length]
return [index(start + " + #{pos} chars"), return [index(start + " + #{pos} chars"),
_ktext_length(match), match] _ktext_length(match), match]
end end
else else
@ -1357,7 +1363,7 @@ class Tk::Text<TkTextWin
pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
if pat.kind_of?(String) if pat.kind_of?(String)
#return [index("1.0 + #{pos} chars"), pat.split('').length] #return [index("1.0 + #{pos} chars"), pat.split('').length]
return [index("1.0 + #{pos} chars"), return [index("1.0 + #{pos} chars"),
_ktext_length(pat), pat.dup] _ktext_length(pat), pat.dup]
else else
#return [index("1.0 + #{pos} chars"), $&.split('').length] #return [index("1.0 + #{pos} chars"), $&.split('').length]
@ -1447,7 +1453,7 @@ class Tk::Text<TkTextWin
idx = str.index(/ /, i) idx = str.index(/ /, i)
result.push str[i..(idx-1)] result.push str[i..(idx-1)]
i = idx + 1 i = idx + 1
# retrieve value # retrieve value
case result[-1] case result[-1]
when 'text' when 'text'
@ -1505,7 +1511,7 @@ class Tk::Text<TkTextWin
break break
end end
end end
kvis = [] kvis = []
until result.empty? until result.empty?
kvis.push [result.shift, result.shift, result.shift] kvis.push [result.shift, result.shift, result.shift]
@ -1570,7 +1576,8 @@ class Tk::Text<TkTextWin
end end
#TkText = Tk::Text unless Object.const_defined? :TkText #TkText = Tk::Text unless Object.const_defined? :TkText
Tk.__set_toplevel_aliases__(:Tk, Tk::Text, :TkText) #Tk.__set_toplevel_aliases__(:Tk, Tk::Text, :TkText)
Tk.__set_loaded_toplevel_aliases__('tk/text.rb', :Tk, Tk::Text, :TkText)
####################################### #######################################
@ -1587,7 +1594,8 @@ class Tk::Text::Peer < Tk::Text
def create_self(keys) def create_self(keys)
if keys and keys != None if keys and keys != None
tk_call_without_enc(@src_text.path, 'peer', 'create', @path) tk_call_without_enc(@src_text.path, 'peer', 'create',
@path, *hash_kv(keys, true))
else else
tk_call_without_enc(@src_text.path, 'peer', 'create', @path) tk_call_without_enc(@src_text.path, 'peer', 'create', @path)
end end

View file

@ -16,19 +16,19 @@ class TkTextImage<TkObject
@path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
elsif index.kind_of? TkTextMark elsif index.kind_of? TkTextMark
if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end') if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
'end - 1 chars')) 'end - 1 chars'))
else else
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
index.path)) index.path))
end end
else else
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
_get_eval_enc_str(index))) _get_eval_enc_str(index)))
end end
@path.gravity = 'left' @path.gravity = 'left'
@index = @path.path @index = @path.path
@id = tk_call_without_enc(@t.path, 'image', 'create', @index, @id = tk_call_without_enc(@t.path, 'image', 'create', @index,
*hash_kv(keys, true)).freeze *hash_kv(keys, true)).freeze
@path.gravity = 'right' @path.gravity = 'right'
end end
@ -78,7 +78,7 @@ class TkTextImage<TkObject
end end
def image=(value) def image=(value)
tk_call_without_enc(@t.path, 'image', 'configure', @index, '-image', tk_call_without_enc(@t.path, 'image', 'configure', @index, '-image',
_get_eval_enc_str(value)) _get_eval_enc_str(value))
#self #self
value value

View file

@ -9,7 +9,7 @@ class TkTextMark<TkObject
TMarkID_TBL = TkCore::INTERP.create_table TMarkID_TBL = TkCore::INTERP.create_table
(Tk_TextMark_ID = ['mark'.freeze, '00000'.taint]).instance_eval{ (Tk_TextMark_ID = ['mark'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -25,7 +25,7 @@ class TkTextMark<TkObject
if TMarkID_TBL[tpath] if TMarkID_TBL[tpath]
TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
else else
id id
end end
} }
end end
@ -46,7 +46,7 @@ class TkTextMark<TkObject
TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath] TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
TMarkID_TBL[@tpath][@id] = self TMarkID_TBL[@tpath][@id] = self
} }
tk_call_without_enc(@t.path, 'mark', 'set', @id, tk_call_without_enc(@t.path, 'mark', 'set', @id,
_get_eval_enc_str(index)) _get_eval_enc_str(index))
@t._addtag id, self @t._addtag id, self
end end
@ -100,7 +100,7 @@ class TkTextMark<TkObject
end end
def set(where) def set(where)
tk_call_without_enc(@t.path, 'mark', 'set', @id, tk_call_without_enc(@t.path, 'mark', 'set', @id,
_get_eval_enc_str(where)) _get_eval_enc_str(where))
self self
end end
@ -159,7 +159,7 @@ class TkTextNamedMark<TkTextMark
end end
if obj && index if obj && index
tk_call_without_enc(parent.path, 'mark', 'set', name, tk_call_without_enc(parent.path, 'mark', 'set', name,
_get_eval_enc_str(index)) _get_eval_enc_str(index))
end end
obj obj
@ -175,7 +175,7 @@ class TkTextNamedMark<TkTextMark
@parent = @t = parent @parent = @t = parent
@tpath = parent.path @tpath = parent.path
@path = @id = name @path = @id = name
tk_call_without_enc(@t.path, 'mark', 'set', @id, tk_call_without_enc(@t.path, 'mark', 'set', @id,
_get_eval_enc_str(index)) if index _get_eval_enc_str(index)) if index
@t._addtag @id, self @t._addtag @id, self
end end

View file

@ -11,7 +11,7 @@ class TkTextTag<TkObject
TTagID_TBL = TkCore::INTERP.create_table TTagID_TBL = TkCore::INTERP.create_table
(Tk_TextTag_ID = ['tag'.freeze, '00000'.taint]).instance_eval{ (Tk_TextTag_ID = ['tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -26,7 +26,7 @@ class TkTextTag<TkObject
TTagID_TBL.mutex.synchronize{ TTagID_TBL.mutex.synchronize{
if TTagID_TBL[tpath] if TTagID_TBL[tpath]
TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
else else
id id
end end
} }
@ -84,13 +84,13 @@ class TkTextTag<TkObject
end end
def add(*indices) def add(*indices)
tk_call_without_enc(@t.path, 'tag', 'add', @id, tk_call_without_enc(@t.path, 'tag', 'add', @id,
*(indices.collect{|idx| _get_eval_enc_str(idx)})) *(indices.collect{|idx| _get_eval_enc_str(idx)}))
self self
end end
def remove(*indices) def remove(*indices)
tk_call_without_enc(@t.path, 'tag', 'remove', @id, tk_call_without_enc(@t.path, 'tag', 'remove', @id,
*(indices.collect{|idx| _get_eval_enc_str(idx)})) *(indices.collect{|idx| _get_eval_enc_str(idx)}))
self self
end end
@ -105,16 +105,16 @@ class TkTextTag<TkObject
end end
def nextrange(first, last=None) def nextrange(first, last=None)
simplelist(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id, simplelist(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id,
_get_eval_enc_str(first), _get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx| _get_eval_enc_str(last))).collect{|idx|
Tk::Text::IndexString.new(idx) Tk::Text::IndexString.new(idx)
} }
end end
def prevrange(first, last=None) def prevrange(first, last=None)
simplelist(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id, simplelist(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id,
_get_eval_enc_str(first), _get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx| _get_eval_enc_str(last))).collect{|idx|
Tk::Text::IndexString.new(idx) Tk::Text::IndexString.new(idx)
} }
@ -129,6 +129,9 @@ class TkTextTag<TkObject
val val
end end
def cget_tkstring(key)
@t.tag_cget_tkstring @id, key
end
def cget(key) def cget(key)
@t.tag_cget @id, key @t.tag_cget @id, key
end end
@ -142,7 +145,7 @@ class TkTextTag<TkObject
_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget', @id, "-#{key}")) _fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget', @id, "-#{key}"))
when 'font', 'kanjifont' when 'font', 'kanjifont'
#fnt = tk_tcl2ruby(tk_call(@t.path, 'tag', 'cget', @id, "-#{key}")) #fnt = tk_tcl2ruby(tk_call(@t.path, 'tag', 'cget', @id, "-#{key}"))
fnt = tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget', fnt = tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
@id, '-font'))) @id, '-font')))
unless fnt.kind_of?(TkFont) unless fnt.kind_of?(TkFont)
fnt = tagfontobj(@id, fnt) fnt = tagfontobj(@id, fnt)
@ -154,7 +157,7 @@ class TkTextTag<TkObject
fnt fnt
end end
else else
tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget', tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
@id, "-#{key}"))) @id, "-#{key}")))
end end
end end
@ -227,13 +230,13 @@ class TkTextTag<TkObject
end end
def raise(above=None) def raise(above=None)
tk_call_without_enc(@t.path, 'tag', 'raise', @id, tk_call_without_enc(@t.path, 'tag', 'raise', @id,
_get_eval_enc_str(above)) _get_eval_enc_str(above))
self self
end end
def lower(below=None) def lower(below=None)
tk_call_without_enc(@t.path, 'tag', 'lower', @id, tk_call_without_enc(@t.path, 'tag', 'lower', @id,
_get_eval_enc_str(below)) _get_eval_enc_str(below))
self self
end end

View file

@ -13,14 +13,14 @@ class TkTextWindow<TkObject
#end #end
@t = parent @t = parent
if index == 'end' || index == :end if index == 'end' || index == :end
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
'end - 1 chars')) 'end - 1 chars'))
elsif index.kind_of?(TkTextMark) elsif index.kind_of?(TkTextMark)
if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end') if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
'end - 1 chars')) 'end - 1 chars'))
else else
@path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
index.path)) index.path))
end end
else else
@ -49,7 +49,7 @@ class TkTextWindow<TkObject
keys['create'] = install_cmd(proc{@id = @p_create.call; _epath(@id)}) keys['create'] = install_cmd(proc{@id = @p_create.call; _epath(@id)})
end end
end end
tk_call_without_enc(@t.path, 'window', 'create', @index, tk_call_without_enc(@t.path, 'window', 'create', @index,
*hash_kv(keys, true)) *hash_kv(keys, true))
@path.gravity = 'right' @path.gravity = 'right'
end end
@ -80,7 +80,7 @@ class TkTextWindow<TkObject
if slot.kind_of?(Hash) if slot.kind_of?(Hash)
slot = _symbolkey2str(slot) slot = _symbolkey2str(slot)
if slot['window'] if slot['window']
@id = slot['window'] @id = slot['window']
# slot['window'] = @id.epath if @id.kind_of?(TkWindow) # slot['window'] = @id.epath if @id.kind_of?(TkWindow)
slot['window'] = _epath(@id) if @id slot['window'] = _epath(@id) if @id
end end
@ -88,19 +88,19 @@ class TkTextWindow<TkObject
self.create=slot.delete('create') self.create=slot.delete('create')
end end
if slot.size > 0 if slot.size > 0
tk_call_without_enc(@t.path, 'window', 'configure', @index, tk_call_without_enc(@t.path, 'window', 'configure', @index,
*hash_kv(slot, true)) *hash_kv(slot, true))
end end
else else
if slot == 'window' || slot == :window if slot == 'window' || slot == :window
@id = value @id = value
# value = @id.epath if @id.kind_of?(TkWindow) # value = @id.epath if @id.kind_of?(TkWindow)
value = _epath(@id) if @id value = _epath(@id) if @id
end end
if slot == 'create' || slot == :create if slot == 'create' || slot == :create
self.create=value self.create=value
else else
tk_call_without_enc(@t.path, 'window', 'configure', @index, tk_call_without_enc(@t.path, 'window', 'configure', @index,
"-#{slot}", _get_eval_enc_str(value)) "-#{slot}", _get_eval_enc_str(value))
end end
end end
@ -123,7 +123,7 @@ class TkTextWindow<TkObject
@id = value @id = value
# value = @id.epath if @id.kind_of?(TkWindow) # value = @id.epath if @id.kind_of?(TkWindow)
value = _epath(@id) if @id value = _epath(@id) if @id
tk_call_without_enc(@t.path, 'window', 'configure', @index, tk_call_without_enc(@t.path, 'window', 'configure', @index,
'-window', _get_eval_enc_str(value)) '-window', _get_eval_enc_str(value))
value value
end end
@ -145,7 +145,7 @@ class TkTextWindow<TkObject
end end
}) })
end end
tk_call_without_enc(@t.path, 'window', 'configure', @index, tk_call_without_enc(@t.path, 'window', 'configure', @index,
'-create', _get_eval_enc_str(value)) '-create', _get_eval_enc_str(value))
value value
end end

View file

@ -11,13 +11,13 @@ class TkTimer
TkCommandNames = ['after'.freeze].freeze TkCommandNames = ['after'.freeze].freeze
(Tk_CBID = ['a'.freeze, '00000'.taint]).instance_eval{ (Tk_CBID = ['a'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
} }
Tk_CBTBL = {}.taint Tk_CBTBL = TkUtil.untrust({})
TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL') TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL')
if {[set st [catch {eval {ruby_cmd TkTimer callback} $id} ret]] != 0} { if {[set st [catch {eval {ruby_cmd TkTimer callback} $id} ret]] != 0} {
@ -76,7 +76,7 @@ class TkTimer
rescue Interrupt rescue Interrupt
exit!(1) exit!(1)
rescue Exception => e rescue Exception => e
if @cancel_on_exception && if @cancel_on_exception &&
@cancel_on_exception.find{|exc| e.kind_of?(exc)} @cancel_on_exception.find{|exc| e.kind_of?(exc)}
cancel cancel
@return_value = e @return_value = e
@ -180,12 +180,12 @@ class TkTimer
@after_script = nil @after_script = nil
@cancel_on_exception = DEFAULT_IGNORE_EXCEPTIONS @cancel_on_exception = DEFAULT_IGNORE_EXCEPTIONS
# Unless @cancel_on_exception, Ruby/Tk shows an error dialog box when # Unless @cancel_on_exception, Ruby/Tk shows an error dialog box when
# an excepsion is raised on TkTimer callback procedure. # an excepsion is raised on TkTimer callback procedure.
# If @cancel_on_exception is an array of exception classes and the raised # If @cancel_on_exception is an array of exception classes and the raised
# exception is included in the array, Ruby/Tk cancels executing TkTimer # exception is included in the array, Ruby/Tk cancels executing TkTimer
# callback procedures silently (TkTimer#cancel is called and no dialog is # callback procedures silently (TkTimer#cancel is called and no dialog is
# shown). # shown).
if b if b
case args.size case args.size
@ -229,7 +229,7 @@ class TkTimer
end end
def current_status def current_status
[@running, @current_sleep, @current_proc, @current_args, [@running, @current_sleep, @current_proc, @current_args,
@do_loop, @cancel_on_exception] @do_loop, @cancel_on_exception]
end end
@ -484,11 +484,11 @@ class TkTimer
def at_end(*arg, &b) def at_end(*arg, &b)
if arg.empty? if arg.empty?
if b if b
@at_end_proc = b @at_end_proc = b
else else
# no proc # no proc
return @at_end_proc return @at_end_proc
end end
else else
fail ArgumentError, "wrong number of arguments" if arg.length != 1 || b fail ArgumentError, "wrong number of arguments" if arg.length != 1 || b
@ -504,17 +504,17 @@ class TkTimer
unless @running unless @running
if @return_value.kind_of?(Exception) if @return_value.kind_of?(Exception)
fail @return_value fail @return_value
else else
return @return_value return @return_value
end end
end end
@wait_var.wait(on_thread, check_root) @wait_var.wait(on_thread, check_root)
if @return_value.kind_of?(Exception) if @return_value.kind_of?(Exception)
fail @return_value fail @return_value
else else
@return_value @return_value
end end
end end
def eventloop_wait(check_root = false) def eventloop_wait(check_root = false)
@ -628,12 +628,12 @@ class TkRTTimer < TkTimer
if @est_time if @est_time
@est_time = Time.at(@est_time.to_i, @est_time.usec + sleep*1000) @est_time = Time.at(@est_time.to_i, @est_time.usec + sleep*1000)
else else
@est_time = Time.at(@cb_start_time.to_i, @est_time = Time.at(@cb_start_time.to_i,
@cb_start_time.usec + sleep*1000) @cb_start_time.usec + sleep*1000)
end end
now = Time.now now = Time.now
real_sleep = ((@est_time.to_i - now.to_i + @offset_s)*1000.0 + real_sleep = ((@est_time.to_i - now.to_i + @offset_s)*1000.0 +
(@est_time.usec - now.usec + @offset_u)/1000.0).round (@est_time.usec - now.usec + @offset_u)/1000.0).round
if real_sleep <= 0 if real_sleep <= 0
real_sleep = 0 real_sleep = 0
@ -653,7 +653,7 @@ class TkRTTimer < TkTimer
if @current_sleep == 0 if @current_sleep == 0
@offset_list.push([ @offset_list.push([
@offset_s - @cb_start_time.to_i, @offset_s - @cb_start_time.to_i,
@offset_u - @cb_start_time.usec @offset_u - @cb_start_time.usec
]) ])
else else

View file

@ -11,7 +11,7 @@ class Tk::Toplevel<TkWindow
TkCommandNames = ['toplevel'.freeze].freeze TkCommandNames = ['toplevel'.freeze].freeze
WidgetClassName = 'Toplevel'.freeze WidgetClassName = 'Toplevel'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
################# old version ################# old version
# def initialize(parent=nil, screen=nil, classname=nil, keys=nil) # def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
@ -38,7 +38,7 @@ class Tk::Toplevel<TkWindow
# s << "-class" << @classname if @classname # s << "-class" << @classname if @classname
# s << "-colormap" << @colormap if @colormap # s << "-colormap" << @colormap if @colormap
# s << "-container" << @container if @container # s << "-container" << @container if @container
# s << "-screen" << @screen if @screen # s << "-screen" << @screen if @screen
# s << "-use" << @use if @use # s << "-use" << @use if @use
# s << "-visual" << @visual if @visual # s << "-visual" << @visual if @visual
# tk_call 'toplevel', @path, *s # tk_call 'toplevel', @path, *s
@ -113,7 +113,7 @@ class Tk::Toplevel<TkWindow
@use = keys['use'] @use = keys['use']
@visual = keys['visual'] @visual = keys['visual']
if !@classname && my_class_name if !@classname && my_class_name
keys['class'] = @classname = my_class_name keys['class'] = @classname = my_class_name
end end
if @classname.kind_of? TkBindTag if @classname.kind_of? TkBindTag
@db_class = @classname @db_class = @classname
@ -127,7 +127,7 @@ class Tk::Toplevel<TkWindow
end end
keys, cmds = _wm_command_option_chk(keys) keys, cmds = _wm_command_option_chk(keys)
super(keys) super(keys)
cmds.each{|k,v| cmds.each{|k,v|
if v.kind_of? Array if v.kind_of? Array
self.__send__(k,*v) self.__send__(k,*v)
else else
@ -162,7 +162,7 @@ class Tk::Toplevel<TkWindow
keys = {} keys = {}
end end
if !@classname && my_class_name if !@classname && my_class_name
keys['class'] = @classname = my_class_name keys['class'] = @classname = my_class_name
end end
if @classname.kind_of? TkBindTag if @classname.kind_of? TkBindTag
@db_class = @classname @db_class = @classname
@ -176,7 +176,7 @@ class Tk::Toplevel<TkWindow
end end
keys, cmds = _wm_command_option_chk(keys) keys, cmds = _wm_command_option_chk(keys)
super(parent, keys) super(parent, keys)
cmds.each{|k,v| cmds.each{|k,v|
if v.kind_of? Array if v.kind_of? Array
self.send(k,*v) self.send(k,*v)
else else
@ -200,8 +200,8 @@ class Tk::Toplevel<TkWindow
def add_menu(menu_info, tearoff=false, opts=nil) def add_menu(menu_info, tearoff=false, opts=nil)
# See tk/menuspec.rb for menu_info. # See tk/menuspec.rb for menu_info.
# opts is a hash of default configs for all of cascade menus. # opts is a hash of default configs for all of cascade menus.
# Configs of menu_info can override it. # Configs of menu_info can override it.
if tearoff.kind_of?(Hash) if tearoff.kind_of?(Hash)
opts = tearoff opts = tearoff
tearoff = false tearoff = false
@ -212,7 +212,7 @@ class Tk::Toplevel<TkWindow
def add_menubar(menu_spec, tearoff=false, opts=nil) def add_menubar(menu_spec, tearoff=false, opts=nil)
# See tk/menuspec.rb for menu_spec. # See tk/menuspec.rb for menu_spec.
# opts is a hash of default configs for all of cascade menus. # opts is a hash of default configs for all of cascade menus.
# Configs of menu_spec can override it. # Configs of menu_spec can override it.
menu_spec.each{|info| add_menu(info, tearoff, opts)} menu_spec.each{|info| add_menu(info, tearoff, opts)}
self.menu self.menu
end end
@ -259,4 +259,6 @@ class Tk::Toplevel<TkWindow
end end
#TkToplevel = Tk::Toplevel unless Object.const_defined? :TkToplevel #TkToplevel = Tk::Toplevel unless Object.const_defined? :TkToplevel
Tk.__set_toplevel_aliases__(:Tk, Tk::Toplevel, :TkToplevel) #Tk.__set_toplevel_aliases__(:Tk, Tk::Toplevel, :TkToplevel)
Tk.__set_loaded_toplevel_aliases__('tk/toplevel.rb', :Tk, Tk::Toplevel,
:TkToplevel)

View file

@ -5,70 +5,92 @@
# toplevel classes/modules # toplevel classes/modules
module Tk module Tk
@TOPLEVEL_ALIAS_TABLE[:Ttk] = { @TOPLEVEL_ALIAS_TABLE[:Ttk] = {
:TkButton => 'tkextlib/tile/tbutton', :TkButton => 'tkextlib/tile/tbutton',
:TkCheckbutton => 'tkextlib/tile/tcheckbutton', :TkCheckbutton => 'tkextlib/tile/tcheckbutton',
:TkCheckButton => 'tkextlib/tile/tcheckbutton', :TkCheckButton => 'tkextlib/tile/tcheckbutton',
# :TkDialog => 'tkextlib/tile/dialog', # :TkDialog => 'tkextlib/tile/dialog',
:TkEntry => 'tkextlib/tile/tentry', :TkEntry => 'tkextlib/tile/tentry',
:TkCombobox => 'tkextlib/tile/tcombobox', :TkCombobox => 'tkextlib/tile/tcombobox',
:TkFrame => 'tkextlib/tile/tframe', :TkFrame => 'tkextlib/tile/tframe',
:TkLabel => 'tkextlib/tile/tlabel', :TkLabel => 'tkextlib/tile/tlabel',
:TkLabelframe => 'tkextlib/tile/tlabelframe', :TkLabelframe => 'tkextlib/tile/tlabelframe',
:TkLabelFrame => 'tkextlib/tile/tlabelframe', :TkLabelFrame => 'tkextlib/tile/tlabelframe',
:TkMenubutton => 'tkextlib/tile/tmenubutton', :TkMenubutton => 'tkextlib/tile/tmenubutton',
:TkMenuButton => 'tkextlib/tile/tmenubutton', :TkMenuButton => 'tkextlib/tile/tmenubutton',
:TkNotebook => 'tkextlib/tile/tnotebook', :TkNotebook => 'tkextlib/tile/tnotebook',
# :TkPaned => 'tkextlib/tile/tpaned', # :TkPaned => 'tkextlib/tile/tpaned',
:TkPanedwindow => 'tkextlib/tile/tpaned', :TkPanedwindow => 'tkextlib/tile/tpaned',
:TkPanedWindow => 'tkextlib/tile/tpaned', :TkPanedWindow => 'tkextlib/tile/tpaned',
:TkProgressbar => 'tkextlib/tile/tprogressbar', :TkProgressbar => 'tkextlib/tile/tprogressbar',
:TkRadiobutton => 'tkextlib/tile/tradiobutton', :TkRadiobutton => 'tkextlib/tile/tradiobutton',
:TkRadioButton => 'tkextlib/tile/tradiobutton', :TkRadioButton => 'tkextlib/tile/tradiobutton',
:TkScale => 'tkextlib/tile/tscale', :TkScale => 'tkextlib/tile/tscale',
# :TkProgress => 'tkextlib/tile/tscale', # :TkProgress => 'tkextlib/tile/tscale',
:TkScrollbar => 'tkextlib/tile/tscrollbar', :TkScrollbar => 'tkextlib/tile/tscrollbar',
:TkXScrollbar => 'tkextlib/tile/tscrollbar', :TkXScrollbar => 'tkextlib/tile/tscrollbar',
:TkYScrollbar => 'tkextlib/tile/tscrollbar', :TkYScrollbar => 'tkextlib/tile/tscrollbar',
:TkSeparator => 'tkextlib/tile/tseparator', :TkSeparator => 'tkextlib/tile/tseparator',
:TkSizeGrip => 'tkextlib/tile/sizegrip', :TkSizeGrip => 'tkextlib/tile/sizegrip',
:TkSizegrip => 'tkextlib/tile/sizegrip', :TkSizegrip => 'tkextlib/tile/sizegrip',
# :TkSquare => 'tkextlib/tile/tsquare', # :TkSquare => 'tkextlib/tile/tsquare',
:TkTreeview => 'tkextlib/tile/treeview', :TkTreeview => 'tkextlib/tile/treeview',
} }
@TOPLEVEL_ALIAS_TABLE[:Tile] = @TOPLEVEL_ALIAS_TABLE[:Ttk]
# @TOPLEVEL_ALIAS_TABLE[:Tile] = @TOPLEVEL_ALIAS_TABLE[:Ttk]
Tk.__create_widget_set__(:Tile, :Ttk)
############################################
# depend on the version of Tcl/Tk
major, minor, type, patchlevel = TclTkLib.get_version
# ttk::spinbox is supported on Tcl/Tk8.6b1 or later
if ([major,minor,type,patchlevel] <=>
[8,6,TclTkLib::RELEASE_TYPE::BETA,1]) >= 0
@TOPLEVEL_ALIAS_TABLE[:Ttk].update(
:TkSpinbox => 'tkextlib/tile/tspinbox'
)
end
################################################ ################################################
# register some Ttk widgets as default # register some Ttk widgets as default
# (Ttk is a standard library on Tcl/Tk8.5+) # (Ttk is a standard library on Tcl/Tk8.5+)
@TOPLEVEL_ALIAS_TABLE[:Ttk].each{|sym, file| @TOPLEVEL_ALIAS_TABLE[:Ttk].each{|sym, file|
unless Object.autoload?(sym) || Object.const_defined?(sym) #unless Tk::TOPLEVEL_ALIASES.autoload?(sym) || Tk::TOPLEVEL_ALIASES.const_defined?(sym)
Object.autoload(sym, file) # @TOPLEVEL_ALIAS_OWNER[sym] = :Ttk
end # Tk::TOPLEVEL_ALIASES.autoload(sym, file)
#end
Tk.__regist_toplevel_aliases__(:Ttk, file, sym)
} }
################################################ ################################################
@TOPLEVEL_ALIAS_SETUP_PROC[:Tile] = # @TOPLEVEL_ALIAS_SETUP_PROC[:Tile] =
@TOPLEVEL_ALIAS_SETUP_PROC[:Ttk] = proc{|mod| # @TOPLEVEL_ALIAS_SETUP_PROC[:Ttk] = proc{|mod|
unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile) # unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
# Object.autoload :Ttk, 'tkextlib/tile'
# Tk.autoload :Tile, 'tkextlib/tile'
# end
# }
Tk.__toplevel_alias_setup_proc__(:Ttk, :Tile){|mod|
unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
Object.autoload :Ttk, 'tkextlib/tile' Object.autoload :Ttk, 'tkextlib/tile'
Tk.autoload :Tile, 'tkextlib/tile' Tk.autoload :Tile, 'tkextlib/tile'
end end

View file

@ -211,21 +211,21 @@ class TkValidateCommand
class ValidateArgs < TkUtil::CallbackSubst class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [ KEY_TBL = [
[ ?d, ?n, :action ], [ ?d, ?n, :action ],
[ ?i, ?x, :index ], [ ?i, ?x, :index ],
[ ?s, ?e, :current ], [ ?s, ?e, :current ],
[ ?v, ?s, :type ], [ ?v, ?s, :type ],
[ ?P, ?e, :value ], [ ?P, ?e, :value ],
[ ?S, ?e, :string ], [ ?S, ?e, :string ],
[ ?V, ?s, :triggered ], [ ?V, ?s, :triggered ],
[ ?W, ?w, :widget ], [ ?W, ?w, :widget ],
nil nil
] ]
PROC_TBL = [ PROC_TBL = [
[ ?n, TkComm.method(:number) ], [ ?n, TkComm.method(:number) ],
[ ?s, TkComm.method(:string) ], [ ?s, TkComm.method(:string) ],
[ ?w, TkComm.method(:window) ], [ ?w, TkComm.method(:window) ],
[ ?e, proc{|val| [ ?e, proc{|val|
#enc = Tk.encoding #enc = Tk.encoding
@ -236,7 +236,7 @@ class TkValidateCommand
TkComm::string(val) TkComm::string(val)
end end
} }
], ],
[ ?x, proc{|val| [ ?x, proc{|val|
idx = TkComm::number(val) idx = TkComm::number(val)
@ -246,7 +246,7 @@ class TkValidateCommand
idx idx
end end
} }
], ],
nil nil
] ]
@ -272,7 +272,7 @@ class TkValidateCommand
_setup_subst_table(KEY_TBL, PROC_TBL); _setup_subst_table(KEY_TBL, PROC_TBL);
# #
# NOTE: The order of parameters which passed to callback procedure is # NOTE: The order of parameters which passed to callback procedure is
# <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ... # <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
# #

View file

@ -16,7 +16,7 @@ class TkVariable
#TkVar_ID_TBL = {} #TkVar_ID_TBL = {}
TkVar_CB_TBL = TkCore::INTERP.create_table TkVar_CB_TBL = TkCore::INTERP.create_table
TkVar_ID_TBL = TkCore::INTERP.create_table TkVar_ID_TBL = TkCore::INTERP.create_table
(Tk_VARIABLE_ID = ["v".freeze, "00000".taint]).instance_eval{ (Tk_VARIABLE_ID = ["v".freeze, TkUtil.untrust("00000")]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -26,10 +26,10 @@ class TkVariable
TkVar_ID_TBL.mutex.synchronize{ TkVar_ID_TBL.clear } TkVar_ID_TBL.mutex.synchronize{ TkVar_ID_TBL.clear }
} }
major, minor, type, type_name, patchlevel = TclTkLib.get_version major, minor, type, patchlevel = TclTkLib.get_version
USE_OLD_TRACE_OPTION_STYLE = (major < 8) || (major == 8 && minor < 4) USE_OLD_TRACE_OPTION_STYLE = (major < 8) || (major == 8 && minor < 4)
#TkCore::INTERP.add_tk_procs('rb_var', 'args', #TkCore::INTERP.add_tk_procs('rb_var', 'args',
# "ruby [format \"TkVariable.callback %%Q!%s!\" $args]") # "ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL') TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
if {[set st [catch {eval {ruby_cmd TkVariable callback} $args} ret]] != 0} { if {[set st [catch {eval {ruby_cmd TkVariable callback} $args} ret]] != 0} {
@ -65,10 +65,10 @@ class TkVariable
exit!(1) exit!(1)
rescue Exception => e rescue Exception => e
begin begin
msg = _toUTF8(e.class.inspect) + ': ' + msg = _toUTF8(e.class.inspect) + ': ' +
_toUTF8(e.message) + "\n" + _toUTF8(e.message) + "\n" +
"\n---< backtrace of Ruby side >-----\n" + "\n---< backtrace of Ruby side >-----\n" +
_toUTF8(e.backtrace.join("\n")) + _toUTF8(e.backtrace.join("\n")) +
"\n---< backtrace of Tk side >-------" "\n---< backtrace of Tk side >-------"
if TkCore::WITH_ENCODING if TkCore::WITH_ENCODING
msg.force_encoding('utf-8') msg.force_encoding('utf-8')
@ -76,9 +76,9 @@ class TkVariable
msg.instance_variable_set(:@encoding, 'utf-8') msg.instance_variable_set(:@encoding, 'utf-8')
end end
rescue Exception rescue Exception
msg = e.class.inspect + ': ' + e.message + "\n" + msg = e.class.inspect + ': ' + e.message + "\n" +
"\n---< backtrace of Ruby side >-----\n" + "\n---< backtrace of Ruby side >-----\n" +
e.backtrace.join("\n") + e.backtrace.join("\n") +
"\n---< backtrace of Tk side >-------" "\n---< backtrace of Tk side >-------"
end end
fail(e, msg) fail(e, msg)
@ -94,7 +94,7 @@ class TkVariable
_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op)) _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
rescue rescue
trace = $!.backtrace trace = $!.backtrace
raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
"\tfrom #{trace[1..pos].join("\n\tfrom ")}" "\tfrom #{trace[1..pos].join("\n\tfrom ")}"
end end
=end =end
@ -112,7 +112,7 @@ class TkVariable
end end
# #
# default_value is available only when the variable is an assoc array. # default_value is available only when the variable is an assoc array.
# #
def default_value(val=nil, &b) def default_value(val=nil, &b)
if b if b
@ -322,7 +322,7 @@ class TkVariable
=begin =begin
if val == [] if val == []
# INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)', # INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)',
# @id, @id, @id)) # @id, @id, @id))
elsif val.kind_of?(Array) elsif val.kind_of?(Array)
a = [] a = []
@ -370,7 +370,7 @@ class TkVariable
else else
INTERP._thread_vwait(@id) INTERP._thread_vwait(@id)
end end
else else
if check_root if check_root
INTERP._invoke_without_enc('tkwait', 'variable', @id) INTERP._invoke_without_enc('tkwait', 'variable', @id)
else else
@ -421,7 +421,7 @@ class TkVariable
else else
# array # array
index = elems.collect{|idx| _get_eval_string(idx, true)}.join(',') index = elems.collect{|idx| _get_eval_string(idx, true)}.join(',')
TkComm.bool(tk_call('info', 'exist', "#{@id}")) && TkComm.bool(tk_call('info', 'exist', "#{@id}")) &&
TkComm.bool(tk_call('info', 'exist', "#{@id}(#{index})")) TkComm.bool(tk_call('info', 'exist', "#{@id}(#{index})"))
end end
end end
@ -433,7 +433,7 @@ class TkVariable
#tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}")) #tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}"))
INTERP._invoke_without_enc('global', @id) INTERP._invoke_without_enc('global', @id)
#tk_split_simplelist(INTERP._fromUTF8(INTERP._invoke_without_enc('array', 'names', @id))) #tk_split_simplelist(INTERP._fromUTF8(INTERP._invoke_without_enc('array', 'names', @id)))
tk_split_simplelist(INTERP._invoke_without_enc('array', 'names', @id), tk_split_simplelist(INTERP._invoke_without_enc('array', 'names', @id),
false, true) false, true)
end end
@ -484,9 +484,9 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
if val.kind_of?(Hash) if val.kind_of?(Hash)
self.clear self.clear
val.each{|k, v| val.each{|k, v|
#INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(k)), #INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(k)),
# _toUTF8(_get_eval_string(v))) # _toUTF8(_get_eval_string(v)))
INTERP._set_global_var2(@id, _get_eval_string(k, true), INTERP._set_global_var2(@id, _get_eval_string(k, true),
_get_eval_string(v, true)) _get_eval_string(v, true))
} }
self.value self.value
@ -494,11 +494,11 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
=begin =begin
INTERP._set_global_var(@id, '') INTERP._set_global_var(@id, '')
val.each{|v| val.each{|v|
#INTERP._set_variable(@id, _toUTF8(_get_eval_string(v)), #INTERP._set_variable(@id, _toUTF8(_get_eval_string(v)),
INTERP._set_variable(@id, _get_eval_string(v, true), INTERP._set_variable(@id, _get_eval_string(v, true),
TclTkLib::VarAccessFlag::GLOBAL_ONLY | TclTkLib::VarAccessFlag::GLOBAL_ONLY |
TclTkLib::VarAccessFlag::LEAVE_ERR_MSG | TclTkLib::VarAccessFlag::LEAVE_ERR_MSG |
TclTkLib::VarAccessFlag::APPEND_VALUE | TclTkLib::VarAccessFlag::APPEND_VALUE |
TclTkLib::VarAccessFlag::LIST_ELEMENT) TclTkLib::VarAccessFlag::LIST_ELEMENT)
} }
self.value self.value
@ -535,9 +535,9 @@ if USE_TCLs_SET_VARIABLE_FUNCTIONS
val = val._value if !type && type != :variable && val.kind_of?(TkVariable) val = val._value if !type && type != :variable && val.kind_of?(TkVariable)
index = args.collect{|idx| _get_eval_string(idx, true)}.join(',') index = args.collect{|idx| _get_eval_string(idx, true)}.join(',')
_fromUTF8(INTERP._set_global_var2(@id, index, _get_eval_string(val, true))) _fromUTF8(INTERP._set_global_var2(@id, index, _get_eval_string(val, true)))
#_fromUTF8(INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(index)), #_fromUTF8(INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(index)),
# _toUTF8(_get_eval_string(val)))) # _toUTF8(_get_eval_string(val))))
#_fromUTF8(INTERP._set_global_var2(@id, _get_eval_string(index, true), #_fromUTF8(INTERP._set_global_var2(@id, _get_eval_string(index, true),
# _get_eval_string(val, true))) # _get_eval_string(val, true)))
end end
@ -562,7 +562,7 @@ else
#INTERP._eval(Kernel.format('set %s', @id)) #INTERP._eval(Kernel.format('set %s', @id))
#INTERP._invoke_without_enc('set', @id) #INTERP._invoke_without_enc('set', @id)
rescue rescue
if INTERP._eval(Kernel.format('global %s; array exists %s', if INTERP._eval(Kernel.format('global %s; array exists %s',
@id, @id)) != "1" @id, @id)) != "1"
#if INTERP._eval(Kernel.format('array exists %s', @id)) != "1" #if INTERP._eval(Kernel.format('array exists %s', @id)) != "1"
#if INTERP._invoke_without_enc('array', 'exists', @id) != "1" #if INTERP._invoke_without_enc('array', 'exists', @id) != "1"
@ -583,7 +583,7 @@ else
#INTERP._eval(Kernel.format('set %s %s', @id, s)) #INTERP._eval(Kernel.format('set %s %s', @id, s))
#_fromUTF8(INTERP._invoke_without_enc('set', @id, _toUTF8(s))) #_fromUTF8(INTERP._invoke_without_enc('set', @id, _toUTF8(s)))
rescue rescue
if INTERP._eval(Kernel.format('global %s; array exists %s', if INTERP._eval(Kernel.format('global %s; array exists %s',
@id, @id)) != "1" @id, @id)) != "1"
#if INTERP._eval(Kernel.format('array exists %s', @id)) != "1" #if INTERP._eval(Kernel.format('array exists %s', @id)) != "1"
#if INTERP._invoke_without_enc('array', 'exists', @id) != "1" #if INTERP._invoke_without_enc('array', 'exists', @id) != "1"
@ -591,7 +591,7 @@ else
else else
if val == [] if val == []
INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id)) INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id))
#INTERP._eval(Kernel.format('unset %s; set %s(0) 0; unset %s(0)', #INTERP._eval(Kernel.format('unset %s; set %s(0) 0; unset %s(0)',
# @id, @id, @id)) # @id, @id, @id))
#INTERP._invoke_without_enc('unset', @id) #INTERP._invoke_without_enc('unset', @id)
#INTERP._invoke_without_enc('set', @id+'(0)', 0) #INTERP._invoke_without_enc('set', @id+'(0)', 0)
@ -601,9 +601,9 @@ else
val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e, true))} val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e, true))}
#s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"' #s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"' s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s', INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
@id, @id, @id, s)) @id, @id, @id, s))
#INTERP._eval(Kernel.format('unset %s; array set %s %s', #INTERP._eval(Kernel.format('unset %s; array set %s %s',
# @id, @id, s)) # @id, @id, s))
#INTERP._invoke_without_enc('unset', @id) #INTERP._invoke_without_enc('unset', @id)
#_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s))) #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
@ -612,9 +612,9 @@ else
# .gsub(/[\[\]$"]/, '\\\\\&') + '"' # .gsub(/[\[\]$"]/, '\\\\\&') + '"'
s = '"' + val.to_a.collect{|e| array2tk_list(e, true)}.join(" ")\ s = '"' + val.to_a.collect{|e| array2tk_list(e, true)}.join(" ")\
.gsub(/[\[\]$\\"]/, '\\\\\&') + '"' .gsub(/[\[\]$\\"]/, '\\\\\&') + '"'
INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s', INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
@id, @id, @id, s)) @id, @id, @id, s))
#INTERP._eval(Kernel.format('unset %s; array set %s %s', #INTERP._eval(Kernel.format('unset %s; array set %s %s',
# @id, @id, s)) # @id, @id, s))
#INTERP._invoke_without_enc('unset', @id) #INTERP._invoke_without_enc('unset', @id)
#_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s))) #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
@ -640,7 +640,7 @@ else
end end
end end
#INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index)) #INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index))
#INTERP._eval(Kernel.format('global %s; set %s(%s)', #INTERP._eval(Kernel.format('global %s; set %s(%s)',
# @id, @id, _get_eval_string(index))) # @id, @id, _get_eval_string(index)))
#INTERP._eval(Kernel.format('set %s(%s)', @id, _get_eval_string(index))) #INTERP._eval(Kernel.format('set %s(%s)', @id, _get_eval_string(index)))
#INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ')') #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ')')
@ -651,13 +651,13 @@ else
type = default_element_value_type(args) type = default_element_value_type(args)
val = val._value if !type && type != :variable && val.kind_of?(TkVariable) val = val._value if !type && type != :variable && val.kind_of?(TkVariable)
index = args.collect{|idx| _get_eval_string(idx)}.join(',') index = args.collect{|idx| _get_eval_string(idx)}.join(',')
INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id, INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
index, _get_eval_string(val))) index, _get_eval_string(val)))
#INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id, #INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
# _get_eval_string(index), _get_eval_string(val))) # _get_eval_string(index), _get_eval_string(val)))
#INTERP._eval(Kernel.format('set %s(%s) %s', @id, #INTERP._eval(Kernel.format('set %s(%s) %s', @id,
# _get_eval_string(index), _get_eval_string(val))) # _get_eval_string(index), _get_eval_string(val)))
#INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ') ' + #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ') ' +
# _get_eval_string(val)) # _get_eval_string(val))
end end
@ -669,7 +669,7 @@ else
else else
index = elems.collect{|idx| _get_eval_string(idx, true)}.join(',') index = elems.collect{|idx| _get_eval_string(idx, true)}.join(',')
INTERP._eval(Kernel.format('global %s; unset %s(%s)', @id, @id, index)) INTERP._eval(Kernel.format('global %s; unset %s(%s)', @id, @id, index))
#INTERP._eval(Kernel.format('global %s; unset %s(%s)', #INTERP._eval(Kernel.format('global %s; unset %s(%s)',
# @id, @id, _get_eval_string(elem))) # @id, @id, _get_eval_string(elem)))
#INTERP._eval(Kernel.format('unset %s(%s)', @id, tk_tcl2ruby(elem))) #INTERP._eval(Kernel.format('unset %s(%s)', @id, tk_tcl2ruby(elem)))
#INTERP._eval('unset ' + @id + '(' + _get_eval_string(elem) + ')') #INTERP._eval('unset ' + @id + '(' + _get_eval_string(elem) + ')')
@ -1239,6 +1239,14 @@ end
end end
end end
def ===(other)
if other.kind_of?(TkVariable)
self.id == other.id
else
super
end
end
def zero? def zero?
numeric.zero? numeric.zero?
end end
@ -1348,10 +1356,10 @@ end
TkVar_CB_TBL[@id] = self TkVar_CB_TBL[@id] = self
@trace_opts = opts @trace_opts = opts
if USE_OLD_TRACE_OPTION_STYLE if USE_OLD_TRACE_OPTION_STYLE
Tk.tk_call_without_enc('trace', 'variable', Tk.tk_call_without_enc('trace', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
else else
Tk.tk_call_without_enc('trace', 'add', 'variable', Tk.tk_call_without_enc('trace', 'add', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
else else
@ -1359,19 +1367,19 @@ end
if USE_OLD_TRACE_OPTION_STYLE if USE_OLD_TRACE_OPTION_STYLE
opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)} opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
if newopts != @trace_opts if newopts != @trace_opts
Tk.tk_call_without_enc('trace', 'vdelete', Tk.tk_call_without_enc('trace', 'vdelete',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
@trace_opts.replace(newopts) @trace_opts.replace(newopts)
Tk.tk_call_without_enc('trace', 'variable', Tk.tk_call_without_enc('trace', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
else else
newopts |= opts newopts |= opts
unless (newopts - @trace_opts).empty? unless (newopts - @trace_opts).empty?
Tk.tk_call_without_enc('trace', 'remove', 'variable', Tk.tk_call_without_enc('trace', 'remove', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
@trace_opts.replace(newopts) @trace_opts.replace(newopts)
Tk.tk_call_without_enc('trace', 'add', 'variable', Tk.tk_call_without_enc('trace', 'add', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
end end
@ -1382,7 +1390,7 @@ end
def trace_element(elem, opts, cmd = Proc.new) def trace_element(elem, opts, cmd = Proc.new)
if @elem if @elem
fail(RuntimeError, fail(RuntimeError,
"invalid for a TkVariable which denotes an element of Tcl's array") "invalid for a TkVariable which denotes an element of Tcl's array")
end end
@ -1394,10 +1402,10 @@ end
TkVar_CB_TBL[@id] = self TkVar_CB_TBL[@id] = self
@trace_opts = opts @trace_opts = opts
if USE_OLD_TRACE_OPTION_STYLE if USE_OLD_TRACE_OPTION_STYLE
Tk.tk_call_without_enc('trace', 'add', 'variable', Tk.tk_call_without_enc('trace', 'add', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
else else
Tk.tk_call_without_enc('trace', 'variable', Tk.tk_call_without_enc('trace', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
else else
@ -1405,19 +1413,19 @@ end
if USE_OLD_TRACE_OPTION_STYLE if USE_OLD_TRACE_OPTION_STYLE
opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)} opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
if newopts != @trace_opts if newopts != @trace_opts
Tk.tk_call_without_enc('trace', 'vdelete', Tk.tk_call_without_enc('trace', 'vdelete',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
@trace_opts.replace(newopts) @trace_opts.replace(newopts)
Tk.tk_call_without_enc('trace', 'variable', Tk.tk_call_without_enc('trace', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
else else
newopts |= opts newopts |= opts
unless (newopts - @trace_opts).empty? unless (newopts - @trace_opts).empty?
Tk.tk_call_without_enc('trace', 'remove', 'variable', Tk.tk_call_without_enc('trace', 'remove', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
@trace_opts.replace(newopts) @trace_opts.replace(newopts)
Tk.tk_call_without_enc('trace', 'add', 'variable', Tk.tk_call_without_enc('trace', 'add', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
end end
@ -1434,7 +1442,7 @@ end
def trace_info_for_element(elem) def trace_info_for_element(elem)
if @elem if @elem
fail(RuntimeError, fail(RuntimeError,
"invalid for a TkVariable which denotes an element of Tcl's array") "invalid for a TkVariable which denotes an element of Tcl's array")
end end
return [] unless @trace_elem return [] unless @trace_elem
@ -1468,7 +1476,7 @@ end
else else
newopts = [] newopts = []
@trace_var.each_with_index{|e, i| @trace_var.each_with_index{|e, i|
if idx < 0 && e[1] == cmd && if idx < 0 && e[1] == cmd &&
e[0].size == opts.size && (e[0] - opts).empty? e[0].size == opts.size && (e[0] - opts).empty?
# find # find
idx = i idx = i
@ -1479,7 +1487,7 @@ end
end end
if idx >= 0 if idx >= 0
@trace_var.delete_at(idx) @trace_var.delete_at(idx)
else else
return self return self
end end
@ -1498,21 +1506,21 @@ end
diff = false diff = false
@trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))} @trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))}
if diff if diff
Tk.tk_call_without_enc('trace', 'vdelete', Tk.tk_call_without_enc('trace', 'vdelete',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
@trace_opts.replace(newopts) @trace_opts.replace(newopts)
unless @trace_opts.empty? unless @trace_opts.empty?
Tk.tk_call_without_enc('trace', 'variable', Tk.tk_call_without_enc('trace', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
end end
else else
unless (@trace_opts - newopts).empty? unless (@trace_opts - newopts).empty?
Tk.tk_call_without_enc('trace', 'remove', 'variable', Tk.tk_call_without_enc('trace', 'remove', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
@trace_opts.replace(newopts) @trace_opts.replace(newopts)
unless @trace_opts.empty? unless @trace_opts.empty?
Tk.tk_call_without_enc('trace', 'add', 'variable', Tk.tk_call_without_enc('trace', 'add', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
end end
@ -1525,7 +1533,7 @@ end
def trace_remove_for_element(elem,opts,cmd) def trace_remove_for_element(elem,opts,cmd)
if @elem if @elem
fail(RuntimeError, fail(RuntimeError,
"invalid for a TkVariable which denotes an element of Tcl's array") "invalid for a TkVariable which denotes an element of Tcl's array")
end end
return self unless @trace_elem.kind_of? Hash return self unless @trace_elem.kind_of? Hash
@ -1550,7 +1558,7 @@ end
} }
else else
@trace_elem[elem].each_with_index{|e, i| @trace_elem[elem].each_with_index{|e, i|
if idx < 0 && e[1] == cmd && if idx < 0 && e[1] == cmd &&
e[0].size == opts.size && (e[0] - opts).empty? e[0].size == opts.size && (e[0] - opts).empty?
# find # find
idx = i idx = i
@ -1567,7 +1575,7 @@ end
if USE_OLD_TRACE_OPTION_STYLE if USE_OLD_TRACE_OPTION_STYLE
newopts = '' newopts = ''
@trace_var.each{|e| @trace_var.each{|e|
e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)} e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
} }
@trace_elem.each{|elem| @trace_elem.each{|elem|
@ -1591,21 +1599,21 @@ end
diff = false diff = false
@trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))} @trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))}
if diff if diff
Tk.tk_call_without_enc('trace', 'vdelete', Tk.tk_call_without_enc('trace', 'vdelete',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
@trace_opts.replace(newopts) @trace_opts.replace(newopts)
unless @trace_opts.empty? unless @trace_opts.empty?
Tk.tk_call_without_enc('trace', 'variable', Tk.tk_call_without_enc('trace', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
end end
else else
unless (@trace_opts - newopts).empty? unless (@trace_opts - newopts).empty?
Tk.tk_call_without_enc('trace', 'remove', 'variable', Tk.tk_call_without_enc('trace', 'remove', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
@trace_opts.replace(newopts) @trace_opts.replace(newopts)
unless @trace_opts.empty? unless @trace_opts.empty?
Tk.tk_call_without_enc('trace', 'add', 'variable', Tk.tk_call_without_enc('trace', 'add', 'variable',
@id, @trace_opts, 'rb_var ' << @id) @id, @trace_opts, 'rb_var ' << @id)
end end
end end
@ -1621,7 +1629,7 @@ class TkVarAccess<TkVariable
def self.new(name, *args) def self.new(name, *args)
if name.kind_of?(TkVariable) if name.kind_of?(TkVariable)
name.value = args[0] unless args.empty? name.value = args[0] unless args.empty?
return name return name
end end
name = name.to_s name = name.to_s
@ -1649,7 +1657,7 @@ class TkVarAccess<TkVariable
fail ArgumentError, "already exist as a scalar variable" fail ArgumentError, "already exist as a scalar variable"
end end
name.value = args[0] unless args.empty? name.value = args[0] unless args.empty?
return name return name
end end
name = name.to_s name = name.to_s

View file

@ -9,7 +9,7 @@ class TkVirtualEvent<TkObject
TkCommandNames = ['event'.freeze].freeze TkCommandNames = ['event'.freeze].freeze
(TkVirtualEventID = ["VirtEvent".freeze, "00000".taint]).instance_eval{ (TkVirtualEventID = ["VirtEvent".freeze, TkUtil.untrust("00000")]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -80,8 +80,8 @@ class TkVirtualEvent<TkObject
def _add_sequences(seq_ary) def _add_sequences(seq_ary)
unless seq_ary.empty? unless seq_ary.empty?
tk_call_without_enc('event', 'add', "<#{@id}>", tk_call_without_enc('event', 'add', "<#{@id}>",
*(seq_ary.collect{|seq| *(seq_ary.collect{|seq|
"<#{tk_event_sequence(seq)}>" "<#{tk_event_sequence(seq)}>"
}) ) }) )
end end
@ -106,8 +106,8 @@ class TkVirtualEvent<TkObject
TkVirtualEventTBL.delete(@id) TkVirtualEventTBL.delete(@id)
} }
else else
tk_call_without_enc('event', 'delete', "<#{@id}>", tk_call_without_enc('event', 'delete', "<#{@id}>",
*(sequences.collect{|seq| *(sequences.collect{|seq|
"<#{tk_event_sequence(seq)}>" "<#{tk_event_sequence(seq)}>"
}) ) }) )
if tk_call_without_enc('event','info',"<#{@id}>").empty? if tk_call_without_enc('event','info',"<#{@id}>").empty?

View file

@ -14,7 +14,7 @@ module TkWinfo
def TkWinfo.atom(name, win=nil) def TkWinfo.atom(name, win=nil)
if win if win
number(tk_call_without_enc('winfo', 'atom', '-displayof', win, number(tk_call_without_enc('winfo', 'atom', '-displayof', win,
_get_eval_enc_str(name))) _get_eval_enc_str(name)))
else else
number(tk_call_without_enc('winfo', 'atom', _get_eval_enc_str(name))) number(tk_call_without_enc('winfo', 'atom', _get_eval_enc_str(name)))
@ -26,7 +26,7 @@ module TkWinfo
def TkWinfo.atomname(id, win=nil) def TkWinfo.atomname(id, win=nil)
if win if win
_fromUTF8(tk_call_without_enc('winfo', 'atomname', _fromUTF8(tk_call_without_enc('winfo', 'atomname',
'-displayof', win, id)) '-displayof', win, id))
else else
_fromUTF8(tk_call_without_enc('winfo', 'atomname', id)) _fromUTF8(tk_call_without_enc('winfo', 'atomname', id))
@ -67,7 +67,7 @@ module TkWinfo
def TkWinfo.containing(rootX, rootY, win=nil) def TkWinfo.containing(rootX, rootY, win=nil)
if win if win
window(tk_call_without_enc('winfo', 'containing', window(tk_call_without_enc('winfo', 'containing',
'-displayof', win, rootX, rootY)) '-displayof', win, rootX, rootY))
else else
window(tk_call_without_enc('winfo', 'containing', rootX, rootY)) window(tk_call_without_enc('winfo', 'containing', rootX, rootY))
@ -128,7 +128,7 @@ module TkWinfo
false, true) false, true)
else else
#tk_split_simplelist(tk_call_without_enc('winfo', 'interps')) #tk_split_simplelist(tk_call_without_enc('winfo', 'interps'))
tk_split_simplelist(tk_call_without_enc('winfo', 'interps'), tk_split_simplelist(tk_call_without_enc('winfo', 'interps'),
false, true) false, true)
end end
end end
@ -303,7 +303,7 @@ module TkWinfo
def TkWinfo.visualsavailable(win, includeids=false) def TkWinfo.visualsavailable(win, includeids=false)
if includeids if includeids
list(tk_call_without_enc('winfo', 'visualsavailable', list(tk_call_without_enc('winfo', 'visualsavailable',
win, "includeids")) win, "includeids"))
else else
list(tk_call_without_enc('winfo', 'visualsavailable', win)) list(tk_call_without_enc('winfo', 'visualsavailable', win))

View file

@ -10,7 +10,8 @@ require 'tk'
module Tk::WinDDE module Tk::WinDDE
end end
#TkWinDDE = Tk::WinDDE #TkWinDDE = Tk::WinDDE
Tk.__set_toplevel_aliases__(:Tk, Tk::WinDDE, :TkWinDDE) #Tk.__set_toplevel_aliases__(:Tk, Tk::WinDDE, :TkWinDDE)
Tk.__set_loaded_toplevel_aliases__('tk/winpkg.rb', :Tk, Tk::WinDDE, :TkWinDDE)
module Tk::WinDDE module Tk::WinDDE
extend Tk extend Tk
@ -45,7 +46,7 @@ module Tk::WinDDE
elsif args.size == 0 elsif args.size == 0
tk_call('dde', 'servername', force, exact, *hash_kv(keys)) tk_call('dde', 'servername', force, exact, *hash_kv(keys))
else else
tk_call('dde', 'servername', force, exact, tk_call('dde', 'servername', force, exact,
*((hash_kv(keys) << '--') + args)) *((hash_kv(keys) << '--') + args))
end end
else else
@ -86,14 +87,16 @@ module Tk::WinDDE
tk_call('dde', 'eval', -async, topic, cmd, *args) tk_call('dde', 'eval', -async, topic, cmd, *args)
end end
module_function :servername, :execute, :async_execute, module_function :servername, :execute, :async_execute,
:poke, :request, :services, :eval :poke, :request, :services, :eval
end end
module Tk::WinRegistry module Tk::WinRegistry
end end
#TkWinRegistry = Tk::WinRegistry #TkWinRegistry = Tk::WinRegistry
Tk.__set_toplevel_aliases__(:Tk, Tk::WinRegistry, :TkWinRegistry) #Tk.__set_toplevel_aliases__(:Tk, Tk::WinRegistry, :TkWinRegistry)
Tk.__set_loaded_toplevel_aliases__('tk/winpkg.rb', :Tk, Tk::WinRegistry,
:TkWinRegistry)
module Tk::WinRegistry module Tk::WinRegistry
extend Tk extend Tk

View file

@ -123,7 +123,7 @@ module Tk
TOPLEVEL_METHODCALL_OPTKEYS['focusmodel'] = 'focusmodel' TOPLEVEL_METHODCALL_OPTKEYS['focusmodel'] = 'focusmodel'
def Wm.forget(win) def Wm.forget(win)
# Tcl/Tk 8.5+ # Tcl/Tk 8.5+
# work with dockable frames # work with dockable frames
tk_call_without_enc('wm', 'forget', win.epath) tk_call_without_enc('wm', 'forget', win.epath)
win win
@ -200,7 +200,7 @@ module Tk
if imgs.empty? if imgs.empty?
win.instance_eval{ win.instance_eval{
@wm_iconphoto = nil unless defined? @wm_iconphoto @wm_iconphoto = nil unless defined? @wm_iconphoto
return @wm_iconphoto return @wm_iconphoto
} }
end end
@ -308,10 +308,10 @@ module Tk
def Wm.manage(win, use_id = nil) def Wm.manage(win, use_id = nil)
# Tcl/Tk 8.5+ feature # Tcl/Tk 8.5+ feature
# -------------------------------------------------------------- # --------------------------------------------------------------
# In the future release, I want to support to embed the 'win' # In the future release, I want to support to embed the 'win'
# into the container which has window-id 'use-id'. # into the container which has window-id 'use-id'.
# It may give users frexibility on controlling their GUI. # It may give users frexibility on controlling their GUI.
# However, it may be difficult for current Tcl/Tk (Tcl/Tk8.5.1), # However, it may be difficult for current Tcl/Tk (Tcl/Tk8.5.1),
# because it seems to require to modify Tcl/Tk's source code. # because it seems to require to modify Tcl/Tk's source code.
# -------------------------------------------------------------- # --------------------------------------------------------------
if use_id if use_id

View file

@ -12,14 +12,14 @@ module TkXIM
def TkXIM.useinputmethods(value = None, win = nil) def TkXIM.useinputmethods(value = None, win = nil)
if value == None if value == None
if win if win
bool(tk_call_without_enc('tk', 'useinputmethods', bool(tk_call_without_enc('tk', 'useinputmethods',
'-displayof', win)) '-displayof', win))
else else
bool(tk_call_without_enc('tk', 'useinputmethods')) bool(tk_call_without_enc('tk', 'useinputmethods'))
end end
else else
if win if win
bool(tk_call_without_enc('tk', 'useinputmethods', bool(tk_call_without_enc('tk', 'useinputmethods',
'-displayof', win, value)) '-displayof', win, value))
else else
bool(tk_call_without_enc('tk', 'useinputmethods', value)) bool(tk_call_without_enc('tk', 'useinputmethods', value))

View file

@ -34,10 +34,10 @@ module Tk
def self.create(*args) # icon, icon, ..., ?option=>value, ...? def self.create(*args) # icon, icon, ..., ?option=>value, ...?
if args[-1].kind_of?(Hash) if args[-1].kind_of?(Hash)
keys = args.pop keys = args.pop
icons = simplelist(tk_call('::icons::icons', 'create', icons = simplelist(tk_call('::icons::icons', 'create',
*(hash_kv(keys) << (args.flatten)))) *(hash_kv(keys) << (args.flatten))))
else else
icons = simplelist(tk_call('::icons::icons', 'create', icons = simplelist(tk_call('::icons::icons', 'create',
args.flatten)) args.flatten))
end end
@ -66,7 +66,7 @@ module Tk
def self.query(*args) # icon, icon, ..., ?option=>value, ...? def self.query(*args) # icon, icon, ..., ?option=>value, ...?
if args[-1].kind_of?(Hash) if args[-1].kind_of?(Hash)
keys = args.pop keys = args.pop
simplelist(tk_call('::icons::icons', 'query', simplelist(tk_call('::icons::icons', 'query',
*(hash_kv(keys) << (args.flatten)))) *(hash_kv(keys) << (args.flatten))))
else else
simplelist(tk_call('::icons::icons', 'query', args.flatten)) simplelist(tk_call('::icons::icons', 'query', args.flatten))
@ -121,7 +121,7 @@ module Tk
end end
def query(keys={}) def query(keys={})
list(simplelist(tk_call('::icons::icons', 'query', list(simplelist(tk_call('::icons::icons', 'query',
*(hash_kv(keys) << @name)) *(hash_kv(keys) << @name))
)[0]) )[0])
end end

View file

@ -2,7 +2,7 @@
# setup.rb -- setup script before calling TkPackage.require() # setup.rb -- setup script before calling TkPackage.require()
# #
# If you need some setup operations (for example, add a library path # If you need some setup operations (for example, add a library path
# to the library search path) before using Tcl/Tk library packages # to the library search path) before using Tcl/Tk library packages
# wrapped by Ruby scripts in this directory, please write the setup # wrapped by Ruby scripts in this directory, please write the setup
# operations in this file. # operations in this file.
# #

View file

@ -55,18 +55,20 @@ script may give you some hints about that.
===< support with some examples (may be beta quality) >======================= ===< support with some examples (may be beta quality) >=======================
Tcllib 1.8 Tcllib 1.11.1
Tklib 0.4.1 http://sourceforge.net/projects/tcllib ==> tcllib Tklib 0.5 http://sourceforge.net/projects/tcllib ==> tcllib
( partial support; primary support target is Tklib)
IWidgets 4.0.2 http://sourceforge.net/projects/incrtcl ==> iwidgets IWidgets 4.0.2 http://sourceforge.net/projects/incrtcl ==> iwidgets
BWidgets 1.7 http://sourceforge.net/projects/tcllib ==> bwidget BWidget 1.8 [ CVS/Hd(2009-07-02) ]
http://sourceforge.net/projects/tcllib ==> bwidget
TkTable 2.9 http://sourceforge.net/projects/tktable ==> tktable TkTable 2.10 http://sourceforge.net/projects/tktable ==> tktable
* see also <http://www.korus.hu/~fery/ruby/tktable.rb> * see also <http://www.korus.hu/~fery/ruby/tktable.rb>
written by Ferenc Engard (ferenc@engard.hu) written by Ferenc Engard (ferenc@engard.hu)
vu 2.3.0 http://sourceforge.net/projects/tktable ==> vu Vu widgets 2.3.0 http://sourceforge.net/projects/tktable ==> vu
TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/ ==> tkHTML TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/ ==> tkHTML
@ -80,25 +82,25 @@ BLT 2.4z http://sourceforge.net/projects/blt
(http://raa.ruby-lang.org/) (http://raa.ruby-lang.org/)
==> blt ==> blt
TkTreeCtrl CVS/Hd(2005-12-02) TkTreeCtrl 2.2.9
http://sourceforge.net/projects/tktreectrl ==> treectrl http://tktreectrl.sourceforge.net/ ==> treectrl
Tile 0.8.0/8.5.1 Tile 0.8.3/8.6b1
http://sourceforge.net/projects/tktable ==> tile http://sourceforge.net/projects/tktable ==> tile
===< support (may be alpha or beta quality) >================================= ===< support (may be alpha or beta quality) >=================================
IncrTcl CVS/Hd(2005-02-14) IncrTcl CVS/Hd(2008-12-15)
http://sourceforge.net/projects/incrtcl ==> itcl, itk http://sourceforge.net/projects/incrtcl ==> itcl, itk
TclX CVS/Hd(2005-02-07) TclX CVS/Hd(2008-12-15)
http://sourceforge.net/projects/tclx http://sourceforge.net/projects/tclx
==> tclx (partial support; infox command and ==> tclx (partial support; infox command and
XPG/3 message catalogs only) XPG/3 message catalogs only)
Trofs 0.4.3 http://math.nist.gov/~DPorter/tcltk/trofs/ Trofs 0.4.4 http://math.nist.gov/~DPorter/tcltk/trofs/

View file

@ -19,6 +19,8 @@ TkPackage.require('BLT')
module Tk module Tk
module BLT module BLT
TkComm::TkExtlibAutoloadModule.unshift(self) TkComm::TkExtlibAutoloadModule.unshift(self)
# Require autoload-symbols which is a same name as widget classname.
# Those are used at TkComm._genobj_for_tkwidget method.
extend TkCore extend TkCore

View file

@ -11,7 +11,7 @@ module Tk::BLT
class Barchart < TkWindow class Barchart < TkWindow
TkCommandNames = ['::blt::barchart'.freeze].freeze TkCommandNames = ['::blt::barchart'.freeze].freeze
WidgetClassName = 'Barchart'.freeze WidgetClassName = 'Barchart'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
include PlotComponent include PlotComponent
include GraphCommand include GraphCommand
@ -22,7 +22,7 @@ module Tk::BLT
private :__boolval_optkeys private :__boolval_optkeys
def __strval_optkeys def __strval_optkeys
['text', 'label', 'title', 'file', ['text', 'label', 'title', 'file',
'background', 'plotbackground'] 'background', 'plotbackground']
end end
private :__strval_optkeys private :__strval_optkeys
@ -33,7 +33,7 @@ module Tk::BLT
private :__tkvariable_optkeys private :__tkvariable_optkeys
=begin =begin
BarElement_ID = ['blt_barchart_bar'.freeze, '00000'.taint].freeze BarElement_ID = ['blt_barchart_bar'.freeze, TkUtil.untrust('00000')].freeze
def bar(elem=nil, keys={}) def bar(elem=nil, keys={})
if elem.kind_of?(Hash) if elem.kind_of?(Hash)

View file

@ -14,7 +14,7 @@ module Tk::BLT
BITMAP_ID_TBL = TkCore::INTERP.create_table BITMAP_ID_TBL = TkCore::INTERP.create_table
(BITMAP_ID = ['blt_bitmap_id'.freeze, '00000'.taint]).instance_eval{ (BITMAP_ID = ['blt_bitmap_id'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze

View file

@ -44,6 +44,7 @@ class << Tk::BLT::Busy
private :__item_config_cmd private :__item_config_cmd
undef itemcget undef itemcget
undef itemcget_tkstring
alias configure itemconfigure alias configure itemconfigure
alias configinfo itemconfiginfo alias configinfo itemconfiginfo
alias current_configinfo current_itemconfiginfo alias current_configinfo current_itemconfiginfo

View file

@ -22,15 +22,15 @@ module Tk::BLT
private :__item_numstrval_optkeys private :__item_numstrval_optkeys
def __item_boolval_optkeys(id) def __item_boolval_optkeys(id)
['hide', 'under', 'descending', 'logscale', 'loose', 'showticks', ['hide', 'under', 'descending', 'logscale', 'loose', 'showticks',
'titlealternate', 'scalesymbols', 'minor', 'raised', 'titlealternate', 'scalesymbols', 'minor', 'raised',
'center', 'decoration', 'landscape', 'maxpect'] 'center', 'decoration', 'landscape', 'maxpect']
end end
private :__item_boolval_optkeys private :__item_boolval_optkeys
def __item_strval_optkeys(id) def __item_strval_optkeys(id)
['text', 'label', 'limits', 'title', ['text', 'label', 'limits', 'title',
'show', 'file', 'maskdata', 'maskfile', 'show', 'file', 'maskdata', 'maskfile',
'color', 'titlecolor', 'fill', 'outline', 'offdash'] 'color', 'titlecolor', 'fill', 'outline', 'offdash']
end end
private :__item_strval_optkeys private :__item_strval_optkeys
@ -82,6 +82,9 @@ module Tk::BLT
end end
private :__item_pathname private :__item_pathname
def axis_cget_tkstring(id, option)
ret = itemcget_tkstring(['axis', tagid(id)], option)
end
def axis_cget(id, option) def axis_cget(id, option)
ret = itemcget(['axis', tagid(id)], option) ret = itemcget(['axis', tagid(id)], option)
end end
@ -94,7 +97,7 @@ module Tk::BLT
value = None value = None
slot = _symbolkey2str(slot) slot = _symbolkey2str(slot)
if cmd = slot.delete('command') if cmd = slot.delete('command')
slot['command'] = proc{|w, tick| slot['command'] = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
@ -103,7 +106,7 @@ module Tk::BLT
slot = args.pop slot = args.pop
if slot == :command || slot == 'command' if slot == :command || slot == 'command'
cmd = value cmd = value
value = proc{|w, tick| value = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
@ -118,6 +121,9 @@ module Tk::BLT
current_itemconfiginfo(['axis', tagid(id)], slot) current_itemconfiginfo(['axis', tagid(id)], slot)
end end
def crosshairs_cget_tkstring(option)
itemcget_tkstring('crosshairs', option)
end
def crosshairs_cget(option) def crosshairs_cget(option)
itemcget('crosshairs', option) itemcget('crosshairs', option)
end end
@ -134,6 +140,9 @@ module Tk::BLT
current_itemconfiginfo('crosshairs', slot) current_itemconfiginfo('crosshairs', slot)
end end
def element_cget_tkstring(id, option)
itemcget_tkstring(['element', tagid(id)], option)
end
def element_cget(id, option) def element_cget(id, option)
itemcget(['element', tagid(id)], option) itemcget(['element', tagid(id)], option)
end end
@ -158,6 +167,9 @@ module Tk::BLT
current_itemconfiginfo(['element', tagid(id)], slot) current_itemconfiginfo(['element', tagid(id)], slot)
end end
def bar_cget_tkstring(id, option)
itemcget_tkstring(['bar', tagid(id)], option)
end
def bar_cget(id, option) def bar_cget(id, option)
itemcget(['bar', tagid(id)], option) itemcget(['bar', tagid(id)], option)
end end
@ -182,6 +194,9 @@ module Tk::BLT
current_itemconfiginfo(['bar', tagid(id)], slot) current_itemconfiginfo(['bar', tagid(id)], slot)
end end
def line_cget_tkstring(id, option)
itemcget_tkstring(['line', tagid(id)], option)
end
def line_cget(id, option) def line_cget(id, option)
itemcget(['line', tagid(id)], option) itemcget(['line', tagid(id)], option)
end end
@ -206,6 +221,9 @@ module Tk::BLT
current_itemconfiginfo(['line', tagid(id)], slot) current_itemconfiginfo(['line', tagid(id)], slot)
end end
def gridline_cget_tkstring(option)
itemcget_tkstring('grid', option)
end
def gridline_cget(option) def gridline_cget(option)
itemcget('grid', option) itemcget('grid', option)
end end
@ -222,6 +240,9 @@ module Tk::BLT
current_itemconfiginfo('grid', slot) current_itemconfiginfo('grid', slot)
end end
def legend_cget_tkstring(option)
itemcget_tkstring('legend', option)
end
def legend_cget(option) def legend_cget(option)
itemcget('legend', option) itemcget('legend', option)
end end
@ -238,6 +259,9 @@ module Tk::BLT
current_itemconfiginfo('legend', slot) current_itemconfiginfo('legend', slot)
end end
def pen_cget_tkstring(id, option)
itemcget_tkstring(['pen', tagid(id)], option)
end
def pen_cget(id, option) def pen_cget(id, option)
itemcget(['pen', tagid(id)], option) itemcget(['pen', tagid(id)], option)
end end
@ -262,6 +286,9 @@ module Tk::BLT
current_itemconfiginfo(['pen', tagid(id)], slot) current_itemconfiginfo(['pen', tagid(id)], slot)
end end
def postscript_cget_tkstring(option)
itemcget_tkstring('postscript', option)
end
def postscript_cget(option) def postscript_cget(option)
itemcget('postscript', option) itemcget('postscript', option)
end end
@ -278,6 +305,9 @@ module Tk::BLT
current_itemconfiginfo('postscript', slot) current_itemconfiginfo('postscript', slot)
end end
def marker_cget_tkstring(id, option)
itemcget_tkstring(['marker', tagid(id)], option)
end
def marker_cget(id, option) def marker_cget(id, option)
itemcget(['marker', tagid(id)], option) itemcget(['marker', tagid(id)], option)
end end
@ -302,12 +332,16 @@ module Tk::BLT
current_itemconfiginfo(['marker', tagid(id)], slot) current_itemconfiginfo(['marker', tagid(id)], slot)
end end
alias __itemcget_tkstring itemcget_tkstring
alias __itemcget itemcget alias __itemcget itemcget
alias __itemcget_strict itemcget_strict alias __itemcget_strict itemcget_strict
alias __itemconfiginfo itemconfiginfo alias __itemconfiginfo itemconfiginfo
alias __current_itemconfiginfo current_itemconfiginfo alias __current_itemconfiginfo current_itemconfiginfo
private :__itemcget, :__itemconfiginfo, :__current_itemconfiginfo private :__itemcget_tkstring, :__itemcget, :__itemconfiginfo, :__current_itemconfiginfo
def itemcget_tkstring(tagOrId, option)
__itemcget_tkstring(tagid(tagOrId), option)
end
def itemcget_strict(tagOrId, option) def itemcget_strict(tagOrId, option)
ret = __itemcget(tagid(tagOrId), option) ret = __itemcget(tagid(tagOrId), option)
if option == 'bindtags' || option == :bindtags if option == 'bindtags' || option == :bindtags
@ -373,13 +407,13 @@ module Tk::BLT
ret ret
end end
private :itemcget, :itemcget_strict private :itemcget_tkstring, :itemcget, :itemcget_strict
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
################# #################
class Axis < TkObject class Axis < TkObject
(OBJ_ID = ['blt_chart_axis'.freeze, '00000'.taint]).instance_eval{ (OBJ_ID = ['blt_chart_axis'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -477,6 +511,9 @@ module Tk::BLT
@id @id
end end
def cget_tkstring(option)
@chart.axis_cget_tkstring(@id, option)
end
def cget(option) def cget(option)
@chart.axis_cget(@id, option) @chart.axis_cget(@id, option)
end end
@ -520,7 +557,7 @@ module Tk::BLT
def name def name
@axis @axis
end end
def transform(val) def transform(val)
@chart.axis_transform(@id, val) @chart.axis_transform(@id, val)
end end
@ -582,6 +619,9 @@ module Tk::BLT
@id @id
end end
def cget_tkstring(option)
@chart.crosshair_cget_tkstring(option)
end
def cget(option) def cget(option)
@chart.crosshair_cget(option) @chart.crosshair_cget(option)
end end
@ -631,7 +671,7 @@ module Tk::BLT
ElementID_TBL.mutex.synchronize{ ElementID_TBL.clear } ElementID_TBL.mutex.synchronize{ ElementID_TBL.clear }
} }
(OBJ_ID = ['blt_chart_element'.freeze, '00000'.taint]).instance_eval{ (OBJ_ID = ['blt_chart_element'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -729,6 +769,10 @@ module Tk::BLT
@id @id
end end
def cget_tkstring(option)
# @chart.element_cget(@id, option)
@chart.__send__(@typename + '_cget_tkstring', @id, option)
end
def cget(option) def cget(option)
# @chart.element_cget(@id, option) # @chart.element_cget(@id, option)
@chart.__send__(@typename + '_cget', @id, option) @chart.__send__(@typename + '_cget', @id, option)
@ -833,6 +877,9 @@ module Tk::BLT
@id @id
end end
def cget_tkstring(option)
@chart.gridline_cget_tkstring(option)
end
def cget(option) def cget(option)
@chart.gridline_cget(option) @chart.gridline_cget(option)
end end
@ -907,6 +954,9 @@ module Tk::BLT
@id @id
end end
def cget_tkstring(option)
@chart.legend_cget_tkstring(option)
end
def cget(option) def cget(option)
@chart.legend_cget(option) @chart.legend_cget(option)
end end
@ -940,7 +990,7 @@ module Tk::BLT
################# #################
class Pen < TkObject class Pen < TkObject
(OBJ_ID = ['blt_chart_pen'.freeze, '00000'.taint]).instance_eval{ (OBJ_ID = ['blt_chart_pen'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -1036,6 +1086,9 @@ module Tk::BLT
@id @id
end end
def cget_tkstring(option)
@chart.pen_cget_tkstring(@id, option)
end
def cget(option) def cget(option)
@chart.pen_cget(@id, option) @chart.pen_cget(@id, option)
end end
@ -1106,6 +1159,9 @@ module Tk::BLT
@id @id
end end
def cget_tkstring(option)
@chart.postscript_cget_tkstring(option)
end
def cget(option) def cget(option)
@chart.postscript_cget(option) @chart.postscript_cget(option)
end end
@ -1221,7 +1277,7 @@ module Tk::BLT
fail RuntimeError, "#{self} is an abstract class" fail RuntimeError, "#{self} is an abstract class"
end end
args, fontkeys = _parse_create_args(keys) args, fontkeys = _parse_create_args(keys)
idnum = tk_call_without_enc(chart.path, 'marker', 'create', idnum = tk_call_without_enc(chart.path, 'marker', 'create',
self::MarkerTypeName, *args) self::MarkerTypeName, *args)
chart.marker_configure(idnum, fontkeys) unless fontkeys.empty? chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
idnum.to_i # 'item id' is an integer number idnum.to_i # 'item id' is an integer number
@ -1229,7 +1285,7 @@ module Tk::BLT
def self.create_type(chart, type, keys={}) def self.create_type(chart, type, keys={})
args, fontkeys = _parse_create_args(keys) args, fontkeys = _parse_create_args(keys)
idnum = tk_call_without_enc(chart.path, 'marker', 'create', idnum = tk_call_without_enc(chart.path, 'marker', 'create',
type, *args) type, *args)
chart.marker_configure(idnum, fontkeys) unless fontkeys.empty? chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
id = idnum.to_i # 'item id' is an integer number id = idnum.to_i # 'item id' is an integer number
@ -1269,6 +1325,9 @@ module Tk::BLT
@id @id
end end
def cget_tkstring(option)
@chart.marker_cget_tkstring(@id, option)
end
def cget(option) def cget(option)
@chart.marker_cget(@id, option) @chart.marker_cget(@id, option)
end end
@ -1486,7 +1545,7 @@ module Tk::BLT
list(tk_send('axis', 'limits', tagid(id))) list(tk_send('axis', 'limits', tagid(id)))
end end
def axis_names(*pats) def axis_names(*pats)
simplelist(tk_send('axis', 'names', simplelist(tk_send('axis', 'names',
*(pats.collect{|pat| tagid(pat)}))).collect{|axis| *(pats.collect{|pat| tagid(pat)}))).collect{|axis|
Tk::BLT::PlotComponent::Axis.id2obj(self, axis) Tk::BLT::PlotComponent::Axis.id2obj(self, axis)
} }
@ -1500,11 +1559,11 @@ module Tk::BLT
end end
def axis_use(id, target=nil) def axis_use(id, target=nil)
if target if target
Tk::BLT::PlotComponent::Axis.id2obj(self, Tk::BLT::PlotComponent::Axis.id2obj(self,
tk_send('axis', 'use', tk_send('axis', 'use',
tagid(id), tagid(target))) tagid(id), tagid(target)))
else else
Tk::BLT::PlotComponent::Axis.id2obj(self, Tk::BLT::PlotComponent::Axis.id2obj(self,
tk_send('axis', 'use', tagid(id))) tk_send('axis', 'use', tagid(id)))
end end
end end
@ -1544,10 +1603,10 @@ module Tk::BLT
def element_closest(x, y, var, *args) def element_closest(x, y, var, *args)
if args[-1].kind_of?(Hash) if args[-1].kind_of?(Hash)
keys = args.pop keys = args.pop
bool(tk_send('element', 'closest', x, y, var, bool(tk_send('element', 'closest', x, y, var,
*(hash_kv(keys).concat(args.collect{|id| tagid(id)})))) *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
else else
bool(tk_send('element', 'closest', x, y, var, bool(tk_send('element', 'closest', x, y, var,
*(args.collect{|id| tagid(id)}))) *(args.collect{|id| tagid(id)})))
end end
end end
@ -1563,7 +1622,7 @@ module Tk::BLT
bool(tk_send('element', 'exists', tagid(id))) bool(tk_send('element', 'exists', tagid(id)))
end end
def element_names(*pats) def element_names(*pats)
simplelist(tk_send('element', 'names', simplelist(tk_send('element', 'names',
*(pats.collect{|pat| tagid(pat)}))).collect{|elem| *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
Tk::BLT::PlotComponent::Element.id2obj(self, elem) Tk::BLT::PlotComponent::Element.id2obj(self, elem)
} }
@ -1601,10 +1660,10 @@ module Tk::BLT
def bar_closest(x, y, var, *args) def bar_closest(x, y, var, *args)
if args[-1].kind_of?(Hash) if args[-1].kind_of?(Hash)
keys = args.pop keys = args.pop
bool(tk_send('bar', 'closest', x, y, var, bool(tk_send('bar', 'closest', x, y, var,
*(hash_kv(keys).concat(args.collect{|id| tagid(id)})))) *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
else else
bool(tk_send('bar', 'closest', x, y, var, bool(tk_send('bar', 'closest', x, y, var,
*(args.collect{|id| tagid(id)}))) *(args.collect{|id| tagid(id)})))
end end
end end
@ -1620,7 +1679,7 @@ module Tk::BLT
bool(tk_send('bar', 'exists', tagid(id))) bool(tk_send('bar', 'exists', tagid(id)))
end end
def bar_names(*pats) def bar_names(*pats)
simplelist(tk_send('bar', 'names', simplelist(tk_send('bar', 'names',
*(pats.collect{|pat| tagid(pat)}))).collect{|elem| *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
Tk::BLT::PlotComponent::Element.id2obj(self, elem) Tk::BLT::PlotComponent::Element.id2obj(self, elem)
} }
@ -1658,10 +1717,10 @@ module Tk::BLT
def line_closest(x, y, var, *args) def line_closest(x, y, var, *args)
if args[-1].kind_of?(Hash) if args[-1].kind_of?(Hash)
keys = args.pop keys = args.pop
bool(tk_send('line', 'closest', x, y, var, bool(tk_send('line', 'closest', x, y, var,
*(hash_kv(keys).concat(args.collect{|id| tagid(id)})))) *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
else else
bool(tk_send('line', 'closest', x, y, var, bool(tk_send('line', 'closest', x, y, var,
*(args.collect{|id| tagid(id)}))) *(args.collect{|id| tagid(id)})))
end end
end end
@ -1677,7 +1736,7 @@ module Tk::BLT
bool(tk_send('line', 'exists', tagid(id))) bool(tk_send('line', 'exists', tagid(id)))
end end
def line_names(*pats) def line_names(*pats)
simplelist(tk_send('line', 'names', simplelist(tk_send('line', 'names',
*(pats.collect{|pat| tagid(pat)}))).collect{|elem| *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
Tk::BLT::PlotComponent::Element.id2obj(self, elem) Tk::BLT::PlotComponent::Element.id2obj(self, elem)
} }
@ -1723,7 +1782,7 @@ module Tk::BLT
keys.delete('without_creating') keys.delete('without_creating')
end end
legend = self.class.new(parent, :without_creating=>true, legend = self.class.new(parent, :without_creating=>true,
:widgetname=>widgetname) :widgetname=>widgetname)
class << legend class << legend
def __destroy_hook__ def __destroy_hook__
@ -1740,24 +1799,24 @@ module Tk::BLT
end end
def legend_activate(*pats) def legend_activate(*pats)
list(tk_send('legend', 'activate', list(tk_send('legend', 'activate',
*(pats.collect{|pat| tagid(pat)}))).collect{|elem| *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
Tk::BLT::PlotComponent::Element.id2obj(self, elem) Tk::BLT::PlotComponent::Element.id2obj(self, elem)
} }
end end
def legend_deactivate(*pats) def legend_deactivate(*pats)
list(tk_send('legend', 'deactivate', list(tk_send('legend', 'deactivate',
*(pats.collect{|pat| tagid(pat)}))).collect{|elem| *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
Tk::BLT::PlotComponent::Element.id2obj(self, elem) Tk::BLT::PlotComponent::Element.id2obj(self, elem)
} }
end end
def legend_get(pos, y=nil) def legend_get(pos, y=nil)
if y if y
Tk::BLT::PlotComponent::Element.id2obj(self, Tk::BLT::PlotComponent::Element.id2obj(self,
tk_send('legend', 'get', tk_send('legend', 'get',
_at(pos, y))) _at(pos, y)))
else else
Tk::BLT::PlotComponent::Element.id2obj(self, Tk::BLT::PlotComponent::Element.id2obj(self,
tk_send('legend', 'get', pos)) tk_send('legend', 'get', pos))
end end
end end
@ -1773,7 +1832,7 @@ module Tk::BLT
self self
end end
def pen_names(*pats) def pen_names(*pats)
simplelist(tk_send('pen', 'names', simplelist(tk_send('pen', 'names',
*(pats.collect{|pat| tagid(pat)}))).collect{|pen| *(pats.collect{|pat| tagid(pat)}))).collect{|pen|
Tk::BLT::PlotComponent::Pen.id2obj(self, pen) Tk::BLT::PlotComponent::Pen.id2obj(self, pen)
} }
@ -1843,7 +1902,7 @@ module Tk::BLT
bool(tk_send('marker', 'exists', tagid(id))) bool(tk_send('marker', 'exists', tagid(id)))
end end
def marker_names(*pats) def marker_names(*pats)
simplelist(tk_send('marker', 'names', simplelist(tk_send('marker', 'names',
*(pats.collect{|pat| tagid(pat)}))).collect{|id| *(pats.collect{|pat| tagid(pat)}))).collect{|id|
Tk::BLT::PlotComponent::Marker.id2obj(self, id) Tk::BLT::PlotComponent::Marker.id2obj(self, id)
} }
@ -1854,6 +1913,9 @@ module Tk::BLT
################### ###################
def xaxis_cget_tkstring(option)
itemcget_tkstring('xaxis', option)
end
def xaxis_cget(option) def xaxis_cget(option)
itemcget('xaxis', option) itemcget('xaxis', option)
end end
@ -1864,13 +1926,13 @@ module Tk::BLT
if slot.kind_of?(Hash) if slot.kind_of?(Hash)
slot = _symbolkey2str(slot) slot = _symbolkey2str(slot)
if cmd = slot.delete('command') if cmd = slot.delete('command')
slot['command'] = proc{|w, tick| slot['command'] = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
elsif slot == :command || slot == 'command' elsif slot == :command || slot == 'command'
cmd = value cmd = value
value = proc{|w, tick| value = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
@ -1918,14 +1980,17 @@ module Tk::BLT
end end
def xaxis_use(target=nil) def xaxis_use(target=nil)
if target if target
Tk::BLT::PlotComponent::Axis.id2obj(self, Tk::BLT::PlotComponent::Axis.id2obj(self,
tk_send('xaxis', 'use', tk_send('xaxis', 'use',
tagid(target))) tagid(target)))
else else
Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('xaxis', 'use')) Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('xaxis', 'use'))
end end
end end
def x2axis_cget_tkstring(option)
itemcget_tkstring('x2axis', option)
end
def x2axis_cget(option) def x2axis_cget(option)
itemcget('x2axis', option) itemcget('x2axis', option)
end end
@ -1936,13 +2001,13 @@ module Tk::BLT
if slot.kind_of?(Hash) if slot.kind_of?(Hash)
slot = _symbolkey2str(slot) slot = _symbolkey2str(slot)
if cmd = slot.delete('command') if cmd = slot.delete('command')
slot['command'] = proc{|w, tick| slot['command'] = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
elsif slot == :command || slot == 'command' elsif slot == :command || slot == 'command'
cmd = value cmd = value
value = proc{|w, tick| value = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
@ -1990,14 +2055,17 @@ module Tk::BLT
end end
def x2axis_use(target=nil) def x2axis_use(target=nil)
if target if target
Tk::BLT::PlotComponent::Axis.id2obj(self, Tk::BLT::PlotComponent::Axis.id2obj(self,
tk_send('x2axis', 'use', tk_send('x2axis', 'use',
tagid(target))) tagid(target)))
else else
Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('x2axis', 'use')) Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('x2axis', 'use'))
end end
end end
def yaxis_cget_tkstring(option)
itemcget_tkstring('yaxis', option)
end
def yaxis_cget(option) def yaxis_cget(option)
itemcget('yaxis', option) itemcget('yaxis', option)
end end
@ -2008,13 +2076,13 @@ module Tk::BLT
if slot.kind_of?(Hash) if slot.kind_of?(Hash)
slot = _symbolkey2str(slot) slot = _symbolkey2str(slot)
if cmd = slot.delete('command') if cmd = slot.delete('command')
slot['command'] = proc{|w, tick| slot['command'] = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
elsif slot == :command || slot == 'command' elsif slot == :command || slot == 'command'
cmd = value cmd = value
value = proc{|w, tick| value = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
@ -2062,14 +2130,17 @@ module Tk::BLT
end end
def yaxis_use(target=nil) def yaxis_use(target=nil)
if target if target
Tk::BLT::PlotComponent::Axis.id2obj(self, Tk::BLT::PlotComponent::Axis.id2obj(self,
tk_send('yaxis', 'use', tk_send('yaxis', 'use',
tagid(target))) tagid(target)))
else else
Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('yaxis', 'use')) Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('yaxis', 'use'))
end end
end end
def y2axis_cget_tkstring(option)
itemcget_tkstring('y2axis', option)
end
def y2axis_cget(option) def y2axis_cget(option)
itemcget('y2axis', option) itemcget('y2axis', option)
end end
@ -2080,13 +2151,13 @@ module Tk::BLT
if slot.kind_of?(Hash) if slot.kind_of?(Hash)
slot = _symbolkey2str(slot) slot = _symbolkey2str(slot)
if cmd = slot.delete('command') if cmd = slot.delete('command')
slot['command'] = proc{|w, tick| slot['command'] = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
elsif slot == :command || slot == 'command' elsif slot == :command || slot == 'command'
cmd = value cmd = value
value = proc{|w, tick| value = proc{|w, tick|
cmd.call(TkComm.window(w), TkComm.num_or_str(tick)) cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
} }
end end
@ -2134,8 +2205,8 @@ module Tk::BLT
end end
def y2axis_use(target=nil) def y2axis_use(target=nil)
if target if target
Tk::BLT::PlotComponent::Axis.id2obj(self, Tk::BLT::PlotComponent::Axis.id2obj(self,
tk_send('y2axis', 'use', tk_send('y2axis', 'use',
tagid(target))) tagid(target)))
else else
Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('y2axis', 'use')) Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('y2axis', 'use'))

View file

@ -10,7 +10,7 @@ module Tk::BLT
class Container < TkWindow class Container < TkWindow
TkCommandNames = ['::blt::container'.freeze].freeze TkCommandNames = ['::blt::container'.freeze].freeze
WidgetClassName = 'Container'.freeze WidgetClassName = 'Container'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def __strval_optkeys def __strval_optkeys
super() << 'name' super() << 'name'

View file

@ -15,7 +15,7 @@ module Tk::BLT
class Token < TkWindow class Token < TkWindow
WidgetClassName = 'DragDropToken'.freeze WidgetClassName = 'DragDropToken'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def initialize(arg) def initialize(arg)
if arg.kind_of?(Hash) # arg is a hash includes the widgetpath of token if arg.kind_of?(Hash) # arg is a hash includes the widgetpath of token
@ -55,6 +55,7 @@ module Tk::BLT
private :__item_strval_optkeys private :__item_strval_optkeys
undef itemcget undef itemcget
undef itemcget_tkstring
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
def source_configure(win, slot, value=None) def source_configure(win, slot, value=None)
@ -77,7 +78,7 @@ module Tk::BLT
] ]
PROC_TBL = [ PROC_TBL = [
[ ?w, TkComm.method(:window) ], [ ?w, TkComm.method(:window) ],
nil nil
] ]
@ -120,8 +121,8 @@ module Tk::BLT
] ]
PROC_TBL = [ PROC_TBL = [
[ ?b, TkComm.method(:bool) ], [ ?b, TkComm.method(:bool) ],
[ ?w, TkComm.method(:window) ], [ ?w, TkComm.method(:window) ],
nil nil
] ]
@ -175,9 +176,9 @@ module Tk::BLT
] ]
PROC_TBL = [ PROC_TBL = [
[ ?i, TkComm.method(:string) ], [ ?i, TkComm.method(:string) ],
[ ?v, TkComm.method(:tk_tcl2ruby) ], [ ?v, TkComm.method(:tk_tcl2ruby) ],
[ ?w, TkComm.method(:window) ], [ ?w, TkComm.method(:window) ],
nil nil
] ]
@ -203,14 +204,14 @@ module Tk::BLT
end end
def self.source_handler(win, datatype, cmd=Proc.new, *args) def self.source_handler(win, datatype, cmd=Proc.new, *args)
_bind_for_event_class(DnD_Handle, _bind_for_event_class(DnD_Handle,
['::blt::drag&drop', 'source', win, 'handler'], ['::blt::drag&drop', 'source', win, 'handler'],
cmd, *args) cmd, *args)
end end
def self.target_handler(win, datatype, cmd=Proc.new, *args) def self.target_handler(win, datatype, cmd=Proc.new, *args)
_bind_for_event_class(DnD_Handle, _bind_for_event_class(DnD_Handle,
['::blt::drag&drop', 'target', win, 'handler'], ['::blt::drag&drop', 'target', win, 'handler'],
cmd, *args) cmd, *args)
end end

View file

@ -11,7 +11,7 @@ module Tk::BLT
class Graph < TkWindow class Graph < TkWindow
TkCommandNames = ['::blt::graph'.freeze].freeze TkCommandNames = ['::blt::graph'.freeze].freeze
WidgetClassName = 'Graph'.freeze WidgetClassName = 'Graph'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
include PlotComponent include PlotComponent
include GraphCommand include GraphCommand
@ -27,7 +27,7 @@ module Tk::BLT
private :__strval_optkeys private :__strval_optkeys
=begin =begin
BarElement_ID = ['blt_graph_bar'.freeze, '00000'.taint].freeze BarElement_ID = ['blt_graph_bar'.freeze, TkUtil.untrust('00000')].freeze
def bar(elem=nil, keys={}) def bar(elem=nil, keys={})
if elem.kind_of?(Hash) if elem.kind_of?(Hash)

View file

@ -19,8 +19,9 @@ module Tk::BLT
TkCommandNames = ['::blt::htext'.freeze].freeze TkCommandNames = ['::blt::htext'.freeze].freeze
WidgetClassName = 'Htext'.freeze WidgetClassName = 'Htext'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
alias window_cget_tkstring itemcget_tkstring
alias window_cget itemcget alias window_cget itemcget
alias window_cget_strict itemcget_strict alias window_cget_strict itemcget_strict
alias window_configure itemconfigure alias window_configure itemconfigure

View file

@ -2,7 +2,7 @@
# setup.rb -- setup script before calling TkPackage.require() # setup.rb -- setup script before calling TkPackage.require()
# #
# If you need some setup operations (for example, add a library path # If you need some setup operations (for example, add a library path
# to the library search path) before using Tcl/Tk library packages # to the library search path) before using Tcl/Tk library packages
# wrapped by Ruby scripts in this directory, please write the setup # wrapped by Ruby scripts in this directory, please write the setup
# operations in this file. # operations in this file.
# #

View file

@ -11,7 +11,7 @@ module Tk::BLT
class Stripchart < TkWindow class Stripchart < TkWindow
TkCommandNames = ['::blt::stripchart'.freeze].freeze TkCommandNames = ['::blt::stripchart'.freeze].freeze
WidgetClassName = 'Stripchart'.freeze WidgetClassName = 'Stripchart'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
include PlotComponent include PlotComponent
include GraphCommand include GraphCommand
@ -22,13 +22,13 @@ module Tk::BLT
private :__boolval_optkeys private :__boolval_optkeys
def __strval_optkeys def __strval_optkeys
['text', 'label', 'title', 'file', ['text', 'label', 'title', 'file',
'background', 'plotbackground'] 'background', 'plotbackground']
end end
private :__strval_optkeys private :__strval_optkeys
=begin =begin
BarElement_ID = ['blt_stripchart_bar'.freeze, '00000'.taint].freeze BarElement_ID = ['blt_stripchart_bar'.freeze, TkUtil.untrust('00000')].freeze
def bar(elem=nil, keys={}) def bar(elem=nil, keys={})
if elem.kind_of?(Hash) if elem.kind_of?(Hash)

View file

@ -26,6 +26,9 @@ module Tk::BLT
self self
end end
def blt_table_cget_tkstring(*args)
Tk::BLT::Table.cget_tkstring(self, *args)
end
def blt_table_cget(*args) def blt_table_cget(*args)
Tk::BLT::Table.cget(self, *args) Tk::BLT::Table.cget(self, *args)
end end
@ -92,6 +95,9 @@ module Tk::BLT
self self
end end
def blt_table_itemcget_tkstring(*args)
Tk::BLT::Table.itemcget_tkstring(self, *args)
end
def blt_table_itemcget(*args) def blt_table_itemcget(*args)
Tk::BLT::Table.itemcget(self, *args) Tk::BLT::Table.itemcget(self, *args)
end end
@ -141,13 +147,14 @@ class << Tk::BLT::Table
end end
private :__item_pathname private :__item_pathname
alias __itemcget_tkstring itemcget_tkstring
alias __itemcget itemcget alias __itemcget itemcget
alias __itemcget_strict itemcget_strict alias __itemcget_strict itemcget_strict
alias __itemconfigure itemconfigure alias __itemconfigure itemconfigure
alias __itemconfiginfo itemconfiginfo alias __itemconfiginfo itemconfiginfo
alias __current_itemconfiginfo current_itemconfiginfo alias __current_itemconfiginfo current_itemconfiginfo
private :__itemcget, :__itemcget_strict private :__itemcget_tkstring, :__itemcget, :__itemcget_strict
private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
def __boolval_optkeys def __boolval_optkeys
@ -180,6 +187,9 @@ class << Tk::BLT::Table
############################################ ############################################
def cget_tkstring(container, option)
__itemcget_tkstring([container], option)
end
def cget(container, option) def cget(container, option)
__itemcget([container], option) __itemcget([container], option)
end end
@ -199,6 +209,9 @@ class << Tk::BLT::Table
__current_itemconfiginfo([container], *args) __current_itemconfiginfo([container], *args)
end end
def itemcget_tkstring(container, item, option)
__itemcget_tkstring([container, tagid(item)], option)
end
def itemcget(container, item, option) def itemcget(container, item, option)
__itemcget([container, tagid(item)], option) __itemcget([container, tagid(item)], option)
end end

View file

@ -11,7 +11,7 @@ module Tk::BLT
class Tabnotebook < Tabset class Tabnotebook < Tabset
TkCommandNames = ['::blt::tabnotebook'.freeze].freeze TkCommandNames = ['::blt::tabnotebook'.freeze].freeze
WidgetClassName = 'Tabnotebook'.freeze WidgetClassName = 'Tabnotebook'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
class Tab < Tk::BLT::Tabset::Tab class Tab < Tk::BLT::Tabset::Tab
def self.new(parent, pos=nil, name=nil, keys={}) def self.new(parent, pos=nil, name=nil, keys={})
@ -99,7 +99,7 @@ module Tk::BLT
pos = nil pos = nil
end end
pos = 'end' if pos.nil? pos = 'end' if pos.nil?
Tk::BLT::Tabnotebook::Tab.new(self, nil, Tk::BLT::Tabnotebook::Tab.new(self, nil,
tk_send('insert', tagindex(pos), keys)) tk_send('insert', tagindex(pos), keys))
end end

View file

@ -13,7 +13,7 @@ module Tk::BLT
TabID_TBL = TkCore::INTERP.create_table TabID_TBL = TkCore::INTERP.create_table
(TabsetTab_ID = ['blt_tabset_tab'.freeze, '00000'.taint]).instance_eval{ (TabsetTab_ID = ['blt_tabset_tab'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -132,6 +132,9 @@ module Tk::BLT
@t.tab_bindinfo(@id, context) @t.tab_bindinfo(@id, context)
end end
def cget_tkstring(*args)
@t.tab_cget_tkstring(@id, *args)
end
def cget(*args) def cget(*args)
@t.tab_cget(@id, *args) @t.tab_cget(@id, *args)
end end
@ -210,7 +213,7 @@ module Tk::BLT
TkCommandNames = ['::blt::tabset'.freeze].freeze TkCommandNames = ['::blt::tabset'.freeze].freeze
WidgetClassName = 'Tabset'.freeze WidgetClassName = 'Tabset'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def __destroy_hook__ def __destroy_hook__
Tk::BLT::Tabset::Tab::TabID_TBL.mutex.synchronize{ Tk::BLT::Tabset::Tab::TabID_TBL.mutex.synchronize{
@ -249,6 +252,7 @@ module Tk::BLT
end end
private :__item_pathname private :__item_pathname
alias tab_cget_tkstring itemcget_tkstring
alias tab_cget itemcget alias tab_cget itemcget
alias tab_cget_strict itemcget_strict alias tab_cget_strict itemcget_strict
alias tab_configure itemconfigure alias tab_configure itemconfigure

View file

@ -30,9 +30,12 @@ module Tk::BLT
end end
private :__item_config_cmd private :__item_config_cmd
private :itemcget, :itemcget_strict private :itemcget_tkstring, :itemcget, :itemcget_strict
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
def cget_tkstring(master, option)
itemcget_tkstring(master, option)
end
def cget(master, option) def cget(master, option)
itemcget(master, option) itemcget(master, option)
end end

View file

@ -8,6 +8,10 @@ require 'tkextlib/blt.rb'
module Tk::BLT module Tk::BLT
module Tile module Tile
TkComm::TkExtlibAutoloadModule.unshift(self)
# Require autoload-symbols which is a same name as widget classname.
# Those are used at TkComm._genobj_for_tkwidget method.
autoload :Button, 'tkextlib/blt/tile/button.rb' autoload :Button, 'tkextlib/blt/tile/button.rb'
autoload :CheckButton, 'tkextlib/blt/tile/checkbutton.rb' autoload :CheckButton, 'tkextlib/blt/tile/checkbutton.rb'
autoload :Checkbutton, 'tkextlib/blt/tile/checkbutton.rb' autoload :Checkbutton, 'tkextlib/blt/tile/checkbutton.rb'

View file

@ -182,7 +182,7 @@ module Tk::BLT
def move(dest, keys={}) def move(dest, keys={})
@tree.keys(@id, dest, keys) @tree.keys(@id, dest, keys)
self self
end end
def next() def next()
@tree.next(@id) @tree.next(@id)
@ -272,7 +272,7 @@ module Tk::BLT
TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear } TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
} }
(TreeTag_ID = ['blt_tree_tag'.freeze, '00000'.taint]).instance_eval{ (TreeTag_ID = ['blt_tree_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -397,10 +397,10 @@ module Tk::BLT
NotifyID_TBL.mutex.synchronize{ NotifyID_TBL.mutex.synchronize{
if tree.kind_of?(Array) if tree.kind_of?(Array)
# not create # not create
tpath = tree[0].path tpath = tree[0].path
NotifyID_TBL[tpath] ||= {} NotifyID_TBL[tpath] ||= {}
unless (obj = NotifyID_TBL[tpath][tree[1]]) unless (obj = NotifyID_TBL[tpath][tree[1]])
(NotifyID_TBL[tpath][tree[1]] = (NotifyID_TBL[tpath][tree[1]] =
obj = self.allocate).instance_eval{ obj = self.allocate).instance_eval{
@parent = @tree = tree[0] @parent = @tree = tree[0]
@tpath = @parent.path @tpath = @parent.path
@ -438,7 +438,7 @@ module Tk::BLT
args = args.collect{|arg| '-' << arg.to_s} args = args.collect{|arg| '-' << arg.to_s}
args << proc{|id, type| args << proc{|id, type|
cmd.call(Tk::BLT::Tree::Node.id2obj(@tree, id), cmd.call(Tk::BLT::Tree::Node.id2obj(@tree, id),
((type[0] == ?-)? type[1..-1]: type)) ((type[0] == ?-)? type[1..-1]: type))
} }
@ -509,7 +509,7 @@ module Tk::BLT
tpath = tree[0].path tpath = tree[0].path
TraceID_TBL[tpath] ||= {} TraceID_TBL[tpath] ||= {}
unless (obj = TraceID_TBL[tpath][tree[1]]) unless (obj = TraceID_TBL[tpath][tree[1]])
(TraceID_TBL[tpath][tree[1]] = (TraceID_TBL[tpath][tree[1]] =
obj = self.allocate).instance_eval{ obj = self.allocate).instance_eval{
@parent = @tree = tree @parent = @tree = tree
@tpath = @parent.path @tpath = @parent.path
@ -541,8 +541,8 @@ module Tk::BLT
end end
end end
@path = @id = tk_call(@tpath, 'trace', 'create', node, key, opts, @path = @id = tk_call(@tpath, 'trace', 'create', node, key, opts,
proc{|t, id, k, ops| proc{|t, id, k, ops|
tobj = Tk::BLT::Tree.id2obj(t) tobj = Tk::BLT::Tree.id2obj(t)
if tobj.kind_of?(Tk::BLT::Tree) if tobj.kind_of?(Tk::BLT::Tree)
nobj = Tk::BLT::Tree::Node.id2obj(tobj, id) nobj = Tk::BLT::Tree::Node.id2obj(tobj, id)
@ -578,7 +578,7 @@ module Tk::BLT
TreeID_TBL = TkCore::INTERP.create_table TreeID_TBL = TkCore::INTERP.create_table
(Tree_ID = ['blt_tree'.freeze, '00000'.taint]).instance_eval{ (Tree_ID = ['blt_tree'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -599,8 +599,8 @@ module Tk::BLT
'recurse'=>nil, 'tags'=>nil, 'recurse'=>nil, 'tags'=>nil,
# sort command # sort command
'ascii'=>nil, 'decreasing'=>nil, 'disctionary'=>nil, 'ascii'=>nil, 'decreasing'=>nil, 'disctionary'=>nil,
'integer'=>nil, 'real'=>nil, 'recurse'=>nil, 'reorder'=>nil, 'integer'=>nil, 'real'=>nil, 'recurse'=>nil, 'reorder'=>nil,
} }
end end
@ -624,7 +624,7 @@ module Tk::BLT
def self.new(name = nil) def self.new(name = nil)
TreeID_TBL.mutex.synchronize{ TreeID_TBL.mutex.synchronize{
if name && TreeID_TBL[name] if name && TreeID_TBL[name]
TreeID_TBL[name] TreeID_TBL[name]
else else
(obj = self.allocate).instance_eval{ (obj = self.allocate).instance_eval{
initialize(name) initialize(name)
@ -680,7 +680,7 @@ module Tk::BLT
end end
def ancestor(node1, node2) def ancestor(node1, node2)
Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'ancestor', Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'ancestor',
tagid(node1), tagid(node2))) tagid(node1), tagid(node2)))
end end
@ -701,14 +701,14 @@ module Tk::BLT
end end
def copy(src, parent, keys={}) def copy(src, parent, keys={})
id = tk_call('::blt::tree', 'copy', tagid(src), tagid(parent), id = tk_call('::blt::tree', 'copy', tagid(src), tagid(parent),
__conv_keyonly_opts(keys)) __conv_keyonly_opts(keys))
Tk::BLT::Tree::Node.new(self, nil, 'node'=>id) Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
end end
def copy_to(src, dest_tree, parent, keys={}) def copy_to(src, dest_tree, parent, keys={})
return copy(src, parent, keys={}) unless dest_tree return copy(src, parent, keys={}) unless dest_tree
id = tk_call('::blt::tree', 'copy', tagid(src), dest_tree, id = tk_call('::blt::tree', 'copy', tagid(src), dest_tree,
tagid(parent), __conv_keyonly_opts(keys)) tagid(parent), __conv_keyonly_opts(keys))
Tk::BLT::Tree::Node.new(dest_tree, nil, 'node'=>id) Tk::BLT::Tree::Node.new(dest_tree, nil, 'node'=>id)
end end
@ -751,7 +751,7 @@ module Tk::BLT
end end
def find(node, keys={}) def find(node, keys={})
simplelist(tk_call('::blt::tree', 'find', tagid(node), simplelist(tk_call('::blt::tree', 'find', tagid(node),
__conv_keyonly_opts(keys))).collect{|n| __conv_keyonly_opts(keys))).collect{|n|
Tk::BLT::Tree::Node.id2obj(self, n) Tk::BLT::Tree::Node.id2obj(self, n)
} }
@ -775,7 +775,7 @@ module Tk::BLT
end end
def index(node) def index(node)
Tk::BLT::Tree::Node.id2obj(self, Tk::BLT::Tree::Node.id2obj(self,
tk_call('::blt::tree', 'index', tagid(node))) tk_call('::blt::tree', 'index', tagid(node)))
end end
@ -785,11 +785,11 @@ module Tk::BLT
end end
def ancestor?(node1, node2) def ancestor?(node1, node2)
bool(tk_call('::blt::tree', 'is', 'ancestor', bool(tk_call('::blt::tree', 'is', 'ancestor',
tagid(node1), tagid(node2))) tagid(node1), tagid(node2)))
end end
def before?(node1, node2) def before?(node1, node2)
bool(tk_call('::blt::tree', 'is', 'before', bool(tk_call('::blt::tree', 'is', 'before',
tagid(node1), tagid(node2))) tagid(node1), tagid(node2)))
end end
def leaf?(node) def leaf?(node)
@ -806,7 +806,7 @@ module Tk::BLT
if nodes.empty? if nodes.empty?
simplelist(tk_call('blt::tree', 'keys', tagid(node))) simplelist(tk_call('blt::tree', 'keys', tagid(node)))
else else
simplelist(tk_call('blt::tree', 'keys', tagid(node), simplelist(tk_call('blt::tree', 'keys', tagid(node),
*(nodes.collect{|n| tagid(n)}))).collect{|lst| *(nodes.collect{|n| tagid(n)}))).collect{|lst|
simplelist(lst) simplelist(lst)
} }
@ -828,7 +828,7 @@ module Tk::BLT
end end
def link(parent, node, keys={}) def link(parent, node, keys={})
ret = tk_call('::blt::tree', 'link', tagid(parent), tagid(node), ret = tk_call('::blt::tree', 'link', tagid(parent), tagid(node),
__conv_keyonly_opts(keys)) __conv_keyonly_opts(keys))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret) (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end end
@ -902,7 +902,7 @@ module Tk::BLT
end end
def restore(node, str, keys={}) def restore(node, str, keys={})
tk_call('::blt::tree', 'restore', tagid(node), str, tk_call('::blt::tree', 'restore', tagid(node), str,
__conv_keyonly_opts(keys)) __conv_keyonly_opts(keys))
self self
end end
@ -915,7 +915,7 @@ module Tk::BLT
end end
def restore_from_file(node, file, keys={}) def restore_from_file(node, file, keys={})
tk_call('::blt::tree', 'restorefile', tagid(node), file, tk_call('::blt::tree', 'restorefile', tagid(node), file,
__conv_keyonly_opts(keys)) __conv_keyonly_opts(keys))
self self
end end
@ -923,13 +923,13 @@ module Tk::BLT
keys = __conv_keyonly_opts(keys) keys = __conv_keyonly_opts(keys)
keys.delete('overwrite') keys.delete('overwrite')
keys.delete(:overwrite) keys.delete(:overwrite)
tk_call('::blt::tree', 'restorefile', tagid(node), file, tk_call('::blt::tree', 'restorefile', tagid(node), file,
'-overwrite', keys) '-overwrite', keys)
self self
end end
def root(node=None) def root(node=None)
Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'root', Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'root',
tagid(node))) tagid(node)))
end end
@ -958,7 +958,7 @@ module Tk::BLT
end end
def tag_delete(tag, *nodes) def tag_delete(tag, *nodes)
tk_call(@path, 'tag', 'delete', tagid(tag), tk_call(@path, 'tag', 'delete', tagid(tag),
*(nodes.collect{|n| tagid(n)})) *(nodes.collect{|n| tagid(n)}))
self self
end end
@ -973,7 +973,7 @@ module Tk::BLT
end end
def tag_get(node, *patterns) def tag_get(node, *patterns)
simplelist(tk_call(@tpath, 'tag', 'get', tagid(node), simplelist(tk_call(@tpath, 'tag', 'get', tagid(node),
*(patterns.collect{|pat| tagid(pat)}))).collect{|str| *(patterns.collect{|pat| tagid(pat)}))).collect{|str|
Tk::BLT::Tree::Tag.id2obj(self, str) Tk::BLT::Tree::Tag.id2obj(self, str)
} }
@ -997,7 +997,7 @@ module Tk::BLT
end end
def tag_unset(node, *tags) def tag_unset(node, *tags)
tk_call(@path, 'tag', 'unset', tagid(node), tk_call(@path, 'tag', 'unset', tagid(node),
*(tags.collect{|t| tagid(t)})) *(tags.collect{|t| tagid(t)}))
self self
end end

View file

@ -95,6 +95,9 @@ module Tk::BLT::Treeview::ConfigMethod
end end
private :__item_pathname private :__item_pathname
def column_cget_tkstring(name, option)
itemcget_tkstring(['column', name], option)
end
def column_cget(name, option) def column_cget(name, option)
itemcget(['column', name], option) itemcget(['column', name], option)
end end
@ -111,6 +114,9 @@ module Tk::BLT::Treeview::ConfigMethod
current_itemconfiginfo(['column', name], slot) current_itemconfiginfo(['column', name], slot)
end end
def button_cget_tkstring(option)
itemcget_tkstring('button', option)
end
def button_cget(option) def button_cget(option)
itemcget('button', option) itemcget('button', option)
end end
@ -127,6 +133,9 @@ module Tk::BLT::Treeview::ConfigMethod
current_itemconfiginfo('button', slot) current_itemconfiginfo('button', slot)
end end
def entry_cget_tkstring(option)
itemcget_tkstring('entry', option)
end
def entry_cget(option) def entry_cget(option)
ret = itemcget('entry', option) ret = itemcget('entry', option)
if option == 'bindtags' || option == :bindtags if option == 'bindtags' || option == :bindtags
@ -181,6 +190,9 @@ module Tk::BLT::Treeview::ConfigMethod
ret ret
end end
def sort_cget_tkstring(option)
itemcget_tkstring('sort', option)
end
def sort_cget(option) def sort_cget(option)
itemcget('sort', option) itemcget('sort', option)
end end
@ -197,6 +209,9 @@ module Tk::BLT::Treeview::ConfigMethod
current_itemconfiginfo('sort', slot) current_itemconfiginfo('sort', slot)
end end
def text_cget_tkstring(option)
itemcget_tkstring('text', option)
end
def text_cget(option) def text_cget(option)
itemcget('text', option) itemcget('text', option)
end end
@ -213,14 +228,14 @@ module Tk::BLT::Treeview::ConfigMethod
current_itemconfiginfo('text', slot) current_itemconfiginfo('text', slot)
end end
private :itemcget, :itemcget_strict private :itemcget_tkstring, :itemcget, :itemcget_strict
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end end
class Tk::BLT::Treeview class Tk::BLT::Treeview
TkCommandNames = ['::blt::treeview'.freeze].freeze TkCommandNames = ['::blt::treeview'.freeze].freeze
WidgetClassName = 'TreeView'.freeze WidgetClassName = 'TreeView'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
include Scrollable include Scrollable
include ValidateConfigure include ValidateConfigure
@ -230,7 +245,7 @@ class Tk::BLT::Treeview
######################## ########################
def __boolval_optkeys def __boolval_optkeys
['autocreate', 'allowduplicates', 'exportselection', 'flat', 'hideroot', ['autocreate', 'allowduplicates', 'exportselection', 'flat', 'hideroot',
'newtags', 'showtitles', 'sortselection'] 'newtags', 'showtitles', 'sortselection']
end end
private :__boolval_optkeys private :__boolval_optkeys
@ -245,17 +260,17 @@ class Tk::BLT::Treeview
class OpenCloseCommand < TkValidateCommand class OpenCloseCommand < TkValidateCommand
class ValidateArgs < TkUtil::CallbackSubst class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [ KEY_TBL = [
[ ?W, ?w, :widget ], [ ?W, ?w, :widget ],
[ ?p, ?s, :name ], [ ?p, ?s, :name ],
[ ?P, ?s, :fullpath ], [ ?P, ?s, :fullpath ],
[ ?#, ?x, :node_id ], [ ?#, ?x, :node_id ],
nil nil
] ]
PROC_TBL = [ PROC_TBL = [
[ ?x, TkComm.method(:num_or_str) ], [ ?x, TkComm.method(:num_or_str) ],
[ ?s, TkComm.method(:string) ], [ ?s, TkComm.method(:string) ],
[ ?w, TkComm.method(:window) ], [ ?w, TkComm.method(:window) ],
nil nil
] ]
@ -463,7 +478,7 @@ class Tk::BLT::Treeview
self self
end end
def entry_children(tag, first=None, last=None) def entry_children(tag, first=None, last=None)
simplelist(tk_send('entry', 'children', tagid(tag), simplelist(tk_send('entry', 'children', tagid(tag),
first, last)).collect{|id| tagid2obj(id)} first, last)).collect{|id| tagid2obj(id)}
end end
def entry_delete(tag, first=None, last=None) def entry_delete(tag, first=None, last=None)
@ -500,17 +515,17 @@ class Tk::BLT::Treeview
class FindExecFlagValue < TkValidateCommand class FindExecFlagValue < TkValidateCommand
class ValidateArgs < TkUtil::CallbackSubst class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [ KEY_TBL = [
[ ?W, ?w, :widget ], [ ?W, ?w, :widget ],
[ ?p, ?s, :name ], [ ?p, ?s, :name ],
[ ?P, ?s, :fullpath ], [ ?P, ?s, :fullpath ],
[ ?#, ?x, :node_id ], [ ?#, ?x, :node_id ],
nil nil
] ]
PROC_TBL = [ PROC_TBL = [
[ ?x, TkComm.method(:num_or_str) ], [ ?x, TkComm.method(:num_or_str) ],
[ ?s, TkComm.method(:string) ], [ ?s, TkComm.method(:string) ],
[ ?w, TkComm.method(:window) ], [ ?w, TkComm.method(:window) ],
nil nil
] ]
@ -646,7 +661,7 @@ class Tk::BLT::Treeview
} }
end end
def range_open(first, last) def range_open(first, last)
simplelist(tk_send('range', '-open', simplelist(tk_send('range', '-open',
tagid(first), tagid(last))).collect{|id| tagid(first), tagid(last))).collect{|id|
tagid2obj(id) tagid2obj(id)
} }
@ -1029,7 +1044,7 @@ class Tk::BLT::Treeview::Node < TkObject
TreeNodeID_TBL = TkCore::INTERP.create_table TreeNodeID_TBL = TkCore::INTERP.create_table
(TreeNode_ID = ['blt_treeview_node'.freeze, '00000'.taint]).instance_eval{ (TreeNode_ID = ['blt_treeview_node'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -1118,7 +1133,7 @@ class Tk::BLT::Treeview::Node < TkObject
at = keys.delete['at'] at = keys.delete['at']
if parent if parent
if parent.kind_of?(Tk::BLT::Treeview::Node) || if parent.kind_of?(Tk::BLT::Treeview::Node) ||
parent.kind_of?(Tk::BLT::Treeview::Tag) parent.kind_of?(Tk::BLT::Treeview::Tag)
path = [get_full(parent.id)[0], name] path = [get_full(parent.id)[0], name]
at = nil # ignore 'at' option at = nil # ignore 'at' option
@ -1150,7 +1165,7 @@ class Tk::BLT::Treeview::Tag < TkObject
TreeTagID_TBL = TkCore::INTERP.create_table TreeTagID_TBL = TkCore::INTERP.create_table
(TreeTag_ID = ['blt_treeview_tag'.freeze, '00000'.taint]).instance_eval{ (TreeTag_ID = ['blt_treeview_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze
@ -1268,5 +1283,5 @@ end
class Tk::BLT::Hiertable class Tk::BLT::Hiertable
TkCommandNames = ['::blt::hiertable'.freeze].freeze TkCommandNames = ['::blt::hiertable'.freeze].freeze
WidgetClassName = 'Hiertable'.freeze WidgetClassName = 'Hiertable'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
end end

View file

@ -30,9 +30,12 @@ module Tk::BLT
end end
private :__item_config_cmd private :__item_config_cmd
private :itemcget, :itemcget_strict private :itemcget_tkstring, :itemcget, :itemcget_strict
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
def cget_tkstring(win, option)
itemcget_tkstring(['cget', win], option)
end
def cget(win, option) def cget(win, option)
itemcget(['cget', win], option) itemcget(['cget', win], option)
end end
@ -49,6 +52,9 @@ module Tk::BLT
current_itemconfiginfo(['configure', win], slot) current_itemconfiginfo(['configure', win], slot)
end end
def token_cget_tkstring(win, option)
itemcget_tkstring(['token', 'cget', win], option)
end
def token_cget(win, option) def token_cget(win, option)
itemcget(['token', 'cget', win], option) itemcget(['token', 'cget', win], option)
end end

View file

@ -49,10 +49,10 @@ module Tk::BLT
size = size.join(':') size = size.join(':')
end end
if size if size
@id = TkCore::INTERP._invoke('::blt::vector', 'create', @id = TkCore::INTERP._invoke('::blt::vector', 'create',
"#auto(#{size})", *hash_kv(keys)) "#auto(#{size})", *hash_kv(keys))
else else
@id = TkCore::INTERP._invoke('::blt::vector', 'create', @id = TkCore::INTERP._invoke('::blt::vector', 'create',
"#auto", *hash_kv(keys)) "#auto", *hash_kv(keys))
end end

View file

@ -14,7 +14,7 @@ module Tk::BLT
WATCH_ID_TBL = TkCore::INTERP.create_table WATCH_ID_TBL = TkCore::INTERP.create_table
(BLT_WATCH_ID = ['blt_watch_id'.freeze, '00000'.taint]).instance_eval{ (BLT_WATCH_ID = ['blt_watch_id'.freeze, TkUtil.untrust('00000')]).instance_eval{
@mutex = Mutex.new @mutex = Mutex.new
def mutex; @mutex; end def mutex; @mutex; end
freeze freeze

View file

@ -38,7 +38,7 @@ class << Tk::BLT::Winop
tk_call('::blt::winop', 'image', 'readjpeg', file, photo) tk_call('::blt::winop', 'image', 'readjpeg', file, photo)
end end
def image_resample(src, dest, horiz_filter=None, vert_filter=None) def image_resample(src, dest, horiz_filter=None, vert_filter=None)
tk_call('::blt::winop', 'image', 'resample', tk_call('::blt::winop', 'image', 'resample',
src, dest, horiz_filter, vert_filter) src, dest, horiz_filter, vert_filter)
end end
def image_rotate(src, dest, angle) def image_rotate(src, dest, angle)
@ -47,9 +47,9 @@ class << Tk::BLT::Winop
def image_snap(win, photo, width=None, height=None) def image_snap(win, photo, width=None, height=None)
tk_call('::blt::winop', 'image', 'snap', win, photo, width, height) tk_call('::blt::winop', 'image', 'snap', win, photo, width, height)
end end
def image_subsample(src, dest, x, y, width, height, def image_subsample(src, dest, x, y, width, height,
horiz_filter=None, vert_filter=None) horiz_filter=None, vert_filter=None)
tk_call('::blt::winop', 'image', 'subsample', tk_call('::blt::winop', 'image', 'subsample',
src, dest, x, y, width, height, horiz_filter, vert_filter) src, dest, x, y, width, height, horiz_filter, vert_filter)
end end
@ -66,13 +66,13 @@ class << Tk::BLT::Winop
end end
def resample(src, dest, horiz_filter=None, vert_filter=None) def resample(src, dest, horiz_filter=None, vert_filter=None)
tk_call('::blt::winop', 'resample', tk_call('::blt::winop', 'resample',
src, dest, horiz_filter, vert_filter) src, dest, horiz_filter, vert_filter)
end end
def subsample(src, dest, x, y, width, height, def subsample(src, dest, x, y, width, height,
horiz_filter=None, vert_filter=None) horiz_filter=None, vert_filter=None)
tk_call('::blt::winop', 'subsample', tk_call('::blt::winop', 'subsample',
src, dest, x, y, width, height, horiz_filter, vert_filter) src, dest, x, y, width, height, horiz_filter, vert_filter)
end end

View file

@ -18,6 +18,8 @@ TkPackage.require('BWidget')
module Tk module Tk
module BWidget module BWidget
TkComm::TkExtlibAutoloadModule.unshift(self) TkComm::TkExtlibAutoloadModule.unshift(self)
# Require autoload-symbols which is a same name as widget classname.
# Those are used at TkComm._genobj_for_tkwidget method.
extend TkCore extend TkCore

View file

@ -17,5 +17,5 @@ end
class Tk::BWidget::ArrowButton class Tk::BWidget::ArrowButton
TkCommandNames = ['ArrowButton'.freeze].freeze TkCommandNames = ['ArrowButton'.freeze].freeze
WidgetClassName = 'ArrowButton'.freeze WidgetClassName = 'ArrowButton'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
end end

View file

@ -17,7 +17,7 @@ end
class Tk::BWidget::Button class Tk::BWidget::Button
TkCommandNames = ['Button'.freeze].freeze TkCommandNames = ['Button'.freeze].freeze
WidgetClassName = 'Button'.freeze WidgetClassName = 'Button'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def __strval_optkeys def __strval_optkeys
super() << 'helptext' super() << 'helptext'

View file

@ -17,7 +17,7 @@ end
class Tk::BWidget::ButtonBox class Tk::BWidget::ButtonBox
TkCommandNames = ['ButtonBox'.freeze].freeze TkCommandNames = ['ButtonBox'.freeze].freeze
WidgetClassName = 'ButtonBox'.freeze WidgetClassName = 'ButtonBox'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
include TkItemConfigMethod include TkItemConfigMethod

View file

@ -21,7 +21,12 @@ class Tk::BWidget::ComboBox
TkCommandNames = ['ComboBox'.freeze].freeze TkCommandNames = ['ComboBox'.freeze].freeze
WidgetClassName = 'ComboBox'.freeze WidgetClassName = 'ComboBox'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] ||= self
def __boolval_optkeys
super() << 'autocomplete' << 'autopost'
end
private :__boolval_optkeys
def get_listbox(&b) def get_listbox(&b)
win = window(tk_send_without_enc('getlistbox')) win = window(tk_send_without_enc('getlistbox'))
@ -35,6 +40,12 @@ class Tk::BWidget::ComboBox
win win
end end
def clear_value
tk_send_without_enc('clearvalue')
self
end
alias clearvalue clear_value
def icursor(idx) def icursor(idx)
tk_send_without_enc('icursor', idx) tk_send_without_enc('icursor', idx)
end end

Some files were not shown because too many files have changed in this diff Show more