1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // KMCompressCellView.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2022/11/26.
- //
- import Cocoa
- class KMCompressCellView: NSTableCellView {
- var backGroundView: NSView = NSView()
- var label: NSTextField = NSTextField(labelWithString: "")
- var selectedLabel: NSTextField = NSTextField(labelWithString: "")
- var button = KMImageTitleButton()
-
- private var mySelected = false
- var isSelected: Bool {
- get {
- return mySelected
- }
- set {
- mySelected = newValue
-
- if newValue {
- selectedLabel.isHidden = false
- } else {
- selectedLabel.isHidden = true
- }
- }
- }
-
- override init(frame frameRect: NSRect) {
- super.init(frame: frameRect)
-
- addSubview(backGroundView)
- addSubview(label)
- addSubview(selectedLabel)
-
- self.addSubview(self.button)
-
- selectedLabel.stringValue = ""
- }
-
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
- override func layout() {
- super.layout()
-
- let width: CGFloat = NSWidth(self.bounds)
- let heigth : CGFloat = NSHeight(self.bounds)
-
- backGroundView.frame = NSMakeRect(10, 10, width-20, heigth-20)
- let labelH: CGFloat = 20
- label.frame = NSMakeRect(35, (heigth-labelH)*0.5, width-35-50, labelH)
- selectedLabel.frame = NSMakeRect(width-50, (heigth-labelH)*0.5, 50, labelH)
-
- let buttonH: CGFloat = 22
- let buttonY: CGFloat = (heigth-buttonH) * 0.5
- self.button.frame = NSMakeRect(10, buttonY, width-17, buttonH)
- }
-
- }
|