TkObject (Class)

In: tk/tkutil.c
tk/lib/tk.rb
Parent: TkKernel

Methods

Included Modules

Public Instance methods

[Source]

# File tk/lib/tk.rb, line 2035
  def [](id)
    cget(id)
  end

[Source]

# File tk/lib/tk.rb, line 2039
  def []=(id, val)
    configure(id, val)
    val
  end

[Source]

# File tk/lib/tk.rb, line 2044
  def cget(slot)
    case slot.to_s
    when 'text', 'label', 'show', 'data', 'file'
      #tk_call(path, 'cget', "-#{slot}")

      _fromUTF8(tk_call_without_enc(path, 'cget', "-#{slot}"))
    when 'font', 'kanjifont'
      #fnt = tk_tcl2ruby(tk_call(path, 'cget', "-#{slot}"))

      #fnt = tk_tcl2ruby(tk_call(path, 'cget', "-font"))

      fnt = tk_tcl2ruby(tk_call_without_enc(path, 'cget', "-font"), true)
      unless fnt.kind_of?(TkFont)
        fnt = fontobj(fnt)
      end
      if slot == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
        # obsolete; just for compatibility

        fnt.kanji_font
      else
        fnt
      end
    else
      tk_tcl2ruby(tk_call_without_enc(path, 'cget', "-#{slot}"), true)
    end
  end

[Source]

# File tk/lib/tk.rb, line 2099
  def configinfo(slot = nil)
    if TkComm::GET_CONFIGINFO_AS_ARRAY
      if slot == 'font' || slot == :font || 
          slot == 'kanjifont' || slot == :kanjifont
        conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure', "-#{slot}")))
        conf[0] = conf[0][1..-1]
        conf[4] = fontobj(conf[4])
        conf
      else
        if slot
          case slot.to_s
          when 'text', 'label', 'show', 'data', 'file'
            conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure', "-#{slot}")))
          else
            conf = tk_split_list(_fromUTF8(tk_send_without_enc('configure', "-#{slot}")))
          end
          conf[0] = conf[0][1..-1]
          conf
        else
          ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure'))).collect{|conflist|
            conf = tk_split_simplelist(conflist)
            conf[0] = conf[0][1..-1]
            case conf[0]
            when 'text', 'label', 'show', 'data', 'file'
            else
              if conf[3]
                if conf[3].index('{')
                  conf[3] = tk_split_list(conf[3]) 
                else
                  conf[3] = tk_tcl2ruby(conf[3]) 
                end
              end
              if conf[4]
                if conf[4].index('{')
                  conf[4] = tk_split_list(conf[4]) 
                else
                  conf[4] = tk_tcl2ruby(conf[4]) 
                end
              end
            end
            conf[1] = conf[1][1..-1] if conf.size == 2 # alias info

            conf
          }
          fontconf = ret.assoc('font')
          if fontconf
            ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
            fontconf[4] = fontobj(fontconf[4])
            ret.push(fontconf)
          else
            ret
          end
        end
      end
    else # ! TkComm::GET_CONFIGINFO_AS_ARRAY

      if slot == 'font' || slot == :font || 
          slot == 'kanjifont' || slot == :kanjifont
        conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure', "-#{slot}")))
        key = conf.shift[1..-1]
        conf[3] = fontobj(conf[3])
        { key => conf }
      else
        if slot
          case slot.to_s
          when 'text', 'label', 'show', 'data', 'file'
            conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure', "-#{slot}")))
          else
            conf = tk_split_list(_fromUTF8(tk_send_without_enc('configure', "-#{slot}")))
          end
          key = conf.shift[1..-1]
          { key => conf }
        else
          ret = {}
          tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure'))).each{|conflist|
            conf = tk_split_simplelist(conflist)
            key = conf.shift[1..-1]
            case key
            when 'text', 'label', 'show', 'data', 'file'
            else
              if conf[2]
                if conf[2].index('{')
                  conf[2] = tk_split_list(conf[2]) 
                else
                  conf[2] = tk_tcl2ruby(conf[2]) 
                end
              end
              if conf[3]
                if conf[3].index('{')
                  conf[3] = tk_split_list(conf[3])
                else
                  conf[3] = tk_tcl2ruby(conf[3]) 
                end
              end
            end
            if conf.size == 1
              ret[key] = conf[0][1..-1]  # alias info

            else
              ret[key] = conf
            end
          }
          fontconf = ret['font']
          if fontconf
            ret.delete('font')
            ret.delete('kanjifont')
            fontconf[3] = fontobj(fontconf[3])
            ret['font'] = fontconf
          end
          ret
        end
      end
    end
  end

[Source]

# File tk/lib/tk.rb, line 2067
  def configure(slot, value=None)
    if slot.kind_of? Hash
      if (slot['font'] || slot[:font] || 
          slot['kanjifont'] || slot[:kanjifont] || 
          slot['latinfont'] || slot[:latinfont] || 
          slot['asciifont'] || slot[:asciifont] )
        font_configure(slot)
      elsif slot.size > 0
        tk_call(path, 'configure', *hash_kv(slot))
      end

    else
      if (slot == 'font' || slot == :font || 
          slot == 'kanjifont' || slot == :kanjifont || 
          slot == 'latinfont' || slot == :latinfont || 
          slot == 'asciifont' || slot == :asciifont )
        if value == None
          fontobj
        else
          font_configure({slot=>value})
        end
      else
        tk_call(path, 'configure', "-#{slot}", value)
      end
    end
    self
  end

[Source]

# File tk/lib/tk.rb, line 2095
  def configure_cmd(slot, value)
    configure(slot, install_cmd(value))
  end

[Source]

# File tk/lib/tk.rb, line 2211
  def current_configinfo(slot = nil)
    if TkComm::GET_CONFIGINFO_AS_ARRAY
      if slot
        conf = configinfo(slot)
        {conf[0] => conf[4]}
      else
        ret = {}
        configinfo().each{|conf|
          ret[conf[0]] = conf[4] if conf.size > 2
        }
        ret
      end
    else # ! TkComm::GET_CONFIGINFO_AS_ARRAY

      ret = {}
      configinfo(slot).each{|key, conf| 
        ret[key] = conf[-1] if conf.kind_of?(Array)
      }
      ret
    end
  end

[Source]

# File tk/lib/tk.rb, line 2254
  def destroy
    tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if @var_id
  end

[Source]

# File tk/lib/tk.rb, line 1994
  def epath
    @path
  end

[Source]

# File tk/lib/tk.rb, line 2232
  def event_generate(context, keys=nil)
    if keys
      #tk_call('event', 'generate', path, 

      #       "<#{tk_event_sequence(context)}>", *hash_kv(keys))

      tk_call_without_enc('event', 'generate', path, 
                          "<#{tk_event_sequence(context)}>", 
                          *hash_kv(keys, true))
    else
      #tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>")

      tk_call_without_enc('event', 'generate', path, 
                          "<#{tk_event_sequence(context)}>")
    end
  end

[Source]

# File tk/lib/tk.rb, line 2013
  def method_missing(id, *args)
    name = id.id2name
    case args.length
    when 1
      if name[-1] == ?=
        configure name[0..-2], args[0]
      else
        configure name, args[0]
      end
    when 0
      begin
        cget(name)
      rescue
        fail NameError, 
             "undefined local variable or method `#{name}' for #{self.to_s}", 
             error_at
      end
    else
      fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
    end
  end

[Source]

# File tk/lib/tk.rb, line 1990
  def path
    @path
  end

/

[Source]

/*************************************/

static VALUE
tkobj_path(self)
    VALUE self;
{
    return rb_ivar_get(self, ID_path);
}

[Source]

# File tk/lib/tk.rb, line 1998
  def to_eval
    @path
  end

[Validate]