1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-28 11:35:35 +03:00
vimr/VimR/PrefPane.swift
Tae Won Ha 738635ca51
GH-339 Make the preview component roughly work
- re-model the view component hierarchy
2016-12-21 07:33:39 +01:00

78 lines
1.8 KiB
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
import RxSwift
class PrefPane: StandardViewComponent {
// Return true to place this to the upper left corner when the scroll view is bigger than this view.
override var isFlipped: Bool {
return true
}
var displayName: String {
preconditionFailure("Please override")
}
var pinToContainer: Bool {
return false
}
func windowWillClose() {
// noop, override
}
}
// MARK: - Control Utils
extension PrefPane {
func paneTitleTextField(title: String) -> NSTextField {
let field = defaultTitleTextField()
field.font = NSFont.boldSystemFont(ofSize: 16)
field.alignment = .left;
field.stringValue = title
return field
}
func titleTextField(title: String) -> NSTextField {
let field = defaultTitleTextField()
field.alignment = .right;
field.stringValue = title
return field
}
func infoTextField(markdown: String) -> NSTextField {
let field = NSTextField(forAutoLayout: ())
field.backgroundColor = NSColor.clear
field.isEditable = false
field.isBordered = false
field.usesSingleLineMode = false
// both are needed, otherwise hyperlink won't accept mousedown
field.isSelectable = true
field.allowsEditingTextAttributes = true
field.attributedStringValue = NSAttributedString.infoLabel(markdown: markdown)
return field
}
func configureCheckbox(button: NSButton, title: String, action: Selector) {
button.title = title
button.setButtonType(.switch)
button.target = self
button.action = action
}
fileprivate func defaultTitleTextField() -> NSTextField {
let field = NSTextField(forAutoLayout: ())
field.backgroundColor = NSColor.clear;
field.isEditable = false;
field.isBordered = false;
return field
}
}