diff options
Diffstat (limited to 'ext/tk/lib/tk')
-rw-r--r-- | ext/tk/lib/tk/event.rb | 14 | ||||
-rw-r--r-- | ext/tk/lib/tk/grid.rb | 49 | ||||
-rw-r--r-- | ext/tk/lib/tk/pack.rb | 17 | ||||
-rw-r--r-- | ext/tk/lib/tk/spinbox.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tk/validation.rb | 9 | ||||
-rw-r--r-- | ext/tk/lib/tk/wm.rb | 4 |
6 files changed, 88 insertions, 7 deletions
diff --git a/ext/tk/lib/tk/event.rb b/ext/tk/lib/tk/event.rb index 0042fcaa63..d8aad6248b 100644 --- a/ext/tk/lib/tk/event.rb +++ b/ext/tk/lib/tk/event.rb @@ -352,6 +352,14 @@ module TkEvent nil ] + # [ <'%' subst-key str>, <proc type char>, <instance var (accessor) name>] + # the subst-key string will be converted to a bytecode (128+idx). + LONGKEY_TBL = [ + # for example, for %CTT and %CST subst-key on tkdnd-2.0 + # ['CTT', ?l, :drop_target_type], + # ['CST', ?l, :drop_source_type], + ] + # [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>] PROC_TBL = [ [ ?n, TkComm.method(:num_or_str) ], @@ -371,6 +379,7 @@ module TkEvent nil ] +=begin # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) KEY_TBL.map!{|inf| if inf.kind_of?(Array) @@ -386,6 +395,7 @@ module TkEvent end inf } +=end # setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys # @@ -399,7 +409,8 @@ module TkEvent # ( which are Tcl strings ) to ruby objects based on the key string # that is generated by _get_subst_key() or _get_all_subst_keys(). # - _setup_subst_table(KEY_TBL, PROC_TBL); + _setup_subst_table(KEY_TBL, PROC_TBL) + # _setup_subst_table(KEY_TBL, LONGKEY_TBL, PROC_TBL) # if use longname-keys # # NOTE: The order of parameters which passed to callback procedure is @@ -447,6 +458,7 @@ module TkEvent extra_args_tbl = klass._get_extra_args_tbl if args.compact.size > 0 + args.map!{|arg| klass._sym2subst(arg)} args = args.join(' ') keys = klass._get_subst_key(args) diff --git a/ext/tk/lib/tk/grid.rb b/ext/tk/lib/tk/grid.rb index 10fdf3569b..0dfd7263a7 100644 --- a/ext/tk/lib/tk/grid.rb +++ b/ext/tk/lib/tk/grid.rb @@ -22,6 +22,7 @@ module TkGrid list(tk_call_without_enc('grid', 'bbox', *args)) end +=begin def configure(win, *args) if args[-1].kind_of?(Hash) opts = args.pop @@ -53,6 +54,48 @@ module TkGrid tk_call_without_enc('grid', 'configure', *params) end end +=end + def configure(*args) + if args[-1].kind_of?(Hash) + opts = args.pop + else + opts = {} + end + fail ArgumentError, 'no widget is given' if args.empty? + params = [] + args.flatten(1).each{|win| + case win + when '-', ?- # RELATIVE PLACEMENT (increase columnspan) + params.push('-') + when /^-+$/ # RELATIVE PLACEMENT (increase columnspan) + params.concat(win.to_s.split(//)) + when '^', ?^ # RELATIVE PLACEMENT (increase rowspan) + params.push('^') + when /^\^+$/ # RELATIVE PLACEMENT (increase rowspan) + params.concat(win.to_s.split(//)) + when 'x', :x, ?x, nil, '' # RELATIVE PLACEMENT (empty column) + params.push('x') + when /^x+$/ # RELATIVE PLACEMENT (empty column) + params.concat(win.to_s.split(//)) + else + params.push(_epath(win)) + end + } + opts.each{|k, v| + params.push("-#{k}") + params.push(_epath(v)) # have to use 'epath' (hash_kv() is unavailable) + } + if Tk::TCL_MAJOR_VERSION < 8 || + (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION <= 3) + if params[0] == '-' || params[0] == 'x' || params[0] == '^' + tk_call_without_enc('grid', *params) + else + tk_call_without_enc('grid', 'configure', *params) + end + else + tk_call_without_enc('grid', 'configure', *params) + end + end alias grid configure def columnconfigure(master, index, args) @@ -61,12 +104,14 @@ module TkGrid tk_call_without_enc("grid", 'columnconfigure', master, index, *hash_kv(args)) end + alias column columnconfigure def rowconfigure(master, index, args) # master = master.epath if master.kind_of?(TkObject) master = _epath(master) tk_call_without_enc("grid", 'rowconfigure', master, index, *hash_kv(args)) end + alias row rowconfigure def columnconfiginfo(master, index, slot=nil) # master = master.epath if master.kind_of?(TkObject) @@ -189,10 +234,10 @@ module TkGrid list(tk_call_without_enc('grid', 'slaves', master, *hash_kv(args))) end - module_function :bbox, :forget, :propagate, :info + module_function :anchor, :bbox, :add, :forget, :propagate, :info module_function :remove, :size, :slaves, :location module_function :grid, :configure, :columnconfigure, :rowconfigure - module_function :columnconfiginfo, :rowconfiginfo + module_function :column, :row, :columnconfiginfo, :rowconfiginfo end =begin def TkGrid(win, *args) diff --git a/ext/tk/lib/tk/pack.rb b/ext/tk/lib/tk/pack.rb index 8fab363121..220a38e524 100644 --- a/ext/tk/lib/tk/pack.rb +++ b/ext/tk/lib/tk/pack.rb @@ -9,6 +9,7 @@ module TkPack TkCommandNames = ['pack'.freeze].freeze +=begin def configure(win, *args) if args[-1].kind_of?(Hash) opts = args.pop @@ -29,6 +30,22 @@ module TkPack } tk_call_without_enc("pack", 'configure', *params) end +=end + def configure(*args) + if args[-1].kind_of?(Hash) + opts = args.pop + else + opts = {} + end + fail ArgumentError, 'no widget is given' if args.empty? + params = [] + args.flatten(1).each{|win| params.push(_epath(win))} + opts.each{|k, v| + params.push("-#{k}") + params.push(_epath(v)) # have to use 'epath' (hash_kv() is unavailable) + } + tk_call_without_enc("pack", 'configure', *params) + end alias pack configure def forget(*args) diff --git a/ext/tk/lib/tk/spinbox.rb b/ext/tk/lib/tk/spinbox.rb index e372c58009..34dc1904f7 100644 --- a/ext/tk/lib/tk/spinbox.rb +++ b/ext/tk/lib/tk/spinbox.rb @@ -37,6 +37,7 @@ class Tk::Spinbox<Tk::Entry nil ] +=begin # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) KEY_TBL.map!{|inf| if inf.kind_of?(Array) @@ -52,6 +53,7 @@ class Tk::Spinbox<Tk::Entry end inf } +=end _setup_subst_table(KEY_TBL, PROC_TBL); diff --git a/ext/tk/lib/tk/validation.rb b/ext/tk/lib/tk/validation.rb index 1da38c776d..60bd433cdc 100644 --- a/ext/tk/lib/tk/validation.rb +++ b/ext/tk/lib/tk/validation.rb @@ -50,7 +50,8 @@ module Tk key2class.each{|key, klass| if keys[key].kind_of?(Array) cmd, *args = keys[key] - keys[key] = klass.new(cmd, args.join(' ')) + #keys[key] = klass.new(cmd, args.join(' ')) + keys[key] = klass.new(cmd, *args) # elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) elsif TkComm._callback_entry?(keys[key]) keys[key] = klass.new(keys[key]) @@ -151,7 +152,8 @@ module Tk key2class.each{|key, klass| if keys[key].kind_of?(Array) cmd, *args = keys[key] - keys[key] = klass.new(cmd, args.join(' ')) + #keys[key] = klass.new(cmd, args.join(' ')) + keys[key] = klass.new(cmd, *args) # elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method) elsif TkComm._callback_entry?(keys[key]) keys[key] = klass.new(keys[key]) @@ -249,6 +251,7 @@ class TkValidateCommand nil ] +=begin # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) ) KEY_TBL.map!{|inf| if inf.kind_of?(Array) @@ -264,6 +267,7 @@ class TkValidateCommand end inf } +=end _setup_subst_table(KEY_TBL, PROC_TBL); @@ -293,6 +297,7 @@ class TkValidateCommand extra_args_tbl = klass._get_extra_args_tbl if args.compact.size > 0 + args.map!{|arg| klass._sym2subst(arg)} args = args.join(' ') keys = klass._get_subst_key(args) if cmd.kind_of?(String) diff --git a/ext/tk/lib/tk/wm.rb b/ext/tk/lib/tk/wm.rb index 49dd4d73c2..0394296189 100644 --- a/ext/tk/lib/tk/wm.rb +++ b/ext/tk/lib/tk/wm.rb @@ -362,7 +362,7 @@ module Tk end end def overrideredirect(mode=TkComm::None) - Wm.overrideredirect(self, mode=TkComm::None) + Wm.overrideredirect(self, mode) end alias wm_overrideredirect overrideredirect TOPLEVEL_METHODCALL_OPTKEYS['overrideredirect'] = 'overrideredirect' @@ -545,7 +545,7 @@ module Tk module Wm_for_General Wm.instance_methods.each{|m| if (m = m.to_s) =~ /^wm_(.*)$/ - eval "def #{m}(*args); Tk::Wm.#{$1}(self, *args); end" + eval "def #{m}(*args, &b); Tk::Wm.#{$1}(self, *args, &b); end" end } end |