summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
blob: 6adb53d9418ae14a741708526e2e597065cb407e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#
#  tkextlib/iwidgets/messagebox.rb
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#

require 'tk'
require 'tkextlib/iwidgets.rb'

module Tk
  module Iwidgets
    class Messagebox < Tk::Iwidgets::Scrolledwidget
    end
  end
end

class Tk::Iwidgets::Messagebox
  TkCommandNames = ['::iwidgets::messagebox'.freeze].freeze
  WidgetClassName = 'Messagebox'.freeze
  WidgetClassNames[WidgetClassName] ||= self

  ####################################

  include TkItemConfigMethod

  def __item_cget_cmd(id)
    [self.path, 'type', 'cget', id]
  end
  private :__item_cget_cmd

  def __item_config_cmd(id)
    [self.path, 'type', 'configure', id]
  end
  private :__item_config_cmd

  def tagid(tagOrId)
    if tagOrId.kind_of?(Tk::Itk::Component)
      tagOrId.name
    else
      #_get_eval_string(tagOrId)
      tagOrId
    end
  end

  def __item_boolval_optkeys(id)
    super(id) << 'bell' << 'show'
  end
  private :__item_boolval_optkeys

  alias typecget_tkstring itemcget_tkstring
  alias typecget itemcget
  alias typecget_strict itemcget_strict
  alias typeconfigure itemconfigure
  alias typeconfiginfo itemconfiginfo
  alias current_typeconfiginfo current_itemconfiginfo

  private :itemcget_tkstring, :itemcget, :itemcget_strict
  private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo

  ####################################

  def __strval_optkeys
    super() << 'filename' << 'savedir'
  end
  private :__strval_optkeys

  def type_add(tag=nil, keys={})
    if tag.kind_of?(Hash)
      keys = tag
      tag = nil
    end
    unless tag
      tag = Tk::Itk::Component.new(self)
    end
    tk_call(@path, 'type', 'add', tagid(tag), *hash_kv(keys))
    tag
  end

  def clear
    tk_call(@path, 'clear')
    self
  end

  def export(file)
    tk_call(@path, 'export', file)
    self
  end

  def issue(string, type=None, *args)
    tk_call(@path, 'issue', string, tagid(type), *args)
    self
  end

end