123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- //
- // KMRedactPropertyWindowController.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/1/17.
- //
- import Cocoa
- class KMRedactPropertyWindowController: KMRedactBaseWindowController {
- var colorViewIndex: Int = 0
-
- var outsideColor: NSColor {
- get {
- return (self.contentView as! KMRedactPropertyContentView).outsideColorView.color!
- }
- }
- var fillColor: NSColor {
- get {
- return (self.contentView as! KMRedactPropertyContentView).fillColorView.color!
- }
- }
- var isOver: Bool {
- get {
- return (self.contentView as! KMRedactPropertyContentView).overTextCheck.state == .on
- }
- }
- var overText: String {
- get {
- return (self.contentView as! KMRedactPropertyContentView).overTextView.string
- }
- }
- var fontColor: NSColor {
- get {
- return (self.contentView as! KMRedactPropertyContentView).textColorView.color!
- }
- }
-
- var aligement: NSTextAlignment = .left
- var font: NSFont = NSFont(name: "Helvetica", size: 0)!
-
- override func windowDidLoad() {
- super.windowDidLoad()
- self.setContentSize(NSSize(width: 444, height: 527))
- self.topLineIsShow(false)
-
- self.titleLabel.stringValue = NSLocalizedString("Settings", comment: "")
- self.funcButton.title = NSLocalizedString("Apply", comment: "")
- self.funcButton.layer?.backgroundColor = NSColor.black.cgColor
- self.funcButton.attributedTitle = NSMutableAttributedString(string: self.funcButton.title, attributes: [NSAttributedString.Key.foregroundColor : NSColor.white])
-
- let contentView = KMRedactPropertyContentView.createFromNib()
- contentView?.frame = self.contentBox.contentView!.bounds
- contentView?.autoresizingMask = [.width,.height]
- self.contentBox.contentView?.addSubview(contentView!)
- self.contentView = contentView
- contentView?.annotation = self.annotation
-
- contentView?.itemClick = { [weak self] index, value in
- if (index == 1) { /// 外观
- self?.colorViewIndex = 1
- self?.showColorPanel()
- return
- } else if (index == 2) { /// 填充
- self?.colorViewIndex = 2
- self?.showColorPanel()
- return
- } else if (index == 3) { /// 覆盖文本check
-
- } else if (index == 4) { /// 覆盖文本编辑
-
- } else if (index == 5) { /// 字体类型
- self?.font = NSFont(name: value as! String, size: (self?.font.pointSize)!)!
- } else if (index == 6) { /// 字体大小
- self?.font = NSFont(name: (self?.font.fontName)!, size: CGFloat(value as! Int))!
- } else if (index == 7) { /// 字体相关
-
- } else if (index == 8) { /// 字体颜色
- self?.colorViewIndex = 3
- self?.showColorPanel()
- return
- } else if (index == 9) { /// 字体aligement
- if (value as! Int == 0) {
- self?.aligement = .left
- } else if (value as! Int == 1) {
- self?.aligement = .center
- } else if (value as! Int == 2) {
- self?.aligement = .right
- }
- }
- }
- }
-
- // MARK: Private Methods
-
- @objc private func showColorPanel() {
- let panel = NSColorPanel.shared
- panel.setTarget(self)
- panel.setAction(#selector(colorPanelAction))
- panel.orderFront(nil)
- }
-
- @objc private func colorPanelAction(sender: NSColorPanel) {
- if (self.colorViewIndex == 1) { /// 外观
- (self.contentView as! KMRedactPropertyContentView).outsideColorView.color = sender.color
- } else if (self.colorViewIndex == 2) {
- (self.contentView as! KMRedactPropertyContentView).fillColorView.color = sender.color
- } else if (self.colorViewIndex == 3) {
- (self.contentView as! KMRedactPropertyContentView).textColorView.color = sender.color
- }
- }
- }
|