KMNBotaSearchCellView.swift 795 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // KMNBotaSearchCellView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2024/12/2.
  6. //
  7. import Cocoa
  8. class KMNBotaSearchCellView: NSTableCellView {
  9. private lazy var label_: NSTextField = {
  10. let view = NSTextField(wrappingLabelWithString: "")
  11. return view
  12. }()
  13. var label: NSTextField {
  14. get {
  15. return label_
  16. }
  17. }
  18. convenience init() {
  19. self.init(frame: .init(x: 0, y: 0, width: 200, height: 40))
  20. addSubview(label_)
  21. }
  22. override func layout() {
  23. super.layout()
  24. let x: CGFloat = 24
  25. let y: CGFloat = 8
  26. let w = max(NSWidth(self.frame)-x*2, 0)
  27. let h = max(NSHeight(self.frame)-y*2, 0)
  28. label.frame = NSMakeRect(x, y, w, h)
  29. }
  30. }