summaryrefslogtreecommitdiff
path: root/trunk/ext/tk/lib/tkextlib/blt/unix_dnd.rb
blob: 445002d7a538ad2333bf16dc390dfbdb4ea2ca83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
#  tkextlib/blt/unix_dnd.rb
#
#    *** This is alpha version, because there is no document on BLT. ***
#
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#

require 'tk'
require 'tkextlib/blt.rb'

module Tk::BLT
  module DnD
    extend TkCore

    TkCommandNames = ['::blt::dnd'.freeze].freeze

    ##############################

    extend TkItemConfigMethod

    class << self
      def __item_cget_cmd(id)
        ['::blt::dnd', *id]
      end
      private :__item_cget_cmd

      def __item_config_cmd(id)
        ['::blt::dnd', *id]
      end
      private :__item_config_cmd

      private :itemcget, :itemcget_strict
      private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo

      def cget(win, option)
        itemcget(['cget', win], option)
      end
      def cget_strict(win, option)
        itemcget_strict(['cget', win], option)
      end
      def configure(win, slot, value=None)
        itemconfigure(['configure', win], slot, value)
      end
      def configinfo(win, slot=nil)
        itemconfiginfo(['configure', win], slot)
      end
      def current_configinfo(win, slot=nil)
        current_itemconfiginfo(['configure', win], slot)
      end

      def token_cget(win, option)
        itemcget(['token', 'cget', win], option)
      end
      def token_cget_strict(win, option)
        itemcget_strict(['token', 'cget', win], option)
      end
      def token_configure(win, slot, value=None)
        itemconfigure(['token', 'configure', win], slot, value)
      end
      def token_configinfo(win, slot=nil)
        itemconfiginfo(['token', 'configure', win], slot)
      end
      def current_token_configinfo(win, slot=nil)
        current_itemconfiginfo(['token', 'configure', win], slot)
      end

      def token_windowconfigure(win, slot, value=None)
        itemconfigure(['token', 'window', win], slot, value)
      end
      def token_windowconfiginfo(win, slot=nil)
        itemconfiginfo(['token', 'window', win], slot)
      end
      def current_token_windowconfiginfo(win, slot=nil)
        current_itemconfiginfo(['token', 'window', win], slot)
      end
    end

    ##############################

    def self.cancel(win)
      tk_call('::blt::dnd', 'cancel', *wins)
    end
    def self.delete(*wins)
      tk_call('::blt::dnd', 'delete', *wins)
    end
    def self.delete_source(*wins)
      tk_call('::blt::dnd', 'delete', '-source', *wins)
    end
    def self.delete_target(*wins)
      tk_call('::blt::dnd', 'delete', '-target', *wins)
    end
    def self.drag(win, x, y, token=None)
      tk_call('::blt::dnd', 'drag', win, x, y, token)
    end
    def self.drop(win, x, y, token=None)
      tk_call('::blt::dnd', 'drop', win, x, y, token)
    end
    def self.get_data(win, fmt=nil, cmd=nil)
      if fmt
        tk_call('::blt::dnd', 'getdata', win, fmt, cmd)
      else
        list(tk_call('::blt::dnd', 'getdata', win))
      end
    end
    def self.names(pat=None)
      list(tk_call('::blt::dnd', 'names', pat))
    end
    def self.source_names(pat=None)
      list(tk_call('::blt::dnd', 'names', '-source', pat))
    end
    def self.target_names(pat=None)
      list(tk_call('::blt::dnd', 'names', '-target', pat))
    end
    def self.pull(win, fmt)
      tk_call('::blt::dnd', 'pull', win, fmt)
    end
    def self.register(win, keys={})
      tk_call('::blt::dnd', 'register', win, keys)
    end
    def self.select(win, x, y, timestamp)
      tk_call('::blt::dnd', 'select', win, x, y, timestamp)
    end
    def self.set_data(win, fmt=nil, cmd=nil)
      if fmt
        tk_call('::blt::dnd', 'setdata', win, fmt, cmd)
      else
        list(tk_call('::blt::dnd', 'setdata', win))
      end
    end
    def self.token(*args)
      tk_call('::blt::dnd', 'token', *args)
    end
  end
end