summaryrefslogtreecommitdiff
path: root/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb
blob: 46a4b9d8b674942c3d420bb5304b8d9abe9195d2 (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
#
#  tkextlib/tcllib/statusbar.rb
#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
#
#   * Part of tcllib extension
#   * statusbar widget
#

require 'tk'
require 'tkextlib/tcllib.rb'

# TkPackage.require('widget::statusbar', '1.2')
TkPackage.require('widget::statusbar')

module Tk::Tcllib
  module Widget
    class Statusbar < Tk::Tile::TFrame
      PACKAGE_NAME = 'widget::statusbar'.freeze
      def self.package_name
        PACKAGE_NAME
      end

      def self.package_version
        begin
          TkPackage.require('widget::statusbar')
        rescue
          ''
        end
      end
    end
  end
end

class Tk::Tcllib::Widget::Statusbar
  TkCommandNames = ['::widget::statusbar'.freeze].freeze

  def __boolval_optkeys
    super() << 'separator' << 'resize' << 'resizeseparator'
  end
  private :__boolval_optkeys

  def create_self(keys)
    if keys and keys != None
      tk_call_without_enc(self.class::TkCommandNames[0], @path,
                          *hash_kv(keys, true))
    else
      tk_call_without_enc(self.class::TkCommandNames[0], @path)
    end
  end
  private :create_self

  def getframe
    window(tk_send_without_enc('getframe'))
  end
  alias get_frame getframe

  def add(w, keys={})
    window(tk_send_without_enc('setwidget', *(hash_kv(keys))))
  end

  def remove(*wins)
    tk_send_without_enc('remove', *wins)
    self
  end

  def remove_with_destroy(*wins)
    tk_send_without_enc('remove', '-destroy', *wins)
    self
  end

  def delete(*wins)
    tk_send_without_enc('delete', *wins)
    self
  end

  def items(pat=None)
    tk_split_list(tk_send('items', pat))
  end
end