2 # tkextlib/tkDND/tkdnd.rb
3 # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
8 # call setup script for general 'tkextlib' libraries
9 require 'tkextlib/setup.rb'
12 require 'tkextlib/tkDND/setup.rb'
14 TkPackage.require('tkdnd')
18 PACKAGE_NAME = 'tkdnd'.freeze
23 def self.package_version
25 TkPackage.require('tkdnd')
31 class DND_Subst < TkUtil::CallbackSubst
37 [ ?d, ?l, :descriptions ],
39 [ ?L, ?l, :source_types ],
40 [ ?m, ?l, :modifiers ],
52 [ ?n, TkComm.method(:num_or_str) ],
53 [ ?s, TkComm.method(:string) ],
54 [ ?l, TkComm.method(:list) ],
55 [ ?L, TkComm.method(:simplelist) ],
56 [ ?w, TkComm.method(:window) ],
61 # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
63 if inf.kind_of?(Array)
64 inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
65 inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
71 if inf.kind_of?(Array)
72 inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
79 _setup_subst_table(KEY_TBL, PROC_TBL);
85 TkPackage.require('tkdnd')
91 def dnd_bindtarget_info(type=nil, event=nil)
93 procedure(tk_call('dnd', 'bindtarget', @path, type, event))
95 procedure(tk_call('dnd', 'bindtarget', @path, type))
97 simplelist(tk_call('dnd', 'bindtarget', @path))
101 #def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args)
102 # event = tk_event_sequence(event)
103 # if prior.kind_of?(Numeric)
104 # tk_call('dnd', 'bindtarget', @path, type, event,
105 # install_bind_for_event_class(DND_Subst, cmd, *args),
108 # tk_call('dnd', 'bindtarget', @path, type, event,
109 # install_bind_for_event_class(DND_Subst, cmd, prior, *args))
113 def dnd_bindtarget(type, event, *args)
114 # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
115 if TkComm._callback_entry?(args[0]) || !block_given?
122 prior = args.shift unless args.empty?
124 event = tk_event_sequence(event)
125 if prior.kind_of?(Numeric)
126 tk_call('dnd', 'bindtarget', @path, type, event,
127 install_bind_for_event_class(DND_Subst, cmd, *args),
130 tk_call('dnd', 'bindtarget', @path, type, event,
131 install_bind_for_event_class(DND_Subst, cmd, prior, *args))
137 tk_call('dnd', 'cleartarget', @path)
141 def dnd_bindsource_info(type=nil)
143 procedure(tk_call('dnd', 'bindsource', @path, type))
145 simplelist(tk_call('dnd', 'bindsource', @path))
149 #def dnd_bindsource(type, cmd=Proc.new, prior=None)
150 # tk_call('dnd', 'bindsource', @path, type, cmd, prior)
153 def dnd_bindsource(type, *args)
154 # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
155 if TkComm._callback_entry?(args[0]) || !block_given?
161 args = [None] if args.empty
163 tk_call('dnd', 'bindsource', @path, type, cmd, *args)
167 def dnd_clearsource()
168 tk_call('dnd', 'clearsource', @path)
172 def dnd_drag(keys=nil)
173 tk_call('dnd', 'drag', @path, *hash_kv(keys))
181 include Tk::TkDND::DND