|
@@ -9,7 +9,7 @@ import Cocoa
|
|
|
import KMComponentLibrary
|
|
|
|
|
|
class KMNWatermarkPropertyController: NSViewController {
|
|
|
-
|
|
|
+
|
|
|
@IBOutlet var contendView: NSView!
|
|
|
@IBOutlet var titleLabel: NSTextField!
|
|
|
@IBOutlet var templateButton: ComponentButton!
|
|
@@ -17,23 +17,28 @@ class KMNWatermarkPropertyController: NSViewController {
|
|
|
@IBOutlet var typeTabs: ComponentTabs!
|
|
|
|
|
|
//Text
|
|
|
+ @IBOutlet var textBGView: NSView!
|
|
|
+ @IBOutlet var text_textareaView: ComponentTextarea!
|
|
|
@IBOutlet var fontNameSelect: ComponentSelect!
|
|
|
@IBOutlet var fontStyleSelect: ComponentSelect!
|
|
|
@IBOutlet var fontSizeSelect: ComponentSelect!
|
|
|
@IBOutlet var fontColorGroup: ComponentCColorGroup!
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
//File
|
|
|
-
|
|
|
-
|
|
|
+ @IBOutlet var fileBGView: NSView!
|
|
|
+ @IBOutlet var fileInputView: ComponentInput!
|
|
|
+ @IBOutlet var fileInputAddonView: ComponentInputAddon!
|
|
|
|
|
|
//Appearance
|
|
|
@IBOutlet var appearanceBGView: NSView!
|
|
|
@IBOutlet var appearanceLabel: NSTextField!
|
|
|
+ @IBOutlet var appearance_RotateSelect: ComponentSelect!
|
|
|
+ @IBOutlet var appearance_OpacitySelect: ComponentSelect!
|
|
|
@IBOutlet var appearanceScaleCheckbox: ComponentCheckBox!
|
|
|
@IBOutlet var appearanceScaleSelect: ComponentSelect!
|
|
|
@IBOutlet var appearanceTopPageRadio: ComponentRadio!
|
|
|
@IBOutlet var appearanceBottomPageRadio: ComponentRadio!
|
|
|
+ @IBOutlet var appearanceBGTopConst: NSLayoutConstraint!
|
|
|
|
|
|
//Position
|
|
|
@IBOutlet var positionBGView: NSView!
|
|
@@ -47,10 +52,17 @@ class KMNWatermarkPropertyController: NSViewController {
|
|
|
@IBOutlet var positionTileVertImage: NSImageView!
|
|
|
@IBOutlet var positionTileHoriInput: ComponentInputNumber!
|
|
|
@IBOutlet var positionTileVertInput: ComponentInputNumber!
|
|
|
+
|
|
|
+ //Save
|
|
|
+ @IBOutlet var saveTemplateBGView: NSView!
|
|
|
+ @IBOutlet var saveButton: ComponentButton!
|
|
|
|
|
|
private var textTabProperty = ComponentTabsProperty(tabsType: .underline_Fill, state: .normal, showIcon: false, title: KMLocalizedString("Text"))
|
|
|
private var fileTabProperty = ComponentTabsProperty(tabsType: .underline_Fill, state: .normal, showIcon: false, title: KMLocalizedString("File"))
|
|
|
|
|
|
+ private var familyNames = CPDFFont.familyNames
|
|
|
+
|
|
|
+
|
|
|
var watermarkModel: KMWatermarkModel = KMWatermarkModel()
|
|
|
|
|
|
override func viewDidLoad() {
|
|
@@ -58,7 +70,7 @@ class KMNWatermarkPropertyController: NSViewController {
|
|
|
// Do view setup here.
|
|
|
|
|
|
setupProperty()
|
|
|
-
|
|
|
+
|
|
|
reloadData()
|
|
|
}
|
|
|
|
|
@@ -69,14 +81,15 @@ class KMNWatermarkPropertyController: NSViewController {
|
|
|
titleLabel.stringValue = KMLocalizedString("Add Watermark")
|
|
|
titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-bold")
|
|
|
-
|
|
|
+
|
|
|
templateButton.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, onlyIcon: true, icon: NSImage(named: "icon_wm_template"))
|
|
|
|
|
|
typeTabs.updateItemProperty([textTabProperty, fileTabProperty])
|
|
|
+ typeTabs.delegate = self
|
|
|
|
|
|
|
|
|
//Text
|
|
|
- let familyNames = CPDFFont.familyNames
|
|
|
+ text_textareaView.properties = ComponentTextareaProperty(size: .s, placeholderString: KMLocalizedString("Please enter..."), totalCount: -1, text: "")
|
|
|
|
|
|
fontNameSelect.properties = ComponentSelectProperties(size: .s,
|
|
|
state: .normal,
|
|
@@ -88,21 +101,47 @@ class KMNWatermarkPropertyController: NSViewController {
|
|
|
menuItemArr.append(item)
|
|
|
}
|
|
|
fontNameSelect.updateMenuItemsArr(menuItemArr)
|
|
|
+ fontNameSelect.selectItemAtIndex(0)
|
|
|
+
|
|
|
+ fontStyleSelect.properties = ComponentSelectProperties(size: .s,
|
|
|
+ state: .normal,
|
|
|
+ text: "")
|
|
|
+
|
|
|
|
|
|
+ fontSizeSelect.properties = ComponentSelectProperties(size: .s,
|
|
|
+ state: .normal,
|
|
|
+ text: "")
|
|
|
|
|
|
//File
|
|
|
+ fileInputView.properties = ComponentInputProperty(size: .s,
|
|
|
+ state:.pressed ,
|
|
|
+ placeholder: "",
|
|
|
+ text: "Select Source File...",
|
|
|
+ creatable: false)
|
|
|
+ fileInputView.properties.propertyInfo.cornerRadius_topLeft = 0
|
|
|
+ fileInputView.properties.propertyInfo.cornerRadius_topRight = 0
|
|
|
+ fileInputView.properties.propertyInfo.cornerRadius_bottomLeft = 0
|
|
|
+ fileInputView.properties.propertyInfo.cornerRadius_bottomRight = 0
|
|
|
+ fileInputView.reloadData()
|
|
|
+
|
|
|
+ fileInputAddonView.properties = ComponentInputAddonProperty(size: .s,
|
|
|
+ state: .normal,
|
|
|
+ addOnBefore: false,
|
|
|
+ onlyRead: false,
|
|
|
+ addonType: .imageWithColor,
|
|
|
+ iconImage: NSImage(named: "icon_folder"))
|
|
|
+
|
|
|
|
|
|
-
|
|
|
//Appearance
|
|
|
appearanceLabel.stringValue = KMLocalizedString("Appearance")
|
|
|
appearanceLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
appearanceLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
|
|
|
-
|
|
|
+
|
|
|
appearanceScaleCheckbox.properties = ComponentCheckBoxProperty(size: .s, text: KMLocalizedString("Scale relative to target page"), checkboxType: .normal)
|
|
|
|
|
|
appearanceTopPageRadio.properties = ComponentCheckBoxProperty(size: .s, text: KMLocalizedString("At the top of the page"), checkboxType: .normal)
|
|
|
appearanceBottomPageRadio.properties = ComponentCheckBoxProperty(size: .s, text: KMLocalizedString("At the bottom of the page"), checkboxType: .normal)
|
|
|
-
|
|
|
+
|
|
|
let colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: NSColor(red: 205/255, green: 205/255, blue: 205/255, alpha: 1))
|
|
|
let colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: NSColor(red: 255/255, green: 173/255, blue: 173/255, alpha: 1))
|
|
|
let colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: NSColor(red: 146/255, green: 222/255, blue: 255/255, alpha: 1))
|
|
@@ -112,24 +151,36 @@ class KMNWatermarkPropertyController: NSViewController {
|
|
|
fontColorGroup.setUpWithColorPropertys([colorAProperty, colorBProperty, colorCProperty, colorDProperty], customItemProperty: colorEProperty)
|
|
|
|
|
|
|
|
|
+ appearanceScaleSelect.properties = ComponentSelectProperties(size: .s,
|
|
|
+ state: .normal,
|
|
|
+ text: "")
|
|
|
+
|
|
|
+ appearance_RotateSelect.properties = ComponentSelectProperties(size: .s,
|
|
|
+ state: .normal,
|
|
|
+ text: "")
|
|
|
+
|
|
|
+ appearance_OpacitySelect.properties = ComponentSelectProperties(size: .s,
|
|
|
+ state: .normal,
|
|
|
+ text: "")
|
|
|
+
|
|
|
//Position
|
|
|
positionLabel.stringValue = KMLocalizedString("Position (mm)")
|
|
|
positionLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
positionLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
|
|
|
-
|
|
|
+
|
|
|
positionItemView.properties = ComponentCPositionProperty(rowCount: 3, columnCount: 3, dash: false, selRow: 1, selColumn: 1)
|
|
|
|
|
|
positionXInput.properties = ComponentInputNumberProperty(alignment: .left,
|
|
|
- size: .s,
|
|
|
- minSize: -1000,
|
|
|
- maxSize: 1000,
|
|
|
- text: "0")
|
|
|
+ size: .s,
|
|
|
+ minSize: -1000,
|
|
|
+ maxSize: 1000,
|
|
|
+ text: "0")
|
|
|
|
|
|
positionYInput.properties = ComponentInputNumberProperty(alignment: .left,
|
|
|
- size: .s,
|
|
|
- minSize: -1000,
|
|
|
- maxSize: 1000,
|
|
|
- text: "0")
|
|
|
+ size: .s,
|
|
|
+ minSize: -1000,
|
|
|
+ maxSize: 1000,
|
|
|
+ text: "0")
|
|
|
|
|
|
positionTileCheckbox.properties = ComponentCheckBoxProperty(size: .s, text: KMLocalizedString("Tile"), checkboxType: .normal)
|
|
|
positionTileCheckbox.setTarget(self, action: #selector(checkBoxClicked(_:)))
|
|
@@ -146,10 +197,46 @@ class KMNWatermarkPropertyController: NSViewController {
|
|
|
text: "0")
|
|
|
|
|
|
|
|
|
+ //Save
|
|
|
+ saveTemplateBGView.wantsLayer = true
|
|
|
+ saveTemplateBGView.layer?.backgroundColor = ComponentLibrary.shared.getComponentColorFromKey("colorBg/layout-middle").cgColor
|
|
|
+ saveButton.properties = ComponentButtonProperty(type: .default_tertiary, size: .m, showLeftIcon: true, buttonText: KMLocalizedString("Save as Template"), icon: NSImage(named: "icon_wm_template_save"))
|
|
|
+ saveButton.setTarget(self, action: #selector(saveButtonClicked(_:)))
|
|
|
+
|
|
|
}
|
|
|
|
|
|
func reloadData() {
|
|
|
|
|
|
+ fileBGView.isHidden = true
|
|
|
+ textBGView.isHidden = true
|
|
|
+ if watermarkModel.type == 0 {
|
|
|
+ textBGView.isHidden = false
|
|
|
+ appearanceBGTopConst.constant = 200
|
|
|
+ } else if watermarkModel.type == 1 {
|
|
|
+ fileBGView.isHidden = false
|
|
|
+ appearanceBGTopConst.constant = 48
|
|
|
+ }
|
|
|
+
|
|
|
+ //Text
|
|
|
+ if let familyName = familyNames.first {
|
|
|
+ let fontNames = CPDFFont.fontNames(forFamilyName: "Helvetica")
|
|
|
+
|
|
|
+ var menuItemArr: [ComponentMenuitemProperty] = []
|
|
|
+ for string in fontNames {
|
|
|
+ let item = ComponentMenuitemProperty(type: .normal, text: string, identifier: string)
|
|
|
+ menuItemArr.append(item)
|
|
|
+ }
|
|
|
+ fontStyleSelect.updateMenuItemsArr(menuItemArr)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //File
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //Appearance
|
|
|
+
|
|
|
|
|
|
|
|
|
//Position
|
|
@@ -179,4 +266,19 @@ class KMNWatermarkPropertyController: NSViewController {
|
|
|
reloadData()
|
|
|
}
|
|
|
|
|
|
+ @objc func saveButtonClicked(_ sender: ComponentButton) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+extension KMNWatermarkPropertyController: ComponentTabsDelegate {
|
|
|
+ func componentTabsDidSelected(_ view: ComponentTabs, _ property: ComponentTabsProperty) {
|
|
|
+ if property == textTabProperty {
|
|
|
+ watermarkModel.type = 0
|
|
|
+ } else if property == fileTabProperty {
|
|
|
+ watermarkModel.type = 1
|
|
|
+ }
|
|
|
+ reloadData()
|
|
|
+ }
|
|
|
}
|