2016-08-14 00:01:08 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
import RxSwift
|
|
|
|
|
2016-09-27 19:02:05 +03:00
|
|
|
class PrefPane: ViewComponent {
|
2016-09-11 15:28:56 +03:00
|
|
|
|
2016-08-14 00:01:08 +03:00
|
|
|
// Return true to place this to the upper left corner when the scroll view is bigger than this view.
|
2016-09-25 18:50:33 +03:00
|
|
|
override var isFlipped: Bool {
|
2016-08-14 00:01:08 +03:00
|
|
|
return true
|
|
|
|
}
|
2016-09-24 17:35:27 +03:00
|
|
|
|
|
|
|
var displayName: String {
|
|
|
|
preconditionFailure("Please override")
|
|
|
|
}
|
2016-08-25 10:27:59 +03:00
|
|
|
|
|
|
|
var pinToContainer: Bool {
|
|
|
|
return false
|
|
|
|
}
|
2016-08-14 00:01:08 +03:00
|
|
|
|
2016-09-13 09:32:58 +03:00
|
|
|
func windowWillClose() {
|
2016-09-27 19:02:05 +03:00
|
|
|
// noop, override
|
2016-09-13 09:32:58 +03:00
|
|
|
}
|
2016-08-14 00:01:08 +03:00
|
|
|
}
|
2016-08-14 16:01:28 +03:00
|
|
|
|
|
|
|
// MARK: - Control Utils
|
|
|
|
extension PrefPane {
|
|
|
|
|
2016-09-25 18:50:33 +03:00
|
|
|
func paneTitleTextField(title: String) -> NSTextField {
|
2016-08-14 16:01:28 +03:00
|
|
|
let field = defaultTitleTextField()
|
2016-09-25 18:50:33 +03:00
|
|
|
field.font = NSFont.boldSystemFont(ofSize: 16)
|
|
|
|
field.alignment = .left;
|
2016-08-14 16:01:28 +03:00
|
|
|
field.stringValue = title
|
|
|
|
return field
|
|
|
|
}
|
|
|
|
|
2016-09-25 18:50:33 +03:00
|
|
|
func titleTextField(title: String) -> NSTextField {
|
2016-08-14 16:01:28 +03:00
|
|
|
let field = defaultTitleTextField()
|
2016-09-25 18:50:33 +03:00
|
|
|
field.alignment = .right;
|
2016-08-14 16:01:28 +03:00
|
|
|
field.stringValue = title
|
|
|
|
return field
|
|
|
|
}
|
|
|
|
|
2016-09-25 18:50:33 +03:00
|
|
|
func infoTextField(text: String) -> NSTextField {
|
2016-09-10 22:46:43 +03:00
|
|
|
let field = NSTextField(forAutoLayout: ())
|
2016-09-25 18:50:33 +03:00
|
|
|
field.font = NSFont.systemFont(ofSize: NSFont.smallSystemFontSize())
|
|
|
|
field.textColor = NSColor.gray
|
|
|
|
field.backgroundColor = NSColor.clear
|
|
|
|
field.isEditable = false
|
|
|
|
field.isBordered = false
|
2016-09-10 22:46:43 +03:00
|
|
|
|
|
|
|
// both are needed, otherwise hyperlink won't accept mousedown
|
2016-09-25 18:50:33 +03:00
|
|
|
field.isSelectable = true
|
2016-09-10 22:46:43 +03:00
|
|
|
field.allowsEditingTextAttributes = true
|
|
|
|
|
|
|
|
field.stringValue = text
|
|
|
|
|
|
|
|
return field
|
|
|
|
}
|
|
|
|
|
2016-09-25 18:50:33 +03:00
|
|
|
func configureCheckbox(button: NSButton, title: String, action: Selector) {
|
2016-08-14 16:01:28 +03:00
|
|
|
button.title = title
|
2016-09-25 18:50:33 +03:00
|
|
|
button.setButtonType(.switch)
|
2016-08-14 16:01:28 +03:00
|
|
|
button.target = self
|
|
|
|
button.action = action
|
|
|
|
}
|
|
|
|
|
2016-09-25 18:50:33 +03:00
|
|
|
fileprivate func defaultTitleTextField() -> NSTextField {
|
2016-08-14 16:01:28 +03:00
|
|
|
let field = NSTextField(forAutoLayout: ())
|
2016-09-25 18:50:33 +03:00
|
|
|
field.backgroundColor = NSColor.clear;
|
|
|
|
field.isEditable = false;
|
|
|
|
field.isBordered = false;
|
2016-08-14 16:01:28 +03:00
|
|
|
return field
|
|
|
|
}
|
|
|
|
}
|