12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- //
- // KMPageEditSettingBaseWindowController.swift
- // PDF Master
- //
- // Created by tangchao on 2023/1/12.
- //
- import Cocoa
- typealias KMPageEditSettingItemClick = (_ index: Int, _ value: Any) -> ()
- class KMPageEditSettingBaseWindowController: NSWindowController {
- @IBOutlet weak var contentWidthConst: NSLayoutConstraint!
- @IBOutlet weak var contentHeightConst: NSLayoutConstraint!
-
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var contentBox: NSBox!
- @IBOutlet weak var funcButton: NSButton!
- @IBOutlet weak var cancelButton: NSButton!
-
- var settingView: KMPageEditSettingBaseView?
- private var myModel: KMPageEditSettingBaseModel?
- var model: KMPageEditSettingBaseModel? {
- get {
- return self.myModel
- }
- set {
- self.myModel = newValue
- }
- }
-
- var itemClick: KMPageEditSettingItemClick!
-
- convenience init(_ model: KMPageEditSettingBaseModel?) {
- self.init(windowNibName: "KMPageEditSettingBaseWindowController")
- self.model = model
- }
-
- override func windowDidLoad() {
- super.windowDidLoad()
- cancelButton.title = NSLocalizedString("Cancel", comment: "")
- cancelButton.isBordered = false
- cancelButton.wantsLayer = true
- cancelButton.layer?.borderWidth = 1
- cancelButton.layer?.borderColor = NSColor.black.cgColor
- cancelButton.layer?.cornerRadius = 4
- cancelButton.target = self
- cancelButton.action = #selector(cancelButtonAction)
-
- funcButton.isBordered = false
- funcButton.wantsLayer = true
- funcButton.layer?.cornerRadius = 4
- funcButton.target = self
- funcButton.action = #selector(funcButtonAction)
- }
-
- public func setWindowSize(_ size: NSSize) {
- self.contentWidthConst.constant = size.width
- self.contentHeightConst.constant = size.height-44-60
- }
-
- @objc func cancelButtonAction() {
- guard let callback = self.itemClick else {
- return
- }
-
- callback(1, "")
- }
-
- @objc func funcButtonAction() {
- guard let callback = self.itemClick else {
- return
- }
-
- callback(2, "")
- }
-
- }
|