OSDN Git Service

ruby-1.9.1-rc1
[splhack/AndroidRuby.git] / lib / ruby-1.9.1-rc1 / ext / tk / lib / tkextlib / iwidgets / radiobox.rb
1 #
2 #  tkextlib/iwidgets/radiobox.rb
3 #                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4 #
5
6 require 'tk'
7 require 'tkextlib/iwidgets.rb'
8
9 module Tk
10   module Iwidgets
11     class Radiobox < Tk::Iwidgets::Labeledframe
12     end
13   end
14 end
15
16 class Tk::Iwidgets::Radiobox
17   TkCommandNames = ['::iwidgets::radiobox'.freeze].freeze
18   WidgetClassName = 'Radiobox'.freeze
19   WidgetClassNames[WidgetClassName] = self
20
21   ####################################
22
23   include TkItemConfigMethod
24
25   def __item_cget_cmd(id)
26     [self.path, 'buttoncget', id]
27   end
28   private :__item_cget_cmd
29
30   def __item_config_cmd(id)
31     [self.path, 'buttonconfigure', id]
32   end
33   private :__item_config_cmd
34
35   def __item_boolval_optkeys(id)
36     super(id) << 'defaultring'
37   end
38   private :__item_boolval_optkeys
39
40   def tagid(tagOrId)
41     if tagOrId.kind_of?(Tk::Itk::Component)
42       tagOrId.name
43     else
44       #_get_eval_string(tagOrId)
45       tagOrId
46     end
47   end
48
49   alias buttoncget itemcget
50   alias buttoncget_strict itemcget_strict
51   alias buttonconfigure itemconfigure
52   alias buttonconfiginfo itemconfiginfo
53   alias current_buttonconfiginfo current_itemconfiginfo
54
55   private :itemcget, :itemcget_strict
56   private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
57
58   ####################################
59
60   def add(tag=nil, keys={})
61     if tag.kind_of?(Hash)
62       keys = tag
63       tag = nil
64     end
65     if tag
66       tag = Tk::Itk::Component.new(self, tagid(tag))
67     else
68       tag = Tk::Itk::Component.new(self)
69     end
70     tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
71     tag
72   end
73
74   def delete(idx)
75     tk_call(@path, 'delete', index(idx))
76     self
77   end
78
79   def deselect(idx)
80     tk_call(@path, 'deselect', index(idx))
81     self
82   end
83
84   def flash(idx)
85     tk_call(@path, 'flash', index(idx))
86     self
87   end
88
89   def get_tag
90     ((tag = tk_call_without_enc(@path, 'get')).empty?)? nil: tag
91   end
92   alias get get_tag
93
94   def get_obj
95     (tag = get_tag)? Tk::Itk::Component.id2obj(self, tag): nil
96   end
97
98   def index(idx)
99     number(tk_call(@path, 'index', tagid(idx)))
100   end
101
102   def insert(idx, tag=nil, keys={})
103     if tag.kind_of?(Hash)
104       keys = tag
105       tag = nil
106     end
107     if tag
108       tag = Tk::Itk::Component.new(self, tagid(tag))
109     else
110       tag = Tk::Itk::Component.new(self)
111     end
112     tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
113     tag
114   end
115
116   def select(idx)
117     tk_call(@path, 'select', index(idx))
118     self
119   end
120 end