123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //
- // KMWatermarkAdjectivePlainView.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2022/12/17.
- //
- import Cocoa
- class KMWatermarkAdjectivePlainView: KMWatermarkAdjectiveBaseView {
- @IBOutlet weak var checkBox: NSButton!
-
- @IBOutlet weak var hImageView: NSImageView!
- @IBOutlet weak var hBox: NSBox!
- var hStepper: KMWatermarkAdjectiveStepper!
-
- @IBOutlet weak var vImageView: NSImageView!
- @IBOutlet weak var vBox: NSBox!
- var vStepper: KMWatermarkAdjectiveStepper!
-
- override init(frame frameRect: NSRect) {
- super.init(frame: frameRect)
-
- // initSubViews()
- }
-
- required init?(coder: NSCoder) {
- super.init(coder: coder)
-
- // initSubViews()
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- initSubViews()
- }
-
- func initSubViews() {
- checkBox.title = NSLocalizedString("Tile", comment: "")
- checkBox.target = self
- checkBox.action = #selector(checkBoxAction)
-
- let hStepper = KMWatermarkAdjectiveStepper()
- hStepper.frame = self.hBox.contentView!.bounds
- hStepper.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
- self.hBox.contentView?.addSubview(hStepper)
- self.hStepper = hStepper
- hStepper.textField.doubleValue = 6
- hStepper.stepper.doubleValue = 6
- hStepper.valueDidChange = {
- (value: Double) in
- guard let callback = self.itemClick else {
- return
- }
-
- callback(2, value)
- }
-
- let vStepper = KMWatermarkAdjectiveStepper()
- vStepper.frame = self.vBox.contentView!.bounds
- vStepper.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
- self.vBox.contentView?.addSubview(vStepper)
- self.vStepper = vStepper
- vStepper.textField.doubleValue = 6
- vStepper.stepper.doubleValue = 6
-
- vStepper.valueDidChange = {
- (value: Double) in
- guard let callback = self.itemClick else {
- return
- }
-
- callback(3, value)
- }
- }
-
- @objc func checkBoxAction(sender: NSButton) {
- if (sender.state == .on) {
- self.hStepper.enabled = true
- self.vStepper.enabled = true
- } else {
- self.hStepper.enabled = false
- self.vStepper.enabled = false
- }
-
- guard let callback = itemClick else {
- return
- }
-
- callback(1, sender.state == .on)
- }
-
- override func setModel(model: KMWatermarkModel) {
- super.setModel(model: model)
-
- if (model.isTilePage) {
- self.checkBox.state = .on
- } else {
- self.checkBox.state = .off
- }
- self.checkBoxAction(sender: self.checkBox)
-
- self.hStepper.value = model.tileHorizontalSpace
- self.vStepper.value = model.tileVerticalSpace
- }
-
- }
|