123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- //
- // KMNLinkMultiController.swift
- // PDF Reader Pro
- //
- // Created by Niehaoyu on 2024/10/21.
- //
- import Cocoa
- import KMComponentLibrary
- @objc protocol KMNLinkMultiControllerDelegate: AnyObject {
-
- @objc optional func multiControllerDidClick(_ controller: KMNLinkMultiController, _ alignmentType: KMAnnotationsAlignmentType)
-
- }
-
- class KMNLinkMultiController: NSViewController {
- @IBOutlet var contendBox: NSBox!
- @IBOutlet var titleLabel: NSTextField!
-
- @IBOutlet var aligLeftButton: ComponentButton!
- @IBOutlet var aligLeftCenterButton: ComponentButton!
- @IBOutlet var aligRightButton: ComponentButton!
- @IBOutlet var aligTopButton: ComponentButton!
- @IBOutlet var aligTopCenterButton: ComponentButton!
- @IBOutlet var aligBottomButton: ComponentButton!
- @IBOutlet var aligHorizontalXButton: ComponentButton!
- @IBOutlet var aligVerticalYButton: ComponentButton!
-
- weak open var delegate: KMNLinkMultiControllerDelegate?
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- titleLabel.stringValue = KMLocalizedString("Alignment")
-
- aligLeftButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
- aligLeftButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "alignLeft")
-
- aligLeftCenterButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
- aligLeftCenterButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "alignXCenter")
-
- aligRightButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
- aligRightButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "alignRight")
-
- aligTopButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
- aligTopButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "alignTop")
-
- aligTopCenterButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
- aligTopCenterButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "alignYCenter")
-
- aligBottomButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
- aligBottomButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "alignBottom")
-
- aligHorizontalXButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
- aligHorizontalXButton.properties.propertyInfo.leftIcon_dis = NSImage(named: "alignHorizonal_dis")
- aligHorizontalXButton.properties.isDisabled = true
-
- aligVerticalYButton.properties = ComponentButtonProperty(type: .text_gray, size: .s, onlyIcon: true)
- aligVerticalYButton.properties.propertyInfo.leftIcon_dis = NSImage(named: "alignAverageVertical_dis")
- aligVerticalYButton.properties.isDisabled = true
-
- for button in [aligLeftButton, aligLeftCenterButton, aligRightButton, aligTopButton,
- aligTopCenterButton, aligBottomButton, aligHorizontalXButton, aligVerticalYButton] {
-
- button?.reloadData()
- button?.setTarget(self, action: #selector(buttonClicked(_:)))
- }
-
- }
-
- @objc func buttonClicked(_ sender: ComponentButton) {
- var alignmentType: KMAnnotationsAlignmentType = .None
- if sender == aligLeftButton {
- alignmentType = .Left
- } else if sender == aligLeftCenterButton {
- alignmentType = .XCenter
- } else if sender == aligRightButton {
- alignmentType = .Right
- } else if sender == aligTopButton {
- alignmentType = .Top
- } else if sender == aligTopCenterButton {
- alignmentType = .YCenter
- } else if sender == aligBottomButton {
- alignmentType = .Bottom
- }
-
- delegate?.multiControllerDidClick?(self, alignmentType)
- }
-
- }
|