12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //
- // KMPDFMergeFileNameTabelViewCell.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2023/10/11.
- //
- import Cocoa
- @objcMembers class KMPDFMergeFileNameTabelViewCell: NSTableCellView {
- var numberLabel: NSTextField?
- var iconImageView: NSImageView?
- var fileNameLabel: NSTextField?
- var pageNumberLabel: NSTextField?
-
- 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() {
- let numberLabel = NSTextField(labelWithString: "")
- numberLabel.textColor = NSColor(red: 37.0/255.0, green: 38.0/255.0, blue: 41.0/255.0, alpha: 1.0)
- numberLabel.font = .SFProTextRegularFont(14)
- numberLabel.alignment = .center
- numberLabel.lineBreakMode = .byTruncatingTail
- self.addSubview(numberLabel)
- self.numberLabel = numberLabel
-
- let iconImageView = NSImageView()
- self.addSubview(iconImageView)
- self.iconImageView = iconImageView
-
- let fileNameLabel = NSTextField(labelWithString: "")
- fileNameLabel.textColor = NSColor(red: 37.0/255.0, green: 38.0/255.0, blue: 41.0/255.0, alpha: 1.0)
- fileNameLabel.font = .SFProTextRegularFont(14)
- fileNameLabel.lineBreakMode = .byTruncatingTail
- self.addSubview(fileNameLabel)
- self.fileNameLabel = fileNameLabel
-
- let pageNumberLabel = NSTextField(labelWithString: "")
- pageNumberLabel.textColor = NSColor(red: 148.0/255.0, green: 152.0/255.0, blue: 156.0/255.0, alpha: 1.0)
- pageNumberLabel.font = .SFProTextRegularFont(14)
- self.addSubview(pageNumberLabel)
- self.pageNumberLabel = pageNumberLabel
- }
-
- override func layout() {
- super.layout()
-
- let width = NSWidth(self.bounds)
- let height = NSHeight(self.bounds)
-
- let labelH = 22.0
- self.numberLabel?.frame = NSMakeRect(16, (height-labelH)*0.5, 30+16, labelH)
-
- let iconSize = 60.0
- self.iconImageView?.frame = NSMakeRect(NSMaxX(self.numberLabel?.frame ?? NSZeroRect)+6, (height-iconSize)*0.5, iconSize, iconSize)
-
- let fileNameX = NSMaxX(self.iconImageView?.frame ?? NSZeroRect)+8
- self.fileNameLabel?.frame = NSMakeRect(fileNameX, 13, width-fileNameX, labelH)
-
- self.pageNumberLabel?.frame = NSMakeRect(fileNameX, NSMaxY(self.fileNameLabel?.frame ?? NSZeroRect)+8, width-fileNameX, labelH)
- }
- }
|