// // KMPageEditSettingBaseWindowController.swift // PDF Master // // Created by tangchao on 2023/1/12. // // 页面编辑 [窗口基类] class KMPageEditSettingBaseWindowController: KMBaseWindowController { @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! private var funcVC_: KMDesignButton? private var cancelVC_: KMDesignButton? var funcVC: KMDesignButton? { get { return self.funcVC_ } } var settingView: KMPageEditSettingBaseView? private var model_: KMPageEditSettingBaseModel? var model: KMPageEditSettingBaseModel? { get { return self.model_ } } var itemClick: KMCommonClickBlock? convenience init(_ model: KMPageEditSettingBaseModel? = nil) { self.init(windowNibName: "KMPageEditSettingBaseWindowController") self.model_ = model } override func initSubViews() { super.initSubViews() self.cancelVC_ = KMDesignButton(withType: .Text) self.cancelButton.addSubview(self.cancelVC_!.view) self.cancelVC_?.view.frame = self.cancelButton.bounds self.cancelVC_?.view.autoresizingMask = [.width, .height] self.funcVC_ = KMDesignButton(withType: .Text) self.funcButton.addSubview(self.funcVC_!.view) self.funcVC_?.view.frame = self.funcButton.bounds self.funcVC_?.view.autoresizingMask = [.width, .height] } override func initDefaultValue() { super.initDefaultValue() self.cancelButton.title = "" self.funcButton.title = "" self.titleLabel.font = .SFProTextSemiboldFont(16) self.titleLabel.textColor = KMAppearance.titleColor() self.cancelVC_?.target = self self.cancelVC_?.action = #selector(cancelButtonAction) self.cancelVC_?.stringValue = NSLocalizedString("Cancel", comment: "") self.cancelVC_?.button(type: .Sec, size: .m) self.cancelVC_?.button.keyEquivalent = KMKeyEquivalent.esc.string() self.funcVC_?.target = self self.funcVC_?.action = #selector(funcButtonAction) self.funcVC_?.button(type: .Cta, size: .m) self.funcVC_?.button.keyEquivalent = KMKeyEquivalent.enter } 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) } }