1#
2#  ::vu::dial widget
3#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4#
5require 'tk'
6
7# create module/class
8module Tk
9  module Vu
10    class Dial < TkWindow
11    end
12  end
13end
14
15# call setup script  --  <libdir>/tkextlib/vu.rb
16require 'tkextlib/vu.rb'
17
18# define module/class
19class Tk::Vu::Dial < TkWindow
20  TkCommandNames = ['::vu::dial'.freeze].freeze
21  WidgetClassName = 'Dial'.freeze
22  WidgetClassNames[WidgetClassName] ||= self
23
24  ###############################
25
26  def __methodcall_optkeys  # { key=>method, ... }
27    {'coords'=>'coords'}
28  end
29  private :__methodcall_optkeys
30
31  ###############################
32
33  def coords(val = nil)
34    if val
35      tk_send_without_enc('coords', val)
36      self
37    else
38      tk_split_list(tk_send_without_enc('coords'))
39    end
40  end
41
42  def constrain(val = None)
43    num_or_str(tk_call(@path, 'constrain', val))
44  end
45
46  def get(*args)
47    num_or_str(tk_call(@path, 'get', *args))
48  end
49
50  def identify(x, y)
51    tk_call(@path, 'identify', x, y)
52  end
53
54  def get_label(val=nil)
55    if val
56      tk_call(@path, 'label', val)
57    else
58      ret = []
59      lst = simplelist(tk_call(@path, 'label'))
60      while lst.size > 0
61        ret << ([num_or_str(lst.shift)] << lst.shift)
62      end
63    end
64  end
65
66  def set_label(val, str, *args)
67    tk_call(@path, 'label', val, str, *args)
68    self
69  end
70
71  def set_label_constrain(val, str, *args)
72    tk_call(@path, 'label', '-constrain', val, str, *args)
73    self
74  end
75
76  def get_tag(val=nil)
77    if val
78      tk_call(@path, 'tag', val)
79    else
80      ret = []
81      lst = simplelist(tk_call(@path, 'tag'))
82      while lst.size > 0
83        ret << ([num_or_str(lst.shift)] << lst.shift)
84      end
85    end
86  end
87
88  def set_tag(val, str, *args)
89    tk_call(@path, 'tag', val, str, *args)
90    self
91  end
92
93  def set_tag_constrain(val, str, *args)
94    tk_call(@path, 'tag', '-constrain', val, str, *args)
95    self
96  end
97
98  def set(val = None)
99    tk_call_without_enc(@path, 'set', val)
100    self
101  end
102end
103