123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // KMPrintSettingView.swift
- // PDF Reader Pro
- //
- // Created by lizhe on 2023/12/4.
- //
- import Cocoa
- typealias KMPrintSettingViewPageSettingChange = (_ view: KMPrintSettingView, _ model: KMPrintModel) -> Void
- typealias KMPrintSettingViewPrintSettingChange = (_ view: KMPrintSettingView, _ model: KMPrintModel) -> Void
- class KMPrintSettingView: KMBaseXibView {
- @IBOutlet weak var defaultView: KMPrintDefaultView!
- @IBOutlet weak var posterView: KMPrintPosterView!
- @IBOutlet weak var multipageView: KMPrintMultipageView!
- @IBOutlet weak var pamphletView: KMPrintPamphletView!
-
- var pageSettingChange: KMPrintSettingViewPageSettingChange?
- var printSettingChange: KMPrintSettingViewPrintSettingChange?
-
- var type: KMPrintModelType = .size {
- didSet {
- self.reloadData()
- }
- }
-
- var printModel: KMPrintModel = KMPrintModel() {
- didSet {
- self.defaultView.printModel = printModel
- self.posterView.printModel = printModel
- self.multipageView.printModel = printModel
- self.pamphletView.printModel = printModel
- }
- }
-
- override func setup() {
- defaultView.pageSettingChange = { [unowned self] view, model in
- self.pageSettingChange?(self, model)
- }
-
- defaultView.printSettingChange = { [unowned self] view, model in
- self.printSettingChange?(self, model)
- }
-
- posterView.pageSettingChangeAction = { [unowned self] view, model in
- self.pageSettingChange?(self, model)
- }
-
- posterView.printSettingChangeAction = { [unowned self] view, model in
- self.printSettingChange?(self, model)
- }
-
- multipageView.pageSettingChangeAction = { [unowned self] view, model in
- self.pageSettingChange?(self, model)
- }
-
- multipageView.printSettingChangeAction = { [unowned self] view, model in
- self.printSettingChange?(self, model)
- }
-
- pamphletView.pageSettingChangeAction = { [unowned self] view, model in
- self.pageSettingChange?(self, model)
- }
-
- pamphletView.printSettingChangeAction = { [unowned self] view, model in
- self.printSettingChange?(self, model)
- }
- }
-
- override func reloadData() {
- self.defaultView.isHidden = true
- self.posterView.isHidden = true
- self.multipageView.isHidden = true
- self.pamphletView.isHidden = true
-
- switch type {
- case .size:
- self.defaultView.isHidden = false
- case .poster:
- self.posterView.isHidden = false
- case .multipage:
- self.multipageView.isHidden = false
- case .pamphlet:
- self.pamphletView.isHidden = false
- default:
- break
- }
- }
- }
|