summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-27 09:23:38 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-11-27 09:23:38 +0000
commitf54418b71f57e00d4a50bd86bf7d18b8b5195287 (patch)
treed5bd57142a0d4736fdfd1f35dcd864ac40cfb045 /ext
parent1f297b8bfc0fdacb8cfb19736cf224b2550281b3 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/tk/lib/tk.rb434
-rw-r--r--ext/tk/lib/tkcanvas.rb68
-rw-r--r--ext/tk/lib/tkclass.rb4
-rw-r--r--ext/tk/lib/tkentry.rb123
-rw-r--r--ext/tk/lib/tktext.rb122
5 files changed, 651 insertions, 100 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index e5c2c2e..a088d5c 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -485,6 +485,56 @@ module TkCore
end
end
+ def after_idle(cmd=Proc.new)
+ myid = _curr_cmd_id
+ cmdid = install_cmd(cmd)
+ tk_call('after','idle',cmdid)
+ end
+
+ def clock_clicks(ms=nil)
+ if ms
+ tk_call('clock','clicks','-milliseconds').to_i
+ else
+ tk_call('clock','clicks').to_i
+ end
+ end
+
+ def clock_format(clk, form=nil)
+ if form
+ tk_call('clock','format',clk,'-format',form).to_i
+ else
+ tk_call('clock','format',clk).to_i
+ end
+ end
+
+ def clock_formatGMT(clk, form=nil)
+ if form
+ tk_call('clock','format',clk,'-format',form,'-gmt','1').to_i
+ else
+ tk_call('clock','format',clk,'-gmt','1').to_i
+ end
+ end
+
+ def clock_scan(str, base=nil)
+ if base
+ tk_call('clock','scan',str,'-base',base).to_i
+ else
+ tk_call('clock','scan',str).to_i
+ end
+ end
+
+ def clock_scanGMT(str, base=nil)
+ if base
+ tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
+ else
+ tk_call('clock','scan',str,'-gmt','1').to_i
+ end
+ end
+
+ def clock_seconds
+ tk_call('clock','seconds').to_i
+ end
+
def TkCore.callback(arg)
arg = Array(tk_split_list(arg))
_get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg))
@@ -1762,10 +1812,28 @@ module TkPack
tk_call 'pack', 'forget' *args
end
+ def info(slave)
+ ilist = list(tk_call('pack', 'info', slave.epath))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ return info
+ end
+
def propagate(master, bool=None)
- bool(tk_call('pack', 'propagate', master.epath, bool))
+ if bool == None
+ bool(tk_call('pack', 'propagate', master.epath))
+ else
+ tk_call('pack', 'propagate', master.epath, bool)
+ end
+ end
+
+ def slaves(master)
+ list(tk_call('pack', 'slaves', master.epath))
end
- module_function :configure, :forget, :propagate
+
+ module_function :configure, :forget, :info, :propagate, :slaves
end
module TkGrid
@@ -1795,6 +1863,32 @@ module TkGrid
tk_call "grid", 'rowconfigure', master, index, *hash_kv(args)
end
+ def columnconfiginfo(master, index, slot=nil)
+ if slot
+ tk_call 'grid', 'columnconfigure', master, index, "-#{slot}"
+ else
+ ilist = list(tk_call('grid', 'columnconfigure', master, index))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ info
+ end
+ end
+
+ def rowconfiginfo(master, index, slot=nil)
+ if slot
+ tk_call 'grid', 'rowconfigure', master, index, "-#{slot}"
+ else
+ ilist = list(tk_call('grid', 'rowconfigure', master, index))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ info
+ end
+ end
+
def add(widget, *args)
configure(widget, *args)
end
@@ -1812,7 +1906,11 @@ module TkGrid
end
def propagate(master, bool=None)
- bool(tk_call('grid', 'propagate', master.epath, bool))
+ if bool == None
+ bool(tk_call('grid', 'propagate', master.epath))
+ else
+ tk_call('grid', 'propagate', master.epath, bool)
+ end
end
def remove(*args)
@@ -1823,13 +1921,63 @@ module TkGrid
tk_call 'grid', 'size', master
end
- def slaves(args)
- list(tk_call('grid', 'slaves', *hash_kv(args)))
+ def slaves(master, args)
+ list(tk_call('grid', 'slaves', master, *hash_kv(args)))
end
module_function :bbox, :forget, :propagate, :info
module_function :remove, :size, :slaves, :location
module_function :configure, :columnconfigure, :rowconfigure
+ module_function :columnconfiginfo, :rowconfiginfo
+end
+
+module TkPlace
+ include Tk
+ extend Tk
+
+ def configure(win, slot, value=None)
+ if slot.kind_of? Hash
+ tk_call 'place', 'configure', win.epath, *hash_kv(slot)
+ else
+ tk_call 'place', 'configure', win.epath, "-#{slot}", value
+ end
+ end
+
+ def configinfo(win, slot = nil)
+ # for >= Tk8.4a2 ?
+ if slot
+ conf = tk_split_list(tk_call('place', 'configure',
+ win.epath, "-#{slot}") )
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_simplelist(tk_call('place', 'configure',
+ win.epath)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ conf
+ }
+ end
+ end
+
+ def forget(win)
+ tk_call 'place', 'forget', win
+ end
+
+ def info(win)
+ ilist = list(tk_call('place', 'info', win.epath))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ return info
+ end
+
+ def slaves(master)
+ list(tk_call('place', 'slaves', master.epath))
+ end
+
+ module_function :configure, :configinfo, :forget, :info, :slaves
end
module TkOption
@@ -1993,7 +2141,12 @@ class TkObject<TkKernel
end
def cget(slot)
- tk_tcl2ruby tk_call path, 'cget', "-#{slot}"
+ case slot
+ when 'text', 'label', 'show', 'data', 'flie'
+ tk_call path, 'cget', "-#{slot}"
+ else
+ tk_tcl2ruby tk_call path, 'cget', "-#{slot}"
+ end
end
def configure(slot, value=None)
@@ -2028,17 +2181,43 @@ class TkObject<TkKernel
fontobj
else
if slot
- conf = tk_split_list(tk_send('configure', "-#{slot}") )
+ case slot
+ when 'text', 'label', 'show', 'data', 'flie'
+ conf = tk_split_simplelist(tk_send('configure', "-#{slot}") )
+ else
+ conf = tk_split_list(tk_send('configure', "-#{slot}") )
+ end
conf[0] = conf[0][1..-1]
conf
else
- ret = tk_split_list(tk_send('configure') ).collect{|conf|
+ ret = tk_split_simplelist(tk_send('configure') ).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'flie'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
conf
}
- if ret.assoc('font')
+ fontconf = ret.assoc('font')
+ if fontconf
ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
- ret.push(['font', fontobj])
+ fontconf[4] = fontobj
+ ret.push(fontconf)
else
ret
end
@@ -2093,6 +2272,36 @@ class TkWindow<TkObject
tk_call 'pack', 'forget', epath
self
end
+ alias pack_forget unpack
+
+ def pack_config(slot, value=None)
+ if slot.kind_of? Hash
+ tk_call 'pack', 'configure', epath, *hash_kv(slot)
+ else
+ tk_call 'pack', 'configure', epath, "-#{slot}", value
+ end
+ end
+
+ def pack_info()
+ ilist = list(tk_call('pack', 'info', epath))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ return info
+ end
+
+ def pack_propagate(mode = nil)
+ if mode
+ tk_call('pack', 'propagate', epath, mode)
+ else
+ bool(tk_call('pack', 'propagate', epath))
+ end
+ end
+
+ def pack_slaves()
+ list(tk_call('pack', 'slaves', epath))
+ end
def grid(keys = nil)
tk_call 'grid', epath, *hash_kv(keys)
@@ -2103,6 +2312,81 @@ class TkWindow<TkObject
tk_call 'grid', 'forget', epath
self
end
+ alias grid_forget ungrid
+
+ def grid_bbox(*args)
+ list(tk_call('grid', 'bbox', epath, *args))
+ end
+
+ def grid_config(slot, value=None)
+ if slot.kind_of? Hash
+ tk_call 'grid', 'configure', epath, *hash_kv(slot)
+ else
+ tk_call 'grid', 'configure', epath, "-#{slot}", value
+ end
+ end
+
+ def grid_columnconfig(index, keys)
+ tk_call('grid', 'columnconfigure', epath, index, hash_kv(keys))
+ end
+
+ def grid_rowconfig(index, keys)
+ tk_call('grid', 'rowconfigure', epath, index, hash_kv(keys))
+ end
+
+ def grid_columnconfiginfo(index, slot=nil)
+ if slot
+ tk_call('grid', 'columnconfigure', epath, index, "-#{slot}")
+ else
+ ilist = list(tk_call('grid', 'columnconfigure', epath, index))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ info
+ end
+ end
+
+ def grid_rowconfiginfo(index, slot=nil)
+ if slot
+ tk_call('grid', 'rowconfigure', epath, index, "-#{slot}")
+ else
+ ilist = list(tk_call('grid', 'rowconfigure', epath, index))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ info
+ end
+ end
+
+ def grid_info()
+ list(tk_call('grid', 'info', epath))
+ end
+
+ def grid_location(x, y)
+ list(tk_call('grid', 'location', epath, x, y))
+ end
+
+ def grid_propagate(mode=nil)
+ if mode
+ tk_call('grid', 'propagate', epath, bool)
+ else
+ bool(tk_call('grid', 'propagate', epath))
+ end
+ end
+
+ def grid_remove()
+ tk_call 'grid', 'remove', epath
+ end
+
+ def grid_size()
+ tk_call 'grid', 'size', epath
+ end
+
+ def grid_slaves(args)
+ list(tk_call('grid', 'slaves', epath, *hash_kv(args)))
+ end
def place(keys = nil)
tk_call 'place', epath, *hash_kv(keys)
@@ -2115,25 +2399,32 @@ class TkWindow<TkObject
end
alias place_forget unplace
- def place_config(keys)
- tk_call "place", 'configure', epath, *hash_kv(keys)
- end
-
- def place_info()
- ilist = list(tk_call('place', 'info', epath))
- info = {}
- while key = ilist.shift
- info[key[1..-1]] = ilist.shift
+ def place_config(slot, value=None)
+ if slot.kind_of? Hash
+ tk_call 'place', 'configure', epath, *hash_kv(slot)
+ else
+ tk_call 'place', 'configure', epath, "-#{slot}", value
end
- return info
end
- def pack_slaves()
- list(tk_call('pack', 'slaves', epath))
+ def place_configinfo(slot = nil)
+ # for >= Tk8.4a2 ?
+ if slot
+ conf = tk_split_list(tk_call('place', 'configure', epath, "-#{slot}") )
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_simplelist(tk_call('place',
+ 'configure', epath)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ conf
+ }
+ end
end
- def pack_info()
- ilist = list(tk_call('pack', 'info', epath))
+ def place_info()
+ ilist = list(tk_call('place', 'info', epath))
info = {}
while key = ilist.shift
info[key[1..-1]] = ilist.shift
@@ -2160,7 +2451,9 @@ class TkWindow<TkObject
elsif args.length == 1
case args[0]
when 'global'
- tk_call 'grab', 'set', '-global', path
+ return(tk_call 'grab', 'set', '-global', path)
+ when 'release'
+ return(tk_call 'grab', 'release', path)
else
val = tk_call('grab', args[0], path)
end
@@ -2360,9 +2653,9 @@ class TkButton<TkLabel
end
end
-class TkRadiobutton<TkButton
+class TkRadioButton<TkButton
WidgetClassNames['Radiobutton'] = self
- def TkRadiobutton.to_eval
+ def TkRadioButton.to_eval
'Radiobutton'
end
def create_self
@@ -2378,11 +2671,11 @@ class TkRadiobutton<TkButton
configure 'variable', tk_trace_variable(v)
end
end
-TkRadioButton = TkRadiobutton
+TkRadiobutton = TkRadioButton
-class TkCheckbutton<TkRadiobutton
+class TkCheckButton<TkRadioButton
WidgetClassNames['Checkbutton'] = self
- def TkCheckbutton.to_eval
+ def TkCheckButton.to_eval
'Checkbutton'
end
def create_self
@@ -2392,7 +2685,7 @@ class TkCheckbutton<TkRadiobutton
tk_send 'toggle'
end
end
-TkCheckButton = TkCheckbutton
+TkCheckbutton = TkCheckButton
class TkMessage<TkLabel
WidgetClassNames['Message'] = self
@@ -2403,7 +2696,6 @@ class TkMessage<TkLabel
tk_call 'message', @path
end
end
-TkRadiobutton = TkRadioButton
class TkScale<TkWindow
WidgetClassName = 'Scale'.freeze
@@ -2432,7 +2724,6 @@ class TkScale<TkWindow
set val
end
end
-TkCheckbutton = TkCheckButton
class TkScrollbar<TkWindow
WidgetClassName = 'Scrollbar'.freeze
@@ -2547,7 +2838,12 @@ class TkListbox<TkTextWin
end
def itemcget(index, key)
- tk_tcl2ruby tk_send 'itemcget', index, "-#{key}"
+ case key
+ when 'text', 'label', 'show'
+ tk_send 'itemcget', index, "-#{key}"
+ else
+ tk_tcl2ruby tk_send 'itemcget', index, "-#{key}"
+ end
end
def itemconfigure(index, key, val=None)
if key.kind_of? Hash
@@ -2570,12 +2866,36 @@ class TkListbox<TkTextWin
def itemconfiginfo(index, key=nil)
if key
- conf = tk_split_list(tk_send('itemconfigure',index,"-#{key}"))
+ case key
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(tk_send('itemconfigure',index,"-#{key}"))
+ else
+ conf = tk_split_list(tk_send('itemconfigure',index,"-#{key}"))
+ end
conf[0] = conf[0][1..-1]
conf
else
- tk_split_list(tk_send('itemconfigure', index)).collect{|conf|
+ tk_split_simplelist(tk_send('itemconfigure', index)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
conf
}
end
@@ -2743,7 +3063,12 @@ class TkMenu<TkWindow
number(tk_send('yposition', index))
end
def entrycget(index, key)
- tk_tcl2ruby tk_send 'entrycget', index, "-#{key}"
+ case key
+ when 'text', 'label', 'show'
+ tk_send 'entrycget', index, "-#{key}"
+ else
+ tk_tcl2ruby tk_send 'entrycget', index, "-#{key}"
+ end
end
def entryconfigure(index, key, val=None)
if key.kind_of? Hash
@@ -2766,12 +3091,36 @@ class TkMenu<TkWindow
def entryconfiginfo(index, key=nil)
if key
- conf = tk_split_list(tk_send('entryconfigure',index,"-#{key}"))
+ case key
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(tk_send('entryconfigure',index,"-#{key}"))
+ else
+ conf = tk_split_list(tk_send('entryconfigure',index,"-#{key}"))
+ end
conf[0] = conf[0][1..-1]
conf
else
- tk_split_list(tk_send('entryconfigure', index)).collect{|conf|
+ tk_split_simplelist(tk_send('entryconfigure', index)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
conf
}
end
@@ -2977,8 +3326,15 @@ autoload :TkEntry, 'tkentry'
autoload :TkSpinbox, 'tkentry'
autoload :TkText, 'tktext'
autoload :TkDialog, 'tkdialog'
+autoload :TkWarning, 'tkdialog'
autoload :TkMenubar, 'tkmenubar'
autoload :TkAfter, 'tkafter'
autoload :TkPalette, 'tkpalette'
autoload :TkFont, 'tkfont'
autoload :TkVirtualEvent, 'tkvirtevent'
+autoload :TkBgError, 'tkbgerror'
+autoload :TkManageFocus, 'tkmngfocus'
+autoload :TkPalette, 'tkpalette'
+autoload :TkWinDDE, 'tkwinpkg'
+autoload :TkWinRegistry, 'tkwinpkg'
+autoload :TkMacResource, 'tkmacpkg'
diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb
index 88a91ae..ff06e93 100644
--- a/ext/tk/lib/tkcanvas.rb
+++ b/ext/tk/lib/tkcanvas.rb
@@ -274,7 +274,19 @@ class TkCanvas<TkWindow
end
def itemcget(tagOrId, option)
- tk_tcl2ruby tk_send 'itemcget', tagid(tagOrId), "-#{option}"
+ case option
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_send('itemcget', tagid(tagOrId), "-#{option}")
+ if conf =~ /^[0-9]/
+ list(conf)
+ else
+ conf
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ tk_send 'itemcget', tagid(tagOrId), "-#{option}"
+ else
+ tk_tcl2ruby tk_send 'itemcget', tagid(tagOrId), "-#{option}"
+ end
end
def itemconfigure(tagOrId, key, value=None)
@@ -308,12 +320,55 @@ class TkCanvas<TkWindow
def itemconfiginfo(tagOrId, key=nil)
if key
- conf = tk_split_list(tk_send 'itemconfigure', tagid(tagOrId), "-#{key}")
+ case key
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_split_simplelist(tk_send 'itemconfigure',
+ tagid(tagOrId), "-#{key}")
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ conf = tk_split_simplelist(tk_send 'itemconfigure',
+ tagid(tagOrId), "-#{key}")
+ else
+ conf = tk_split_list(tk_send 'itemconfigure',
+ tagid(tagOrId), "-#{key}")
+ end
conf[0] = conf[0][1..-1]
conf
else
- tk_split_list(tk_send 'itemconfigure', tagid(tagOrId)).collect{|conf|
+ tk_split_simplelist(tk_send 'itemconfigure',
+ tagid(tagOrId)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ when 'dash', 'activedash', 'disableddash'
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
conf
}
end
@@ -820,7 +875,12 @@ class TkPhotoImage<TkImage
end
def cget(option)
- tk_tcl2ruby tk_send 'cget', option
+ case option
+ when 'data', 'flie'
+ tk_send 'cget', option
+ else
+ tk_tcl2ruby tk_send 'cget', option
+ end
end
def copy(source, *opts)
diff --git a/ext/tk/lib/tkclass.rb b/ext/tk/lib/tkclass.rb
index fe49c55..0b33d4e 100644
--- a/ext/tk/lib/tkclass.rb
+++ b/ext/tk/lib/tkclass.rb
@@ -9,8 +9,8 @@ TopLevel = TkToplevel
Frame = TkFrame
Label = TkLabel
Button = TkButton
-Radiobutton = TkRadiobutton
-Checkbutton = TkCheckbutton
+Radiobutton = TkRadioButton
+Checkbutton = TkCheckButton
Message = TkMessage
Entry = TkEntry
Text = TkText
diff --git a/ext/tk/lib/tkentry.rb b/ext/tk/lib/tkentry.rb
index 6c050d7..6b25be3 100644
--- a/ext/tk/lib/tkentry.rb
+++ b/ext/tk/lib/tkentry.rb
@@ -14,6 +14,47 @@ class TkEntry<TkLabel
WidgetClassName
end
+ class ValidateCmd
+ include TkComm
+
+ class ValidateArgs
+ def initialize(d,i,s,v,pp,ss,vv,ww)
+ @action = d
+ @index = i
+ @current = s
+ @type = v
+ @value = pp
+ @string = ss
+ @triggered = vv
+ @widget = ww
+ end
+ attr :action
+ attr :index
+ attr :current
+ attr :type
+ attr :value
+ attr :string
+ attr :triggered
+ attr :widget
+ end
+
+ def initialize(cmd = Proc.new, args=nil)
+ if args
+ @id = install_cmd(proc{|*arg|
+ TkUtil.eval_cmd cmd, *arg
+ }) + " " + args
+ else
+ @id = install_cmd(proc{|arg|
+ TkUtil.eval_cmd cmd, ValidateArgs.new(*arg)
+ }) + ' %d %i %s %v %P %S %V %W'
+ end
+ end
+
+ def to_eval
+ @id
+ end
+ end
+
def create_self
tk_call 'entry', @path
end
@@ -26,6 +67,47 @@ class TkEntry<TkLabel
tk_send 'delete', s, e
end
+ def configure(slot, value=None)
+ if slot.kind_of? Hash
+ if slot['vcmd'].kind_of? Array
+ cmd, *args = slot['vcmd']
+ slot['vcmd'] = ValidateCmd.new(cmd, args.join(' '))
+ elsif slot['vcmd'].kind_of? Proc
+ slot['vcmd'] = ValidateCmd.new(slot['vcmd'])
+ end
+ if slot['validatecommand'].kind_of? Array
+ cmd, *args = slot['validatecommand']
+ slot['validatecommand'] = ValidateCmd.new(cmd, args.join(' '))
+ elsif slot['validatecommand'].kind_of? Proc
+ slot['validatecommand'] = ValidateCmd.new(slot['validatecommand'])
+ end
+ if slot['invcmd'].kind_of? Array
+ cmd, *args = slot['invcmd']
+ slot['invcmd'] = ValidateCmd.new(cmd, args.join(' '))
+ elsif slot['invcmd'].kind_of? Proc
+ slot['invcmd'] = ValidateCmd.new(slot['invcmd'])
+ end
+ if slot['invalidcommand'].kind_of? Array
+ cmd, *args = slot['invalidcommand']
+ slot['invalidcommand'] = ValidateCmd.new(cmd, args.join(' '))
+ elsif slot['invalidcommand'].kind_of? Proc
+ slot['invalidcommand'] = ValidateCmd.new(slot['invalidcommand'])
+ end
+ super(slot)
+ else
+ if (slot == 'vcmd' || slot == 'validatecommand' ||
+ slot == 'invcmd' || slot == 'invalidcommand')
+ if value.kind_of? Array
+ cmd, *args = value
+ value = ValidateCmd.new(cmd, args.join(' '))
+ elsif value.kind_of? Proc
+ value = ValidateCmd.new(value)
+ end
+ end
+ super(slot, value)
+ end
+ end
+
def cursor
tk_send 'index', 'insert'
end
@@ -75,47 +157,6 @@ class TkEntry<TkLabel
end
end
- class ValidateCmd
- include TkComm
-
- class ValidateArgs
- def initialize(d,i,s,v,pp,ss,vv,ww)
- @action = d
- @index = i
- @current = s
- @type = v
- @value = pp
- @string = ss
- @triggered = vv
- @widget = ww
- end
- attr :action
- attr :index
- attr :current
- attr :type
- attr :value
- attr :string
- attr :triggered
- attr :widget
- end
-
- def initialize(cmd = Proc.new, args=nil)
- if args
- @id = install_cmd(proc{|*arg|
- TkUtil.eval_cmd cmd, *arg
- }) + " " + args
- else
- @id = install_cmd(proc{|arg|
- TkUtil.eval_cmd cmd, ValidateArgs.new(*arg)
- }) + ' %d %i %s %v %P %S %V %W'
- end
- end
-
- def to_eval
- @id
- end
- end
-
def validatecommand(cmd = ValidateCmd.new, args = nil)
if cmd.kind_of?(ValidateCmd)
configure('validatecommand', cmd)
diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb
index c8b171c..bb3d537 100644
--- a/ext/tk/lib/tktext.rb
+++ b/ext/tk/lib/tktext.rb
@@ -270,7 +270,12 @@ class TkText<TkTextWin
end
def tag_cget(tag, key)
- tk_tcl2ruby tk_call @path, 'tag', 'cget', tag, "-#{key}"
+ case key
+ when 'text', 'label', 'show', 'data', 'flie'
+ tk_call @path, 'tag', 'cget', tag, "-#{key}"
+ else
+ tk_tcl2ruby tk_call @path, 'tag', 'cget', tag, "-#{key}"
+ end
end
def tag_configure(tag, key, val=None)
@@ -294,12 +299,36 @@ class TkText<TkTextWin
def tag_configinfo(tag, key=nil)
if key
- conf = tk_split_list(tk_send('tag','configure',tag,"-#{key}"))
+ case key
+ when 'text', 'label', 'show', 'data', 'flie'
+ conf = tk_split_simplelist(tk_send('tag','configure',tag,"-#{key}"))
+ else
+ conf = tk_split_list(tk_send('tag','configure',tag,"-#{key}"))
+ end
conf[0] = conf[0][1..-1]
conf
else
- tk_split_list(tk_send('tag', 'configure', tag)).collect{|conf|
+ tk_split_simplelist(tk_send('tag', 'configure', tag)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'flie'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
conf
}
end
@@ -674,7 +703,12 @@ class TkTextTag<TkObject
end
def cget(key)
- tk_tcl2ruby tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
+ case key
+ when 'text', 'label', 'show', 'data', 'flie'
+ tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
+ else
+ tk_tcl2ruby tk_call @t.path, 'tag', 'cget', @id, "-#{key}"
+ end
end
def configure(key, val=None)
@@ -853,7 +887,12 @@ class TkTextWindow<TkObject
end
def cget(slot)
- tk_tcl2ruby tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
+ case slot
+ when 'text', 'label', 'show', 'data', 'flie'
+ tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
+ else
+ tk_tcl2ruby tk_call @t.path, 'window', 'cget', @index, "-#{slot}"
+ end
end
def configure(slot, value=None)
@@ -899,14 +938,39 @@ class TkTextWindow<TkObject
def configinfo(slot = nil)
if slot
- conf = tk_split_list(tk_call @t.path, 'window', 'configure',
- @index, "-#{slot}")
+ case slot
+ when 'text', 'label', 'show', 'data', 'flie'
+ conf = tk_split_simplelist(tk_call @t.path, 'window', 'configure',
+ @index, "-#{slot}")
+ else
+ conf = tk_split_list(tk_call @t.path, 'window', 'configure',
+ @index, "-#{slot}")
+ end
conf[0] = conf[0][1..-1]
conf
else
- tk_split_list(tk_call @t.path, 'window', 'configure',
- @index).collect{|conf|
+ tk_split_simplelist(tk_call @t.path, 'window', 'configure',
+ @index).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'flie'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
conf
}
end
@@ -944,7 +1008,12 @@ class TkTextImage<TkObject
end
def cget(slot)
- tk_tcl2ruby tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
+ case slot
+ when 'text', 'label', 'show', 'data', 'flie'
+ tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
+ else
+ tk_tcl2ruby tk_call @t.path, 'image', 'cget', @index, "-#{slot}"
+ end
end
def configure(slot, value=None)
@@ -968,14 +1037,39 @@ class TkTextImage<TkObject
def configinfo(slot = nil)
if slot
- conf = tk_split_list(tk_call @t.path, 'image', 'configure',
- @index, "-#{slot}")
+ case slot
+ when 'text', 'label', 'show', 'data', 'flie'
+ conf = tk_split_simplelist(tk_call @t.path, 'image', 'configure',
+ @index, "-#{slot}")
+ else
+ conf = tk_split_list(tk_call @t.path, 'image', 'configure',
+ @index, "-#{slot}")
+ end
conf[0] = conf[0][1..-1]
conf
else
- tk_split_list(tk_call @t.path, 'image', 'configure',
- @index).collect{|conf|
+ tk_split_simplelist(tk_call @t.path, 'image', 'configure',
+ @index).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'flie'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
conf
}
end