KMPageDisplayThemeCollectionViewItem.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // KMPageDisplayThemeCollectionViewItem.swift
  3. // PDF Master
  4. //
  5. // Created by lxy on 2023/1/29.
  6. //
  7. import Cocoa
  8. typealias KMThemesItemActionCallback = (_ index: Int) -> ()
  9. class KMPageDisplayThemeCollectionViewItem: NSCollectionViewItem {
  10. @IBOutlet weak var itemImageView: NSImageView!
  11. @IBOutlet weak var itemLabel: NSTextField!
  12. @IBOutlet weak var themesBox: KMBox!
  13. @IBOutlet weak var vipImageView: NSImageView!
  14. @IBOutlet weak var closeButton: NSButton!
  15. var itemCallBack : KMThemesItemActionCallback!
  16. override func viewDidLoad() {
  17. super.viewDidLoad()
  18. self.closeButton.isHidden = true
  19. self.itemImageView.wantsLayer = true
  20. self.itemImageView.layer?.cornerRadius = 10
  21. self.itemImageView.layer?.masksToBounds = true
  22. self.itemImageView.layer?.borderWidth = 0.5
  23. self.itemImageView.layer?.borderColor = NSColor.gridColor.cgColor
  24. }
  25. private func swatchWithColor(color:NSColor,size:NSSize) -> NSImage {
  26. let image = NSImage(size: size)
  27. image.lockFocus()
  28. color.drawSwatch(in: NSRect(x: 0, y: 0, width: size.width, height: size.height))
  29. image.unlockFocus()
  30. return image
  31. }
  32. func themesCollectionCellItem(item:NSInteger,itemData:[Any]) {
  33. }
  34. }