123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- //
- // KMConvertWordSettingView.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2022/12/6.
- //
- import KMComponentLibrary
- class KMConvertWordSettingView: KMConvertSettingView {
- @IBOutlet weak var pageSettingTitleLabel: NSTextField!
-
- @IBOutlet weak var saveFlowTextRadio: ComponentRadio!
- @IBOutlet weak var savePageLayoutRadio: ComponentRadio!
-
- @IBOutlet weak var textOCRBox: NSBox!
- @IBOutlet weak var pageRangeBox: NSBox!
-
- // 流排 0 框排 1
- var pageSettingSelectedIndex: Int = 0
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- saveFlowTextRadio.properties = ComponentCheckBoxProperty(size: .s,
- state: .normal,
- isDisabled: false,
- showhelp: false,
- text: NSLocalizedString("Retain Flowing Text", comment: ""),
- checkboxType: .normal)
- saveFlowTextRadio.setTarget(self, action: #selector(saveFlowTextRadioAction))
-
- savePageLayoutRadio.properties = ComponentCheckBoxProperty(size: .s,
- state: .normal,
- isDisabled: false,
- showhelp: false,
- text: NSLocalizedString("Retain Page Layout", comment: ""),
- checkboxType: .normal)
- savePageLayoutRadio.setTarget(self, action: #selector(savePageLayoutRadioAction))
-
- self._flowTextAction()
- }
-
- override func initSubViews() {
- super.initSubViews()
-
- self.tipView?.km_add_left_constraint(constant: 8)
- self.tipView?.km_add_top_constraint(equalTo: self.pageRangeBox, attribute: .bottom, constant: -5)
- self.tipView?.km_add_right_constraint()
- self.tipView?.km_add_height_constraint(constant: 16+20+16)
- }
-
- override func initDefaultVlaue() {
- super.initDefaultVlaue()
-
- self.pageSettingTitleLabel.stringValue = NSLocalizedString("Layout Settings", comment: "")
- self.pageSettingTitleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
- }
-
- override func viewDidMoveToWindow() {
- super.viewDidMoveToWindow()
-
- if (self.ocrItemView == nil) {
- self.ocrItemView = KMConvertOCRSettingItemView.createFromNib()
- self.textOCRBox.contentView = self.ocrItemView
-
- self.ocrItemView?.titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
- self.ocrItemView?.titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
- }
- self.ocrItemView?.languageIndex = self.ocrLanuguageIndex
- if (self.pageRangeItemView == nil) {
- self.pageRangeItemView = KMConvertPageRangeSettingItemView.createFromNib()
- self.pageRangeBox.contentView = self.pageRangeItemView
-
- self.pageRangeItemView?.titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
- self.pageRangeItemView?.titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
- }
- }
-
- @objc func saveFlowTextRadioAction(sender: AnyObject) {
- self._flowTextAction()
- }
- @objc func savePageLayoutRadioAction(sender: AnyObject) {
- self._pageLayoutAction()
- }
-
- // MARK: - Private Methods
-
- private func _flowTextAction() {
- self.saveFlowTextRadio.properties.checkboxType = .selected
- self.saveFlowTextRadio.reloadData()
-
- self.savePageLayoutRadio.properties.checkboxType = .normal
- self.savePageLayoutRadio.reloadData()
-
- self.pageSettingSelectedIndex = 0
- }
-
- private func _pageLayoutAction() {
- self.savePageLayoutRadio.properties.checkboxType = .selected
- self.savePageLayoutRadio.reloadData()
-
- self.saveFlowTextRadio.properties.checkboxType = .normal
- self.saveFlowTextRadio.reloadData()
-
- self.pageSettingSelectedIndex = 1
- }
- }
|