|
@@ -30,7 +30,17 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
@IBOutlet var colorOpacitySelect: ComponentSelect!
|
|
|
|
|
|
private var familyNames = CPDFFont.familyNames
|
|
|
-
|
|
|
+
|
|
|
+ private let fontStyle_boldItem: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: "fontStyle_bold"), identifier: "fontStyle_bold")
|
|
|
+ private let fontStyle_ItalityItem: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: "fontStyle_Itality"), identifier: "fontStyle_Itality")
|
|
|
+ private let fontStyle_CenterItem: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: "fontStyle_Center"), identifier: "fontStyle_Center")
|
|
|
+ private let fontStyle_Underline: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: "fontStyle_Underline"), identifier: "fontStyle_Underline")
|
|
|
+
|
|
|
+ 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")
|
|
|
+ private let fontAlign_rightItem: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: "fontAlign_right"), identifier: "fontAlign_right")
|
|
|
+ private let fontAlign_justifyItem: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: "fontAlign_justify"), identifier: "fontAlign_justify")
|
|
|
+
|
|
|
var pdfView: CPDFListView?
|
|
|
|
|
|
var currentArea: CPDFEditTextArea?
|
|
@@ -98,21 +108,23 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
if true {
|
|
|
var sizeItemArr: [ComponentMenuitemProperty] = []
|
|
|
for string in KMHeaderFooterManager.getFontSize() {
|
|
|
- let item = ComponentMenuitemProperty(type: .normal, text: string, identifier: string)
|
|
|
+ let item = ComponentMenuitemProperty(type: .normal, text: string + " pt", identifier: string)
|
|
|
sizeItemArr.append(item)
|
|
|
}
|
|
|
fontSizeSelect.updateMenuItemsArr(sizeItemArr)
|
|
|
}
|
|
|
fontSizeSelect.delegate = self
|
|
|
-
|
|
|
+
|
|
|
+ if true {
|
|
|
+ let itemArr: [ComponentCSelectorProperty] = [fontStyle_boldItem, fontStyle_ItalityItem, fontStyle_CenterItem, fontStyle_Underline]
|
|
|
+ fontStyleGroup.updateItemProperty(itemArr)
|
|
|
+ fontStyleGroup.delegate = self
|
|
|
+ }
|
|
|
|
|
|
if true {
|
|
|
- var itemArr: [ComponentCSelectorProperty] = []
|
|
|
- for string in ["fontAlign_left", "fontAlign_center", "fontAlign_right", "fontAlign_justify"] {
|
|
|
- let propertyItem: ComponentCSelectorProperty = ComponentCSelectorProperty.init(size: .m, state: .normal, iconImage: NSImage(named: string))
|
|
|
- itemArr.append(propertyItem)
|
|
|
- }
|
|
|
+ let itemArr: [ComponentCSelectorProperty] = [fontAlign_leftItem, fontAlign_centerItem, fontAlign_rightItem, fontAlign_justifyItem]
|
|
|
fontAlignmentGroup.updateItemProperty(itemArr)
|
|
|
+ fontAlignmentGroup.delegate = self
|
|
|
}
|
|
|
|
|
|
//Color
|
|
@@ -195,27 +207,49 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
|
|
|
if let fontSizes = pdfView?.km_editTextAreasFontSizes([area]) {
|
|
|
if let fontSize = fontSizes.first {
|
|
|
-
|
|
|
+ fontSizeSelect.properties.text = String(format: "%.0f", fontSize)
|
|
|
+ fontSizeSelect.reloadData()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if let bolds = pdfView?.km_editTextAreasFontBolds([area]) {
|
|
|
- if let bold = bolds.first {
|
|
|
-
|
|
|
+ if let bold = bolds.first, bold == true {
|
|
|
+ fontStyle_boldItem.state = .pressed
|
|
|
+ } else {
|
|
|
+ fontStyle_boldItem.state = .normal
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if let italitys = pdfView?.km_editTextAreasFontItalics([area]) {
|
|
|
- if let itality = italitys.first {
|
|
|
-
|
|
|
+ if let itality = italitys.first, itality == true {
|
|
|
+ fontStyle_ItalityItem.state = .pressed
|
|
|
+ } else {
|
|
|
+ fontStyle_ItalityItem.state = .normal
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+ fontStyle_CenterItem.state = .normal
|
|
|
+ fontStyle_Underline.state = .normal
|
|
|
+
|
|
|
+ fontStyleGroup.reloadData()
|
|
|
|
|
|
if let alignments = pdfView?.km_editTextAreasTextAlignments([area]) {
|
|
|
if let alignment = alignments.first {
|
|
|
|
|
|
+ fontAlign_leftItem.state = .normal
|
|
|
+ fontAlign_centerItem.state = .normal
|
|
|
+ fontAlign_rightItem.state = .normal
|
|
|
+ fontAlign_justifyItem.state = .normal
|
|
|
+
|
|
|
+ if alignment == .left {
|
|
|
+ fontAlign_leftItem.state = .pressed
|
|
|
+ } else if alignment == .center {
|
|
|
+ fontAlign_centerItem.state = .pressed
|
|
|
+ } else if alignment == .right {
|
|
|
+ fontAlign_rightItem.state = .pressed
|
|
|
+ } else if alignment == .justified {
|
|
|
+ fontAlign_justifyItem.state = .pressed
|
|
|
+ }
|
|
|
+ fontAlignmentGroup.reloadData()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -250,6 +284,11 @@ class KMEditPDFTextPropertyViewController: NSViewController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ override func mouseDown(with event: NSEvent) {
|
|
|
+ super.mouseDown(with: event)
|
|
|
+
|
|
|
+ view.window?.makeFirstResponder(nil)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -319,3 +358,33 @@ extension KMEditPDFTextPropertyViewController: ComponentSliderDelegate {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+//MARK: - ComponentCSelectorGroupDelegate
|
|
|
+extension KMEditPDFTextPropertyViewController: ComponentCSelectorGroupDelegate {
|
|
|
+ func componentCSelectorGroupDidChoose(_ view: ComponentCSelectorGroup, _ item: ComponentCSelectorItem) {
|
|
|
+ if view == fontStyleGroup {
|
|
|
+ if item.properties.identifier == "fontStyle_bold" {
|
|
|
+ pdfView?.setEditingTextarea_Bold()
|
|
|
+ } else if item.properties.identifier == "fontStyle_Itality" {
|
|
|
+ pdfView?.setEditingTextarea_Italic()
|
|
|
+ } else if item.properties.identifier == "fontStyle_Center" {
|
|
|
+
|
|
|
+ } else if item.properties.identifier == "fontStyle_Underline" {
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if view == fontAlignmentGroup {
|
|
|
+ if item.properties.identifier == "fontAlign_left" {
|
|
|
+ pdfView?.setEditingTextarea_Alignment(align: .left)
|
|
|
+ } else if item.properties.identifier == "fontAlign_center" {
|
|
|
+ pdfView?.setEditingTextarea_Alignment(align: .center)
|
|
|
+ } else if item.properties.identifier == "fontAlign_right" {
|
|
|
+ pdfView?.setEditingTextarea_Alignment(align: .right)
|
|
|
+ } else if item.properties.identifier == "fontAlign_justify" {
|
|
|
+ pdfView?.setEditingTextarea_Alignment(align: .justified)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ reloadData()
|
|
|
+
|
|
|
+ }
|
|
|
+}
|