Class | Tk::BLT::Watch
In: | tk/lib/tkextlib/blt/watch.rb
Parent: | TkObject

### Methods

activate cget configinfo deactivate delete info names new

### Constants

TkCommandNames | = | ['::blt::watch'.freeze].freeze
WATCH_ID_TBL | = | TkCore::INTERP.create_table
BLT_WATCH_ID | = | ['blt_watch_id'.freeze, '00000'.taint].freeze

### Public Class methods

names(state = None)

[Source]

    # File tk/lib/tkextlib/blt/watch.rb, line 18
        def self.names(state = None)
          tk_split_list(tk_call('::blt::watch', 'names', state)).collect{|name|
            WATCH_ID_TBL[name] || name
          }
        end

new(name = nil, keys = {})

[Source]

    # File tk/lib/tkextlib/blt/watch.rb, line 39
        def initialize(name = nil, keys = {})
          if name.kind_of?(Hash)
            keys = name
            name = nil
          end

          if name
            @id = name.to_s
          else
            @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
            BLT_WATCH_ID[1].succ!
          end

          @path = @id

          WATCH_ID_TBL[@id] = self
          tk_call('::blt::watch', 'create', @id, *hash_kv(keys))
        end

### Public Instance methods

activate()

[Source]

    # File tk/lib/tkextlib/blt/watch.rb, line 58
        def activate
          tk_call('::blt::watch', 'activate', @id)
          self
        end

cget(key)

[Source]

    # File tk/lib/tkextlib/blt/watch.rb, line 133
        def cget(key)
          key = key.to_s
          begin
            info.assoc(key)[1]
          rescue
            fail ArgumentError, "unknown option '#{key}'"
          end
        end

configinfo(slot = nil)

[Source]

    # File tk/lib/tkextlib/blt/watch.rb, line 116
        def configinfo(slot = nil)
          if slot
            slot = slot.to_s
            v = cget(slot)
            if TkComm::GET_CONFIGINFO_AS_ARRAY
              [slot, v]
            else
              {slot=>v}
            end
          else
            if TkComm::GET_CONFIGINFO_AS_ARRAY
              info
            else
              Hash[*(info.flatten)]
            end
          end
        end

deactivate()

[Source]

    # File tk/lib/tkextlib/blt/watch.rb, line 62
        def deactivate
          tk_call('::blt::watch', 'deactivate', @id)
          self
        end

delete()

[Source]

    # File tk/lib/tkextlib/blt/watch.rb, line 66
        def delete
          tk_call('::blt::watch', 'delete', @id)
          self
        end

info()

[Source]

    # File tk/lib/tkextlib/blt/watch.rb, line 70
        def info
          ret = []
          lst = tk_split_simplelist(tk_call('::blt::watch', 'info', @id))
          until lst.empty?
            k, v, *lst = lst
            k = k[1..-1]
            case k
            when /^(#{__strval_optkeys.join('|')})$/
              # do nothing

            when /^(#{__numval_optkeys.join('|')})$/
              begin
                v = number(v)
              rescue
                v = nil
              end

            when /^(#{__numstrval_optkeys.join('|')})$/
              v = num_or_str(v)

            when /^(#{__boolval_optkeys.join('|')})$/
              begin
                v = bool(v)
              rescue
                v = nil
              end

            when /^(#{__listval_optkeys.join('|')})$/
              v = simplelist(v)

            when /^(#{__numlistval_optkeys.join('|')})$/
              v = list(v)

            else
              if v.index('{')
                v = tk_split_list(v)
              else
                v = tk_tcl2ruby(v)
              end
            end

            ret << [k, v]
          end

          ret
        end

[Validate]