aboutsummaryrefslogtreecommitdiffstats
path: root/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-06 09:42:12 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-07-06 09:42:12 +0000
commitd8465ff9abf63545262b7d8f88b069522ae82823 (patch)
treeea1597d41d1de11febd12cc38b71838e0691bfcb /ext/tk/lib/tkextlib/bwidget/buttonbox.rb
parent3d8fa5556164f3aa2f6f1733ffe4a96fc4f33ed8 (diff)
downloadruby-d8465ff9abf63545262b7d8f88b069522ae82823.tar.gz
* ext/tk/lib : improve framework of developping Tcl/Tk extension wrappers
* BWidget extension support on Ruby/Tk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib/bwidget/buttonbox.rb')
-rw-r--r--ext/tk/lib/tkextlib/bwidget/buttonbox.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
new file mode 100644
index 0000000000..477de8a61f
--- /dev/null
+++ b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/bwidget/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/button'
+
+module Tk
+ module BWidget
+ class ButtonBox < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ButtonBox
+ TkCommandNames = ['ButtonBox'.freeze].freeze
+ WidgetClassName = 'ButtonBox'.freeze
+ WidgetClassNames[WidgetClassName] = self
+
+ include TkItemConfigMethod
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::BWidget::Button)
+ name = tagOrId[:name]
+ return index(name) unless name.empty?
+ end
+ if tagOrId.kind_of?(TkButton)
+ return index(tagOrId[:text])
+ end
+ # index(tagOrId.to_s)
+ index(_get_eval_string(tagOrId))
+ end
+
+ def add(keys={}, &b)
+ win = window(tk_send('add', *hash_kv(keys)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def delete(idx)
+ tk_send('delete', tagid(idx))
+ self
+ end
+
+ def index(idx)
+ if idx.kind_of?(Tk::BWidget::Button)
+ name = idx[:name]
+ idx = name unless name.empty?
+ end
+ if idx.kind_of?(TkButton)
+ idx = idx[:text]
+ end
+ number(tk_send('index', idx.to_s))
+ end
+
+ def insert(idx, keys={}, &b)
+ win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
+ win.instance_eval(&b) if b
+ win
+ end
+
+ def invoke(idx)
+ tk_send('invoke', tagid(idx))
+ self
+ end
+
+ def set_focus(idx)
+ tk_send('setfocus', tagid(idx))
+ self
+ end
+end