summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb
blob: 4d04974a55d7b5debc09b88a327b289ec5880021 (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
#
#  ::vu::dial widget
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
require 'tk'

# create module/class
module Tk
  module Vu
    class Dial < TkWindow
    end
  end
end

# call setup script  --  <libdir>/tkextlib/vu.rb
require 'tkextlib/vu.rb'

# define module/class
class Tk::Vu::Dial < TkWindow
  TkCommandNames = ['::vu::dial'.freeze].freeze
  WidgetClassName = 'Dial'.freeze
  WidgetClassNames[WidgetClassName] ||= self

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

  def __methodcall_optkeys  # { key=>method, ... }
    {'coords'=>'coords'}
  end
  private :__methodcall_optkeys

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

  def coords(val = nil)
    if val
      tk_send_without_enc('coords', val)
      self
    else
      tk_split_list(tk_send_without_enc('coords'))
    end
  end

  def constrain(val = None)
    num_or_str(tk_call(@path, 'constrain', val))
  end

  def get(*args)
    num_or_str(tk_call(@path, 'get', *args))
  end

  def identify(x, y)
    tk_call(@path, 'identify', x, y)
  end

  def get_label(val=nil)
    if val
      tk_call(@path, 'label', val)
    else
      ret = []
      lst = simplelist(tk_call(@path, 'label'))
      while lst.size > 0
        ret << ([num_or_str(lst.shift)] << lst.shift)
      end
    end
  end

  def set_label(val, str, *args)
    tk_call(@path, 'label', val, str, *args)
    self
  end

  def set_label_constrain(val, str, *args)
    tk_call(@path, 'label', '-constrain', val, str, *args)
    self
  end

  def get_tag(val=nil)
    if val
      tk_call(@path, 'tag', val)
    else
      ret = []
      lst = simplelist(tk_call(@path, 'tag'))
      while lst.size > 0
        ret << ([num_or_str(lst.shift)] << lst.shift)
      end
    end
  end

  def set_tag(val, str, *args)
    tk_call(@path, 'tag', val, str, *args)
    self
  end

  def set_tag_constrain(val, str, *args)
    tk_call(@path, 'tag', '-constrain', val, str, *args)
    self
  end

  def set(val = None)
    tk_call_without_enc(@path, 'set', val)
    self
  end
end