|
@@ -7,32 +7,39 @@
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
-class KMRedactPropertiesWindowController: NSWindowController {
|
|
|
+import KMComponentLibrary
|
|
|
+
|
|
|
+class KMRedactPropertiesWindowController: KMNBaseWindowController {
|
|
|
|
|
|
var readactAnnotation: CPDFRedactAnnotation?
|
|
|
|
|
|
+ @IBOutlet weak var titleLabel: NSTextField!
|
|
|
+ @IBOutlet weak var subLabel: NSTextField!
|
|
|
+
|
|
|
@IBOutlet weak var outlineColorLabel: NSTextField!
|
|
|
- @IBOutlet weak var outlineColorWell: NSColorWell!
|
|
|
+ @IBOutlet weak var outlineColorItem: ComponentCColorItem!
|
|
|
@IBOutlet weak var fillColorLabel: NSTextField!
|
|
|
- @IBOutlet weak var fillColorWell: NSColorWell!
|
|
|
+ @IBOutlet weak var fillColorItem: ComponentCColorItem!
|
|
|
|
|
|
- @IBOutlet weak var overlayTextButton: NSButton!
|
|
|
@IBOutlet weak var overlayTextLabel: NSTextField!
|
|
|
- @IBOutlet weak var overlayTextField: NSTextField!
|
|
|
+ @IBOutlet weak var overlayTextarea: ComponentTextarea!
|
|
|
@IBOutlet weak var fontSizeLabel: NSTextField!
|
|
|
|
|
|
- @IBOutlet weak var fontSizeComboBox: NSComboBox!
|
|
|
+ @IBOutlet weak var fontSizeComboSelect: ComponentSelect!
|
|
|
@IBOutlet weak var alignementLabel: NSTextField!
|
|
|
- @IBOutlet weak var segmentedControl: NSSegmentedControl!
|
|
|
+ @IBOutlet var alightLeftButton: ComponentButton!
|
|
|
+ @IBOutlet var alightRightButton: ComponentButton!
|
|
|
+ @IBOutlet var alightCenteButton: ComponentButton!
|
|
|
+
|
|
|
@IBOutlet weak var fontColorLabel: NSTextField!
|
|
|
+ @IBOutlet weak var fontColorItem: ComponentCColorItem!
|
|
|
+ @IBOutlet weak var makePropertiesButton: ComponentButton!
|
|
|
+ @IBOutlet weak var cancelButton: ComponentButton!
|
|
|
+ @IBOutlet weak var okButton: ComponentButton!
|
|
|
|
|
|
- @IBOutlet weak var fontColorWell: NSColorWell!
|
|
|
- @IBOutlet weak var makePropertiesButton: NSButton!
|
|
|
- @IBOutlet weak var cancelButton: NSButton!
|
|
|
- @IBOutlet weak var okButton: NSButton!
|
|
|
- /*
|
|
|
- @property (nonatomic,assign) NSModalSession modalSession;
|
|
|
- */
|
|
|
+ @IBOutlet var cancelWidthButton:NSLayoutConstraint!
|
|
|
+ @IBOutlet var okWidthButton:NSLayoutConstraint!
|
|
|
+ @IBOutlet var makePropertiesWidthButton:NSLayoutConstraint!
|
|
|
|
|
|
var callback: ((_ anno: CPDFRedactAnnotation?)->Void)?
|
|
|
|
|
@@ -40,148 +47,446 @@ class KMRedactPropertiesWindowController: NSWindowController {
|
|
|
self.init(windowNibName: "KMRedactPropertiesWindowController")
|
|
|
}
|
|
|
|
|
|
+ override func initContentView() {
|
|
|
+ super.initContentView()
|
|
|
+
|
|
|
+ fontColorItem.properties = ComponentCColorProperty(colorType: .color,
|
|
|
+ state: .normal,
|
|
|
+ isCustom: true,
|
|
|
+ color: NSColor.red)
|
|
|
+ fontColorItem.delegate = self
|
|
|
+ fontColorItem.reloadData()
|
|
|
+
|
|
|
+ outlineColorItem.properties = ComponentCColorProperty(colorType: .color,
|
|
|
+ state: .normal,
|
|
|
+ isCustom: true,
|
|
|
+ color: NSColor.red)
|
|
|
+ outlineColorItem.delegate = self
|
|
|
+ outlineColorItem.reloadData()
|
|
|
+
|
|
|
+ fillColorItem.properties = ComponentCColorProperty(colorType: .color,
|
|
|
+ state: .normal,
|
|
|
+ isCustom: true,
|
|
|
+ color: NSColor.red)
|
|
|
+ fillColorItem.delegate = self
|
|
|
+ fillColorItem.reloadData()
|
|
|
+
|
|
|
+ alightLeftButton.properties = ComponentButtonProperty(type: .text_gray,
|
|
|
+ size: .s,
|
|
|
+ state: .normal,
|
|
|
+ onlyIcon: true,
|
|
|
+ icon:NSImage(named: "KMNImageNameListViewPopAlightLeft"))
|
|
|
+ alightLeftButton.setTarget(self, action: #selector(alightLeftButtonClicked(_ :)))
|
|
|
+
|
|
|
+ alightRightButton.properties = ComponentButtonProperty(type: .text_gray,
|
|
|
+ size: .s,
|
|
|
+ state: .normal,
|
|
|
+ onlyIcon: true,
|
|
|
+ icon:NSImage(named: "KMNImageNameListViewPopAlightRight"))
|
|
|
+ alightRightButton.setTarget(self, action: #selector(alightRightButtonClicked(_ :)))
|
|
|
+
|
|
|
+ alightCenteButton.properties = ComponentButtonProperty(type: .text_gray,
|
|
|
+ size: .s,
|
|
|
+ state: .normal,
|
|
|
+ onlyIcon: true,
|
|
|
+ icon:NSImage(named: "KMNImageNameListViewPopAlightCenter"))
|
|
|
+ alightCenteButton.setTarget(self, action: #selector(alightCenterButtonClicked(_ :)))
|
|
|
+
|
|
|
+ titleLabel.font = ComponentLibrary.shared.getFontFromKey ("mac/body-m-medium")
|
|
|
+ subLabel.font = ComponentLibrary.shared.getFontFromKey ("mac/body-s-medium")
|
|
|
+ outlineColorLabel.font = ComponentLibrary.shared.getFontFromKey ("mac/body-s-regular")
|
|
|
+ fillColorLabel.font = ComponentLibrary.shared.getFontFromKey ("mac/body-s-regular")
|
|
|
+ overlayTextLabel.font = ComponentLibrary.shared.getFontFromKey ("mac/body-s-medium")
|
|
|
+ fontColorLabel.font = ComponentLibrary.shared.getFontFromKey ("mac/body-s-regular")
|
|
|
+ fontSizeLabel.font = ComponentLibrary.shared.getFontFromKey ("mac/body-s-regular")
|
|
|
+ alignementLabel.font = ComponentLibrary.shared.getFontFromKey ("mac/body-s-regular")
|
|
|
+
|
|
|
+ okButton.properties = ComponentButtonProperty(type: .primary,
|
|
|
+ size: .s,
|
|
|
+ state: .normal,
|
|
|
+ buttonText: KMLocalizedString("OK"))
|
|
|
+ okButton.setTarget(self, action: #selector(okButtonClicked(_ :)))
|
|
|
+
|
|
|
+ cancelButton.properties = ComponentButtonProperty(type: .default_tertiary,
|
|
|
+ size: .s,
|
|
|
+ state: .normal,
|
|
|
+ buttonText: KMLocalizedString("Cancel"))
|
|
|
+ cancelButton.setTarget(self, action: #selector(cancelButtonClicked(_ :)))
|
|
|
+
|
|
|
+ makePropertiesButton.properties = ComponentButtonProperty(type: .default_tertiary,
|
|
|
+ size: .s,
|
|
|
+ state: .normal,
|
|
|
+ buttonText: KMLocalizedString("Make Properties Default"))
|
|
|
+ makePropertiesButton.setTarget(self, action: #selector(makePropertiesButtonClicked(_ :)))
|
|
|
+
|
|
|
+ overlayTextarea.properties = ComponentTextareaProperty(size: .s, state: .normal, isError: false, placeholderString: KMLocalizedString("Encrypted Content"), totalCount: -1, text: "", isDisabled: false)
|
|
|
+ overlayTextarea.delegate = self
|
|
|
+
|
|
|
+ fontSizeComboSelect.properties = ComponentSelectProperties(size: .s,
|
|
|
+ state: .normal,
|
|
|
+ isDisabled: false,
|
|
|
+ isError: false,
|
|
|
+ leftIcon: false,
|
|
|
+ placeholder: nil,
|
|
|
+ errorText: nil,
|
|
|
+ creatable: true,
|
|
|
+ text: "4 pt")
|
|
|
+
|
|
|
+ let menuItemString:[String] = ["4 pt",
|
|
|
+ "6 pt",
|
|
|
+ "8 pt",
|
|
|
+ "9 pt",
|
|
|
+ "10 pt",
|
|
|
+ "11 pt",
|
|
|
+ "12 pt",
|
|
|
+ "13 pt",
|
|
|
+ "14 pt",
|
|
|
+ "15 pt",
|
|
|
+ "16 pt",
|
|
|
+ "17 pt",
|
|
|
+ "18 pt",
|
|
|
+ "24 pt",
|
|
|
+ "36 pt",
|
|
|
+ "48 pt",
|
|
|
+ "64 pt",
|
|
|
+ "72 pt",
|
|
|
+ "98 pt",
|
|
|
+ "144 pt",
|
|
|
+ "288 pt"]
|
|
|
+
|
|
|
+ var menuItemArr: [ComponentMenuitemProperty] = []
|
|
|
+ for language in menuItemString {
|
|
|
+ let itemProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
|
|
|
+ itemSelected: false,
|
|
|
+ isDisabled: false,
|
|
|
+ keyEquivalent: nil,
|
|
|
+ text: language)
|
|
|
+ menuItemArr.append(itemProperty)
|
|
|
+ }
|
|
|
+
|
|
|
+ fontSizeComboSelect.delegate = self
|
|
|
+ fontSizeComboSelect.updateMenuItemsArr(menuItemArr)
|
|
|
+ }
|
|
|
+
|
|
|
+ override func updateUILanguage() {
|
|
|
+ super.updateUILanguage()
|
|
|
+
|
|
|
+ outlineColorLabel.stringValue = KMLocalizedString("Redaction Mark Outline Color:")
|
|
|
+ fillColorLabel.stringValue = KMLocalizedString("Redact Area Fill Color:")
|
|
|
+ overlayTextLabel.stringValue = KMLocalizedString("Overlay Text:")
|
|
|
+ alignementLabel.stringValue = KMLocalizedString("Text Alignment")
|
|
|
+ fontSizeLabel.stringValue = KMLocalizedString("Font Size")
|
|
|
+ fontColorLabel.stringValue = String(format: "%@:", KMLocalizedString("Font Color"))
|
|
|
+
|
|
|
+ titleLabel.stringValue = KMLocalizedString("Redact Properties")
|
|
|
+ subLabel.stringValue = KMLocalizedString("Mark Color")
|
|
|
+
|
|
|
+ okButton.properties.buttonText = KMLocalizedString("OK")
|
|
|
+ cancelButton.properties.buttonText = KMLocalizedString("Cancel")
|
|
|
+ makePropertiesButton.properties.buttonText = KMLocalizedString("Make Properties Default")
|
|
|
+
|
|
|
+ okWidthButton.constant = okButton.properties.propertyInfo.viewWidth
|
|
|
+ cancelWidthButton.constant = cancelButton.properties.propertyInfo.viewWidth
|
|
|
+ makePropertiesWidthButton.constant = makePropertiesButton.properties.propertyInfo.viewWidth
|
|
|
+ }
|
|
|
+
|
|
|
+ override func updateUIThemeColor() {
|
|
|
+ super.updateUIThemeColor()
|
|
|
+
|
|
|
+ window?.contentView?.wantsLayer = true
|
|
|
+ window?.contentView?.layer?.backgroundColor = ComponentLibrary.shared.getComponentColorFromKey("colorBg/popup").cgColor
|
|
|
+
|
|
|
+ titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/1")
|
|
|
+ subLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
+ outlineColorLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
|
|
|
+ fillColorLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
|
|
|
+ overlayTextLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
+ fontColorLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
|
|
|
+ fontSizeLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
|
|
|
+ alignementLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
|
|
|
+ }
|
|
|
+
|
|
|
+ private func updateLabelUI() {
|
|
|
+ if overlayTextarea.properties.text.isEmpty == true {
|
|
|
+ fontColorLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label-dis")
|
|
|
+ fontSizeLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label-dis")
|
|
|
+ alignementLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label-dis")
|
|
|
+
|
|
|
+ fontSizeComboSelect.properties.isDisabled = true
|
|
|
+ fontSizeComboSelect.reloadData()
|
|
|
+
|
|
|
+ alightLeftButton.properties.isDisabled = true
|
|
|
+ alightLeftButton.reloadData()
|
|
|
+
|
|
|
+ alightCenteButton.properties.isDisabled = true
|
|
|
+ alightCenteButton.reloadData()
|
|
|
+
|
|
|
+ alightRightButton.properties.isDisabled = true
|
|
|
+ alightRightButton.reloadData()
|
|
|
+
|
|
|
+ } else {
|
|
|
+ fontColorLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
|
|
|
+ fontSizeLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
|
|
|
+ alignementLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("comp-form/colorText-label")
|
|
|
+
|
|
|
+ fontSizeComboSelect.properties.isDisabled = false
|
|
|
+ fontSizeComboSelect.reloadData()
|
|
|
+
|
|
|
+ alightLeftButton.properties.isDisabled = false
|
|
|
+ alightLeftButton.reloadData()
|
|
|
+
|
|
|
+ alightCenteButton.properties.isDisabled = false
|
|
|
+ alightCenteButton.reloadData()
|
|
|
+
|
|
|
+ alightRightButton.properties.isDisabled = false
|
|
|
+ alightRightButton.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override func windowDidLoad() {
|
|
|
super.windowDidLoad()
|
|
|
-
|
|
|
- self.outlineColorLabel.stringValue = KMLocalizedString("Redaction Mark Outline Color:")
|
|
|
- self.fillColorLabel.stringValue = KMLocalizedString("Redact Area Fill Color:")
|
|
|
- self.overlayTextButton.title = KMLocalizedString("Use Overlay Text")
|
|
|
- self.overlayTextLabel.stringValue = KMLocalizedString("Overlay Text:")
|
|
|
- // self.repeatTextButton.title = NSLocalizedString(@"Repeat Text");
|
|
|
- // self.autoSizeTextButton.title = NSLocalizedString(@"Auto-Size text to fit redaction region");
|
|
|
- self.alignementLabel.stringValue = KMLocalizedString("Text Alignment")
|
|
|
- self.fontSizeLabel.stringValue = KMLocalizedString("Font Size")
|
|
|
- self.fontColorLabel.stringValue = String(format: "%@:", KMLocalizedString("Font Color"))
|
|
|
- self.makePropertiesButton.title = KMLocalizedString("Make Properties Default")
|
|
|
- self.cancelButton.title = KMLocalizedString("Cancel")
|
|
|
- self.okButton.title = KMLocalizedString("OK")
|
|
|
-
|
|
|
- if let anno = self.readactAnnotation {
|
|
|
- self.outlineColorWell.color = anno.borderColor() ?? .red
|
|
|
- self.fillColorWell.color = anno.interiorColor() ?? .clear
|
|
|
- self.fontColorWell.color = anno.fontColor() ?? .red
|
|
|
-
|
|
|
- self.fontSizeComboBox.stringValue = String(format: "%.lf pt", anno.font().pointSize)
|
|
|
- var segment = 0
|
|
|
+
|
|
|
+ if let anno = readactAnnotation {
|
|
|
+ outlineColorItem.properties?.color = anno.borderColor() ?? .red
|
|
|
+ outlineColorItem.reloadData()
|
|
|
+
|
|
|
+ fillColorItem.properties?.color = anno.interiorColor() ?? .clear
|
|
|
+ fillColorItem.reloadData()
|
|
|
+
|
|
|
+ fontColorItem.properties?.color = anno.fontColor() ?? .red
|
|
|
+ fontColorItem.reloadData()
|
|
|
+
|
|
|
+ fontSizeComboSelect.properties.text = String(format: "%.lf pt", anno.fontSize())
|
|
|
+ fontSizeComboSelect.reloadData()
|
|
|
+
|
|
|
if(anno.alignment().rawValue == 1) {
|
|
|
- segment = 1
|
|
|
+ alightLeftButton.properties.state = .normal
|
|
|
+ alightCenteButton.properties.state = .pressed
|
|
|
+ alightRightButton.properties.state = .normal
|
|
|
} else if (anno.alignment().rawValue == 2) {
|
|
|
- segment = 2
|
|
|
- }
|
|
|
- self.segmentedControl.setSelected(true, forSegment: segment)
|
|
|
- self.overlayTextField.stringValue = anno.overlayText() ?? ""
|
|
|
- if(anno.overlayText().isEmpty == false) {
|
|
|
- self.overlayTextButton.state = .on
|
|
|
+ alightLeftButton.properties.state = .normal
|
|
|
+ alightCenteButton.properties.state = .normal
|
|
|
+ alightRightButton.properties.state = .pressed
|
|
|
} else {
|
|
|
- self.overlayTextButton.state = .off
|
|
|
+ alightLeftButton.properties.state = .pressed
|
|
|
+ alightCenteButton.properties.state = .normal
|
|
|
+ alightRightButton.properties.state = .normal
|
|
|
}
|
|
|
- self.makePropertiesButton.isHidden = false
|
|
|
+ alightLeftButton.reloadData()
|
|
|
+ alightCenteButton.reloadData()
|
|
|
+ alightRightButton.reloadData()
|
|
|
+
|
|
|
+ overlayTextarea.properties.text = anno.overlayText() ?? ""
|
|
|
+ overlayTextarea.reloadData()
|
|
|
+
|
|
|
+ makePropertiesButton.isHidden = false
|
|
|
} else {
|
|
|
- self.outlineColorWell.color = KMPDFAnnotationRedactConfig.shared.redactOutlineColor!
|
|
|
- self.fillColorWell.color = KMPDFAnnotationRedactConfig.shared.redactFillColor!
|
|
|
- self.fontColorWell.color = KMPDFAnnotationRedactConfig.shared.redactFontColor!
|
|
|
- self.overlayTextButton.state = KMPDFAnnotationRedactConfig.shared.overlayText ? .on : .off
|
|
|
- // self.repeatTextButton.state = [KMPDFAnnotationRedactConfig sharedInstance].repeatText ? NSControlStateValueOn : NSControlStateValueOff;
|
|
|
- // self.autoSizeTextButton.state = [KMPDFAnnotationRedactConfig sharedInstance].autoSizeText ? NSControlStateValueOn : NSControlStateValueOff;
|
|
|
- self.overlayTextField.stringValue = KMPDFAnnotationRedactConfig.shared.overlayTextString
|
|
|
- self.fontSizeComboBox.stringValue = String(format: "%ld pt", KMPDFAnnotationRedactConfig.shared.fontSize)
|
|
|
- var segment = 0
|
|
|
+ outlineColorItem.properties?.color = KMPDFAnnotationRedactConfig.shared.redactOutlineColor!
|
|
|
+ outlineColorItem.reloadData()
|
|
|
+
|
|
|
+ fillColorItem.properties?.color = KMPDFAnnotationRedactConfig.shared.redactFillColor!
|
|
|
+ fillColorItem.reloadData()
|
|
|
+
|
|
|
+ fontColorItem.properties?.color = KMPDFAnnotationRedactConfig.shared.redactFontColor!
|
|
|
+ fontColorItem.reloadData()
|
|
|
+
|
|
|
+ overlayTextarea.properties.text = KMPDFAnnotationRedactConfig.shared.overlayTextString
|
|
|
+ overlayTextarea.reloadData()
|
|
|
+
|
|
|
+ fontSizeComboSelect.properties.text = String(format: "%ld pt", KMPDFAnnotationRedactConfig.shared.fontSize)
|
|
|
+ fontSizeComboSelect.reloadData()
|
|
|
+
|
|
|
if(KMPDFAnnotationRedactConfig.shared.textAlignment == 1) {
|
|
|
- segment = 1
|
|
|
+ alightLeftButton.properties.state = .normal
|
|
|
+ alightCenteButton.properties.state = .pressed
|
|
|
+ alightRightButton.properties.state = .normal
|
|
|
} else if (KMPDFAnnotationRedactConfig.shared.textAlignment == 2) {
|
|
|
- segment = 2
|
|
|
+ alightLeftButton.properties.state = .normal
|
|
|
+ alightCenteButton.properties.state = .normal
|
|
|
+ alightRightButton.properties.state = .pressed
|
|
|
+ } else {
|
|
|
+ alightLeftButton.properties.state = .pressed
|
|
|
+ alightCenteButton.properties.state = .normal
|
|
|
+ alightRightButton.properties.state = .normal
|
|
|
}
|
|
|
- self.segmentedControl.setSelected(true, forSegment: segment)
|
|
|
- self.makePropertiesButton.isHidden = true
|
|
|
+ alightLeftButton.reloadData()
|
|
|
+ alightCenteButton.reloadData()
|
|
|
+ alightRightButton.reloadData()
|
|
|
+
|
|
|
+ makePropertiesButton.isHidden = true
|
|
|
}
|
|
|
|
|
|
- self.updateUIState()
|
|
|
+ updateLabelUI()
|
|
|
+ }
|
|
|
+
|
|
|
+ //MARK: - Action
|
|
|
+ @objc func alightLeftButtonClicked(_ sender: NSView) {
|
|
|
+ alightCenteButton.properties.state = .normal
|
|
|
+ alightRightButton.properties.state = .normal
|
|
|
+
|
|
|
+ alightCenteButton.reloadData()
|
|
|
+ alightRightButton.reloadData()
|
|
|
}
|
|
|
|
|
|
- @IBAction func cancel_button(_ sender: AnyObject?) {
|
|
|
+ @objc func alightRightButtonClicked(_ sender: NSView) {
|
|
|
+ alightLeftButton.properties.state = .normal
|
|
|
+ alightRightButton.properties.state = .normal
|
|
|
+
|
|
|
+ alightLeftButton.reloadData()
|
|
|
+ alightRightButton.reloadData()
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func alightCenterButtonClicked(_ sender: NSView) {
|
|
|
+ alightLeftButton.properties.state = .normal
|
|
|
+ alightCenteButton.properties.state = .normal
|
|
|
+
|
|
|
+ alightLeftButton.reloadData()
|
|
|
+ alightCenteButton.reloadData()
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func makePropertiesButtonClicked(_ sender: AnyObject?) {
|
|
|
+ let s = (fontSizeComboSelect.properties.text as? NSString)?.trimmingCharacters(in: CharacterSet(charactersIn: " pt")) ?? ""
|
|
|
+ let fontsize = Int(s) ?? 12
|
|
|
+
|
|
|
+ KMPDFAnnotationRedactConfig.shared.redactOutlineColor = outlineColorItem.properties?.color
|
|
|
+ KMPDFAnnotationRedactConfig.shared.redactFillColor = fillColorItem.properties?.color
|
|
|
+ KMPDFAnnotationRedactConfig.shared.redactFontColor = fontColorItem.properties?.color
|
|
|
+ KMPDFAnnotationRedactConfig.shared.fontSize = fontsize
|
|
|
+ if alightLeftButton.properties.state == .pressed {
|
|
|
+ KMPDFAnnotationRedactConfig.shared.textAlignment = 0
|
|
|
+ } else if alightCenteButton.properties.state == .pressed {
|
|
|
+ KMPDFAnnotationRedactConfig.shared.textAlignment = 1
|
|
|
+ } else if alightRightButton.properties.state == .pressed {
|
|
|
+ KMPDFAnnotationRedactConfig.shared.textAlignment = 2
|
|
|
+ }
|
|
|
+ KMPDFAnnotationRedactConfig.shared.overlayTextString = overlayTextarea.properties.text
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func cancelButtonClicked(_ sender: AnyObject?) {
|
|
|
if self.callback != nil {
|
|
|
self.callback!(self.readactAnnotation)
|
|
|
}
|
|
|
self.km_quick_endSheet()
|
|
|
}
|
|
|
|
|
|
- @IBAction func sure_button(_ sender: AnyObject?) {
|
|
|
- let s = (self.fontSizeComboBox.stringValue as? NSString)?.trimmingCharacters(in: CharacterSet(charactersIn: " pt")) ?? ""
|
|
|
+ @objc func okButtonClicked(_ sender: AnyObject?) {
|
|
|
+ let s = (fontSizeComboSelect.properties.text as? NSString)?.trimmingCharacters(in: CharacterSet(charactersIn: " pt")) ?? ""
|
|
|
let fontsize = Int(s) ?? 12
|
|
|
+
|
|
|
var alignment: NSTextAlignment = .left
|
|
|
- if(self.segmentedControl.indexOfSelectedItem == 1) {
|
|
|
+ if alightCenteButton.properties.state == .pressed {
|
|
|
alignment = .center
|
|
|
- } else if (self.segmentedControl.indexOfSelectedItem == 2) {
|
|
|
+ } else if alightRightButton.properties.state == .pressed {
|
|
|
alignment = .right
|
|
|
}
|
|
|
-
|
|
|
- if(self.readactAnnotation == nil || self.makePropertiesButton.state == .on) {
|
|
|
- KMPDFAnnotationRedactConfig.shared.redactOutlineColor = self.outlineColorWell.color
|
|
|
- KMPDFAnnotationRedactConfig.shared.redactFillColor = self.fillColorWell.color
|
|
|
- KMPDFAnnotationRedactConfig.shared.redactFontColor = self.fontColorWell.color
|
|
|
- KMPDFAnnotationRedactConfig.shared.overlayText = self.overlayTextButton.state == .on
|
|
|
- KMPDFAnnotationRedactConfig.shared.fontSize = fontsize
|
|
|
- KMPDFAnnotationRedactConfig.shared.textAlignment = alignment.rawValue
|
|
|
- if(self.overlayTextButton.state == .on) {
|
|
|
- KMPDFAnnotationRedactConfig.shared.overlayTextString = self.overlayTextField.stringValue
|
|
|
- } else {
|
|
|
- KMPDFAnnotationRedactConfig.shared.overlayTextString = ""
|
|
|
- }
|
|
|
+
|
|
|
+ if let anno = readactAnnotation {
|
|
|
+ anno.setBorderColor(outlineColorItem.properties?.color)
|
|
|
+ anno.setInteriorColor(fillColorItem.properties?.color)
|
|
|
+ anno.setFontColor(fontColorItem.properties?.color)
|
|
|
+ anno.fontSize = fontsize.cgFloat
|
|
|
+ anno.setAlignment(alignment)
|
|
|
+ anno.setOverlayText(overlayTextarea.properties.text)
|
|
|
+ } else {
|
|
|
+ makePropertiesButtonClicked(makePropertiesButton)
|
|
|
}
|
|
|
|
|
|
- if let anno = self.readactAnnotation {
|
|
|
- anno.setBorderColor(self.outlineColorWell.color)
|
|
|
- anno.setInteriorColor(self.fillColorWell.color)
|
|
|
- anno.setFontColor(self.fontColorWell.color)
|
|
|
- if(self.overlayTextButton.state == .on) {
|
|
|
- anno.setFont(.init(name: "Helvetica", size: fontsize.cgFloat))
|
|
|
- anno.setAlignment(alignment)
|
|
|
- anno.setOverlayText(self.overlayTextField.stringValue)
|
|
|
- } else {
|
|
|
- anno.setOverlayText("")
|
|
|
- }
|
|
|
- }
|
|
|
- if self.callback != nil {
|
|
|
- self.callback!(self.readactAnnotation)
|
|
|
- }
|
|
|
+ callback?(readactAnnotation)
|
|
|
+
|
|
|
self.km_quick_endSheet()
|
|
|
}
|
|
|
|
|
|
@IBAction func useOverlayText_button(_ sender: AnyObject?) {
|
|
|
- self.updateUIState()
|
|
|
+ updateLabelUI()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//MARK: - ComponentTextareaDelegate
|
|
|
+extension KMRedactPropertiesWindowController: ComponentTextareaDelegate {
|
|
|
+ func componentTextareaTextDidBeginEditing(_ view: ComponentTextarea) {
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- @IBAction func autoSzieText_button(_ sender: AnyObject?) {
|
|
|
- self.updateUIState()
|
|
|
+ func componentTextareaTextDidChange(_ view: ComponentTextarea) {
|
|
|
+ updateLabelUI()
|
|
|
}
|
|
|
|
|
|
- @IBAction func fontSize_Combox(_ sender: AnyObject?) {
|
|
|
+ func componentTextareaTextDidEndEditing(_ view: ComponentTextarea) {
|
|
|
|
|
|
}
|
|
|
+}
|
|
|
|
|
|
- func updateUIState() {
|
|
|
- let state = self.overlayTextButton.state
|
|
|
- let enabled = state == .on
|
|
|
- self.overlayTextLabel.isEnabled = enabled
|
|
|
- self.overlayTextField.isEnabled = enabled
|
|
|
- // self.autoSizeTextButton.enabled = state;
|
|
|
- self.fontSizeLabel.isEnabled = enabled
|
|
|
- self.fontSizeComboBox.isEnabled = enabled
|
|
|
- self.alignementLabel.isEnabled = enabled
|
|
|
- self.segmentedControl.isEnabled = enabled
|
|
|
- // self.repeatTextButton.enabled = state;
|
|
|
- self.fontColorLabel.isEnabled = enabled
|
|
|
- self.fontColorWell.isEnabled = enabled
|
|
|
- if(enabled) {
|
|
|
- self.overlayTextLabel.textColor = .labelColor
|
|
|
- self.fontSizeLabel.textColor = .labelColor
|
|
|
- self.alignementLabel.textColor = .labelColor
|
|
|
- self.fontColorLabel.textColor = .labelColor
|
|
|
- } else {
|
|
|
- self.overlayTextLabel.textColor = .tertiaryLabelColor
|
|
|
- self.fontSizeLabel.textColor = .tertiaryLabelColor
|
|
|
- self.fontColorLabel.textColor = .tertiaryLabelColor
|
|
|
- self.alignementLabel.textColor = .tertiaryLabelColor
|
|
|
+//MARK: - ComponentSelectDelegate
|
|
|
+extension KMRedactPropertiesWindowController: ComponentSelectDelegate {
|
|
|
+
|
|
|
+ func componentSelectDidSelect(view: ComponentSelect?, menuItemProperty: ComponentMenuitemProperty?) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ func componentSelectTextDidBeginEditing(_ view: ComponentSelect) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ func componentSelectTextDidChange(_ view: ComponentSelect) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ func componentSelectTextDidEndEditing(_ view: ComponentSelect) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ func componentSelectTextDidEndEditing(_ view: ComponentSelect, removeUnit text: String?) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func fontColorChange(_ sender: Any) {
|
|
|
+ if let color = (sender as? NSColorPanel)?.color {
|
|
|
+ fontColorItem.properties?.color = color
|
|
|
+ fontColorItem.reloadData()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @objc func borderColorChange(_ sender: Any) {
|
|
|
+ if let color = (sender as? NSColorPanel)?.color {
|
|
|
+ outlineColorItem.properties?.color = color
|
|
|
+ outlineColorItem.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func fillColorChange(_ sender: Any) {
|
|
|
+ if let color = (sender as? NSColorPanel)?.color {
|
|
|
+ fillColorItem.properties?.color = color
|
|
|
+ fillColorItem.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+//MARK: - ComponentSelectDelegate
|
|
|
+extension KMRedactPropertiesWindowController: ComponentCColorDelegate {
|
|
|
+ func componentCColorDidChooseColor(_ view: NSView, _ color: NSColor?) {
|
|
|
+ let colorPanel = NSColorPanel.shared
|
|
|
+
|
|
|
+ colorPanel.setTarget(self)
|
|
|
+ colorPanel.showsAlpha = false
|
|
|
+
|
|
|
+ if (view == fontColorItem) {
|
|
|
+ fontColorItem.properties?.state = .normal
|
|
|
+ fontColorItem.reloadData()
|
|
|
+
|
|
|
+ colorPanel.setAction(#selector(self.fontColorChange(_:)))
|
|
|
+ } else if(view == outlineColorItem) {
|
|
|
+ outlineColorItem.properties?.state = .normal
|
|
|
+ outlineColorItem.reloadData()
|
|
|
+
|
|
|
+ colorPanel.setAction(#selector(self.borderColorChange(_:)))
|
|
|
+ } else if(view == fillColorItem) {
|
|
|
+ fillColorItem.properties?.state = .normal
|
|
|
+ fillColorItem.reloadData()
|
|
|
+
|
|
|
+ colorPanel.setAction(#selector(self.fillColorChange(_:)))
|
|
|
+ }
|
|
|
+ colorPanel.orderFront(nil)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|