12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //
- // KMNPreView.swift
- // PDF Reader Pro
- //
- // Created by User-Tangchao on 2024/10/25.
- //
- import Cocoa
- import KMComponentLibrary
- class KMNPreView: NSView, NibLoadable {
- @IBOutlet weak var pdfPreView: KMNPDFPreView!
- @IBOutlet weak var paginationBox: NSBox!
-
- @IBOutlet weak var pdfPreViewLeftConst: NSLayoutConstraint!
- @IBOutlet weak var pdfPreViewTopConst: NSLayoutConstraint!
- @IBOutlet weak var pdfPreViewRightConst: NSLayoutConstraint!
-
- @IBOutlet weak var paginationTopSpaceConst: NSLayoutConstraint!
- @IBOutlet weak var paginationLeftConst: NSLayoutConstraint!
- @IBOutlet weak var paginationRightConst: NSLayoutConstraint!
- @IBOutlet weak var paginationBottomConst: NSLayoutConstraint!
-
- var contentInset: NSEdgeInsets = .init(top: 16, left: 16, bottom: 16, right: 16) {
- didSet {
- pdfPreViewLeftConst.constant = contentInset.left
- pdfPreViewTopConst.constant = contentInset.top
- pdfPreViewRightConst.constant = contentInset.right
-
- paginationBottomConst.constant = contentInset.bottom
- }
- }
-
- private var pagination_ = ComponentPagination()
-
-
- deinit {
- KMPrint("KMNPreView deinit.")
- }
-
- override func draw(_ dirtyRect: NSRect) {
- super.draw(dirtyRect)
- // Drawing code here.
- }
-
- convenience init(fileUrl: URL, password: String?) {
- self.init()
-
- initSubviews()
- initDefaultValue()
-
- setFileUrl(fileUrl, password: password)
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- initSubviews()
- initDefaultValue()
- }
-
- func initSubviews() {
- self.paginationBox.contentView = self.pagination_
- }
-
- func initDefaultValue() {
- // self.contentBox_.borderWidth = 2
- // self.contentBox_.borderColor = .red
- }
-
- func setFileUrl(_ fileUrl: URL, password: String?) {
- pdfPreView.setFileUrl(fileUrl, password: password)
- }
-
- }
|