Sha256: 6ff7ca9243b303a12820b529f468181499fe11105afd0832d6933c37ee7a7150
Contents?: true
Size: 1.04 KB
Versions: 34
Compression:
Stored size: 1.04 KB
Contents
class NSString # @return [NSImage] def nsimage NSImage.imageNamed(self).tap do |retval| NSLog("No image named #{self}") unless retval end end # @return [NSFont] def nsfont(size=nil) size ||= NSFont.systemFontSize NSFont.fontWithName(self, size: size) end # @param font [NSFont] Optional, defaults to NSFont.systemFontOfSize(NSFont.systemFontSize) # @return [NSLabel] def nslabel(font=nil) font ||= :system.nsfont(NSFont.labelFontSize) size = self.sizeWithAttributes({ NSFontAttributeName => font }) label = NSTextField.alloc.initWithFrame([[0, 0], size]) label.bezeled = false label.drawsBackground = false label.editable = false label.selectable = false label.stringValue = self label.font = font return label end # @return [NSImageView] def nsimageview image_view = NSImageView.alloc.init image_view.image = self.nsimage frame = image_view.frame frame.size = image_view.intrinsicContentSize image_view.frame = frame return image_view end end
Version data entries
34 entries across 34 versions & 1 rubygems