Module: TkFont::Fontchooser (Ruby 2.3.4)

In Files

  • tk/lib/tk/fontchooser.rb

Class/Module Index [+]

Quicksearch

TkFont::Fontchooser

Public Class Methods

[](slot)
 
               # File tk/lib/tk/fontchooser.rb, line 122
def [](slot)
  cget slot
end
            
[]=(slot, val)
 
               # File tk/lib/tk/fontchooser.rb, line 126
def []=(slot, val)
  configure slot, val
  val
end
            
cget(slot)
 
               # File tk/lib/tk/fontchooser.rb, line 118
def cget(slot)
  configinfo slot
end
            
command(cmd=nil, &b)
 
               # File tk/lib/tk/fontchooser.rb, line 108
def command(cmd=nil, &b)
  if cmd
    configure_cmd('command', cmd)
  elsif b
    configure_cmd('command', Proc.new(&b))
  else
    cget('command')
  end
end
            
configinfo(option=nil)
 
               # File tk/lib/tk/fontchooser.rb, line 61
def configinfo(option=nil)
  if !option && TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
    lst = tk_split_simplelist(tk_call('tk', 'fontchooser', 'configure'))
    ret = []
    TkComm.slice_ary(lst, 2){|k, v|
      k = k[1..-1]
      ret << [k, __configinfo_value(k, v)]
    }
    ret
  else
    current_configinfo(option)
  end
end
            
configure(option, value=None)
 
               # File tk/lib/tk/fontchooser.rb, line 92
def configure(option, value=None)
  if option.kind_of? Hash
    tk_call('tk', 'fontchooser', 'configure',
            *hash_kv(_symbolkey2str(option)))
  else
    opt = option.to_s
    fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.empty?
    tk_call('tk', 'fontchooser', 'configure', "-#{opt}", value)
  end
  self
end
            
configure_cmd(slot, value)
 
               # File tk/lib/tk/fontchooser.rb, line 104
def configure_cmd(slot, value)
  configure(slot, install_cmd(value))
end
            
current_configinfo(option=nil)
 
               # File tk/lib/tk/fontchooser.rb, line 75
def current_configinfo(option=nil)
  if option
    opt = option.to_s
    fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.empty?
    __configinfo_value(option.to_s, tk_call('tk','fontchooser',
                                            'configure',"-#{opt}"))
  else
    lst = tk_split_simplelist(tk_call('tk', 'fontchooser', 'configure'))
    ret = {}
    TkComm.slice_ary(lst, 2){|k, v|
      k = k[1..-1]
      ret[k] = __configinfo_value(k, v)
    }
    ret
  end
end
            
hide()
 
               # File tk/lib/tk/fontchooser.rb, line 136
def hide
  tk_call('tk', 'fontchooser', 'hide')
  self
end
            
method_missing(id, *args)
 
               # File tk/lib/tk/fontchooser.rb, line 17
def method_missing(id, *args)
  name = id.id2name
  case args.length
  when 1
    if name[-1] == ?=
      configure name[0..-2], args[0]
      args[0]
    else
      configure name, args[0]
      self
    end
  when 0
    begin
      cget(name)
    rescue
      super(id, *args)
    end
  else
    super(id, *args)
  end
end
            
set_for(target, title="Font")
 
               # File tk/lib/tk/fontchooser.rb, line 146
def set_for(target, title="Font")
  if target.kind_of? TkFont
    configs = {
      :font=>target.actual_hash,
      :command=>proc{|fnt, *args|
        target.configure(TkFont.actual_hash(fnt))
      }
    }
  elsif target.kind_of? Hash
    # key=>value list or OptionObj
    fnt = target[:font] rescue ''
    fnt = fnt.actual_hash if fnt.kind_of?(TkFont)
    configs = {
      :font => fnt,
      :command=>proc{|fnt, *args|
        target[:font] = TkFont.actual_hash(fnt)
      }
    }
  else
    configs = {
      :font=>target.cget_tkstring(:font),
      :command=>proc{|fnt, *args|
        target.font = TkFont.actual_hash_displayof(fnt, target)
      }
    }
  end

  configs[:title] = title if title
  configure(configs)
  target
end
            
show()
 
               # File tk/lib/tk/fontchooser.rb, line 131
def show
  tk_call('tk', 'fontchooser', 'show')
  self
end
            
toggle()
 
               # File tk/lib/tk/fontchooser.rb, line 141
def toggle
  cget(:visible) ?  hide: show
  self
end
            
unset()
 
               # File tk/lib/tk/fontchooser.rb, line 178
def unset
  configure(:command, nil)
end