KMPageEditSettingBaseWindowController.swift 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // KMPageEditSettingBaseWindowController.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2023/1/12.
  6. //
  7. // 页面编辑 [窗口基类]
  8. class KMPageEditSettingBaseWindowController: KMBaseWindowController {
  9. @IBOutlet weak var contentWidthConst: NSLayoutConstraint!
  10. @IBOutlet weak var contentHeightConst: NSLayoutConstraint!
  11. @IBOutlet weak var titleLabel: NSTextField!
  12. @IBOutlet weak var contentBox: NSBox!
  13. @IBOutlet weak var funcButton: NSButton!
  14. @IBOutlet weak var cancelButton: NSButton!
  15. private var funcVC_: KMDesignButton?
  16. private var cancelVC_: KMDesignButton?
  17. var funcVC: KMDesignButton? {
  18. get {
  19. return self.funcVC_
  20. }
  21. }
  22. var settingView: KMPageEditSettingBaseView?
  23. private var model_: KMPageEditSettingBaseModel?
  24. var model: KMPageEditSettingBaseModel? {
  25. get {
  26. return self.model_
  27. }
  28. }
  29. var itemClick: KMCommonClickBlock?
  30. convenience init(_ model: KMPageEditSettingBaseModel? = nil) {
  31. self.init(windowNibName: "KMPageEditSettingBaseWindowController")
  32. self.model_ = model
  33. }
  34. override func initSubViews() {
  35. super.initSubViews()
  36. self.cancelVC_ = KMDesignButton(withType: .Text)
  37. self.cancelButton.addSubview(self.cancelVC_!.view)
  38. self.cancelVC_?.view.frame = self.cancelButton.bounds
  39. self.cancelVC_?.view.autoresizingMask = [.width, .height]
  40. self.funcVC_ = KMDesignButton(withType: .Text)
  41. self.funcButton.addSubview(self.funcVC_!.view)
  42. self.funcVC_?.view.frame = self.funcButton.bounds
  43. self.funcVC_?.view.autoresizingMask = [.width, .height]
  44. }
  45. override func initDefaultValue() {
  46. super.initDefaultValue()
  47. self.cancelButton.title = ""
  48. self.funcButton.title = ""
  49. self.titleLabel.font = .SFProTextSemiboldFont(16)
  50. self.titleLabel.textColor = KMAppearance.titleColor()
  51. self.cancelVC_?.target = self
  52. self.cancelVC_?.action = #selector(cancelButtonAction)
  53. self.cancelVC_?.stringValue = NSLocalizedString("Cancel", comment: "")
  54. self.cancelVC_?.button(type: .Sec, size: .m)
  55. self.cancelVC_?.button.keyEquivalent = KMKeyEquivalent.esc.string()
  56. self.funcVC_?.target = self
  57. self.funcVC_?.action = #selector(funcButtonAction)
  58. self.funcVC_?.button(type: .Cta, size: .m)
  59. self.funcVC_?.button.keyEquivalent = KMKeyEquivalent.enter
  60. }
  61. public func setWindowSize(_ size: NSSize) {
  62. self.contentWidthConst.constant = size.width
  63. self.contentHeightConst.constant = size.height-44-60
  64. }
  65. @objc func cancelButtonAction() {
  66. guard let callback = self.itemClick else {
  67. return
  68. }
  69. callback(1)
  70. }
  71. @objc func funcButtonAction() {
  72. guard let callback = self.itemClick else {
  73. return
  74. }
  75. callback(2)
  76. }
  77. }