Sha256: d91243eee61f5ff891d0b7f16bc457f6cf8868e2bbb20c2264c177838675da2d

Contents?: true

Size: 1.25 KB

Versions: 24

Compression:

Stored size: 1.25 KB

Contents

=begin
Example:

    # fonts
    :system.nsfont => NSFont.systemFontOfSize(NSFont.systemFontSize)
    :label.nsfont => NSFont.systemFontOfSize(NSFont.labelFontSize)

You can extend the defaults by adding entries:

    Symbol.nsfontsize[:big] = 40

    :big.nsfont => NSFont

=end
class Symbol

  def nsfont(size=nil)
    size ||= NSFont.systemFontSize
    # system fonts
    if Symbol.nsfont.has_key? self
      font = SugarCube.look_in(self, Symbol.nsfont)
      if size.is_a?(Symbol)
        size = size.nsfontsize
      end

      if font.is_a?(Symbol)
        return NSFont.send(font, size)
      else
        return font.nsfont(size)
      end
    else
      if size.is_a?(Symbol)
          size = size.nsfontsize
      end
      return NSFont.systemFontOfSize(size)
    end
  end

  def nsfontsize
    size = SugarCube.look_in(self, Symbol.nsfontsize)
    if size.is_a?(Symbol)
      return NSFont.send(size)
    end
    return size.to_f
  end

  class << self
    attr :nsfont
    attr :nsfontsize
  end

  @nsfont = {
    system: :"systemFontOfSize:",
    bold:   :"boldSystemFontOfSize:",
    monospace: 'Courier New',
  }

  @nsfontsize = {
    label:  :labelFontSize,
    button: :buttonFontSize,
    small:  :smallSystemFontSize,
    system: :systemFontSize,
  }


end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
sugarcube-3.3.6 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.3.5 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.3.4 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.3.3 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.3.2 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.3.1 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.3.0 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.2.0 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.1.1 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.1.0 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.8 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.7 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.6 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.5 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.4 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.3 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.2 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.1 lib/osx/sugarcube-ui/symbol.rb
sugarcube-3.0.0 lib/osx/sugarcube-appkit/symbol.rb
sugarcube-2.12.3 lib/osx/sugarcube-appkit/symbol.rb