~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to ext/tk/lib/tkextlib/bwidget/buttonbox.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#  tkextlib/bwidget/buttonbox.rb
 
3
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
 
4
#
 
5
 
 
6
require 'tk'
 
7
require 'tkextlib/bwidget.rb'
 
8
require 'tkextlib/bwidget/button'
 
9
 
 
10
module Tk
 
11
  module BWidget
 
12
    class ButtonBox < TkWindow
 
13
    end
 
14
  end
 
15
end
 
16
 
 
17
class Tk::BWidget::ButtonBox
 
18
  TkCommandNames = ['ButtonBox'.freeze].freeze
 
19
  WidgetClassName = 'ButtonBox'.freeze
 
20
  WidgetClassNames[WidgetClassName] = self
 
21
 
 
22
  include TkItemConfigMethod
 
23
 
 
24
  def __boolval_optkeys
 
25
    super() << 'homogeneous'
 
26
  end
 
27
  private :__boolval_optkeys
 
28
 
 
29
  def tagid(tagOrId)
 
30
    if tagOrId.kind_of?(Tk::BWidget::Button)
 
31
      name = tagOrId[:name]
 
32
      return index(name) unless name.empty?
 
33
    end
 
34
    if tagOrId.kind_of?(TkButton)
 
35
      return index(tagOrId[:text])
 
36
    end
 
37
    # index(tagOrId.to_s)
 
38
    index(_get_eval_string(tagOrId))
 
39
  end
 
40
 
 
41
  def add(keys={}, &b)
 
42
    win = window(tk_send('add', *hash_kv(keys)))
 
43
    win.instance_eval(&b) if b
 
44
    win
 
45
  end
 
46
 
 
47
  def delete(idx)
 
48
    tk_send('delete', tagid(idx))
 
49
    self
 
50
  end
 
51
 
 
52
  def index(idx)
 
53
    if idx.kind_of?(Tk::BWidget::Button)
 
54
      name = idx[:name]
 
55
      idx = name unless name.empty?
 
56
    end
 
57
    if idx.kind_of?(TkButton)
 
58
      idx = idx[:text]
 
59
    end
 
60
    number(tk_send('index', idx.to_s))
 
61
  end
 
62
 
 
63
  def insert(idx, keys={}, &b)
 
64
    win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
 
65
    win.instance_eval(&b) if b
 
66
    win
 
67
  end
 
68
 
 
69
  def invoke(idx)
 
70
    tk_send('invoke', tagid(idx))
 
71
    self
 
72
  end
 
73
 
 
74
  def set_focus(idx)
 
75
    tk_send('setfocus', tagid(idx))
 
76
    self
 
77
  end
 
78
end