| 1 | # |
|---|
| 2 | # tkextlib/blt/unix_dnd.rb |
|---|
| 3 | # |
|---|
| 4 | # *** This is alpha version, because there is no document on BLT. *** |
|---|
| 5 | # |
|---|
| 6 | # by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) |
|---|
| 7 | # |
|---|
| 8 | |
|---|
| 9 | require 'tk' |
|---|
| 10 | require 'tkextlib/blt.rb' |
|---|
| 11 | |
|---|
| 12 | module Tk::BLT |
|---|
| 13 | module DnD |
|---|
| 14 | extend TkCore |
|---|
| 15 | |
|---|
| 16 | TkCommandNames = ['::blt::dnd'.freeze].freeze |
|---|
| 17 | |
|---|
| 18 | ############################## |
|---|
| 19 | |
|---|
| 20 | extend TkItemConfigMethod |
|---|
| 21 | |
|---|
| 22 | class << self |
|---|
| 23 | def __item_cget_cmd(id) |
|---|
| 24 | ['::blt::dnd', *id] |
|---|
| 25 | end |
|---|
| 26 | private :__item_cget_cmd |
|---|
| 27 | |
|---|
| 28 | def __item_config_cmd(id) |
|---|
| 29 | ['::blt::dnd', *id] |
|---|
| 30 | end |
|---|
| 31 | private :__item_config_cmd |
|---|
| 32 | |
|---|
| 33 | private :itemcget, :itemconfigure |
|---|
| 34 | private :itemconfiginfo, :current_itemconfiginfo |
|---|
| 35 | |
|---|
| 36 | def cget(win, option) |
|---|
| 37 | itemconfigure(['cget', win], slot, value) |
|---|
| 38 | end |
|---|
| 39 | def configure(win, slot, value=None) |
|---|
| 40 | itemconfigure(['configure', win], slot, value) |
|---|
| 41 | end |
|---|
| 42 | def configinfo(win, slot=nil) |
|---|
| 43 | itemconfiginfo(['configure', win], slot) |
|---|
| 44 | end |
|---|
| 45 | def current_configinfo(win, slot=nil) |
|---|
| 46 | current_itemconfiginfo(['configure', win], slot) |
|---|
| 47 | end |
|---|
| 48 | |
|---|
| 49 | def tokwn_cget(win, option) |
|---|
| 50 | itemconfigure(['token', 'cget', win], slot, value) |
|---|
| 51 | end |
|---|
| 52 | def token_configure(win, slot, value=None) |
|---|
| 53 | itemconfigure(['token', 'configure', win], slot, value) |
|---|
| 54 | end |
|---|
| 55 | def token_configinfo(win, slot=nil) |
|---|
| 56 | itemconfiginfo(['token', 'configure', win], slot) |
|---|
| 57 | end |
|---|
| 58 | def current_token_configinfo(win, slot=nil) |
|---|
| 59 | current_itemconfiginfo(['token', 'configure', win], slot) |
|---|
| 60 | end |
|---|
| 61 | |
|---|
| 62 | def token_windowconfigure(win, slot, value=None) |
|---|
| 63 | itemconfigure(['token', 'window', win], slot, value) |
|---|
| 64 | end |
|---|
| 65 | def token_windowconfiginfo(win, slot=nil) |
|---|
| 66 | itemconfiginfo(['token', 'window', win], slot) |
|---|
| 67 | end |
|---|
| 68 | def current_token_windowconfiginfo(win, slot=nil) |
|---|
| 69 | current_itemconfiginfo(['token', 'window', win], slot) |
|---|
| 70 | end |
|---|
| 71 | end |
|---|
| 72 | |
|---|
| 73 | ############################## |
|---|
| 74 | |
|---|
| 75 | def self.cancel(win) |
|---|
| 76 | tk_call('::blt::dnd', 'cancel', *wins) |
|---|
| 77 | end |
|---|
| 78 | def self.delete(*wins) |
|---|
| 79 | tk_call('::blt::dnd', 'delete', *wins) |
|---|
| 80 | end |
|---|
| 81 | def self.delete_source(*wins) |
|---|
| 82 | tk_call('::blt::dnd', 'delete', '-source', *wins) |
|---|
| 83 | end |
|---|
| 84 | def self.delete_target(*wins) |
|---|
| 85 | tk_call('::blt::dnd', 'delete', '-target', *wins) |
|---|
| 86 | end |
|---|
| 87 | def self.drag(win, x, y, token=None) |
|---|
| 88 | tk_call('::blt::dnd', 'drag', win, x, y, token) |
|---|
| 89 | end |
|---|
| 90 | def self.drop(win, x, y, token=None) |
|---|
| 91 | tk_call('::blt::dnd', 'drop', win, x, y, token) |
|---|
| 92 | end |
|---|
| 93 | def self.get_data(win, fmt=nil, cmd=nil) |
|---|
| 94 | if fmt |
|---|
| 95 | tk_call('::blt::dnd', 'getdata', win, fmt, cmd) |
|---|
| 96 | else |
|---|
| 97 | list(tk_call('::blt::dnd', 'getdata', win)) |
|---|
| 98 | end |
|---|
| 99 | end |
|---|
| 100 | def self.names(pat=None) |
|---|
| 101 | list(tk_call('::blt::dnd', 'names', pat)) |
|---|
| 102 | end |
|---|
| 103 | def self.source_names(pat=None) |
|---|
| 104 | list(tk_call('::blt::dnd', 'names', '-source', pat)) |
|---|
| 105 | end |
|---|
| 106 | def self.target_names(pat=None) |
|---|
| 107 | list(tk_call('::blt::dnd', 'names', '-target', pat)) |
|---|
| 108 | end |
|---|
| 109 | def self.pull(win, fmt) |
|---|
| 110 | tk_call('::blt::dnd', 'pull', win, fmt) |
|---|
| 111 | end |
|---|
| 112 | def self.register(win, keys={}) |
|---|
| 113 | tk_call('::blt::dnd', 'register', win, keys) |
|---|
| 114 | end |
|---|
| 115 | def self.select(win, x, y, timestamp) |
|---|
| 116 | tk_call('::blt::dnd', 'select', win, x, y, timestamp) |
|---|
| 117 | end |
|---|
| 118 | def self.set_data(win, fmt=nil, cmd=nil) |
|---|
| 119 | if fmt |
|---|
| 120 | tk_call('::blt::dnd', 'setdata', win, fmt, cmd) |
|---|
| 121 | else |
|---|
| 122 | list(tk_call('::blt::dnd', 'setdata', win)) |
|---|
| 123 | end |
|---|
| 124 | end |
|---|
| 125 | def self.token(*args) |
|---|
| 126 | tk_call('::blt::dnd', 'token', *args) |
|---|
| 127 | end |
|---|
| 128 | end |
|---|
| 129 | end |
|---|