KMPrintSettingView.swift 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // KMPrintSettingView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lizhe on 2023/12/4.
  6. //
  7. import Cocoa
  8. typealias KMPrintSettingViewPageSettingChange = (_ view: KMPrintSettingView, _ model: KMPrintModel) -> Void
  9. typealias KMPrintSettingViewPrintSettingChange = (_ view: KMPrintSettingView, _ model: KMPrintModel) -> Void
  10. class KMPrintSettingView: BaseXibView {
  11. @IBOutlet weak var defaultView: KMPrintDefaultView!
  12. @IBOutlet weak var posterView: KMPrintPosterView!
  13. @IBOutlet weak var multipageView: KMPrintMultipageView!
  14. @IBOutlet weak var pamphletView: KMPrintPamphletView!
  15. var pageSettingChange: KMPrintSettingViewPageSettingChange?
  16. var printSettingChange: KMPrintSettingViewPrintSettingChange?
  17. var type: KMPrintModelType = .size {
  18. didSet {
  19. self.reloadData()
  20. }
  21. }
  22. var printModel: KMPrintModel = KMPrintModel() {
  23. didSet {
  24. self.defaultView.printModel = printModel
  25. self.posterView.printModel = printModel
  26. self.multipageView.printModel = printModel
  27. self.pamphletView.printModel = printModel
  28. }
  29. }
  30. func setup() {
  31. defaultView.pageSettingChange = { [unowned self] view, model in
  32. self.pageSettingChange?(self, model)
  33. }
  34. defaultView.printSettingChange = { [unowned self] view, model in
  35. self.printSettingChange?(self, model)
  36. }
  37. posterView.pageSettingChangeAction = { [unowned self] view, model in
  38. self.pageSettingChange?(self, model)
  39. }
  40. posterView.printSettingChangeAction = { [unowned self] view, model in
  41. self.printSettingChange?(self, model)
  42. }
  43. multipageView.pageSettingChangeAction = { [unowned self] view, model in
  44. self.pageSettingChange?(self, model)
  45. }
  46. multipageView.printSettingChangeAction = { [unowned self] view, model in
  47. self.printSettingChange?(self, model)
  48. }
  49. pamphletView.pageSettingChangeAction = { [unowned self] view, model in
  50. self.pageSettingChange?(self, model)
  51. }
  52. pamphletView.printSettingChangeAction = { [unowned self] view, model in
  53. self.printSettingChange?(self, model)
  54. }
  55. }
  56. func reloadData() {
  57. self.defaultView.isHidden = true
  58. self.posterView.isHidden = true
  59. self.multipageView.isHidden = true
  60. self.pamphletView.isHidden = true
  61. switch type {
  62. case .size:
  63. self.defaultView.isHidden = false
  64. case .poster:
  65. self.posterView.isHidden = false
  66. case .multipage:
  67. self.multipageView.isHidden = false
  68. case .pamphlet:
  69. self.pamphletView.isHidden = false
  70. default:
  71. break
  72. }
  73. }
  74. }