123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //
- // KMWatermarkAdjectivePositionView.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2022/12/17.
- //
- import Cocoa
- class KMWatermarkAdjectivePositionView: KMWatermarkAdjectiveBaseView {
- @IBOutlet weak var titleLabel: NSTextField!
-
- @IBOutlet weak var positionView: NSView!
- var myPositionView: KMWatermarkPositionView!
-
- @IBOutlet weak var xOffsetTitleLabel: NSTextField!
- @IBOutlet weak var xOffsetBox: NSBox!
- var xOffsetStepper: KMWatermarkAdjectiveStepper!
-
- @IBOutlet weak var yOffsetTitleLabel: NSTextField!
- @IBOutlet weak var yOffsetBox: NSBox!
- var yOffsetStepper: KMWatermarkAdjectiveStepper!
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- titleLabel.stringValue = NSLocalizedString("Position", comment: "")
-
- let positionView = KMWatermarkPositionView()
- positionView.frame = self.positionView.bounds
- positionView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
- self.positionView.addSubview(positionView)
- self.myPositionView = positionView
- positionView.itemClick = {
- (position: KMWatermarkPosition) in
- guard let callback = self.itemClick else {
- return
- }
-
- callback(1, position)
- }
-
- xOffsetTitleLabel.stringValue = NSLocalizedString("X", comment: "")
- let xStepper = KMWatermarkAdjectiveStepper()
- xStepper.frame = self.xOffsetBox.contentView!.bounds
- xStepper.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
- self.xOffsetBox.contentView?.addSubview(xStepper)
- self.xOffsetStepper = xStepper
- xStepper.valueDidChange = {
- (value: Double) in
- guard let callback = self.itemClick else {
- return
- }
-
- callback(2, value)
- }
-
- yOffsetTitleLabel.stringValue = NSLocalizedString("Y", comment: "")
- let yStepper = KMWatermarkAdjectiveStepper()
- yStepper.frame = self.yOffsetBox.contentView!.bounds
- yStepper.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
- self.yOffsetBox.contentView?.addSubview(yStepper)
- self.yOffsetStepper = yStepper
- yStepper.valueDidChange = {
- (value: Double) in
- guard let callback = self.itemClick else {
- return
- }
-
- callback(3, value)
- }
- }
-
- override func setModel(model: KMWatermarkModel) {
- super.setModel(model: model)
-
- if (model.horizontalMode == 0) {
- if (model.verticalMode == 0) {
- self.myPositionView.selectPosition(positon: .leftTop)
- } else if (model.verticalMode == 1) {
- self.myPositionView.selectPosition(positon: .top)
- } else if (model.verticalMode == 2) {
- self.myPositionView.selectPosition(positon: .rightTop)
- }
- }
-
- if (model.horizontalMode == 1) {
- if (model.verticalMode == 0) {
- self.myPositionView.selectPosition(positon: .leftMiddle)
- } else if (model.verticalMode == 1) {
- self.myPositionView.selectPosition(positon: .middle)
- } else if (model.verticalMode == 2) {
- self.myPositionView.selectPosition(positon: .rightMiddle)
- }
- }
-
- if (model.horizontalMode == 2) {
- if (model.verticalMode == 0) {
- self.myPositionView.selectPosition(positon: .leftBottom)
- } else if (model.verticalMode == 1) {
- self.myPositionView.selectPosition(positon: .bottom)
- } else if (model.verticalMode == 2) {
- self.myPositionView.selectPosition(positon: .rightBottom)
- }
- }
-
- self.xOffsetStepper.value = model.horizontalSpace
- self.yOffsetStepper.value = model.verticalSpace
- }
-
- }
|