2
# tkextlib/bwidget/buttonbox.rb
3
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
7
require 'tkextlib/bwidget.rb'
8
require 'tkextlib/bwidget/button'
12
class ButtonBox < TkWindow
17
class Tk::BWidget::ButtonBox
18
TkCommandNames = ['ButtonBox'.freeze].freeze
19
WidgetClassName = 'ButtonBox'.freeze
20
WidgetClassNames[WidgetClassName] = self
22
include TkItemConfigMethod
25
super() << 'homogeneous'
27
private :__boolval_optkeys
30
if tagOrId.kind_of?(Tk::BWidget::Button)
32
return index(name) unless name.empty?
34
if tagOrId.kind_of?(TkButton)
35
return index(tagOrId[:text])
38
index(_get_eval_string(tagOrId))
42
win = window(tk_send('add', *hash_kv(keys)))
43
win.instance_eval(&b) if b
48
tk_send('delete', tagid(idx))
53
if idx.kind_of?(Tk::BWidget::Button)
55
idx = name unless name.empty?
57
if idx.kind_of?(TkButton)
60
number(tk_send('index', idx.to_s))
63
def insert(idx, keys={}, &b)
64
win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
65
win.instance_eval(&b) if b
70
tk_send('invoke', tagid(idx))
75
tk_send('setfocus', tagid(idx))