KMWatermarkAdjectivePropertyBaseController.swift 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //
  2. // KMWatermarkAdjectivePropertyBaseController.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2022/12/15.
  6. //
  7. import Cocoa
  8. protocol KMWatermarkAdjectivePropertyDelegate: NSObjectProtocol {
  9. func propertyInfoDidChange(model: AnyObject)
  10. }
  11. typealias KMWatermarkAdjectivePropertyRightButtonClick = (_ index: Int)->()
  12. typealias KMWatermarkAdjectivePropertyBackButtonClick = ()->()
  13. /// 水印相关 属性控制器(基类)
  14. class KMWatermarkAdjectivePropertyBaseController: NSViewController {
  15. @IBOutlet weak var backButtton: NSButton!
  16. @IBOutlet weak var backButtonWidthConst: NSLayoutConstraint!
  17. @IBOutlet weak var titleLabel: NSTextField!
  18. @IBOutlet weak var addButton: NSButton!
  19. @IBOutlet weak var contentBox: NSBox!
  20. @IBOutlet weak var segementControl: KMWatermarkAdjectiveSegementControl!
  21. @IBOutlet weak var segementControlHeightConst: NSLayoutConstraint!
  22. @IBOutlet weak var tabView: NSTabView!
  23. var childViewController: Array<NSViewController> = []
  24. var rightButtonClick: KMWatermarkAdjectivePropertyRightButtonClick!
  25. var backClick: KMWatermarkAdjectivePropertyBackButtonClick!
  26. weak var delegate: KMWatermarkAdjectivePropertyDelegate?
  27. var preView: CPDFView!
  28. var model: AnyObject!
  29. /// 存储标记模型 【恢复功能】
  30. var flagModel: AnyObject?
  31. init() {
  32. super.init(nibName: "KMWatermarkAdjectivePropertyBaseController", bundle: nil)
  33. }
  34. required init?(coder: NSCoder) {
  35. super.init(nibName: "KMWatermarkAdjectivePropertyBaseController", bundle: nil)
  36. }
  37. override func viewDidLoad() {
  38. super.viewDidLoad()
  39. self.view.wantsLayer = true
  40. self.view.layer?.backgroundColor = NSColor(white: 243.0/255.0, alpha: 1.0).cgColor
  41. self.backButtton.target = self
  42. self.backButtton.action = #selector(backButttonAction)
  43. self.addButton.title = NSLocalizedString("+", comment: "")
  44. self.addButton.target = self
  45. self.addButton.action = #selector(addButtonAction)
  46. self.tabView.delegate = self;
  47. }
  48. func showBack(show: Bool) {
  49. if (show) {
  50. self.backButtton.isHidden = false
  51. self.backButtonWidthConst.constant = 20
  52. } else {
  53. self.backButtton.isHidden = true
  54. self.backButtonWidthConst.constant = 0
  55. }
  56. }
  57. func initDatas() {
  58. }
  59. func updateDatas() {
  60. }
  61. @objc func addButtonAction() {
  62. guard let callback = rightButtonClick else {
  63. return
  64. }
  65. callback(self.tabView.indexOfTabViewItem(self.tabView.selectedTabViewItem!))
  66. }
  67. @objc func backButttonAction() {
  68. guard let callback = backClick else {
  69. return
  70. }
  71. callback()
  72. }
  73. func selectTabIndex(index: Int) {
  74. if (index < self.tabView.numberOfTabViewItems) {
  75. self.segementControl.selectItemIndex = index
  76. self.tabView.selectTabViewItem(at: index)
  77. }
  78. }
  79. // MARK: 恢复
  80. public func resume() {
  81. }
  82. public func needResume() -> Bool {
  83. if (self.flagModel == nil) {
  84. return false
  85. }
  86. if (childViewController.count <= 0) {
  87. return false
  88. }
  89. return true
  90. }
  91. }
  92. extension KMWatermarkAdjectivePropertyBaseController: NSTabViewDelegate {
  93. }