1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- //
- // KMRedactBaseWindowController.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/1/17.
- //
- import Cocoa
- typealias KMRedactBaseWindowItemClick = (_ index: Int, _ value: Any?) -> ()
- class KMRedactBaseWindowController: NSWindowController {
-
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var topLine: NSBox!
- @IBOutlet weak var contentBox: NSBox!
- @IBOutlet weak var funcButton: NSButton!
- @IBOutlet weak var cancelButton: NSButton!
-
- @IBOutlet weak var contentWidthConst: NSLayoutConstraint!
- @IBOutlet weak var contentHeightConst: NSLayoutConstraint!
-
- var contentView: KMRedactContentBaseView!
- var pageCount: Int = 0
-
- var annotation: CPDFRedactAnnotation?
- // class func init(_ annotation: CPDFRedactAnnotation?) {
- // self.init(windowNibName: "KMRedactBaseWindowController")
- // self.annotation = annotation
- // }
- // func initWithWindowNibName
-
-
- var itemClick: KMRedactBaseWindowItemClick!
-
- override func windowDidLoad() {
- super.windowDidLoad()
- cancelButton.title = NSLocalizedString("Cancel", comment: "")
- cancelButton.isBordered = false
- cancelButton.wantsLayer = true
- cancelButton.layer?.borderWidth = 1
- cancelButton.layer?.borderColor = NSColor.black.cgColor
- cancelButton.layer?.cornerRadius = 4
- cancelButton.target = self
- cancelButton.action = #selector(cancelButtonAction)
-
- funcButton.isBordered = false
- funcButton.wantsLayer = true
- funcButton.layer?.cornerRadius = 4
- funcButton.target = self
- funcButton.action = #selector(funcButtonAction)
- }
-
- // MARK: Private Methods
-
- @objc private func cancelButtonAction() {
- guard let callback = self.itemClick else {
- return
- }
-
- callback(1, nil)
- }
-
- @objc private func funcButtonAction() {
- guard let callback = self.itemClick else {
- return
- }
-
- callback(2, nil)
- }
-
- // Mark: Publick Methods
-
- public func setContentSize(_ size: NSSize) {
- self.contentWidthConst.constant = size.width
- self.contentHeightConst.constant = size.height - 44 - 60
- }
-
- public func topLineIsShow(_ show: Bool) {
- self.topLine.isHidden = !show
- }
-
- }
|