KMCloudFileEmptyView.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // KMCloudFileEmptyView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/2/14.
  6. //
  7. import Cocoa
  8. class KMCloudFileEmptyView: NSView {
  9. var imageView = NSImageView()
  10. var titleLabel = NSTextField(labelWithString: "")
  11. var despLabel = NSTextField(labelWithString: "")
  12. override var isFlipped: Bool {
  13. return true
  14. }
  15. override init(frame frameRect: NSRect) {
  16. super.init(frame: frameRect)
  17. initSubViews()
  18. }
  19. required init?(coder: NSCoder) {
  20. super.init(coder: coder)
  21. initSubViews()
  22. }
  23. public func initSubViews() {
  24. self.addSubview(self.imageView)
  25. self.addSubview(self.titleLabel)
  26. self.addSubview(self.despLabel)
  27. self.titleLabel.alignment = .center
  28. self.titleLabel.stringValue = NSLocalizedString("There are no files in this folder", comment: "")
  29. self.despLabel.alignment = .center
  30. self.despLabel.stringValue = NSLocalizedString("no files here.", comment: "")
  31. }
  32. override func layout() {
  33. super.layout()
  34. let width: CGFloat = NSWidth(self.bounds)
  35. let imageSize: NSSize = NSMakeSize(80, 80)
  36. self.imageView.frame = NSMakeRect((width-imageSize.width)*0.5, 20, imageSize.width, imageSize.height)
  37. self.titleLabel.frame = NSMakeRect(0, self.imageView.frame.maxY+20, width, 22)
  38. self.despLabel.frame = NSMakeRect(0, self.titleLabel.frame.maxY+2, width, 20)
  39. }
  40. }