1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 15:25:14 +03:00
vimr/VimR/PrefPane.swift

78 lines
1.8 KiB
Swift
Raw Normal View History

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
import RxSwift
class PrefPane: StandardViewComponent {
2016-09-11 15:28:56 +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 {
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
}
func windowWillClose() {
2016-09-27 19:02:05 +03:00
// noop, override
}
}
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
}
func infoTextField(markdown: String) -> NSTextField {
2016-09-10 22:46:43 +03:00
let field = NSTextField(forAutoLayout: ())
2016-09-25 18:50:33 +03:00
field.backgroundColor = NSColor.clear
field.isEditable = false
field.isBordered = false
field.usesSingleLineMode = 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.attributedStringValue = NSAttributedString.infoLabel(markdown: markdown)
2016-09-10 22:46:43 +03:00
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
}
}