KMToolbarCustomWindowController.swift 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // KMToolbarCustomWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/10/26.
  6. //
  7. import Cocoa
  8. class KMToolbarCustomWindowController: NSWindowController {
  9. weak var toolbar: KMToolbarView?
  10. var toolbarCustomViewController: KMToolbarCustomViewController?
  11. deinit {
  12. Swift.debugPrint("KMToolbarCustomWindowController deinit")
  13. }
  14. convenience init() {
  15. self.init(windowNibName: "KMToolbarCustomWindowController")
  16. }
  17. override func windowDidLoad() {
  18. super.windowDidLoad()
  19. self.toolbarCustomViewController = KMToolbarCustomViewController()
  20. self.toolbarCustomViewController?.toolbar = self.toolbar
  21. if self.responds(to: NSSelectorFromString("setContentViewController:")) {
  22. self.contentViewController = self.toolbarCustomViewController
  23. } else {
  24. self.toolbarCustomViewController?.view.frame = self.window?.contentView?.bounds ?? .zero
  25. if let sview = self.toolbarCustomViewController?.view {
  26. self.window?.contentView?.addSubview(sview)
  27. }
  28. }
  29. }
  30. }