|
@@ -27,7 +27,7 @@ class FormsTextFieldController: NSViewController {
|
|
|
@IBOutlet var defaultValueLabel: NSTextField!
|
|
|
@IBOutlet var defaultValueTextarea: ComponentTextarea!
|
|
|
@IBOutlet var defaultValueCheckbox: ComponentCheckBox!
|
|
|
-
|
|
|
+
|
|
|
|
|
|
@IBOutlet var appearanceBox: NSBox!
|
|
|
//Color
|
|
@@ -36,7 +36,7 @@ class FormsTextFieldController: NSViewController {
|
|
|
@IBOutlet var fontColorGroup: ComponentCColorGroup!
|
|
|
@IBOutlet var borderColorGroup: ComponentCColorGroup!
|
|
|
@IBOutlet var fillColorGroup: ComponentCColorGroup!
|
|
|
-
|
|
|
+
|
|
|
//Font
|
|
|
@IBOutlet var fontBGView: NSView!
|
|
|
@IBOutlet var fontLabel: NSTextField!
|
|
@@ -44,12 +44,12 @@ class FormsTextFieldController: NSViewController {
|
|
|
@IBOutlet var fontStyleSelect: ComponentSelect!
|
|
|
@IBOutlet var fontSizeSelect: ComponentSelect!
|
|
|
@IBOutlet var fontAlignmentGroup: ComponentCSelectorGroup!
|
|
|
-
|
|
|
+
|
|
|
|
|
|
private var tabIndex: Int = 0
|
|
|
private var generalTabProperty: ComponentTabsProperty = ComponentTabsProperty(tabsType: .underline_Fill, state: .normal, showIcon: false, title: KMLocalizedString("General"))
|
|
|
private var appearanceTabProperty: ComponentTabsProperty = ComponentTabsProperty(tabsType: .underline_Fill, state: .normal, showIcon: false, title: KMLocalizedString("Appearance"))
|
|
|
-
|
|
|
+
|
|
|
private var familyNames = CPDFFont.familyNames
|
|
|
private let fontAlign_leftItem: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: "fontAlign_left"), identifier: "fontAlign_left")
|
|
|
private let fontAlign_centerItem: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: "fontAlign_center"), identifier: "fontAlign_center")
|
|
@@ -72,7 +72,7 @@ class FormsTextFieldController: NSViewController {
|
|
|
func setupProperty() {
|
|
|
typeTabs.updateItemProperty([generalTabProperty, appearanceTabProperty])
|
|
|
typeTabs.delegate = self
|
|
|
-
|
|
|
+
|
|
|
//MARK: -General
|
|
|
nameInput.properties = ComponentInputProperty(size: .s, text: "")
|
|
|
nameInput.delegate = self
|
|
@@ -149,7 +149,7 @@ class FormsTextFieldController: NSViewController {
|
|
|
func reloadUI() {
|
|
|
self.view.wantsLayer = true
|
|
|
self.view.layer?.backgroundColor = ComponentLibrary.shared.getComponentColorFromKey("colorBg/layout-middle").cgColor
|
|
|
-
|
|
|
+
|
|
|
generalBox.fillColor = NSColor.clear
|
|
|
|
|
|
appearanceBox.fillColor = NSColor.clear
|
|
@@ -166,7 +166,7 @@ class FormsTextFieldController: NSViewController {
|
|
|
formFieldLabel.stringValue = KMLocalizedString("Form Field")
|
|
|
formFieldLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
formFieldLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
|
|
|
-
|
|
|
+
|
|
|
defaultValueLabel.stringValue = KMLocalizedString("Default Value")
|
|
|
defaultValueLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
defaultValueLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
|
|
@@ -261,7 +261,7 @@ class FormsTextFieldController: NSViewController {
|
|
|
print("1")
|
|
|
|
|
|
var name: String?
|
|
|
- var formFieldIndex: Int = 0
|
|
|
+ var formFieldIndex: Int = -1
|
|
|
var defaultValueText: String?
|
|
|
var isMultiLine: Bool = false
|
|
|
|
|
@@ -294,7 +294,7 @@ class FormsTextFieldController: NSViewController {
|
|
|
defaultValueText = annotation.stringValue
|
|
|
isMultiLine = annotation.isMultiline
|
|
|
|
|
|
- textColor = annotation.color
|
|
|
+ textColor = annotation.fontColor
|
|
|
borderColor = annotation.borderColor
|
|
|
fillColor = annotation.backgroundColor
|
|
|
|
|
@@ -304,15 +304,64 @@ class FormsTextFieldController: NSViewController {
|
|
|
alignment = annotation.alignment
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ if let value = name {
|
|
|
+ nameInput.properties.text = value
|
|
|
+ }
|
|
|
+ if formFieldIndex >= 0 {
|
|
|
+ formFieldSelect.selectItemAtIndex(formFieldIndex)
|
|
|
+ }
|
|
|
+ if let value = defaultValueText {
|
|
|
+ defaultValueTextarea.properties.text = value
|
|
|
+ }
|
|
|
+ defaultValueCheckbox.properties.checkboxType = isMultiLine ? .selected : .normal
|
|
|
+
|
|
|
+ if let value = textColor {
|
|
|
+ fontColorGroup.currentColor = value
|
|
|
+ } else {
|
|
|
+ fontColorGroup.currentColor = nil
|
|
|
+ }
|
|
|
+
|
|
|
+ if let value = borderColor {
|
|
|
+ borderColorGroup.currentColor = value
|
|
|
+ } else {
|
|
|
+ borderColorGroup.currentColor = nil
|
|
|
+ }
|
|
|
+
|
|
|
+ if let value = fillColor {
|
|
|
+ fillColorGroup.currentColor = value
|
|
|
+ } else {
|
|
|
+ fillColorGroup.currentColor = nil
|
|
|
+ }
|
|
|
|
|
|
+ fontNameSelect.properties.text = fontName ?? "-"
|
|
|
+ fontStyleSelect.properties.text = fontStyle ?? "-"
|
|
|
+ if let value = fontSize {
|
|
|
+ fontSizeSelect.properties.text = String(format: "%.0f", value)
|
|
|
+ } else {
|
|
|
+ fontSizeSelect.properties.text = "-"
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ nameInput.reloadData()
|
|
|
+ formFieldSelect.reloadData()
|
|
|
+ defaultValueTextarea.reloadData()
|
|
|
+ defaultValueCheckbox.reloadData()
|
|
|
|
|
|
+ fontColorGroup.refreshUI()
|
|
|
+ borderColorGroup.refreshUI()
|
|
|
+ fillColorGroup.refreshUI()
|
|
|
+
|
|
|
+ fontNameSelect.reloadData()
|
|
|
+ fontStyleSelect.reloadData()
|
|
|
+ fontSizeSelect.reloadData()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@objc func multilineCheckboxClicked(_ box: ComponentCheckBox) {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//MARK: - Mouse
|
|
|
override func mouseDown(with event: NSEvent) {
|
|
@@ -349,13 +398,13 @@ extension FormsTextFieldController: ComponentInputDelegate {
|
|
|
//MARK: - ComponentCColorDelegate
|
|
|
extension FormsTextFieldController: ComponentCColorDelegate {
|
|
|
func componentCColorDidChooseColor(_ view: NSView, _ color: NSColor?) {
|
|
|
-// if view == fontColorGroup {
|
|
|
-// CPDFFreeTextAnnotation.updateFontColor(annotations, color, withPDFView: pdfView)
|
|
|
-// } else if view == borderColorGroup {
|
|
|
-// CPDFFreeTextAnnotation.updateBorderColor(annotations, color, withPDFView: pdfView)
|
|
|
-// } else if view == fillColorGroup {
|
|
|
-// CPDFFreeTextAnnotation.updateColor(annotations, color, withPDFView: pdfView)
|
|
|
-// }
|
|
|
+ // if view == fontColorGroup {
|
|
|
+ // CPDFFreeTextAnnotation.updateFontColor(annotations, color, withPDFView: pdfView)
|
|
|
+ // } else if view == borderColorGroup {
|
|
|
+ // CPDFFreeTextAnnotation.updateBorderColor(annotations, color, withPDFView: pdfView)
|
|
|
+ // } else if view == fillColorGroup {
|
|
|
+ // CPDFFreeTextAnnotation.updateColor(annotations, color, withPDFView: pdfView)
|
|
|
+ // }
|
|
|
reloadData()
|
|
|
}
|
|
|
}
|
|
@@ -364,26 +413,26 @@ extension FormsTextFieldController: ComponentCColorDelegate {
|
|
|
extension FormsTextFieldController: ComponentSelectDelegate {
|
|
|
func componentSelectTextDidEndEditing(_ view: ComponentSelect, removeUnit text: String?) {
|
|
|
if let result = text {
|
|
|
-// if view == opacitySelect {
|
|
|
-// let opacity = max(0, min(1, result.stringToCGFloat()/100))
|
|
|
-// CPDFFreeTextAnnotation.updateOpacity(annotations, opacity, withPDFView: pdfView)
|
|
|
-// } else if view == lineWidthSelect {
|
|
|
-// var value = result.stringToCGFloat()
|
|
|
-// if value > 18 {
|
|
|
-// value = 18
|
|
|
-// } else if value < 1 {
|
|
|
-// value = 1
|
|
|
-// }
|
|
|
-// CPDFFreeTextAnnotation.updateLineWidth(annotations, value, withPDFView: pdfView)
|
|
|
-// } else if view == lineDashSelect {
|
|
|
-// var value = result.stringToCGFloat()
|
|
|
-// if value > 18 {
|
|
|
-// value = 18
|
|
|
-// } else if value < 1 {
|
|
|
-// value = 1
|
|
|
-// }
|
|
|
-// CPDFFreeTextAnnotation.updateDashPattern(annotations, value, withPDFView: pdfView)
|
|
|
-// }
|
|
|
+ // if view == opacitySelect {
|
|
|
+ // let opacity = max(0, min(1, result.stringToCGFloat()/100))
|
|
|
+ // CPDFFreeTextAnnotation.updateOpacity(annotations, opacity, withPDFView: pdfView)
|
|
|
+ // } else if view == lineWidthSelect {
|
|
|
+ // var value = result.stringToCGFloat()
|
|
|
+ // if value > 18 {
|
|
|
+ // value = 18
|
|
|
+ // } else if value < 1 {
|
|
|
+ // value = 1
|
|
|
+ // }
|
|
|
+ // CPDFFreeTextAnnotation.updateLineWidth(annotations, value, withPDFView: pdfView)
|
|
|
+ // } else if view == lineDashSelect {
|
|
|
+ // var value = result.stringToCGFloat()
|
|
|
+ // if value > 18 {
|
|
|
+ // value = 18
|
|
|
+ // } else if value < 1 {
|
|
|
+ // value = 1
|
|
|
+ // }
|
|
|
+ // CPDFFreeTextAnnotation.updateDashPattern(annotations, value, withPDFView: pdfView)
|
|
|
+ // }
|
|
|
reloadData()
|
|
|
}
|
|
|
}
|
|
@@ -393,39 +442,39 @@ extension FormsTextFieldController: ComponentSelectDelegate {
|
|
|
if let textUnit = view?.properties.textUnit {
|
|
|
result = result.stringByDeleteCharString(textUnit)
|
|
|
}
|
|
|
-// if view == fontNameSelect {
|
|
|
-// var styleName = "Regular"
|
|
|
-// let styleNames = CPDFFont.fontNames(forFamilyName: result)
|
|
|
-// if let first = styleNames.first {
|
|
|
-// styleName = first
|
|
|
-// }
|
|
|
-// CPDFFreeTextAnnotation.updateFont(annotations, CPDFFont(familyName: result, fontStyle: styleName), withPDFView: pdfView)
|
|
|
-// } else if view == fontStyleSelect {
|
|
|
-// let styleName = fontNameSelect.properties.text ?? "Helvetica"
|
|
|
-// CPDFFreeTextAnnotation.updateFont(annotations, CPDFFont(familyName: result, fontStyle: styleName), withPDFView: pdfView)
|
|
|
-// } else if view == fontSizeSelect {
|
|
|
-// let size = result.stringToCGFloat()
|
|
|
-// CPDFFreeTextAnnotation.updateFontSize(annotations, size, withPDFView: pdfView)
|
|
|
-// } else if view == opacitySelect {
|
|
|
-// let opacity = max(0, min(1, result.stringToCGFloat()/100))
|
|
|
-// CPDFFreeTextAnnotation.updateOpacity(annotations, opacity, withPDFView: pdfView)
|
|
|
-// } else if view == lineWidthSelect {
|
|
|
-// var value = result.stringToCGFloat()
|
|
|
-// if value > 18 {
|
|
|
-// value = 18
|
|
|
-// } else if value < 1 {
|
|
|
-// value = 1
|
|
|
-// }
|
|
|
-// CPDFFreeTextAnnotation.updateLineWidth(annotations, value, withPDFView: pdfView)
|
|
|
-// } else if view == lineDashSelect {
|
|
|
-// var value = result.stringToCGFloat()
|
|
|
-// if value > 18 {
|
|
|
-// value = 18
|
|
|
-// } else if value < 1 {
|
|
|
-// value = 1
|
|
|
-// }
|
|
|
-// CPDFFreeTextAnnotation.updateDashPattern(annotations, value, withPDFView: pdfView)
|
|
|
-// }
|
|
|
+ // if view == fontNameSelect {
|
|
|
+ // var styleName = "Regular"
|
|
|
+ // let styleNames = CPDFFont.fontNames(forFamilyName: result)
|
|
|
+ // if let first = styleNames.first {
|
|
|
+ // styleName = first
|
|
|
+ // }
|
|
|
+ // CPDFFreeTextAnnotation.updateFont(annotations, CPDFFont(familyName: result, fontStyle: styleName), withPDFView: pdfView)
|
|
|
+ // } else if view == fontStyleSelect {
|
|
|
+ // let styleName = fontNameSelect.properties.text ?? "Helvetica"
|
|
|
+ // CPDFFreeTextAnnotation.updateFont(annotations, CPDFFont(familyName: result, fontStyle: styleName), withPDFView: pdfView)
|
|
|
+ // } else if view == fontSizeSelect {
|
|
|
+ // let size = result.stringToCGFloat()
|
|
|
+ // CPDFFreeTextAnnotation.updateFontSize(annotations, size, withPDFView: pdfView)
|
|
|
+ // } else if view == opacitySelect {
|
|
|
+ // let opacity = max(0, min(1, result.stringToCGFloat()/100))
|
|
|
+ // CPDFFreeTextAnnotation.updateOpacity(annotations, opacity, withPDFView: pdfView)
|
|
|
+ // } else if view == lineWidthSelect {
|
|
|
+ // var value = result.stringToCGFloat()
|
|
|
+ // if value > 18 {
|
|
|
+ // value = 18
|
|
|
+ // } else if value < 1 {
|
|
|
+ // value = 1
|
|
|
+ // }
|
|
|
+ // CPDFFreeTextAnnotation.updateLineWidth(annotations, value, withPDFView: pdfView)
|
|
|
+ // } else if view == lineDashSelect {
|
|
|
+ // var value = result.stringToCGFloat()
|
|
|
+ // if value > 18 {
|
|
|
+ // value = 18
|
|
|
+ // } else if value < 1 {
|
|
|
+ // value = 1
|
|
|
+ // }
|
|
|
+ // CPDFFreeTextAnnotation.updateDashPattern(annotations, value, withPDFView: pdfView)
|
|
|
+ // }
|
|
|
reloadData()
|
|
|
}
|
|
|
}
|
|
@@ -435,21 +484,21 @@ extension FormsTextFieldController: ComponentSelectDelegate {
|
|
|
//MARK: - ComponentCSelectorGroupDelegate
|
|
|
extension FormsTextFieldController: ComponentCSelectorGroupDelegate {
|
|
|
func componentCSelectorGroupDidChoose(_ view: ComponentCSelectorGroup, _ item: ComponentCSelectorItem) {
|
|
|
-// if view == fontAlignmentGroup {
|
|
|
-// if item.properties == fontAlign_leftItem {
|
|
|
-// CPDFFreeTextAnnotation.updateFontAlignment(annotations, .left, withPDFView: pdfView)
|
|
|
-// } else if item.properties == fontAlign_centerItem {
|
|
|
-// CPDFFreeTextAnnotation.updateFontAlignment(annotations, .center, withPDFView: pdfView)
|
|
|
-// } else if item.properties == fontAlign_rightItem {
|
|
|
-// CPDFFreeTextAnnotation.updateFontAlignment(annotations, .right, withPDFView: pdfView)
|
|
|
-// }
|
|
|
-// } else if view == lineTypeSelector {
|
|
|
-// if item.properties == solidProperty {
|
|
|
-// CPDFFreeTextAnnotation.updateBorderStyle(annotations, .solid, withPDFView: pdfView)
|
|
|
-// } else if item.properties == dashProperty {
|
|
|
-// CPDFFreeTextAnnotation.updateBorderStyle(annotations, .dashed, withPDFView: pdfView)
|
|
|
-// }
|
|
|
-// }
|
|
|
+ // if view == fontAlignmentGroup {
|
|
|
+ // if item.properties == fontAlign_leftItem {
|
|
|
+ // CPDFFreeTextAnnotation.updateFontAlignment(annotations, .left, withPDFView: pdfView)
|
|
|
+ // } else if item.properties == fontAlign_centerItem {
|
|
|
+ // CPDFFreeTextAnnotation.updateFontAlignment(annotations, .center, withPDFView: pdfView)
|
|
|
+ // } else if item.properties == fontAlign_rightItem {
|
|
|
+ // CPDFFreeTextAnnotation.updateFontAlignment(annotations, .right, withPDFView: pdfView)
|
|
|
+ // }
|
|
|
+ // } else if view == lineTypeSelector {
|
|
|
+ // if item.properties == solidProperty {
|
|
|
+ // CPDFFreeTextAnnotation.updateBorderStyle(annotations, .solid, withPDFView: pdfView)
|
|
|
+ // } else if item.properties == dashProperty {
|
|
|
+ // CPDFFreeTextAnnotation.updateBorderStyle(annotations, .dashed, withPDFView: pdfView)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
reloadData()
|
|
|
}
|
|
|
}
|