KMConvertWordSettingView.swift 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // KMConvertWordSettingView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2022/12/6.
  6. //
  7. class KMConvertWordSettingView: KMConvertSettingView {
  8. @IBOutlet weak var pageSettingTitleLabel: NSTextField!
  9. @IBOutlet weak var saveFlowTextRadio: KMImageTitleButton!
  10. @IBOutlet weak var savePageLayoutRadio: KMImageTitleButton!
  11. @IBOutlet weak var textOCRBox: NSBox!
  12. @IBOutlet weak var pageRangeBox: NSBox!
  13. private var flowTextVC: KMDesignButton?
  14. private var pageLayoutVC: KMDesignButton?
  15. // 流排 0 框排 1
  16. var pageSettingSelectedIndex: Int = 0
  17. override func awakeFromNib() {
  18. super.awakeFromNib()
  19. self._flowTextAction()
  20. }
  21. override func initSubViews() {
  22. super.initSubViews()
  23. self.flowTextVC = KMDesignButton.init(withType: .RadioButton)
  24. self.saveFlowTextRadio.addSubview(self.flowTextVC!.view)
  25. self.flowTextVC?.view.frame = self.saveFlowTextRadio.bounds
  26. self.flowTextVC?.view.autoresizingMask = [.width, .height]
  27. self.flowTextVC?.target = self
  28. self.flowTextVC?.action = #selector(saveFlowTextRadioAction)
  29. self.flowTextVC?.stringValue = NSLocalizedString("Retain Flowing Text", comment: "")
  30. self.flowTextVC?.checkbox_radio()
  31. self.pageLayoutVC = KMDesignButton.init(withType: .RadioButton)
  32. self.savePageLayoutRadio.addSubview(self.pageLayoutVC!.view)
  33. self.pageLayoutVC?.view.frame = self.savePageLayoutRadio.bounds
  34. self.pageLayoutVC?.view.autoresizingMask = [.width, .height]
  35. self.pageLayoutVC?.target = self
  36. self.pageLayoutVC?.action = #selector(savePageLayoutRadioAction)
  37. self.pageLayoutVC?.stringValue = NSLocalizedString("Retain Page Layout", comment: "")
  38. self.pageLayoutVC?.checkbox_radio()
  39. self.tipView?.km_add_left_constraint(constant: 8)
  40. self.tipView?.km_add_top_constraint(equalTo: self.pageRangeBox, attribute: .bottom, constant: -5)
  41. self.tipView?.km_add_right_constraint()
  42. // self.tipView?.km_add_width_constraint(constant: 300)
  43. self.tipView?.km_add_height_constraint(constant: 16+20+16)
  44. }
  45. override func initDefaultVlaue() {
  46. super.initDefaultVlaue()
  47. self.pageSettingTitleLabel.stringValue = NSLocalizedString("Layout Settings", comment: "")
  48. self.pageSettingTitleLabel.textColor = NSColor.km_init(hex: "#616469")
  49. self.pageSettingTitleLabel.font = .SFProTextRegularFont(12)
  50. }
  51. override func viewDidMoveToWindow() {
  52. super.viewDidMoveToWindow()
  53. if (self.ocrItemView == nil) {
  54. self.ocrItemView = KMConvertOCRSettingItemView.createFromNib()
  55. self.textOCRBox.contentView = self.ocrItemView
  56. }
  57. self.ocrItemView?.languageIndex = self.ocrLanuguageIndex
  58. if (self.pageRangeItemView == nil) {
  59. self.pageRangeItemView = KMConvertPageRangeSettingItemView.createFromNib()
  60. self.pageRangeBox.contentView = self.pageRangeItemView
  61. }
  62. }
  63. @objc func saveFlowTextRadioAction(sender: AnyObject) {
  64. self._flowTextAction()
  65. }
  66. @objc func savePageLayoutRadioAction(sender: AnyObject) {
  67. self._pageLayoutAction()
  68. }
  69. // MARK: - Private Methods
  70. private func _flowTextAction() {
  71. self.flowTextVC?.state = .Checked
  72. self.pageLayoutVC?.state = .Norm
  73. self.pageSettingSelectedIndex = 0
  74. }
  75. private func _pageLayoutAction() {
  76. self.pageLayoutVC?.state = .Checked
  77. self.flowTextVC?.state = .Norm
  78. self.pageSettingSelectedIndex = 1
  79. }
  80. }