mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-22 21:21:32 +03:00
65 lines
1.6 KiB
Swift
65 lines
1.6 KiB
Swift
/**
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
* See LICENSE
|
|
*/
|
|
|
|
import Cocoa
|
|
import PureLayout
|
|
|
|
class ImageAndTextTableCell: NSView {
|
|
|
|
var text: NSAttributedString {
|
|
get {
|
|
return self.textField.attributedStringValue
|
|
}
|
|
|
|
set {
|
|
self.textField.attributedStringValue = newValue
|
|
}
|
|
}
|
|
|
|
var image: NSImage? {
|
|
get {
|
|
return self.imageView.image
|
|
}
|
|
|
|
set {
|
|
self.imageView.image = newValue
|
|
}
|
|
}
|
|
|
|
fileprivate let textField: NSTextField = NSTextField(forAutoLayout: ())
|
|
fileprivate let imageView: NSImageView = NSImageView(forAutoLayout: ())
|
|
|
|
init(withIdentifier identifier: String) {
|
|
super.init(frame: CGRect.zero)
|
|
|
|
self.identifier = identifier
|
|
|
|
let textField = self.textField
|
|
textField.isBordered = false
|
|
textField.isEditable = false
|
|
textField.lineBreakMode = .byTruncatingTail
|
|
textField.drawsBackground = false
|
|
|
|
let imageView = self.imageView
|
|
|
|
self.addSubview(textField)
|
|
self.addSubview(imageView)
|
|
|
|
imageView.autoPinEdge(toSuperviewEdge: .top, withInset: 2)
|
|
imageView.autoPinEdge(toSuperviewEdge: .left, withInset: 2)
|
|
imageView.autoSetDimension(.width, toSize: 16)
|
|
imageView.autoSetDimension(.height, toSize: 16)
|
|
|
|
textField.autoPinEdge(toSuperviewEdge: .top, withInset: 2)
|
|
textField.autoPinEdge(toSuperviewEdge: .right, withInset: 2)
|
|
textField.autoPinEdge(toSuperviewEdge: .bottom, withInset: 2)
|
|
textField.autoPinEdge(.left, to: .right, of: imageView, withOffset: 4)
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|