1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/tk/lib/tk.rb: fix typo on Tk.grid_propagate.

* ext/tk/lib/tk.rb: Tk.event_generate and TkWindow#event_generate
  accept TkEvent::Event object as context argument.
* ext/tk/lib/tk/event.rb: add TkEvent::Event#valid_fields and
  valid_for_generate to get field parameters of event_generate.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2005-06-24 03:29:24 +00:00
parent fc114887e6
commit 2e3404c1bb
3 changed files with 61 additions and 17 deletions

View file

@ -1,3 +1,13 @@
Fri Jun 24 12:23:19 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: fix typo on Tk.grid_propagate.
* ext/tk/lib/tk.rb: Tk.event_generate and TkWindow#event_generate
accept TkEvent::Event object as context argument.
* ext/tk/lib/tk/event.rb: add TkEvent::Event#valid_fields and
valid_for_generate to get field parameters of event_generate.
Thu Jun 23 23:55:59 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* runruby.rb: should load built rbconfig.rb.

View file

@ -1516,7 +1516,9 @@ module TkCore
def event_generate(win, context, keys=nil)
#win = win.path if win.kind_of?(TkObject)
if keys
if context.kind_of?(TkEvent::Event)
context.generate(win, ((keys)? keys: {}))
elsif keys
tk_call_without_enc('event', 'generate', win,
"<#{tk_event_sequence(context)}>",
*hash_kv(keys, true))
@ -3500,7 +3502,9 @@ class TkObject<TkKernel
=end
def event_generate(context, keys=nil)
if keys
if context.kind_of?(TkEvent::Event)
context.generate(self, ((keys)? keys: {}))
elsif keys
#tk_call('event', 'generate', path,
# "<#{tk_event_sequence(context)}>", *hash_kv(keys))
tk_call_without_enc('event', 'generate', path,
@ -3832,9 +3836,9 @@ class TkWindow<TkObject
# self
#end
if mode == None
TkGrid.propagete(self)
TkGrid.propagate(self)
else
TkGrid.propagete(self, mode)
TkGrid.propagate(self, mode)
self
end
end
@ -4149,7 +4153,7 @@ end
#Tk.freeze
module Tk
RELEASE_DATE = '2005-06-23'.freeze
RELEASE_DATE = '2005-06-24'.freeze
autoload :AUTO_PATH, 'tk/variable'
autoload :TCL_PACKAGE_PATH, 'tk/variable'

View file

@ -212,29 +212,59 @@ module TkEvent
#-------------------------------------------
def generate(win, modkeys={})
klass = self.class
type_id = self.type
type_name = klass.type_name(type_id)
group_flag = klass.group_flag(type_id)
opts = {}
def valid_fields(group_flag=nil)
group_flag = self.class.group_flag(self.type) unless group_flag
fields = {}
FIELD_FLAG.each{|key, flag|
next if (flag & group_flag) == 0
begin
val = self.__send__(key)
val = FIELD_OPERATION[key].call(val) if FIELD_OPERATION[key]
rescue
next
end
next if !val || val == '??'
opts[key] = val
fields[key] = val
}
fields
end
def valid_for_generate(group_flag=nil)
fields = valid_fields(group_flag)
FIELD_OPERATION.each{|key, cmd|
next unless fields.has_key?(key)
val = FIELD_OPERATION[key].call(fields[key])
if val
fields[key] = val
else
fields.delete(key)
end
}
fields
end
def generate(win, modkeys={})
klass = self.class
if modkeys.has_key?(:type) || modkeys.has_key?('type')
modkeys = TkComm._symbolkey2str(modkeys)
type_id = modkeys.delete('type')
else
type_id = self.type
end
type_name = klass.type_name(type_id)
unless type_name
fail RuntimeError, "type_id #{type_id} is invalid"
end
group_flag = klass.group_flag(type_id)
opts = valid_for_generate(group_flag)
modkeys.each{|key, val|
if val
opts[key.to_s] = val