1#
2#  tkextlib/iwidgets/panedwindow.rb
3#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4#
5
6require 'tk'
7require 'tkextlib/iwidgets.rb'
8
9module Tk
10  module Iwidgets
11    class Panedwindow < Tk::Itk::Widget
12    end
13  end
14end
15
16class Tk::Iwidgets::Panedwindow
17  TkCommandNames = ['::iwidgets::panedwindow'.freeze].freeze
18  WidgetClassName = 'Panedwindow'.freeze
19  WidgetClassNames[WidgetClassName] ||= self
20
21  ####################################
22
23  include TkItemConfigMethod
24
25  def __item_cget_cmd(id)
26    [self.path, 'panecget', id]
27  end
28  private :__item_cget_cmd
29
30  def __item_config_cmd(id)
31    [self.path, 'paneconfigure', id]
32  end
33  private :__item_config_cmd
34
35  def tagid(tagOrId)
36    if tagOrId.kind_of?(Tk::Itk::Component)
37      tagOrId.name
38    else
39      #_get_eval_string(tagOrId)
40      tagOrId
41    end
42  end
43
44  alias panecget_tkstring itemcget_tkstring
45  alias panecget itemcget
46  alias panecget_strict itemcget_strict
47  alias paneconfigure itemconfigure
48  alias paneconfiginfo itemconfiginfo
49  alias current_paneconfiginfo current_itemconfiginfo
50
51  private :itemcget_tkstring, :itemcget, :itemcget_strict
52  private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
53
54  ####################################
55
56  def __boolval_optkeys
57    super() << 'showhandle'
58  end
59  private :__boolval_optkeys
60
61  def add(tag=nil, keys={})
62    if tag.kind_of?(Hash)
63      keys = tag
64      tag = nil
65    end
66    if tag
67      tag = Tk::Itk::Component.new(self, tagid(tag))
68    else
69      tag = Tk::Itk::Component.new(self)
70    end
71    window(tk_call(@path, 'add', tagid(tag), *hash_kv(keys)))
72    tag
73  end
74
75  def child_site_list
76    list(tk_call(@path, 'childsite'))
77  end
78
79  def child_site(idx)
80    window(tk_call(@path, 'childsite', index(idx)))
81  end
82
83  def delete(idx)
84    tk_call(@path, 'delete', index(idx))
85    self
86  end
87
88  def fraction(*percentages)
89    tk_call(@path, 'fraction', *percentages)
90    self
91  end
92
93  def hide(idx)
94    tk_call(@path, 'hide', index(idx))
95    self
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    window(tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)))
113    tag
114  end
115
116  def invoke(idx=nil)
117    if idx
118      tk_call(@path, 'invoke', index(idx))
119    else
120      tk_call(@path, 'invoke')
121    end
122    self
123  end
124
125  def reset
126    tk_call(@path, 'reset')
127    self
128  end
129
130  def show(idx)
131    tk_call(@path, 'show', index(idx))
132    self
133  end
134end
135