* 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>
* 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>
* ext/tk/lib/tkextlib/blt/tabset.rb,

View file

@ -140,8 +140,7 @@ module TclTklib
[module methods]
get_version()
: return an array of major, minor, release-type number,
: number, release-type name, and patchlevel of current
: Tcl/Tk library.
: and patchlevel of current Tcl/Tk library.
mainloop(check_root = true)
: 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
: 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)
_fromUTF8(str, encoding=nil)
: Call the function (which is internal function of Tcl/Tk) to

View file

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

View file

@ -1,18 +1,53 @@
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
Tcl/Tk libraries or header files are installed but are not found, you can
give the information by arguments of the 'configure' script. Please give
some or all of the following options.
--with-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>
force version of Tcl/Tk libaray
(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-tklib=<libname> (e.g. libtk8.4.so ==> --with-tklib=tk8.4)
--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>
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
--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>
Tcl framework headers directory
(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 MultiTkIp
@@IP_TABLE = {}.taint unless defined?(@@IP_TABLE)
@@TK_TABLE_LIST = [].taint unless defined?(@@TK_TABLE_LIST)
@@IP_TABLE = TkUtil.untrust({}) unless defined?(@@IP_TABLE)
@@TK_TABLE_LIST = TkUtil.untrust([]) unless defined?(@@TK_TABLE_LIST)
def self._IP_TABLE; @@IP_TABLE; end
def self._TK_TABLE_LIST; @@TK_TABLE_LIST; end
@ -88,10 +88,14 @@ class RemoteTkIp
@slave_ip_tbl = {}
@slave_ip_top = {}
@tk_windows.taint unless @tk_windows.tainted?
@tk_table_list.taint unless @tk_table_list.tainted?
@slave_ip_tbl.taint unless @slave_ip_tbl.tainted?
@slave_ip_top.taint unless @slave_ip_top.tainted?
@force_default_encoding ||= TkUtil.untrust([false])
@encoding ||= TkUtil.untrust([nil])
def @encoding.to_s; self.join(nil); end
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
@ -114,8 +118,8 @@ class RemoteTkIp
@@DEFAULT_MASTER.assign_receiver_and_watchdog(self)
@@IP_TABLE[@threadgroup] = self
@@TK_TABLE_LIST.size.times{
(tbl = {}).tainted? || tbl.taint
@@TK_TABLE_LIST.size.times{
(tbl = {}).tainted? || TkUtil.untrust(tbl)
@tk_table_list << tbl
}
@ -154,13 +158,13 @@ class RemoteTkIp
return nil if timeout < 1
@ret_val.value = ''
@interp._invoke('send', '-async', @remote,
'send', '-async', Tk.appname,
@interp._invoke('send', '-async', @remote,
'send', '-async', Tk.appname,
"set #{@ret_val.id} ready")
Tk.update
if @ret_val != 'ready'
(1..(timeout*5)).each{
sleep 0.2
sleep 0.2
Tk.update
break if @ret_val == 'ready'
}
@ -204,10 +208,10 @@ class RemoteTkIp
cmds = @interp._merge_tklist(*TkUtil::_conv_args([], enc_mode, *cmds))
if @displayof
if async
@interp.__invoke('send', '-async', '-displayof', @displayof,
@interp.__invoke('send', '-async', '-displayof', @displayof,
'--', @remote, *cmds)
else
@interp.__invoke('send', '-displayof', @displayof,
@interp.__invoke('send', '-displayof', @displayof,
'--', @remote, *cmds)
end
else
@ -229,7 +233,7 @@ class RemoteTkIp
def is_rubytk?
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') ]
end
@ -298,7 +302,7 @@ class RemoteTkIp
raise SecurityError, "no permission to manipulate" unless self.manipulable?
if @displayof
lst = @interp._invoke_without_enc('winfo', 'interps',
lst = @interp._invoke_without_enc('winfo', 'interps',
'-displayof', @displayof)
else
lst = @interp._invoke_without_enc('winfo', 'interps')

View file

@ -84,7 +84,7 @@ end
# class TclTkInterpreter: tcl/tk interpreter
class TclTkInterpreter
# initialize():
# initialize():
def initialize()
# generate interpreter object
@ip = TclTkIp.new()
@ -181,7 +181,7 @@ end
# class TclTkObject: base class of the tcl/tk objects
class TclTkObject
# initialize(ip, exp):
# initialize(ip, exp):
# ip: interpreter(TclTkIp)
# exp: tcl/tk representation
def initialize(ip, exp)
@ -211,7 +211,7 @@ end
# class TclTkLibCommand: tcl/tk commands in the library
class TclTkLibCommand < TclTkCommand
# initialize(ip, name):
# initialize(ip, name):
# ip: interpreter(TclTkInterpreter)
# name: command name (String)
def initialize(ip, name)
@ -222,7 +222,7 @@ end
# class TclTkVariable: tcl/tk variable
class TclTkVariable < TclTkObject
# initialize(interp, dat):
# initialize(interp, dat):
# interp: interpreter(TclTkInterpreter)
# dat: the value to set(String)
# if nil, not initialize variable
@ -255,7 +255,7 @@ end
# class TclTkWidget: tcl/tk widget
class TclTkWidget < TclTkCommand
# initialize(*args):
# initialize(*args):
# *args: parameters
def initialize(*args)
if args[0].kind_of?(TclTkIp)
@ -281,7 +281,7 @@ class TclTkWidget < TclTkCommand
# interp: interpreter(TclTkInterpreter)
# parent: parent widget
# command: widget generating tk command(label Åù)
# *args: argument to the command
# *args: argument to the command
interp, parent, command, *args = args
# generate widget name
@ -303,14 +303,14 @@ end
# class TclTkCallback: tcl/tk callbacks
class TclTkCallback < TclTkObject
# initialize(interp, pr, arg):
# initialize(interp, pr, arg):
# interp: interpreter(TclTkInterpreter)
# pr: callback procedure(Proc)
# arg: string to pass as block parameters of pr
# bind command of tcl/tk uses % replacement for parameters
# pr can receive replaced data using block parameter
# 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
# without specifying any replacement
def initialize(interp, pr, arg = nil)
@ -347,7 +347,7 @@ end
# class TclTkImage: tcl/tk images
class TclTkImage < TclTkCommand
# initialize(interp, t, *args):
# initialize(interp, t, *args):
# generating image is done by TclTkImage.new()
# destrying is done by image delete (inconsistent, sigh)
# 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
module Tk
autoload :Busy, 'tk/busy'
autoload :Button, 'tk/button'
autoload :Canvas, 'tk/canvas'
@ -250,78 +252,85 @@ autoload :TkXIM, 'tk/xim'
module Tk
@TOPLEVEL_ALIAS_TABLE = {}
@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',
# :TkDialog2 => 'tk/dialog',
# :TkDialogObj => 'tk/dialog',
# :TkWarning => 'tk/dialog',
# :TkWarning2 => 'tk/dialog',
# :TkWarningObj => 'tk/dialog',
# :TkDialog => 'tk/dialog',
# :TkDialog2 => 'tk/dialog',
# :TkDialogObj => 'tk/dialog',
# :TkWarning => 'tk/dialog',
# :TkWarning2 => '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',
:TkMenuClone => 'tk/menu',
:TkCloneMenu => 'tk/menu',
# :TkSystemMenu => 'tk/menu',
:TkSysMenu_Help => 'tk/menu',
:TkSysMenu_System => 'tk/menu',
:TkSysMenu_Apple => 'tk/menu',
:TkMenubutton => 'tk/menu',
:TkMenuButton => 'tk/menu',
:TkOptionMenubutton => 'tk/menu',
:TkOptionMenuButton => 'tk/menu',
:TkMenu => 'tk/menu',
:TkMenuClone => 'tk/menu',
:TkCloneMenu => 'tk/menu',
# :TkSystemMenu => 'tk/menu',
:TkSysMenu_Help => 'tk/menu',
:TkSysMenu_System => 'tk/menu',
:TkSysMenu_Apple => 'tk/menu',
:TkMenubutton => 'tk/menu',
:TkMenuButton => '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',
:TkXScrollbar => 'tk/scrollbar',
:TkYScrollbar => 'tk/scrollbar',
:TkScrollbar => 'tk/scrollbar',
:TkXScrollbar => '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',
:TkWinRegistry => 'tk/winpkg',
:TkWinDDE => 'tk/winpkg',
:TkWinRegistry => 'tk/winpkg',
}
@TOPLEVEL_ALIAS_OWNER = {}
@TOPLEVEL_ALIAS_SETUP_PROC = {}
@AUTOLOAD_FILE_SYM_TABLE = Hash.new{|h,k| h[k]={}} # TABLE[file][sym] -> obj
@current_default_widget_set = nil
module TOPLEVEL_ALIASES; end
end
class Object
include Tk::TOPLEVEL_ALIASES
end
############################################
# methods to control default widget set
@ -343,50 +352,387 @@ class << Tk
_replace_toplevel_aliases(target)
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] ||= {}
symbols.each{|sym|
@TOPLEVEL_ALIAS_TABLE[target][sym = sym.to_sym] = obj
# if @current_default_widget_set == target
if @TOPLEVEL_ALIAS_OWNER[sym] == target
Object.class_eval{remove_const sym} if Object.const_defined?(sym)
Object.const_set(sym, obj)
if !topalias_defined?(sym) || target == @current_default_widget_set
@TOPLEVEL_ALIAS_OWNER[sym] = target
replace_topalias(sym, obj)
replace_topobj(sym, obj) unless obj.kind_of?(String) # NOT autoload
end
}
end
###################################
private
def _replace_toplevel_aliases(target)
# check already autoloaded
if (table = @TOPLEVEL_ALIAS_TABLE[current = @current_default_widget_set])
table.each{|sym, file|
if !Object.autoload?(sym) && Object.const_defined?(sym) &&
@TOPLEVEL_ALIAS_TABLE[current][sym].kind_of?(String)
# autoload -> class
@TOPLEVEL_ALIAS_TABLE[current][sym] = Object.const_get(sym)
def regist_sym_for_loaded_file(auto, obj, sym)
@AUTOLOAD_FILE_SYM_TABLE[auto][sym] = obj
reg = /^#{Regexp.quote(auto)}(\.rb|\.so|)$/
@TOPLEVEL_ALIAS_TABLE.each_key{|set|
if @TOPLEVEL_ALIAS_TABLE[set][sym] =~ reg
@TOPLEVEL_ALIAS_TABLE[set][sym] = obj
if @TOPLEVEL_ALIAS_OWNER[sym].nil? || @TOPLEVEL_ALIAS_OWNER[sym] == set
replace_topalias(sym, obj)
replace_topobj(sym, obj) if set == @current_default_widget_set
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
# setup autoloads
@TOPLEVEL_ALIAS_TABLE[target].each{|sym, file|
Object.class_eval{remove_const sym} if Object.const_defined?(sym)
if file.kind_of?(String)
# file => autoload target file
Object.autoload(sym, file)
else
# file => loaded class object
Object.const_set(sym, file)
sym
end
private :set_topalias
def __set_toplevel_aliases__(target, obj, *symbols)
# obj is a kind of String : define autoload path
# Class : use the class object
target = target.to_sym
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
@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
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
############################################
# setup 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
# major, minor, type, type_name, patchlevel = TclTkLib.get_version
# major, minor, type, patchlevel = TclTkLib.get_version
############################################
# Ttk (Tile) support
=begin
if major > 8 ||
(major == 8 && minor > 5) ||
(major == 8 && minor == 5 && type >= TclTkLib::RELEASE_TYPE::BETA)
if major > 8 ||
(major == 8 && minor > 5) ||
(major == 8 && minor == 5 && type >= TclTkLib::RELEASE_TYPE::BETA)
# Tcl/Tk 8.5 beta or later
Object.autoload :Ttk, 'tkextlib/tile'
Tk.autoload :Tile, 'tkextlib/tile'

View file

@ -9,7 +9,7 @@ class TkBindTag
#BTagID_TBL = {}
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
def mutex; @mutex; end
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
TkCommandNames = ['button'.freeze].freeze
WidgetClassName = 'Button'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
# tk_call_without_enc('button', @path, *hash_kv(keys, true))
@ -27,4 +27,5 @@ class Tk::Button<Tk::Label
end
#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)
# maybe need to override
super(id) + [
'fill', 'activefill', 'disabledfill',
'fill', 'activefill', 'disabledfill',
'outline', 'activeoutline', 'disabledoutline'
]
end
@ -45,7 +45,7 @@ class Tk::Canvas<TkWindow
TkCommandNames = ['canvas'.freeze].freeze
WidgetClassName = 'Canvas'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
def __destroy_hook__
TkcItem::CItemID_TBL.delete(@path)
@ -117,7 +117,7 @@ class Tk::Canvas<TkWindow
end
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)}))
end
@ -181,7 +181,7 @@ class Tk::Canvas<TkWindow
end
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))
self
end
@ -214,7 +214,7 @@ class Tk::Canvas<TkWindow
alias deltag dtag
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)
}
end
@ -265,12 +265,18 @@ class Tk::Canvas<TkWindow
self
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)
number(tk_send_without_enc('index', tagid(tagOrId), idx))
end
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))
self
end
@ -300,7 +306,7 @@ class Tk::Canvas<TkWindow
fnt
end
else
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
"-#{option}")))
end
end
@ -315,16 +321,16 @@ class Tk::Canvas<TkWindow
|| key['latinfont'] || key['asciifont'] )
tagfont_configure(tagid(tagOrId), key.dup)
else
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
*hash_kv(key, true)))
end
else
if ( key == 'coords' || key == :coords )
self.coords(tagOrId, value)
elsif ( key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont ||
elsif ( key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont )
if value == None
tagfontobj(tagid(tagOrId))
@ -332,7 +338,7 @@ class Tk::Canvas<TkWindow
tagfont_configure(tagid(tagOrId), {key=>value})
end
else
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
"-#{key}", _get_eval_enc_str(value)))
end
end
@ -389,16 +395,16 @@ class Tk::Canvas<TkWindow
else
if conf[3]
if conf[3].index('{')
conf[3] = tk_split_list(conf[3])
conf[3] = tk_split_list(conf[3])
else
conf[3] = tk_tcl2ruby(conf[3])
conf[3] = tk_tcl2ruby(conf[3])
end
end
if conf[4]
if conf[4].index('{')
conf[4] = tk_split_list(conf[4])
conf[4] = tk_split_list(conf[4])
else
conf[4] = tk_tcl2ruby(conf[4])
conf[4] = tk_tcl2ruby(conf[4])
end
end
end
@ -421,8 +427,8 @@ class Tk::Canvas<TkWindow
when 'coords'
{'coords' => ['', '', '', self.coords(tagOrId)]}
when 'dash', 'activedash', 'disableddash'
conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
tagid(tagOrId),
conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
tagid(tagOrId),
"-#{key}"))
if conf[3] && conf[3] =~ /^[0-9]/
conf[3] = list(conf[3])
@ -457,16 +463,16 @@ class Tk::Canvas<TkWindow
else
if conf[2]
if conf[2].index('{')
conf[2] = tk_split_list(conf[2])
conf[2] = tk_split_list(conf[2])
else
conf[2] = tk_tcl2ruby(conf[2])
conf[2] = tk_tcl2ruby(conf[2])
end
end
if conf[3]
if conf[3].index('{')
conf[3] = tk_split_list(conf[3])
conf[3] = tk_split_list(conf[3])
else
conf[3] = tk_tcl2ruby(conf[3])
conf[3] = tk_tcl2ruby(conf[3])
end
end
end
@ -523,11 +529,18 @@ class Tk::Canvas<TkWindow
self
end
def move(tag, x, y)
tk_send_without_enc('move', tagid(tag), x, y)
def move(tag, dx, dy)
tk_send_without_enc('move', tagid(tag), dx, dy)
self
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)
tk_send("postscript", *hash_kv(keys))
end
@ -541,6 +554,15 @@ class Tk::Canvas<TkWindow
self
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)
tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
self
@ -581,7 +603,8 @@ class Tk::Canvas<TkWindow
end
#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
@ -676,7 +699,7 @@ class TkcItem<TkObject
fail RuntimeError, "#{self} is an abstract class"
end
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)
canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty?
idnum.to_i # 'canvas item id' is an integer number

View file

@ -60,6 +60,9 @@ module TkcTagAccess
@c.itembindinfo(@id, seq)
end
def cget_tkstring(option)
@c.itemcget_tkstring(@id, option)
end
def cget(option)
@c.itemcget(@id, option)
end
@ -116,6 +119,13 @@ module TkcTagAccess
self
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)
@c.index(@id, idx)
end
@ -135,6 +145,13 @@ module TkcTagAccess
self
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)
@c.raise(@id, abovethis)
self
@ -145,6 +162,14 @@ module TkcTagAccess
self
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)
@c.select('adjust', @id, index)
self
@ -203,7 +228,7 @@ class TkcTag<TkObject
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
def mutex; @mutex; end
freeze
@ -218,7 +243,7 @@ class TkcTag<TkObject
CTagID_TBL.mutex.synchronize{
if CTagID_TBL[cpath]
CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
else
else
id
end
}
@ -389,7 +414,7 @@ class TkcTagCurrent<TkcTagString
end
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
def mutex; @mutex; end
freeze
@ -414,7 +439,7 @@ class TkcGroup<TkcTag
include(*args) if args != []
end
#private :create_self
def include(*tags)
for i in tags
#i.addtag(@id)

View file

@ -7,7 +7,7 @@ require 'tk/radiobutton'
class Tk::CheckButton<Tk::RadioButton
TkCommandNames = ['checkbutton'.freeze].freeze
WidgetClassName = 'Checkbutton'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
# tk_call_without_enc('checkbutton', @path, *hash_kv(keys, true))
@ -26,5 +26,7 @@ end
Tk::Checkbutton = Tk::CheckButton
#TkCheckButton = Tk::CheckButton unless Object.const_defined? :TkCheckButton
#TkCheckbutton = Tk::Checkbutton unless Object.const_defined? :TkCheckbutton
Tk.__set_toplevel_aliases__(:Tk, Tk::CheckButton,
:TkCheckButton, :TkCheckbutton)
#Tk.__set_toplevel_aliases__(:Tk, Tk::CheckButton,
# :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'
@ -145,16 +145,34 @@ module TkComposite
str.chop << ' @epath=' << @epath.inspect << '>'
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)
opts.each{|m_set, m_cget, m_info|
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
@option_methods[m_set] = {
:set => m_set, :cget => m_cget, :info => m_info
if opts.size == 1 && opts[0].kind_of?(Hash)
# {name => [m_set, m_cget, m_info], name => method} style
opts[0].each{|name, arg|
m_set, m_cget, m_info = _get_opt_method_list(arg)
@option_methods[name.to_s] = {
: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
def delegate_alias(alias_opt, option, *wins)
@ -215,6 +233,14 @@ module TkComposite
end
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)
if (ret = __cget_delegates(slot)) == None
super(slot)
@ -358,7 +384,7 @@ module TkComposite
opt, wins = tbl[0]
next unless wins && wins[-1]
if slot == opt
info_list.delete_if{|i| i[0] == slot} <<
info_list.delete_if{|i| i[0] == slot} <<
wins[-1].configinfo(slot)
else
info = wins[-1].configinfo(opt)
@ -367,7 +393,7 @@ module TkComposite
end
else
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)]
end
}

View file

@ -28,7 +28,7 @@ module TkConsole
# supports a Tcl script only
# 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)))
end
def self.maininterp_eval(tcl_script)
@ -36,7 +36,7 @@ module TkConsole
# supports a Tcl script only
# 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)))
end
@ -45,7 +45,7 @@ module TkConsole
# supports a Tcl script only
# 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)))
end

View file

@ -18,11 +18,11 @@ class TkDialogObj < TkWindow
def _set_button_config(configs)
set_config = proc{|c,i|
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")
end
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(' '))
# @config << @path+'.button'+i.to_s+' configure '+hash_kv(c).join(' ')+'; '
@config << @path+'.button'+i.to_s+' configure '+
@ -103,7 +103,7 @@ class TkDialogObj < TkWindow
#end
if @buttons.kind_of?(Array)
_set_button_config(@buttons.collect{|cfg|
_set_button_config(@buttons.collect{|cfg|
(cfg.kind_of? Array)? cfg[1]: nil})
@buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg}
end
@ -127,7 +127,7 @@ class TkDialogObj < TkWindow
=end
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(' '))
# @config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';'
@config << @path+'.msg configure '+
@ -135,7 +135,7 @@ class TkDialogObj < TkWindow
end
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(' '))
# @config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';'
@config << @path+'.top configure '+
@ -143,7 +143,7 @@ class TkDialogObj < TkWindow
end
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(' '))
# @config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';'
@config << @path+'.bot configure '+
@ -151,7 +151,7 @@ class TkDialogObj < TkWindow
end
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(' '))
# @config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';'
@config << @path+'.bitmap configure '+
@ -176,19 +176,19 @@ class TkDialogObj < TkWindow
# default_button = '{}' if default_button == nil
default_button = '' if default_button == nil
#Tk.ip_eval('eval {global '+@var.id+';'+@config+
# 'set '+@var.id+' [tk_dialog '+
# 'set '+@var.id+' [tk_dialog '+
# @path+" "+@title+" {#{@message}} "+@bitmap+" "+
# String(default_button)+" "+@buttons.join(' ')+']}')
Tk.ip_eval(@config)
# @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title +
# ' {' + @message + '} ' + @bitmap + ' ' +
# @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title +
# ' {' + @message + '} ' + @bitmap + ' ' +
# String(default_button) + ' ' + @buttons.join(' ')).to_i
# @val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' +
# @title + ' {' + @message + '} ' + @bitmap + ' ' +
# @val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' +
# @title + ' {' + @message + '} ' + @bitmap + ' ' +
# String(default_button) + ' ' + @buttons.join(' ')).to_i
@val = Tk.ip_eval(array2tk_list([
self.class::TkCommandNames[0],
@path, @title, @message, @bitmap,
self.class::TkCommandNames[0],
@path, @title, @message, @bitmap,
String(default_button)
].concat(@buttons))).to_i
end
@ -226,7 +226,7 @@ class TkDialogObj < TkWindow
return nil
end
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')
return "info"
end

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@ class TkImage<TkObject
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
def mutex; @mutex; end
freeze
@ -45,7 +45,7 @@ class TkImage<TkObject
keys.delete('imagename')
keys.delete('without_creating')
obj.instance_eval{
tk_call_without_enc('image', 'create',
tk_call_without_enc('image', 'create',
@type, @path, *hash_kv(keys, true))
}
end
@ -78,7 +78,7 @@ class TkImage<TkObject
}
end
unless without_creating
tk_call_without_enc('image', 'create',
tk_call_without_enc('image', 'create',
@type, @path, *hash_kv(keys, true))
end
end

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@ require 'tk'
class Tk::Label<TkWindow
TkCommandNames = ['label'.freeze].freeze
WidgetClassName = 'Label'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
# tk_call_without_enc('label', @path, *hash_kv(keys, true))
@ -18,4 +18,5 @@ class Tk::Label<TkWindow
end
#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
TkCommandNames = ['labelframe'.freeze].freeze
WidgetClassName = 'Labelframe'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
# tk_call_without_enc('labelframe', @path, *hash_kv(keys, true))
@ -26,4 +26,6 @@ end
Tk::Labelframe = Tk::LabelFrame
#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
WidgetClassName = 'Listbox'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
@ -92,7 +92,7 @@ class Tk::Listbox<TkTextWin
fail ArgumentError, 'an Array is expected'
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
end
@ -110,7 +110,7 @@ class Tk::Listbox<TkTextWin
_fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}"))
when 'font', 'kanjifont'
#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')))
unless fnt.kind_of?(TkFont)
fnt = tagfontobj(index, fnt)
@ -127,9 +127,9 @@ class Tk::Listbox<TkTextWin
end
def itemconfigure(index, key, val=None)
if key.kind_of? Hash
if (key['font'] || key[:font] ||
key['kanjifont'] || key[:kanjifont] ||
key['latinfont'] || key[:latinfont] ||
if (key['font'] || key[:font] ||
key['kanjifont'] || key[:kanjifont] ||
key['latinfont'] || key[:latinfont] ||
key['asciifont'] || key[:asciifont] )
tagfont_configure(index, _symbolkey2str(key))
else
@ -137,9 +137,9 @@ class Tk::Listbox<TkTextWin
end
else
if (key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont ||
if (key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont )
if val == None
tagfontobj(index)
@ -176,16 +176,16 @@ class Tk::Listbox<TkTextWin
else
if conf[3]
if conf[3].index('{')
conf[3] = tk_split_list(conf[3])
conf[3] = tk_split_list(conf[3])
else
conf[3] = tk_tcl2ruby(conf[3])
conf[3] = tk_tcl2ruby(conf[3])
end
end
if conf[4]
if conf[4].index('{')
conf[4] = tk_split_list(conf[4])
conf[4] = tk_split_list(conf[4])
else
conf[4] = tk_tcl2ruby(conf[4])
conf[4] = tk_tcl2ruby(conf[4])
end
end
end
@ -224,16 +224,16 @@ class Tk::Listbox<TkTextWin
else
if conf[2]
if conf[2].index('{')
conf[2] = tk_split_list(conf[2])
conf[2] = tk_split_list(conf[2])
else
conf[2] = tk_tcl2ruby(conf[2])
conf[2] = tk_tcl2ruby(conf[2])
end
end
if conf[3]
if conf[3].index('{')
conf[3] = tk_split_list(conf[3])
conf[3] = tk_split_list(conf[3])
else
conf[3] = tk_tcl2ruby(conf[3])
conf[3] = tk_tcl2ruby(conf[3])
end
end
end
@ -279,4 +279,6 @@ class Tk::Listbox<TkTextWin
end
#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
end
#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
extend Tk

View file

@ -33,13 +33,14 @@ module TkMenuEntryConfig
end
private :__item_val2ruby_optkeys
alias entrycget_tkstring itemcget_tkstring
alias entrycget itemcget
alias entrycget_strict itemcget_strict
alias entryconfigure itemconfigure
alias entryconfiginfo itemconfiginfo
alias current_entryconfiginfo current_itemconfiginfo
private :itemcget, :itemcget_strict
private :itemcget_tkstring, :itemcget, :itemcget_strict
private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
end
@ -50,7 +51,7 @@ class Tk::Menu<TkWindow
TkCommandNames = ['menu'.freeze].freeze
WidgetClassName = 'Menu'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
@ -155,13 +156,13 @@ class Tk::Menu<TkWindow
_fromUTF8(tk_send_without_enc('invoke', _get_eval_enc_str(index)))
end
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))
self
end
def delete(first, last=nil)
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))
else
tk_send_without_enc('delete', _get_eval_enc_str(first))
@ -170,7 +171,7 @@ class Tk::Menu<TkWindow
end
def popup(x, y, index=nil)
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))
else
tk_call_without_enc('tk_popup', path, x, y)
@ -214,7 +215,7 @@ class Tk::Menu<TkWindow
def entrycget(index, key)
case key.to_s
when 'text', 'label', 'show'
_fromUTF8(tk_send_without_enc('entrycget',
_fromUTF8(tk_send_without_enc('entrycget',
_get_eval_enc_str(index), "-#{key}"))
when 'font', 'kanjifont'
#fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}"))
@ -234,20 +235,20 @@ class Tk::Menu<TkWindow
end
def entryconfigure(index, key, val=None)
if key.kind_of? Hash
if (key['font'] || key[:font] ||
key['kanjifont'] || key[:kanjifont] ||
key['latinfont'] || key[:latinfont] ||
if (key['font'] || key[:font] ||
key['kanjifont'] || key[:kanjifont] ||
key['latinfont'] || key[:latinfont] ||
key['asciifont'] || key[:asciifont])
tagfont_configure(index, _symbolkey2str(key))
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))
end
else
if (key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont ||
if (key == 'font' || key == :font ||
key == 'kanjifont' || key == :kanjifont ||
key == 'latinfont' || key == :latinfont ||
key == 'asciifont' || key == :asciifont )
if val == None
tagfontobj(index)
@ -284,16 +285,16 @@ class Tk::Menu<TkWindow
else
if conf[3]
if conf[3].index('{')
conf[3] = tk_split_list(conf[3])
conf[3] = tk_split_list(conf[3])
else
conf[3] = tk_tcl2ruby(conf[3])
conf[3] = tk_tcl2ruby(conf[3])
end
end
if conf[4]
if conf[4].index('{')
conf[4] = tk_split_list(conf[4])
conf[4] = tk_split_list(conf[4])
else
conf[4] = tk_tcl2ruby(conf[4])
conf[4] = tk_tcl2ruby(conf[4])
end
end
end
@ -331,16 +332,16 @@ class Tk::Menu<TkWindow
else
if conf[2]
if conf[2].index('{')
conf[2] = tk_split_list(conf[2])
conf[2] = tk_split_list(conf[2])
else
conf[2] = tk_tcl2ruby(conf[2])
conf[2] = tk_tcl2ruby(conf[2])
end
end
if conf[3]
if conf[3].index('{')
conf[3] = tk_split_list(conf[3])
conf[3] = tk_split_list(conf[3])
else
conf[3] = tk_tcl2ruby(conf[3])
conf[3] = tk_tcl2ruby(conf[3])
end
end
end
@ -386,9 +387,33 @@ class Tk::Menu<TkWindow
end
#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
=begin
def initialize(parent, type=None)
@ -446,7 +471,9 @@ end
Tk::CloneMenu = Tk::MenuClone
#TkMenuClone = Tk::MenuClone unless Object.const_defined? :TkMenuClone
#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
def initialize(parent, keys=nil)
@ -480,7 +507,9 @@ class Tk::SysMenu_Help<Tk::Menu
SYSMENU_NAME = 'help'
end
#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
@ -489,7 +518,9 @@ class Tk::SysMenu_System<Tk::Menu
SYSMENU_NAME = 'system'
end
#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
@ -498,29 +529,31 @@ class Tk::SysMenu_Apple<Tk::Menu
SYSMENU_NAME = 'apple'
end
#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
TkCommandNames = ['menubutton'.freeze].freeze
WidgetClassName = 'Menubutton'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
def create_self(keys)
if keys and keys != None
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
# 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))
else
begin
tk_call_without_enc(self.class::TkCommandNames[0], @path,
tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true))
rescue
tk_call_without_enc(self.class::TkCommandNames[0], @path)
keys = __check_available_configure_options(keys)
unless keys.empty?
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))
end
end
@ -541,7 +574,9 @@ end
Tk::MenuButton = Tk::Menubutton
#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
@ -571,7 +606,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
parent = nil
if !args.empty? && (args[0].kind_of?(TkWindow) || args[0] == nil)
keys.delete('parent') # ignore
parent = args.shift
parent = args.shift
else
parent = keys.delete('parent')
end
@ -579,7 +614,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
@variable = nil
if !args.empty? && (args[0].kind_of?(TkVariable) || args[0] == nil)
keys.delete('variable') # ignore
@variable = args.shift
@variable = args.shift
else
@variable = keys.delete('variable')
end
@ -593,7 +628,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
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))
configure(keys) if keys
@ -612,7 +647,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
self
end
def add(value)
@menu.add('radiobutton', 'variable'=>@variable,
@menu.add('radiobutton', 'variable'=>@variable,
'label'=>value, 'value'=>value)
self
end
@ -623,7 +658,7 @@ class Tk::OptionMenubutton<Tk::Menubutton
@menu.invoke(index)
end
def insert(index, value)
@menu.insert(index, 'radiobutton', 'variable'=>@variable,
@menu.insert(index, 'radiobutton', 'variable'=>@variable,
'label'=>value, 'value'=>value)
self
end
@ -677,5 +712,7 @@ end
Tk::OptionMenuButton = Tk::OptionMenubutton
#TkOptionMenubutton = Tk::OptionMenubutton unless Object.const_defined? :TkOptionMenubutton
#TkOptionMenuButton = Tk::OptionMenuButton unless Object.const_defined? :TkOptionMenuButton
Tk.__set_toplevel_aliases__(:Tk, Tk::OptionMenubutton,
:TkOptionMenubutton, :TkOptionMenuButton)
#Tk.__set_toplevel_aliases__(:Tk, Tk::OptionMenubutton,
# :TkOptionMenubutton, :TkOptionMenuButton)
Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::OptionMenubutton,
:TkOptionMenubutton, :TkOptionMenuButton)

View file

@ -2,7 +2,7 @@
# tk/menubar.rb
#
# 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.
# Usage:
@ -52,18 +52,18 @@
# {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
# '---',
# ['Check_A', TkVariable.new(true), 6],
# {:type=>'checkbutton', :label=>'Check_B',
# {:type=>'checkbutton', :label=>'Check_B',
# :variable=>TkVariable.new, :underline=>6},
# '---',
# ['Radio_X', [radio_var, 'x'], 6],
# ['Radio_Y', [radio_var, 'y'], 6],
# ['Radio_Z', [radio_var, 'z'], 6],
# '---',
# ['cascade', [
# ['sss', proc{p 'sss'}, 0],
# ['ttt', proc{p 'ttt'}, 0],
# ['uuu', proc{p 'uuu'}, 0],
# ['vvv', proc{p 'vvv'}, 0],
# ['cascade', [
# ['sss', proc{p 'sss'}, 0],
# ['ttt', proc{p 'ttt'}, 0],
# ['uuu', proc{p 'uuu'}, 0],
# ['vvv', proc{p 'vvv'}, 0],
# ], 0],
# '---',
# ['Quit', proc{exit}, 0]],
@ -92,25 +92,31 @@ require 'tk/menuspec'
class TkMenubar<Tk::Frame
include TkComposite
include TkMenuSpec
def initialize(parent = nil, spec = nil, options = nil)
def initialize(parent = nil, spec = nil, options = {})
if parent.kind_of? Hash
options = _symbolkey2str(parent)
spec = options.delete('spec')
super(options)
else
super(parent, options)
options = parent
parent = nil
spec = (options.has_key?('spec'))? options.delete('spec'): nil
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 = []
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
end
def add_menu(menu_info)
mbtn, menu = _create_menubutton(@frame, menu_info)
def add_menu(menu_info, menuspec_opt={})
mbtn, menu = _create_menubutton(@frame, menu_info, menuspec_opt)
submenus = _get_cascade_menus(menu).flatten
@ -124,7 +130,7 @@ class TkMenubar<Tk::Frame
delegate('font', mbtn, menu, *submenus)
delegate('kanjifont', mbtn, menu, *submenus)
end
def [](index)
return @menus[index]
end

View file

@ -3,35 +3,50 @@
# Hidethoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
# 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.
#
# 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)
# [label, command, underline, accelerator, configs], # command entry
# [label, TkVar_obj, underline, accelerator, configs], # checkbutton entry
# [label, [TkVar_obj, value],
# [label, [TkVar_obj, value],
# underline, accelerator, configs], # radiobutton entry
# [label, [[...menu_info...], [...menu_info...], ...],
# [label, [[...menu_info...], [...menu_info...], ...],
# underline, accelerator, configs], # cascade entry (*2)
# '---', # separator
# ...
# ]
#
# underline, accelerator, and configs are optional pearameters.
# Hashes are OK instead of Arrays. Then the entry type ('command',
# A menu_info is an array of menu entries:
# [ 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
# (e.g. :type=>'cascade'). When type is 'cascade', an array of menu_info
# 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)
# 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,
# 'system' for Win, and 'apple' for Mac) option to the configs hash of
# 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,
# 'system' for Win, and 'apple' for Mac) option to the configs hash of
# menu button/entry information.
#
# NOTE: (*2)
@ -39,7 +54,11 @@
# to the configs of the cascade entry.
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)
if tearoff.kind_of?(Hash)
default_opts = tearoff
@ -59,6 +78,7 @@ module TkMenuSpec
end
tearoff = orig_opts.delete('tearoff') if orig_opts.key?('tearoff')
tearoff = false unless tearoff # nil --> false
if menu_name
#menu = Tk::Menu.new(parent, :widgetname=>menu_name, :tearoff=>tearoff)
@ -80,10 +100,27 @@ module TkMenuSpec
menu_opts.update(_symbolkey2str(options.delete('menu_config') || {}))
if item_type == 'cascade' && options['menu'].kind_of?(Array)
# create cascade menu
submenu = _create_menu(menu, options['menu'], menu_name,
submenu = _create_menu(menu, options['menu'], menu_name,
tearoff, menu_opts)
options['menu'] = submenu
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)
elsif item_info.kind_of?(Array)
@ -117,7 +154,7 @@ module TkMenuSpec
menu_config = opts.delete('menu_config') || {}
menu_opts.update(_symbolkey2str(menu_config))
end
submenu = _create_menu(menu, item_info[1], menu_name,
submenu = _create_menu(menu, item_info[1], menu_name,
tearoff, menu_opts)
options['menu'] = submenu
end
@ -138,6 +175,25 @@ module TkMenuSpec
end
options.update(opts)
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)
elsif /^-+$/ =~ item_info
@ -155,7 +211,7 @@ module TkMenuSpec
def _use_menubar?(parent)
use_menubar = false
if parent.kind_of?(Tk::Root) || parent.kind_of?(Tk::Toplevel)
true
true
elsif parent.current_configinfo.has_key?('menu')
true
else
@ -177,7 +233,7 @@ module TkMenuSpec
end
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]
if tearoff.kind_of?(Hash)
@ -186,14 +242,49 @@ module TkMenuSpec
end
if default_opts.kind_of?(Hash)
keys = _symbolkey2str(default_opts)
else
keys = {}
default_opts = _symbolkey2str(default_opts)
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
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
mbar = _create_menu_for_menubar(parent)
@ -202,19 +293,57 @@ module TkMenuSpec
if btn_info.kind_of?(Hash)
keys.update(_symbolkey2str(btn_info))
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)
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)
keys.update(_symbolkey2str(btn_info[2]))
menu_name = keys.delete('menu_name')
end
else
keys = {:label=>btn_info}
end
menu = _create_menu(mbar, menu_info[1..-1], menu_name,
menu = _create_menu(mbar, menu_info[1..-1], menu_name,
tearoff, default_opts)
menu.tearoff(tearoff)
@ -234,9 +363,42 @@ module TkMenuSpec
if btn_info.kind_of?(Hash)
keys.update(_symbolkey2str(btn_info))
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)
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('underline', btn_info[1]) if btn_info[1]
# mbtn.configure('accelerator', btn_info[2]) if btn_info[2]
@ -245,22 +407,41 @@ module TkMenuSpec
menu_name = keys.delete('menu_name')
mbtn.configure(keys)
end
else
mbtn.configure('text', btn_info)
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)
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]
end
end
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)
menus = []
(0..(menu.index('last'))).each{|idx|

View file

@ -7,7 +7,7 @@ require 'tk/label'
class Tk::Message<Tk::Label
TkCommandNames = ['message'.freeze].freeze
WidgetClassName = 'Message'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
# tk_call_without_enc('message', @path, *hash_kv(keys, true))
@ -19,4 +19,6 @@ class Tk::Message<Tk::Label
end
#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
TkCommandNames = [
'tk_focusFollowMouse'.freeze,
'tk_focusNext'.freeze,
'tk_focusFollowMouse'.freeze,
'tk_focusNext'.freeze,
'tk_focusPrev'.freeze
].freeze

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@ require 'tk'
class Tk::PanedWindow<TkWindow
TkCommandNames = ['panedwindow'.freeze].freeze
WidgetClassName = 'Panedwindow'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
# 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 = _epath(win)
if key
#conf = tk_split_list(tk_send_without_enc('paneconfigure',
#conf = tk_split_list(tk_send_without_enc('paneconfigure',
# win, "-#{key}"))
conf = tk_split_list(tk_send_without_enc('paneconfigure',
win, "-#{key}"),
conf = tk_split_list(tk_send_without_enc('paneconfigure',
win, "-#{key}"),
false, true)
conf[0] = conf[0][1..-1]
if conf[0] == 'hide'
@ -140,10 +140,10 @@ class Tk::PanedWindow<TkWindow
end
conf
else
#tk_split_simplelist(tk_send_without_enc('paneconfigure',
#tk_split_simplelist(tk_send_without_enc('paneconfigure',
# win)).collect{|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|
conf = tk_split_simplelist(conflist, false, true)
conf[0] = conf[0][1..-1]
@ -151,18 +151,18 @@ class Tk::PanedWindow<TkWindow
if conf[0] == 'hide'
conf[3] = bool(conf[3]) unless conf[3].empty?
elsif conf[3].index('{')
conf[3] = tk_split_list(conf[3])
conf[3] = tk_split_list(conf[3])
else
conf[3] = tk_tcl2ruby(conf[3])
conf[3] = tk_tcl2ruby(conf[3])
end
end
if conf[4]
if conf[0] == 'hide'
conf[4] = bool(conf[4]) unless conf[4].empty?
elsif conf[4].index('{')
conf[4] = tk_split_list(conf[4])
conf[4] = tk_split_list(conf[4])
else
conf[4] = tk_tcl2ruby(conf[4])
conf[4] = tk_tcl2ruby(conf[4])
end
end
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 = _epath(win)
if key
#conf = tk_split_list(tk_send_without_enc('paneconfigure',
#conf = tk_split_list(tk_send_without_enc('paneconfigure',
# win, "-#{key}"))
conf = tk_split_list(tk_send_without_enc('paneconfigure',
win, "-#{key}"),
conf = tk_split_list(tk_send_without_enc('paneconfigure',
win, "-#{key}"),
false, true)
key = conf.shift[1..-1]
if key == 'hide'
@ -186,10 +186,10 @@ class Tk::PanedWindow<TkWindow
{ key => conf }
else
ret = {}
#tk_split_simplelist(tk_send_without_enc('paneconfigure',
#tk_split_simplelist(tk_send_without_enc('paneconfigure',
# win)).each{|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|
conf = tk_split_simplelist(conflist, false, true)
key = conf.shift[1..-1]
@ -197,18 +197,18 @@ class Tk::PanedWindow<TkWindow
if key == 'hide'
conf[2] = bool(conf[2]) unless conf[2].empty?
elsif conf[2].index('{')
conf[2] = tk_split_list(conf[2])
conf[2] = tk_split_list(conf[2])
else
conf[2] = tk_tcl2ruby(conf[2])
conf[2] = tk_tcl2ruby(conf[2])
end
end
if conf[3]
if key == 'hide'
conf[3] = bool(conf[3]) unless conf[3].empty?
elsif conf[3].index('{')
conf[3] = tk_split_list(conf[3])
conf[3] = tk_split_list(conf[3])
else
conf[3] = tk_tcl2ruby(conf[3])
conf[3] = tk_tcl2ruby(conf[3])
end
end
if conf.size == 1
@ -254,5 +254,7 @@ end
Tk::Panedwindow = Tk::PanedWindow
#TkPanedWindow = Tk::PanedWindow unless Object.const_defined? :TkPanedWindow
#TkPanedwindow = Tk::Panedwindow unless Object.const_defined? :TkPanedwindow
Tk.__set_toplevel_aliases__(:Tk, Tk::PanedWindow,
:TkPanedWindow, :TkPanedwindow)
#Tk.__set_toplevel_aliases__(:Tk, Tk::PanedWindow,
# :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 = _epath(win)
if slot
#conf = tk_split_list(tk_call_without_enc('place', 'configure',
#conf = tk_split_list(tk_call_without_enc('place', 'configure',
# win, "-#{slot}") )
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
win, "-#{slot}") )
conf[0] = conf[0][1..-1]
conf[1] = tk_tcl2ruby(conf[1])
@ -46,7 +46,7 @@ module TkPlace
conf[4] = tk_tcl2ruby(conf[1])
conf
else
tk_split_simplelist(tk_call_without_enc('place', 'configure',
tk_split_simplelist(tk_call_without_enc('place', 'configure',
win)).collect{|conflist|
#conf = list(conflist)
conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)}
@ -63,16 +63,16 @@ module TkPlace
# win = win.epath if win.kind_of?(TkObject)
win = _epath(win)
if slot
#conf = tk_split_list(tk_call_without_enc('place', 'configure',
#conf = tk_split_list(tk_call_without_enc('place', 'configure',
# win, "-#{slot}") )
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
win, "-#{slot}") )
# { conf[0][1..-1] => conf[1] }
{ conf[0][1..-1] => tk_tcl2ruby(conf[4]) }
else
ret = {}
#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|
#ret[conf[0][1..-1]] = conf[1]
conf = simplelist(conf_list)

View file

@ -7,7 +7,7 @@ require 'tk/button'
class Tk::RadioButton<Tk::Button
TkCommandNames = ['radiobutton'.freeze].freeze
WidgetClassName = 'Radiobutton'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
#def create_self(keys)
# if keys and keys != None
# tk_call_without_enc('radiobutton', @path, *hash_kv(keys, true))
@ -67,5 +67,7 @@ end
Tk::Radiobutton = Tk::RadioButton
#TkRadioButton = Tk::RadioButton unless Object.const_defined? :TkRadioButton
#TkRadiobutton = Tk::Radiobutton unless Object.const_defined? :TkRadiobutton
Tk.__set_toplevel_aliases__(:Tk, Tk::RadioButton,
:TkRadioButton, :TkRadiobutton)
#Tk.__set_toplevel_aliases__(:Tk, Tk::RadioButton,
# :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)
unless TkCore::INTERP.tk_windows['.']
TkCore::INTERP.tk_windows['.'] =
TkCore::INTERP.tk_windows['.'] =
super(:without_creating=>true, :widgetname=>'.'){}
end
root = TkCore::INTERP.tk_windows['.']
@ -52,7 +52,7 @@ class Tk::Root<TkWindow
end
WidgetClassName = 'Tk'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
def self.to_eval
# self::WidgetClassName
@ -70,8 +70,8 @@ class Tk::Root<TkWindow
def add_menu(menu_info, tearoff=false, opts=nil)
# See tk/menuspec.rb for menu_info.
# opts is a hash of default configs for all of cascade menus.
# Configs of menu_info can override it.
# opts is a hash of default configs for all of cascade menus.
# Configs of menu_info can override it.
if tearoff.kind_of?(Hash)
opts = tearoff
tearoff = false
@ -82,7 +82,7 @@ class Tk::Root<TkWindow
def add_menubar(menu_spec, tearoff=false, opts=nil)
# See tk/menuspec.rb for menu_spec.
# 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)}
self.menu
end

View file

@ -6,7 +6,7 @@ require 'tk'
class Tk::Scale<TkWindow
TkCommandNames = ['scale'.freeze].freeze
WidgetClassName = 'Scale'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
def create_self(keys)
if keys and keys != None
@ -16,11 +16,11 @@ class Tk::Scale<TkWindow
end
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
#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))
else
begin
tk_call_without_enc(self.class::TkCommandNames[0], @path,
tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true))
rescue
tk_call_without_enc(self.class::TkCommandNames[0], @path)
@ -33,7 +33,7 @@ class Tk::Scale<TkWindow
configure(keys)
else
# 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))
end
end
@ -69,7 +69,7 @@ class Tk::Scale<TkWindow
def configure(slot, value=None)
if (slot == 'command' || slot == :command)
configure('command'=>value)
elsif slot.kind_of?(Hash) &&
elsif slot.kind_of?(Hash) &&
(slot.key?('command') || slot.key?(:command))
slot = _symbolkey2str(slot)
slot['command'] = _wrap_command_arg(slot.delete('command'))
@ -108,4 +108,5 @@ class Tk::Scale<TkWindow
end
#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
TkCommandNames = ['scrollbar'.freeze].freeze
WidgetClassName = 'Scrollbar'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
def create_self(keys)
@assigned = []
@scroll_proc = proc{|*args|
@scroll_proc = proc{|*args|
if self.orient == 'horizontal'
@assigned.each{|w| w.xview(*args)}
else # 'vertical'
@ -21,11 +21,11 @@ class Tk::Scrollbar<TkWindow
if keys and keys != None
unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
#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))
else
begin
tk_call_without_enc(self.class::TkCommandNames[0], @path,
tk_call_without_enc(self.class::TkCommandNames[0], @path,
*hash_kv(keys, true))
rescue
tk_call_without_enc(self.class::TkCommandNames[0], @path)
@ -38,7 +38,7 @@ class Tk::Scrollbar<TkWindow
configure(keys)
else
# 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))
end
end
@ -148,7 +148,9 @@ class Tk::Scrollbar<TkWindow
end
#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
@ -161,7 +163,9 @@ class Tk::XScrollbar<Tk::Scrollbar
end
#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
@ -174,4 +178,6 @@ class Tk::YScrollbar<Tk::Scrollbar
end
#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
def self.clear_on_display(win, sel=nil)
if sel
tk_call_without_enc('selection', 'clear',
tk_call_without_enc('selection', 'clear',
'-displayof', win, '-selection', sel)
else
tk_call_without_enc('selection', 'clear', '-displayof', win)
@ -35,7 +35,7 @@ module TkSelection
end
def self.get_on_display(win, keys=nil)
#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)))
end
def get(keys=nil)
@ -65,7 +65,7 @@ module TkSelection
end
def self.get_owner_on_display(win, sel=nil)
if sel
window(tk_call_without_enc('selection', 'own',
window(tk_call_without_enc('selection', 'own',
'-displayof', win, '-selection', sel))
else
window(tk_call_without_enc('selection', 'own', '-displayof', win))

View file

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

View file

@ -16,19 +16,19 @@ class TkTextImage<TkObject
@path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
elsif index.kind_of? TkTextMark
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'))
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))
end
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)))
end
@path.gravity = 'left'
@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
@path.gravity = 'right'
end
@ -78,7 +78,7 @@ class TkTextImage<TkObject
end
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))
#self
value

View file

@ -9,7 +9,7 @@ class TkTextMark<TkObject
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
def mutex; @mutex; end
freeze
@ -25,7 +25,7 @@ class TkTextMark<TkObject
if TMarkID_TBL[tpath]
TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
else
id
id
end
}
end
@ -46,7 +46,7 @@ class TkTextMark<TkObject
TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
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))
@t._addtag id, self
end
@ -100,7 +100,7 @@ class TkTextMark<TkObject
end
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))
self
end
@ -159,7 +159,7 @@ class TkTextNamedMark<TkTextMark
end
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))
end
obj
@ -175,7 +175,7 @@ class TkTextNamedMark<TkTextMark
@parent = @t = parent
@tpath = parent.path
@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
@t._addtag @id, self
end

View file

@ -11,7 +11,7 @@ class TkTextTag<TkObject
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
def mutex; @mutex; end
freeze
@ -26,7 +26,7 @@ class TkTextTag<TkObject
TTagID_TBL.mutex.synchronize{
if TTagID_TBL[tpath]
TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
else
else
id
end
}
@ -84,13 +84,13 @@ class TkTextTag<TkObject
end
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)}))
self
end
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)}))
self
end
@ -105,16 +105,16 @@ class TkTextTag<TkObject
end
def nextrange(first, last=None)
simplelist(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id,
_get_eval_enc_str(first),
simplelist(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id,
_get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx|
Tk::Text::IndexString.new(idx)
}
end
def prevrange(first, last=None)
simplelist(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id,
_get_eval_enc_str(first),
simplelist(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id,
_get_eval_enc_str(first),
_get_eval_enc_str(last))).collect{|idx|
Tk::Text::IndexString.new(idx)
}
@ -129,6 +129,9 @@ class TkTextTag<TkObject
val
end
def cget_tkstring(key)
@t.tag_cget_tkstring @id, key
end
def cget(key)
@t.tag_cget @id, key
end
@ -142,7 +145,7 @@ class TkTextTag<TkObject
_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget', @id, "-#{key}"))
when 'font', 'kanjifont'
#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')))
unless fnt.kind_of?(TkFont)
fnt = tagfontobj(@id, fnt)
@ -154,7 +157,7 @@ class TkTextTag<TkObject
fnt
end
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}")))
end
end
@ -227,13 +230,13 @@ class TkTextTag<TkObject
end
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))
self
end
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))
self
end

View file

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

View file

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

View file

@ -11,7 +11,7 @@ class Tk::Toplevel<TkWindow
TkCommandNames = ['toplevel'.freeze].freeze
WidgetClassName = 'Toplevel'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
################# old version
# def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
@ -38,7 +38,7 @@ class Tk::Toplevel<TkWindow
# s << "-class" << @classname if @classname
# s << "-colormap" << @colormap if @colormap
# s << "-container" << @container if @container
# s << "-screen" << @screen if @screen
# s << "-screen" << @screen if @screen
# s << "-use" << @use if @use
# s << "-visual" << @visual if @visual
# tk_call 'toplevel', @path, *s
@ -113,7 +113,7 @@ class Tk::Toplevel<TkWindow
@use = keys['use']
@visual = keys['visual']
if !@classname && my_class_name
keys['class'] = @classname = my_class_name
keys['class'] = @classname = my_class_name
end
if @classname.kind_of? TkBindTag
@db_class = @classname
@ -127,7 +127,7 @@ class Tk::Toplevel<TkWindow
end
keys, cmds = _wm_command_option_chk(keys)
super(keys)
cmds.each{|k,v|
cmds.each{|k,v|
if v.kind_of? Array
self.__send__(k,*v)
else
@ -162,7 +162,7 @@ class Tk::Toplevel<TkWindow
keys = {}
end
if !@classname && my_class_name
keys['class'] = @classname = my_class_name
keys['class'] = @classname = my_class_name
end
if @classname.kind_of? TkBindTag
@db_class = @classname
@ -176,7 +176,7 @@ class Tk::Toplevel<TkWindow
end
keys, cmds = _wm_command_option_chk(keys)
super(parent, keys)
cmds.each{|k,v|
cmds.each{|k,v|
if v.kind_of? Array
self.send(k,*v)
else
@ -200,8 +200,8 @@ class Tk::Toplevel<TkWindow
def add_menu(menu_info, tearoff=false, opts=nil)
# See tk/menuspec.rb for menu_info.
# opts is a hash of default configs for all of cascade menus.
# Configs of menu_info can override it.
# opts is a hash of default configs for all of cascade menus.
# Configs of menu_info can override it.
if tearoff.kind_of?(Hash)
opts = tearoff
tearoff = false
@ -212,7 +212,7 @@ class Tk::Toplevel<TkWindow
def add_menubar(menu_spec, tearoff=false, opts=nil)
# See tk/menuspec.rb for menu_spec.
# 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)}
self.menu
end
@ -259,4 +259,6 @@ class Tk::Toplevel<TkWindow
end
#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
module Tk
@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',
:TkPanedwindow => 'tkextlib/tile/tpaned',
:TkPanedWindow => 'tkextlib/tile/tpaned',
# :TkPaned => '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',
# :TkProgress => 'tkextlib/tile/tscale',
:TkScale => 'tkextlib/tile/tscale',
# :TkProgress => 'tkextlib/tile/tscale',
:TkScrollbar => 'tkextlib/tile/tscrollbar',
:TkXScrollbar => 'tkextlib/tile/tscrollbar',
:TkYScrollbar => 'tkextlib/tile/tscrollbar',
:TkScrollbar => 'tkextlib/tile/tscrollbar',
:TkXScrollbar => '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
# (Ttk is a standard library on Tcl/Tk8.5+)
@TOPLEVEL_ALIAS_TABLE[:Ttk].each{|sym, file|
unless Object.autoload?(sym) || Object.const_defined?(sym)
Object.autoload(sym, file)
end
#unless Tk::TOPLEVEL_ALIASES.autoload?(sym) || Tk::TOPLEVEL_ALIASES.const_defined?(sym)
# @TOPLEVEL_ALIAS_OWNER[sym] = :Ttk
# Tk::TOPLEVEL_ALIASES.autoload(sym, file)
#end
Tk.__regist_toplevel_aliases__(:Ttk, file, sym)
}
################################################
@TOPLEVEL_ALIAS_SETUP_PROC[:Tile] =
@TOPLEVEL_ALIAS_SETUP_PROC[:Ttk] = proc{|mod|
unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
# @TOPLEVEL_ALIAS_SETUP_PROC[:Tile] =
# @TOPLEVEL_ALIAS_SETUP_PROC[:Ttk] = proc{|mod|
# 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'
Tk.autoload :Tile, 'tkextlib/tile'
end

View file

@ -211,21 +211,21 @@ class TkValidateCommand
class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [
[ ?d, ?n, :action ],
[ ?i, ?x, :index ],
[ ?s, ?e, :current ],
[ ?v, ?s, :type ],
[ ?P, ?e, :value ],
[ ?S, ?e, :string ],
[ ?V, ?s, :triggered ],
[ ?W, ?w, :widget ],
[ ?d, ?n, :action ],
[ ?i, ?x, :index ],
[ ?s, ?e, :current ],
[ ?v, ?s, :type ],
[ ?P, ?e, :value ],
[ ?S, ?e, :string ],
[ ?V, ?s, :triggered ],
[ ?W, ?w, :widget ],
nil
]
PROC_TBL = [
[ ?n, TkComm.method(:number) ],
[ ?s, TkComm.method(:string) ],
[ ?w, TkComm.method(:window) ],
[ ?n, TkComm.method(:number) ],
[ ?s, TkComm.method(:string) ],
[ ?w, TkComm.method(:window) ],
[ ?e, proc{|val|
#enc = Tk.encoding
@ -236,7 +236,7 @@ class TkValidateCommand
TkComm::string(val)
end
}
],
],
[ ?x, proc{|val|
idx = TkComm::number(val)
@ -246,7 +246,7 @@ class TkValidateCommand
idx
end
}
],
],
nil
]
@ -272,7 +272,7 @@ class TkValidateCommand
_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>, ...
#

View file

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

View file

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

View file

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

View file

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

View file

@ -123,7 +123,7 @@ module Tk
TOPLEVEL_METHODCALL_OPTKEYS['focusmodel'] = 'focusmodel'
def Wm.forget(win)
# Tcl/Tk 8.5+
# Tcl/Tk 8.5+
# work with dockable frames
tk_call_without_enc('wm', 'forget', win.epath)
win
@ -200,7 +200,7 @@ module Tk
if imgs.empty?
win.instance_eval{
@wm_iconphoto = nil unless defined? @wm_iconphoto
return @wm_iconphoto
return @wm_iconphoto
}
end
@ -308,10 +308,10 @@ module Tk
def Wm.manage(win, use_id = nil)
# 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'.
# It may give users frexibility on controlling their GUI.
# However, it may be difficult for current Tcl/Tk (Tcl/Tk8.5.1),
# It may give users frexibility on controlling their GUI.
# 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.
# --------------------------------------------------------------
if use_id

View file

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

View file

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

View file

@ -2,7 +2,7 @@
# setup.rb -- setup script before calling TkPackage.require()
#
# If you need some setup operations (for example, add a library path
# to the library search path) before using Tcl/Tk library packages
# wrapped by Ruby scripts in this directory, please write the setup
# to the library search path) before using Tcl/Tk library packages
# wrapped by Ruby scripts in this directory, please write the setup
# 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) >=======================
Tcllib 1.8
Tklib 0.4.1 http://sourceforge.net/projects/tcllib ==> tcllib
Tcllib 1.11.1
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
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>
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
@ -80,25 +82,25 @@ BLT 2.4z http://sourceforge.net/projects/blt
(http://raa.ruby-lang.org/)
==> blt
TkTreeCtrl CVS/Hd(2005-12-02)
http://sourceforge.net/projects/tktreectrl ==> treectrl
TkTreeCtrl 2.2.9
http://tktreectrl.sourceforge.net/ ==> treectrl
Tile 0.8.0/8.5.1
Tile 0.8.3/8.6b1
http://sourceforge.net/projects/tktable ==> tile
===< 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
TclX CVS/Hd(2005-02-07)
TclX CVS/Hd(2008-12-15)
http://sourceforge.net/projects/tclx
==> tclx (partial support; infox command and
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 BLT
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

View file

@ -11,7 +11,7 @@ module Tk::BLT
class Barchart < TkWindow
TkCommandNames = ['::blt::barchart'.freeze].freeze
WidgetClassName = 'Barchart'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
include PlotComponent
include GraphCommand
@ -22,7 +22,7 @@ module Tk::BLT
private :__boolval_optkeys
def __strval_optkeys
['text', 'label', 'title', 'file',
['text', 'label', 'title', 'file',
'background', 'plotbackground']
end
private :__strval_optkeys
@ -33,7 +33,7 @@ module Tk::BLT
private :__tkvariable_optkeys
=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={})
if elem.kind_of?(Hash)

View file

@ -14,7 +14,7 @@ module Tk::BLT
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
def mutex; @mutex; end
freeze

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@ module Tk::BLT
class Graph < TkWindow
TkCommandNames = ['::blt::graph'.freeze].freeze
WidgetClassName = 'Graph'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
include PlotComponent
include GraphCommand
@ -27,7 +27,7 @@ module Tk::BLT
private :__strval_optkeys
=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={})
if elem.kind_of?(Hash)

View file

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

View file

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

View file

@ -11,7 +11,7 @@ module Tk::BLT
class Stripchart < TkWindow
TkCommandNames = ['::blt::stripchart'.freeze].freeze
WidgetClassName = 'Stripchart'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
include PlotComponent
include GraphCommand
@ -22,13 +22,13 @@ module Tk::BLT
private :__boolval_optkeys
def __strval_optkeys
['text', 'label', 'title', 'file',
['text', 'label', 'title', 'file',
'background', 'plotbackground']
end
private :__strval_optkeys
=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={})
if elem.kind_of?(Hash)

View file

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

View file

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

View file

@ -13,7 +13,7 @@ module Tk::BLT
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
def mutex; @mutex; end
freeze
@ -132,6 +132,9 @@ module Tk::BLT
@t.tab_bindinfo(@id, context)
end
def cget_tkstring(*args)
@t.tab_cget_tkstring(@id, *args)
end
def cget(*args)
@t.tab_cget(@id, *args)
end
@ -210,7 +213,7 @@ module Tk::BLT
TkCommandNames = ['::blt::tabset'.freeze].freeze
WidgetClassName = 'Tabset'.freeze
WidgetClassNames[WidgetClassName] = self
WidgetClassNames[WidgetClassName] ||= self
def __destroy_hook__
Tk::BLT::Tabset::Tab::TabID_TBL.mutex.synchronize{
@ -249,6 +252,7 @@ module Tk::BLT
end
private :__item_pathname
alias tab_cget_tkstring itemcget_tkstring
alias tab_cget itemcget
alias tab_cget_strict itemcget_strict
alias tab_configure itemconfigure

View file

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

View file

@ -8,6 +8,10 @@ require 'tkextlib/blt.rb'
module Tk::BLT
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 :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={})
@tree.keys(@id, dest, keys)
self
end
end
def next()
@tree.next(@id)
@ -272,7 +272,7 @@ module Tk::BLT
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
def mutex; @mutex; end
freeze
@ -397,10 +397,10 @@ module Tk::BLT
NotifyID_TBL.mutex.synchronize{
if tree.kind_of?(Array)
# not create
tpath = tree[0].path
tpath = tree[0].path
NotifyID_TBL[tpath] ||= {}
unless (obj = NotifyID_TBL[tpath][tree[1]])
(NotifyID_TBL[tpath][tree[1]] =
(NotifyID_TBL[tpath][tree[1]] =
obj = self.allocate).instance_eval{
@parent = @tree = tree[0]
@tpath = @parent.path
@ -438,7 +438,7 @@ module Tk::BLT
args = args.collect{|arg| '-' << arg.to_s}
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))
}
@ -509,7 +509,7 @@ module Tk::BLT
tpath = tree[0].path
TraceID_TBL[tpath] ||= {}
unless (obj = TraceID_TBL[tpath][tree[1]])
(TraceID_TBL[tpath][tree[1]] =
(TraceID_TBL[tpath][tree[1]] =
obj = self.allocate).instance_eval{
@parent = @tree = tree
@tpath = @parent.path
@ -541,8 +541,8 @@ module Tk::BLT
end
end
@path = @id = tk_call(@tpath, 'trace', 'create', node, key, opts,
proc{|t, id, k, ops|
@path = @id = tk_call(@tpath, 'trace', 'create', node, key, opts,
proc{|t, id, k, ops|
tobj = Tk::BLT::Tree.id2obj(t)
if tobj.kind_of?(Tk::BLT::Tree)
nobj = Tk::BLT::Tree::Node.id2obj(tobj, id)
@ -578,7 +578,7 @@ module Tk::BLT
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
def mutex; @mutex; end
freeze
@ -599,8 +599,8 @@ module Tk::BLT
'recurse'=>nil, 'tags'=>nil,
# sort command
'ascii'=>nil, 'decreasing'=>nil, 'disctionary'=>nil,
'integer'=>nil, 'real'=>nil, 'recurse'=>nil, 'reorder'=>nil,
'ascii'=>nil, 'decreasing'=>nil, 'disctionary'=>nil,
'integer'=>nil, 'real'=>nil, 'recurse'=>nil, 'reorder'=>nil,
}
end
@ -624,7 +624,7 @@ module Tk::BLT
def self.new(name = nil)
TreeID_TBL.mutex.synchronize{
if name && TreeID_TBL[name]
TreeID_TBL[name]
TreeID_TBL[name]
else
(obj = self.allocate).instance_eval{
initialize(name)
@ -680,7 +680,7 @@ module Tk::BLT
end
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)))
end
@ -701,14 +701,14 @@ module Tk::BLT
end
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))
Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
end
def copy_to(src, dest_tree, parent, keys={})
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))
Tk::BLT::Tree::Node.new(dest_tree, nil, 'node'=>id)
end
@ -751,7 +751,7 @@ module Tk::BLT
end
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|
Tk::BLT::Tree::Node.id2obj(self, n)
}
@ -775,7 +775,7 @@ module Tk::BLT
end
def index(node)
Tk::BLT::Tree::Node.id2obj(self,
Tk::BLT::Tree::Node.id2obj(self,
tk_call('::blt::tree', 'index', tagid(node)))
end
@ -785,11 +785,11 @@ module Tk::BLT
end
def ancestor?(node1, node2)
bool(tk_call('::blt::tree', 'is', 'ancestor',
bool(tk_call('::blt::tree', 'is', 'ancestor',
tagid(node1), tagid(node2)))
end
def before?(node1, node2)
bool(tk_call('::blt::tree', 'is', 'before',
bool(tk_call('::blt::tree', 'is', 'before',
tagid(node1), tagid(node2)))
end
def leaf?(node)
@ -806,7 +806,7 @@ module Tk::BLT
if nodes.empty?
simplelist(tk_call('blt::tree', 'keys', tagid(node)))
else
simplelist(tk_call('blt::tree', 'keys', tagid(node),
simplelist(tk_call('blt::tree', 'keys', tagid(node),
*(nodes.collect{|n| tagid(n)}))).collect{|lst|
simplelist(lst)
}
@ -828,7 +828,7 @@ module Tk::BLT
end
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))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
@ -902,7 +902,7 @@ module Tk::BLT
end
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))
self
end
@ -915,7 +915,7 @@ module Tk::BLT
end
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))
self
end
@ -923,13 +923,13 @@ module Tk::BLT
keys = __conv_keyonly_opts(keys)
keys.delete('overwrite')
keys.delete(:overwrite)
tk_call('::blt::tree', 'restorefile', tagid(node), file,
tk_call('::blt::tree', 'restorefile', tagid(node), file,
'-overwrite', keys)
self
end
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)))
end
@ -958,7 +958,7 @@ module Tk::BLT
end
def tag_delete(tag, *nodes)
tk_call(@path, 'tag', 'delete', tagid(tag),
tk_call(@path, 'tag', 'delete', tagid(tag),
*(nodes.collect{|n| tagid(n)}))
self
end
@ -973,7 +973,7 @@ module Tk::BLT
end
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|
Tk::BLT::Tree::Tag.id2obj(self, str)
}
@ -997,7 +997,7 @@ module Tk::BLT
end
def tag_unset(node, *tags)
tk_call(@path, 'tag', 'unset', tagid(node),
tk_call(@path, 'tag', 'unset', tagid(node),
*(tags.collect{|t| tagid(t)}))
self
end

View file

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

View file

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

View file

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

View file

@ -14,7 +14,7 @@ module Tk::BLT
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
def mutex; @mutex; end
freeze

View file

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

View file

@ -18,6 +18,8 @@ TkPackage.require('BWidget')
module Tk
module BWidget
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

View file

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

View file

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

View file

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

View file

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

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