1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // KMThumbnail.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/11/16.
- //
- import Cocoa
- let thumbnailMethodKey = "KMThumbnailMethodKey"
- let outlineMethodKey = "KMOutlineMethoddKey"
- let bookMarkMethodKey = "KMBookMarkMethodKey"
- let anntationMethodKey = "KMAnntationMethodKey"
- let searchMethodKey = "KMSearchMethodKey"
- let formMethodKey = "KMFormMethodKey"
- let signatureMethodKey = "KMSignatureMethodKey"
- let snapshotMethodKey = "KMSnapshotMethodKey"
- @objc protocol KMThumbnailDelegate: NSObjectProtocol {
- @objc optional func generateImage(for thumbnail: KMThumbnail) -> Bool
- }
- class KMThumbnail: NSObject {
- weak var delegate: KMThumbnailDelegate?
- var dirty = false
- private var _image: NSImage?
- var image: NSImage? {
- get {
- if let data = self.delegate?.generateImage?(for: self), data && self.dirty {
- self.dirty = false
- }
- return self._image
- }
- set {
- self._image = newValue
- }
- }
- private var _label: String = ""
- var label: String {
- get {
- return self._label
- }
- }
- private var _pageIndex: Int = 0
- var pageIndex: Int {
- get {
- return self._pageIndex
- }
- }
- var size: NSSize {
- get {
- return self.image?.size ?? .zero
- }
- }
- var thumiii: NSImageView?
-
- convenience init(image: NSImage?, label: String, pageIndex: Int) {
- self.init()
-
- self.image = image
- self._label = label
- self._pageIndex = pageIndex
- self.dirty = false
- }
- }
|