From ac3b12233b23713a29c83eee3f92dd41f3ac3a77 Mon Sep 17 00:00:00 2001 From: nagai Date: Wed, 8 Dec 2004 18:14:15 +0000 Subject: * ext/tcltklib/tcltklib.c (ip_init): set root-win title to "ruby" when the running script is '-e one-liner' or '-' (stdin). * ext/tcltklib/extconf.rb: add find_library("#{lib}#{ver}",..) for stub libs * ext/tk/lib/tk/textmark.rb: TkTextMarkCurrent and TkTextMarkAnchor have a wrong parent class. * ext/tk/lib/tk/dialog.rb: rename TkDialog2 --> TkDialogObj and TkWarning2 --> TkWarningObj (old names are changed to alias names) * ext/tk/lib/tk/dialog.rb: bug fix of treatment of 'prev_command' option and hashes for configuration * ext/tk/lib/tk/dialog.rb: add TkDialogObj#name to return the button name * ext/tk/lib/tk/radiobutton.rb: rename enbugged method value() ==> get_value() and value=(val) ==> set_value(val). * ext/tk/lib/tk/menu.rb: add TkMenu.new_menuspec * ext/tk/lib/tk/menu.rb: add alias (TkMenuButton = TkMenubutton, TkOptionMenuButton = TkOptionMenubutton) * ext/tk/lib/tk/event.rb: new method aliases (same as option keys of event_generate) for Event object * ext/tk/lib/tk/font.rb: configinfo returns proper types of values * ext/tk/lib/tk.rb: bind methods accept subst_args + block * ext/tk/lib/tk/canvas.rb: ditto * ext/tk/lib/tk/canvastag.rb: ditto * ext/tk/lib/tk/frame.rb: ditto * ext/tk/lib/tk/text.rb: ditto * ext/tk/lib/tk/texttag.rb: ditto * ext/tk/lib/tk/toplevel.rb: ditto * ext/tk/lib/tkextlib/*: ditto and bug fix git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tkextlib/bwidget/labelentry.rb | 26 ++++++++++-- ext/tk/lib/tkextlib/bwidget/listbox.rb | 56 ++++++++++++++++++++++---- ext/tk/lib/tkextlib/bwidget/notebook.rb | 38 +++++++++++++---- ext/tk/lib/tkextlib/bwidget/spinbox.rb | 26 ++++++++++-- ext/tk/lib/tkextlib/bwidget/tree.rb | 56 ++++++++++++++++++++++---- ext/tk/lib/tkextlib/itk/incr_tk.rb | 44 +++++++++++++++++--- ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb | 22 +++++++++- ext/tk/lib/tkextlib/tkDND/tkdnd.rb | 39 ++++++++++++++++-- ext/tk/lib/tkextlib/treectrl/tktreectrl.rb | 27 ++++++++++++- 9 files changed, 290 insertions(+), 44 deletions(-) (limited to 'ext/tk/lib/tkextlib') diff --git a/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/ext/tk/lib/tkextlib/bwidget/labelentry.rb index 7a6a7f01d6..1425ef7730 100644 --- a/ext/tk/lib/tkextlib/bwidget/labelentry.rb +++ b/ext/tk/lib/tkextlib/bwidget/labelentry.rb @@ -23,13 +23,31 @@ class Tk::BWidget::LabelEntry WidgetClassName = 'LabelEntry'.freeze WidgetClassNames[WidgetClassName] = self - def entrybind(*args) - _bind([path, 'bind'], *args) + #def entrybind(*args) + # _bind([path, 'bind'], *args) + # self + #end + def entrybind(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind([path, 'bind'], context, cmd, *args) self end - def entrybind_append(*args) - _bind_append([path, 'bind'], *args) + #def entrybind_append(*args) + # _bind_append([path, 'bind'], *args) + # self + #end + def entrybind_append(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_append([path, 'bind'], context, cmd, *args) self end diff --git a/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ext/tk/lib/tkextlib/bwidget/listbox.rb index 9f505703f2..7f218c923c 100644 --- a/ext/tk/lib/tkextlib/bwidget/listbox.rb +++ b/ext/tk/lib/tkextlib/bwidget/listbox.rb @@ -44,13 +44,33 @@ class Tk::BWidget::ListBox end end - def imagebind(*args) - _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + #def imagebind(*args) + # _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + # self + #end + def imagebind(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_for_event_class(Event_for_Items, [path, 'bindImage'], + context, cmd, *args) self end - def imagebind_append(*args) - _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + #def imagebind_append(*args) + # _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + # self + #end + def imagebind_append(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], + context, cmd, *args) self end @@ -63,13 +83,33 @@ class Tk::BWidget::ListBox _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args) end - def textbind(*args) - _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args) + #def textbind(*args) + # _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args) + # self + #end + def textbind(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_for_event_class(Event_for_Items, [path, 'bindText'], + context, cmd, *args) self end - def textbind_append(*args) - _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args) + #def textbind_append(*args) + # _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args) + # self + #end + def textbind_append(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], + context, cmd, *args) self end diff --git a/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ext/tk/lib/tkextlib/bwidget/notebook.rb index aba222ff8a..8888ab224b 100644 --- a/ext/tk/lib/tkextlib/bwidget/notebook.rb +++ b/ext/tk/lib/tkextlib/bwidget/notebook.rb @@ -41,13 +41,33 @@ class Tk::BWidget::NoteBook end end - def tabbind(*args) - _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args) + #def tabbind(*args) + # _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args) + # self + #end + def tabbind(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'], + context, cmd, *args) self end - def tabbind_append(*args) - _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args) + #def tabbind_append(*args) + # _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args) + # self + #end + def tabbind_append(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'], + context, cmd, *args) self end @@ -105,9 +125,13 @@ class Tk::BWidget::NoteBook list(tk_send('pages', first, last)) end - def raise(page=None) - tk_send('raise', page) - self + def raise(page=nil) + if page + tk_send('raise', page) + self + else + tk_send('raise') + end end def see(page) diff --git a/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/ext/tk/lib/tkextlib/bwidget/spinbox.rb index 4380e38355..66501ed702 100644 --- a/ext/tk/lib/tkextlib/bwidget/spinbox.rb +++ b/ext/tk/lib/tkextlib/bwidget/spinbox.rb @@ -22,13 +22,31 @@ class Tk::BWidget::SpinBox WidgetClassName = 'SpinBox'.freeze WidgetClassNames[WidgetClassName] = self - def entrybind(*args) - _bind([path, 'bind'], *args) + #def entrybind(*args) + # _bind([path, 'bind'], *args) + # self + #end + def entrybind(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind([path, 'bind'], context, cmd, *args) self end - def entrybind_append(*args) - _bind_append([path, 'bind'], *args) + #def entrybind_append(*args) + # _bind_append([path, 'bind'], *args) + # self + #end + def entrybind_append(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_append([path, 'bind'], context, cmd, *args) self end diff --git a/ext/tk/lib/tkextlib/bwidget/tree.rb b/ext/tk/lib/tkextlib/bwidget/tree.rb index 9a49a96bb7..16ca8e8927 100644 --- a/ext/tk/lib/tkextlib/bwidget/tree.rb +++ b/ext/tk/lib/tkextlib/bwidget/tree.rb @@ -41,13 +41,33 @@ class Tk::BWidget::Tree end end - def imagebind(*args) - _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + #def imagebind(*args) + # _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + # self + #end + def imagebind(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_for_event_class(Event_for_Items, [path, 'bindImage'], + context, cmd, *args) self end - def imagebind_append(*args) - _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + #def imagebind_append(*args) + # _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args) + # self + #end + def imagebind_append(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], + context, cmd, *args) self end @@ -60,13 +80,33 @@ class Tk::BWidget::Tree _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args) end - def textbind(*args) - _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args) + #def textbind(*args) + # _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args) + # self + #end + def textbind(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_for_event_class(Event_for_Items, [path, 'bindText'], + context, cmd, *args) self end - def textbind_append(*args) - _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args) + #def textbind_append(*args) + # _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args) + # self + #end + def textbind_append(context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], + context, cmd, *args) self end diff --git a/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ext/tk/lib/tkextlib/itk/incr_tk.rb index f11d9d7913..106ffa3519 100644 --- a/ext/tk/lib/tkextlib/itk/incr_tk.rb +++ b/ext/tk/lib/tkextlib/itk/incr_tk.rb @@ -330,7 +330,18 @@ module Tk end end - def bind(*args) + #def bind(*args) + # unless @widget + # begin + # @widget = window(tk_call(@master, 'component', @component)) + # @path = @widget.path + # rescue + # fail RuntimeError, 'component is not assigned to a widget' + # end + # end + # @widget.bind(*args) + #end + def bind(context, *args) unless @widget begin @widget = window(tk_call(@master, 'component', @component)) @@ -339,10 +350,26 @@ module Tk fail RuntimeError, 'component is not assigned to a widget' end end - @widget.bind(*args) - end - - def bind_append(*args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + @widget.bind(context, cmd, *args) + end + + #def bind_append(*args) + # unless @widget + # begin + # @widget = window(tk_call(@master, 'component', @component)) + # @path = @widget.path + # rescue + # fail RuntimeError, 'component is not assigned to a widget' + # end + # end + # @widget.bind_append(*args) + #end + def bind_append(context, *args) unless @widget begin @widget = window(tk_call(@master, 'component', @component)) @@ -351,7 +378,12 @@ module Tk fail RuntimeError, 'component is not assigned to a widget' end end - @widget.bind_append(*args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + @widget.bind_append(context, cmd, *args) end def bind_remove(*args) diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb index f3c4260482..ba563ba589 100644 --- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb +++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb @@ -97,12 +97,30 @@ class Tk::Iwidgets::Scrolledcanvas *tags.collect{|t| tagid(t)})) end - def itembind(tag, context, cmd=Proc.new, *args) + #def itembind(tag, context, cmd=Proc.new, *args) + # _bind([path, "bind", tagid(tag)], context, cmd, *args) + # self + #end + def itembind(tag, context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end _bind([path, "bind", tagid(tag)], context, cmd, *args) self end - def itembind_append(tag, context, cmd=Proc.new, *args) + #def itembind_append(tag, context, cmd=Proc.new, *args) + # _bind_append([path, "bind", tagid(tag)], context, cmd, *args) + # self + #end + def itembind_append(tag, context, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end _bind_append([path, "bind", tagid(tag)], context, cmd, *args) self end diff --git a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb index 78381f8df0..d40d60217a 100644 --- a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb +++ b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb @@ -75,7 +75,28 @@ module Tk end end - def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args) + #def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args) + # event = tk_event_sequence(event) + # if prior.kind_of?(Numeric) + # tk_call('dnd', 'bindtarget', @path, type, event, + # install_bind_for_event_class(DND_Subst, cmd, *args), + # prior) + # else + # tk_call('dnd', 'bindtarget', @path, type, event, + # install_bind_for_event_class(DND_Subst, cmd, prior, *args)) + # end + # self + #end + def dnd_bindtarget(type, event, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + + prior = 50 + prior = args.shift unless args.empty? + event = tk_event_sequence(event) if prior.kind_of?(Numeric) tk_call('dnd', 'bindtarget', @path, type, event, @@ -101,8 +122,20 @@ module Tk end end - def dnd_bindsource(type, cmd=Proc.new, prior=None) - tk_call('dnd', 'bindsource', @path, type, cmd, prior) + #def dnd_bindsource(type, cmd=Proc.new, prior=None) + # tk_call('dnd', 'bindsource', @path, type, cmd, prior) + # self + #end + def dnd_bindsource(type, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end + + args = [None] if args.empty + + tk_call('dnd', 'bindsource', @path, type, cmd, *args) self end diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb index 729007edfb..11f723a8ff 100644 --- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb +++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb @@ -743,16 +743,39 @@ class Tk::TreeCtrl marquee_visible() end - def notify_bind(obj, event, cmd=Proc.new, *args) + #def notify_bind(obj, event, cmd=Proc.new, *args) + # _bind([@path, 'notify', 'bind', obj], event, cmd, *args) + # self + #end + def notify_bind(obj, event, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end _bind([@path, 'notify', 'bind', obj], event, cmd, *args) self end - def notify_bind_append(obj, event, cmd=Proc.new, *args) + #def notify_bind_append(obj, event, cmd=Proc.new, *args) + # _bind([@path, 'notify', 'bind', obj], event, cmd, *args) + # self + #end + def notify_bind_append(obj, event, *args) + if args[0].kind_of?(Proc) || args[0].kind_of?(Method) + cmd = args.shift + else + cmd = Proc.new + end _bind([@path, 'notify', 'bind', obj], event, cmd, *args) self end + def notify_bindremove(obj, event) + _bind_remove([@path, 'notify', 'bind', obj], event) + self + end + def notify_bindinfo(obj, event=nil) _bindinfo([@path, 'notify', 'bind', obj], event) end -- cgit v1.2.3