KMLinkPopupBaseView.swift 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // KMLinkPopupBaseView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by Niehaoyu on 2024/10/18.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. class KMLinkPopupBaseView: BaseXibView {
  10. @IBOutlet var contendBox: NSBox!
  11. @IBOutlet var baseView: NSView!
  12. @IBOutlet var pageButton: ComponentButton!
  13. @IBOutlet var webButton: ComponentButton!
  14. @IBOutlet var emailButton: ComponentButton!
  15. @IBOutlet var moreButton: ComponentButton!
  16. override func draw(_ dirtyRect: NSRect) {
  17. super.draw(dirtyRect)
  18. // Drawing code here.
  19. }
  20. //MARK: - Setter
  21. var linkPopupType: PDFLinkPopupType = .None {
  22. didSet {
  23. self.refreshUI()
  24. self.reloadData()
  25. }
  26. }
  27. func setUpProperty() {
  28. pageButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, state: .normal, onlyIcon: false, showLeftIcon: true, showRightIcon: false, buttonText: KMLocalizedString("Page"))
  29. pageButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "")
  30. webButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, state: .normal, onlyIcon: false, showLeftIcon: true, showRightIcon: false, buttonText: KMLocalizedString("Web"))
  31. webButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "")
  32. emailButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, state: .normal, onlyIcon: false, showLeftIcon: true, showRightIcon: false, buttonText: KMLocalizedString("Email"))
  33. emailButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "")
  34. moreButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
  35. moreButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "")
  36. }
  37. func refreshUI() {
  38. var rect = self.frame
  39. if linkPopupType == .None {
  40. rect.size.width = 303
  41. rect.size.height = 40
  42. } else if linkPopupType == .Page {
  43. rect.size.width = 256
  44. rect.size.height = 240
  45. } else if linkPopupType == .Web {
  46. rect.size.width = 328
  47. rect.size.height = 40
  48. } else if linkPopupType == .Email {
  49. rect.size.width = 328
  50. rect.size.height = 40
  51. }
  52. NSAnimationContext.runAnimationGroup({ context in
  53. context.duration = 0.35
  54. self.animator().frame = rect
  55. }, completionHandler: nil)
  56. }
  57. func reloadData() {
  58. }
  59. }