123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // KMPDFMergeSizeTabelViewCell.swift
- // PDF Master
- //
- // Created by tangchao on 2023/10/12.
- //
- import Cocoa
- @objcMembers class KMPDFMergeSizeTabelViewCell: NSTableCellView {
- var label: NSTextField?
- var button: NSButton?
-
- var callback: KMEmptyBlock?
-
- override init(frame frameRect: NSRect) {
- super.init(frame: frameRect)
- self.initSubviews()
- }
-
- required init?(coder: NSCoder) {
- super.init(coder: coder)
- self.initSubviews()
- }
-
- override var isFlipped: Bool {
- return true
- }
-
- func initSubviews() {
- var label = NSTextField(labelWithString: "")
- label.textColor = NSColor(red: 148.0/255.0, green: 152.0/255.0, blue: 156.0/255.0, alpha: 1.0)
- label.font = .SFProTextRegularFont(14)
- self.addSubview(label)
- self.label = label
-
- var button = NSButton()
- button.isBordered = false
- button.image = NSImage(named: "KMImageNameSecureClearIcon")
- self.addSubview(button)
- self.button = button
- self.button?.target = self
- self.button?.action = #selector(buttonAction)
- }
-
- override func layout() {
- super.layout()
-
- let height = NSHeight(self.bounds)
-
- let labelH = 22.0
- self.label?.frame = NSMakeRect(16, (height-labelH)*0.5, 70, labelH)
- let buttonSize = 20.0
- self.button?.frame = NSMakeRect(NSMaxX(self.label?.frame ?? NSZeroRect)+5, (height-buttonSize)*0.5, buttonSize, buttonSize)
- }
-
- @objc func buttonAction() {
- guard let data = self.callback else {
- return
- }
- data()
- }
- }
|