OSDN Git Service

ruby-1.9.1-rc1
[splhack/AndroidRuby.git] / lib / ruby-1.9.1-rc1 / ext / tk / lib / tkextlib / iwidgets / dialogshell.rb
1 #
2 #  tkextlib/iwidgets/dialogshell.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 Dialogshell < Tk::Iwidgets::Shell
12     end
13   end
14 end
15
16 class Tk::Iwidgets::Dialogshell
17   TkCommandNames = ['::iwidgets::dialogshell'.freeze].freeze
18   WidgetClassName = 'Dialogshell'.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 default(idx)
75     tk_call(@path, 'default', index(idx))
76     self
77   end
78
79   def delete(idx)
80     tk_call(@path, 'delete', index(idx))
81     self
82   end
83
84   def hide(idx)
85     tk_call(@path, 'hide', index(idx))
86     self
87   end
88
89   def index(idx)
90     number(tk_call(@path, 'index', tagid(idx)))
91   end
92
93   def insert(idx, tag=nil, keys={})
94     if tag.kind_of?(Hash)
95       keys = tag
96       tag = nil
97     end
98     if tag
99       tag = Tk::Itk::Component.new(self, tagid(tag))
100     else
101       tag = Tk::Itk::Component.new(self)
102     end
103     tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
104     tag
105   end
106
107   def invoke(idx=nil)
108     if idx
109       tk_call(@path, 'invoke', index(idx))
110     else
111       tk_call(@path, 'invoke')
112     end
113     self
114   end
115
116   def show(idx)
117     tk_call(@path, 'show', index(idx))
118     self
119   end
120 end