ViewController.swift 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. //
  2. // ViewController.swift
  3. // KdanAuto
  4. //
  5. // Created by 朱东勇 on 2022/11/17.
  6. //
  7. import Cocoa
  8. let testCaseNames = [
  9. "PDF2RTF_Font_Auto_Test",
  10. "PDF2RTF_Color_Auto_Test",
  11. "PDF2RTF_China_Auto_Test",
  12. "PDF2RTF_SpecialCharacter_Auto_Test"
  13. ]
  14. class ViewController : NSViewController, SettingViewControllerDelegate,
  15. NSTableViewDelegate, NSTableViewDataSource {
  16. @IBOutlet var settingVCWindow : NSWindow!
  17. @IBOutlet var settingVC : SettingViewController!
  18. @IBOutlet var itemsList : NSTableView!
  19. override func viewDidLoad() {
  20. super.viewDidLoad()
  21. // Do any additional setup after loading the view.
  22. }
  23. override var representedObject: Any? {
  24. didSet {
  25. // Update the view, if already loaded.
  26. }
  27. }
  28. func reloadListData() {
  29. }
  30. // IBAction
  31. @IBAction func showSettingVC(_ sender:NSButton) {
  32. let settingVC = SettingViewController.shared()
  33. settingVC.delegate = self
  34. settingVC.show()
  35. }
  36. // TableView Delegate
  37. func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
  38. let cellView = TestCaseCellView.shared()
  39. cellView?.setTitle(testCaseNames[row])
  40. cellView?.setCheckKeys(["Color", "Font Size", "Font Name", "Font Style"])
  41. return cellView
  42. }
  43. //
  44. // func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
  45. // let cell = TestCaseCellView.shared()
  46. //
  47. // cell?.setTitle(testCaseNames[row])
  48. //
  49. // return cell as! NSTableRowView
  50. // }
  51. // func tableView(_ tableView: NSTableView, dataCellFor tableColumn: NSTableColumn?, row: Int) -> NSCell? {
  52. // var cell = NSCell.init(textCell: testCaseNames[row]);
  53. //
  54. // cell.title = testCaseNames[row]
  55. //
  56. // return cell
  57. // }
  58. func selectionShouldChange(in tableView: NSTableView) -> Bool {
  59. return true
  60. }
  61. func tableView(_ tableView: NSTableView, shouldSelectRow row: Int) -> Bool {
  62. return true
  63. }
  64. func tableView(_ tableView: NSTableView, shouldSelect tableColumn: NSTableColumn?) -> Bool {
  65. return false
  66. }
  67. func tableView(_ tableView: NSTableView, mouseDownInHeaderOf tableColumn: NSTableColumn) {
  68. }
  69. func tableView(_ tableView: NSTableView, didClick tableColumn: NSTableColumn) {
  70. }
  71. func tableView(_ tableView: NSTableView, didDrag tableColumn: NSTableColumn) {
  72. }
  73. func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
  74. return 60
  75. }
  76. func tableView(_ tableView: NSTableView, isGroupRow row: Int) -> Bool {
  77. return false
  78. }
  79. func tableView(_ tableView: NSTableView, sizeToFitWidthOfColumn column: Int) -> CGFloat {
  80. return tableView.frame.width
  81. }
  82. func tableView(_ tableView: NSTableView, rowActionsForRow row: Int, edge: NSTableView.RowActionEdge) -> [NSTableViewRowAction] {
  83. return []
  84. }
  85. // TableView Data Source
  86. func numberOfRows(in tableView: NSTableView) -> Int {
  87. return testCaseNames.count;
  88. }
  89. /* This method is required for the "Cell Based" TableView, and is optional for the "View Based" TableView. If implemented in the latter case, the value will be set to the view at a given row/column if the view responds to -setObjectValue: (such as NSControl and NSTableCellView). Note that NSTableCellView does not actually display the objectValue, and its value is to be used for bindings. See NSTableCellView.h for more information.
  90. */
  91. func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
  92. return testCaseNames[row]
  93. }
  94. // SettingViewConntroller
  95. func settingViewDidFinished() {
  96. reloadListData()
  97. }
  98. }