// // KMAnnotationTableViewController.swift // PDF Reader Pro // // Created by wanjun on 2023/11/7. // import Cocoa class KMLineStyleButtonCell: NSButtonCell { override func highlight(_ flag: Bool, withFrame cellFrame: NSRect, in controlView: NSView) { if flag { print("111") controlView.layer?.backgroundColor = KMAppearance.Status.selColor().cgColor } else { print("111") } } } @objcMembers class KMAnnotationTableViewController: NSViewController { var annotation: KMTableAnnotation? weak var pdfView: CPDFListView? var _annotationModel: CPDFAnnotationModel? var _annotations: [KMTableAnnotation] = [] var point: NSPoint = NSPoint.zero @IBOutlet weak var styleLabel: NSTextField! @IBOutlet weak var styleBox0: KMBox! @IBOutlet weak var styleBox1: KMBox! @IBOutlet weak var styleBox2: KMBox! @IBOutlet weak var styleBox3: KMBox! @IBOutlet weak var styleBox4: KMBox! @IBOutlet weak var styleBox5: KMBox! @IBOutlet weak var cellSizeLabel: NSTextField! @IBOutlet weak var cellWidthLabel: NSTextField! @IBOutlet weak var cellHeightLabel: NSTextField! @IBOutlet weak var cellWidthTextField: NSTextField! @IBOutlet weak var cellHeightTextField: NSTextField! @IBOutlet weak var cellWidthStepper: NSStepper! @IBOutlet weak var cellHeightStepper: NSStepper! @IBOutlet weak var titleEndTableLabel: NSTextField! @IBOutlet weak var sidebarPopUpButton: KMPopUpButton! @IBOutlet weak var headerPopUpButton: KMPopUpButton! @IBOutlet weak var footerPopUpButton: KMPopUpButton! @IBOutlet weak var bordersAndColorsLabel: NSTextField! @IBOutlet weak var backgroundColorLabel: NSTextField! @IBOutlet weak var backgroudColorBox: KMBox! @IBOutlet weak var backgrourdColorView: NSView! @IBOutlet weak var borderColorLabel: NSTextField! @IBOutlet weak var borderColorBox: KMBox! @IBOutlet weak var borderColorView: NSView! @IBOutlet weak var widthLabel: NSTextField! @IBOutlet weak var widthSlider: NSSlider! @IBOutlet weak var widthPopUpButton: KMPopUpButton! @IBOutlet weak var lineStyleLabel: NSTextField! @IBOutlet weak var lineStyleButton: KMButton! @IBOutlet weak var dottedLineStyleButton: KMButton! @IBOutlet weak var rightArrowStyleButton: KMButton! @IBOutlet weak var alternateColorButton: NSButton! @IBOutlet weak var alternateColorLabel: NSTextField! @IBOutlet weak var alternateColorBox: KMBox! @IBOutlet weak var alternateColorView: NSView! var backgroudColorBoxIsEnabled: Bool = false var notUpdateBackgroundColor: Bool = false var lineStyleCount: Int = 0 deinit { NotificationCenter.default.removeObserver(self) DistributedNotificationCenter.default().removeObserver(self) } override func viewDidLoad() { super.viewDidLoad() // Do view setup here. self.styleLabel.stringValue = NSLocalizedString("Table Styles", comment: "") self.styleLabel.textColor = KMAppearance.Layout.h0Color() self.cellSizeLabel.stringValue = NSLocalizedString("Cell Size", comment: "") self.cellSizeLabel.textColor = KMAppearance.Layout.h0Color() self.cellWidthLabel.stringValue = "\(NSLocalizedString("Cell Width", comment: ""))(cm)" self.cellWidthLabel.toolTip = "\(NSLocalizedString("Cell Width", comment: ""))(cm)" self.cellWidthLabel.allowsExpansionToolTips = true self.cellWidthLabel.textColor = KMAppearance.Layout.h1Color() self.cellHeightLabel.stringValue = "\(NSLocalizedString("Cell Height", comment: ""))(cm)" self.cellHeightLabel.toolTip = "\(NSLocalizedString("Cell Height", comment: ""))(cm)" self.cellHeightLabel.allowsExpansionToolTips = true self.cellHeightLabel.textColor = KMAppearance.Layout.h1Color() self.titleEndTableLabel.stringValue = NSLocalizedString("Headers & Footers", comment: "") self.titleEndTableLabel.textColor = KMAppearance.Layout.h0Color() self.bordersAndColorsLabel.stringValue = NSLocalizedString("Borders & Colors", comment: "") self.bordersAndColorsLabel.textColor = KMAppearance.Layout.h0Color() self.backgroundColorLabel.stringValue = NSLocalizedString("Background Color", comment: "") self.backgroundColorLabel.textColor = KMAppearance.Layout.h1Color() self.borderColorLabel.stringValue = NSLocalizedString("Border Color", comment: "") self.borderColorLabel.textColor = KMAppearance.Layout.h1Color() self.widthLabel.stringValue = NSLocalizedString("Line Width", comment: "") self.widthLabel.textColor = KMAppearance.Layout.h1Color() self.lineStyleLabel.stringValue = NSLocalizedString("Line Style", comment: "") self.lineStyleLabel.textColor = KMAppearance.Layout.h1Color() self.alternateColorLabel.stringValue = NSLocalizedString("Alternate", comment: "") self.alternateColorLabel.textColor = KMAppearance.Layout.h0Color() let styleBoxArr: [KMBox] = [self.styleBox0, self.styleBox1, self.styleBox2, self.styleBox3, self.styleBox4, self.styleBox5] for box in styleBoxArr { box.moveCallback = { mouseEntered, mouseBox in if mouseEntered { mouseBox.fillColor = KMAppearance.Status.selColor() } else { mouseBox.fillColor = NSColor.clear } } } self.widthPopUpButton.removeAllItems() self.widthPopUpButton.addItems(withTitles: ["0.1 pt","0.2 pt","0.3 pt","0.4 pt","0.5 pt","0.6 pt","0.7 pt","0.8 pt","0.9 pt","1.0 pt","1.1 pt","1.2 pt","1.3 pt","1.4 pt","1.5 pt","1.6 pt","1.7 pt","1.8 pt","1.9 pt","2.0 pt","2.1 pt","2.2 pt","2.3 pt","2.4 pt","2.5 pt","2.6 pt","2.7 pt","2.8 pt","2.9 pt","3.0 pt"]) self.widthPopUpButton.type = .arrowDown self.backgroudColorBox.borderWidth = 1.0 self.backgroudColorBox.borderColor = KMAppearance.Interactive.s0Color() self.backgroudColorBox.fillColor = KMAppearance.Layout.l1Color() self.backgroudColorBox.cornerRadius = 1.0 self.backgroudColorBox.downCallback = {downEntered, mouseBox, event in if downEntered { if self.backgroudColorBoxIsEnabled { NSColorPanel.shared.setTarget(self) NSColorPanel.shared.setAction(#selector(self.backgroudColorPanelColorDidChange(_:))) NSColorPanel.shared.orderFront(nil) } else { NSSound.beep() } } } self.backgrourdColorView.wantsLayer = true self.borderColorView.wantsLayer = true self.alternateColorView.wantsLayer = true self.backgrourdColorView.layer?.backgroundColor = NSColor.white.cgColor self.backgrourdColorView.layer?.borderWidth = 0.5 self.borderColorView.layer?.borderWidth = 0.5 self.alternateColorView.layer?.borderWidth = 0.5 self.backgrourdColorView.layer?.borderColor = KMAppearance.Interactive.s0Color().cgColor self.borderColorView.layer?.borderColor = KMAppearance.Interactive.s0Color().cgColor self.alternateColorView.layer?.borderColor = KMAppearance.Interactive.s0Color().cgColor self.borderColorBox.borderWidth = 1.0 self.borderColorBox.borderColor = KMAppearance.Interactive.s0Color() self.borderColorBox.fillColor = KMAppearance.Layout.l1Color() self.borderColorBox.cornerRadius = 1.0 self.borderColorBox.downCallback = { downEntered, mouseBox, event in if downEntered { NSColorPanel.shared.setTarget(self) NSColorPanel.shared.setAction(#selector(self.borderColorPanelColorDidChange(_:))) NSColorPanel.shared.orderFront(nil) } } self.alternateColorBox.borderWidth = 1.0 self.alternateColorBox.borderColor = KMAppearance.Interactive.s0Color() self.alternateColorBox.fillColor = KMAppearance.Layout.l1Color() self.alternateColorBox.cornerRadius = 1.0 self.alternateColorBox.downCallback = { downEntered, mouseBox, event in if downEntered { NSColorPanel.shared.setTarget(self) NSColorPanel.shared.setAction(#selector(self.alternateColorPanelColorDidChange(_:))) NSColorPanel.shared.orderFront(nil) } } self.lineStyleButton.image = self.borderStyleSolid(isSelect: false) self.lineStyleButton.wantsLayer = true self.dottedLineStyleButton.image = self.borderStyleDashed(isSelect: false) self.dottedLineStyleButton.wantsLayer = true self.rightArrowStyleButton.image = self.borderStyleDashed(isSelect: false) self.rightArrowStyleButton.wantsLayer = true let buttonArray: [KMButton] = [self.lineStyleButton, self.dottedLineStyleButton, self.rightArrowStyleButton] for button in buttonArray { button.layer?.borderColor = KMAppearance.Interactive.s0Color().cgColor button.layer?.borderWidth = 1.0 button.layer?.cornerRadius = 1.0 if button.tag == self.lineStyleCount { button.layer?.backgroundColor = KMAppearance.Status.selColor().cgColor } else { button.layer?.backgroundColor = KMAppearance.Layout.l1Color().cgColor } button.mouseMoveCallback = {[weak self] mouseEntered in if button.tag == self?.lineStyleCount { return } if mouseEntered { button.layer?.backgroundColor = KMAppearance.Status.selColor().cgColor button.layer?.borderWidth = 0.0 if button.tag == 0 { self?.lineStyleButton.image = self?.borderStyleSolid(isSelect: true) } else if button.tag == 1 { self?.dottedLineStyleButton.image = self?.borderStyleDashed(isSelect: true) } } else { button.layer?.backgroundColor = KMAppearance.Layout.l1Color().cgColor button.layer?.borderWidth = 1.0 if button.tag == 0 { self?.lineStyleButton.image = self?.borderStyleSolid(isSelect: false) } else { self?.dottedLineStyleButton.image = self?.borderStyleDashed(isSelect: false) } } } } self.rightArrowStyleButton.isHidden = true self.sidebarPopUpButton.buttonImage = NSImage(named: KMImageNameUXIconPropertybarTableTitleLeft) self.sidebarPopUpButton.type = .table self.headerPopUpButton.buttonImage = NSImage(named: KMImageNameUXIconPropertybarTableTitleAbove) self.headerPopUpButton.type = .table; self.footerPopUpButton.buttonImage = NSImage(named: KMImageNameUXIconPropertybarTableBottom) self.footerPopUpButton.type = .table; self.cellWidthTextField.backgroundColor = KMAppearance.Layout.l1Color() self.cellHeightTextField.backgroundColor = KMAppearance.Layout.l1Color() self.cellWidthTextField.wantsLayer = true self.cellHeightTextField.wantsLayer = true self.sidebarPopUpButton.wantsLayer = true self.widthPopUpButton.wantsLayer = true self.headerPopUpButton.wantsLayer = true self.footerPopUpButton.wantsLayer = true self.cellWidthTextField.layer!.borderWidth = 1.0 self.cellHeightTextField.layer?.borderWidth = 1.0 self.sidebarPopUpButton.layer!.borderWidth = 1.0 self.widthPopUpButton.layer!.borderWidth = 1.0 self.headerPopUpButton.layer!.borderWidth = 1.0 self.footerPopUpButton.layer!.borderWidth = 1.0 self.cellWidthTextField.layer?.cornerRadius = 1.0 self.cellHeightTextField.layer?.cornerRadius = 1.0 self.sidebarPopUpButton.layer?.cornerRadius = 1.0 self.widthPopUpButton.layer?.cornerRadius = 1.0 self.headerPopUpButton.layer?.cornerRadius = 1.0 self.updateViewColor() // NotificationCenter.default.addObserver(self, selector: #selector(PDFViewTableAnnotationDidChangeNotification(_:)), name: Notification.Name("KMPDFViewTableAnnotationDidChangeNotification"), object: nil) NotificationCenter.default.addObserver(self, selector: #selector(controlTextDidEndEditingNotification(_:)), name: NSControl.textDidEndEditingNotification, object: self.cellWidthTextField) NotificationCenter.default.addObserver(self, selector: #selector(controlTextDidEndEditingNotification(_:)), name: NSControl.textDidEndEditingNotification, object: self.cellHeightTextField) DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChanged(_:)), name: Notification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil) } override func viewWillAppear() { super.viewWillAppear() reloadData(with: self.point) } // MARK: Set & Get var annotations: [KMTableAnnotation] { set { _annotations = newValue self.annotation = newValue.first } get { return _annotations } } var annotationModel: CPDFAnnotationModel { get { return _annotationModel! } set { _annotationModel = newValue if _annotationModel?.annotations != nil { if annotationModel.annotations.count > 0 { annotations = _annotationModel?.annotations as! [KMTableAnnotation] } } } } // MARK: Private Methods func reloadData(with point: NSPoint) { let rect = annotation?.isInCell(with: point) ?? .zero if !NSEqualRects(rect, NSRectFromCGRect(CGRect.zero)) { var color = annotation?.getCellData(withRow: annotation!.currentCell.row, andColumn: annotation!.currentCell.column).backgroundColor var maxWidth: CGFloat = 10 let minHeight: CGFloat = 10 if annotation!.currentCell.column == annotation!.columnNumber - 1 { maxWidth = CGFloat(MAXFLOAT) } else { if let rect1 = annotation?.getCellBounds(withRow: annotation!.currentCell.row, column: annotation!.currentCell.column + 1) { maxWidth = rect1.size.width + rect.size.width - 10 } } cellWidthStepper.maxValue = Double(maxWidth) cellHeightStepper.minValue = Double(minHeight) if color == nil { color = NSColor(deviceRed: 1, green: 1, blue: 1, alpha: 1) } backgroudColorBoxIsEnabled = true backgrourdColorView.wantsLayer = true backgrourdColorView.layer?.backgroundColor = color!.cgColor } else { backgroudColorBoxIsEnabled = false backgrourdColorView.wantsLayer = true backgrourdColorView.layer?.backgroundColor = NSColor.white.cgColor } self.setCell(width: rect.size.width, height: rect.size.height) var lineWidth: Float = 0.0 if let data = self.annotation?.border { lineWidth = Float(data.lineWidth) } else { lineWidth = Float(self.annotation?.lineWidth() ?? 0) } self.widthSlider.floatValue = lineWidth let sliderString = String(format: "%.1f pt", lineWidth) if widthPopUpButton.itemTitles.contains(sliderString) { if let index = widthPopUpButton.itemTitles.firstIndex(of: sliderString) { widthPopUpButton.selectItem(at: index) } } widthSlider.toolTip = sliderString lineStyleCount = 0 if annotation?.border?.style == .solid { lineStyleButton.layer?.backgroundColor = KMAppearance.Status.selColor().cgColor lineStyleButton.layer?.borderWidth = 0.0 lineStyleButton.image = borderStyleSolid(isSelect: true) dottedLineStyleButton.layer?.backgroundColor = KMAppearance.Layout.l1Color().cgColor dottedLineStyleButton.layer?.borderWidth = 1.0 lineStyleButton.image = borderStyleSolid(isSelect: false) } else if annotation?.border?.style == .dashed { dottedLineStyleButton.layer?.backgroundColor = KMAppearance.Status.selColor().cgColor dottedLineStyleButton.layer?.borderWidth = 0.0 dottedLineStyleButton.image = borderStyleDashed(isSelect: true) lineStyleButton.layer?.backgroundColor = KMAppearance.Layout.l1Color().cgColor lineStyleButton.layer?.borderWidth = 1.0 lineStyleButton.image = borderStyleSolid(isSelect: false) lineStyleCount = 1 } borderColorView.wantsLayer = true borderColorView.layer?.backgroundColor = annotation?.color.cgColor if let alternateColor = annotation?.alternatingColor { alternateColorView.wantsLayer = true alternateColorView.layer?.backgroundColor = alternateColor.cgColor } alternateColorButton.state = (annotation?.isAlternateColor ?? false) ? .on : .off sidebarPopUpButton.selectItem(at: (annotation?.sidebarCount())!) headerPopUpButton.selectItem(at: (annotation?.headerCount())!) footerPopUpButton.selectItem(at: (annotation?.footerCount())!) } func setCell(width cellWidth: CGFloat, height cellHeight: CGFloat) { if cellWidth == 0 && cellHeight == 0 { cellWidthStepper.isEnabled = false cellHeightStepper.isEnabled = false cellWidthTextField.isEnabled = false cellHeightTextField.isEnabled = false } else { cellWidthStepper.isEnabled = true cellHeightStepper.isEnabled = true cellWidthTextField.isEnabled = true cellHeightTextField.isEnabled = true } let widthText = String(format: "%0.2f", cellWidth * 0.04) cellWidthTextField.stringValue = widthText cellWidthStepper.doubleValue = Double(cellWidth) let heightText = String(format: "%0.2f", cellHeight * 0.04) cellHeightTextField.stringValue = heightText cellHeightStepper.doubleValue = Double(cellHeight) } func reloadDataStepper(_ stepper: NSStepper) { guard let table = self.annotation else { return } if table.currentCell.row >= 0 && table.currentCell.column >= 0 { let row = table.currentCell.row let column = table.currentCell.column if stepper == self.cellWidthStepper { let distance = self.cellWidthStepper.doubleValue - table.getCellBounds(withRow: row, column: column).size.width table.moveVerticalLine(of: column + 1, withDistance: distance) } else if stepper == self.cellHeightStepper { let distance = table.getCellBounds(withRow: row, column: column).size.height - self.cellHeightStepper.doubleValue table.moveCrossLine(of: table.rowNumber - row - 1, withDistance: distance) table.setOldRowHeights() } table.afreshDrawLine() table.updateAppearanceInk(withIsAdd: false) } pdfView?.setNeedsDisplayAnnotationViewFor(table.page) } func colorWithCGColor(_ cgColor: CGColor?) -> NSColor? { guard let cgColor = cgColor else { return nil } return NSColor(cgColor: cgColor) } func borderStyleSolid(isSelect: Bool) -> NSImage { let size = NSSize(width: 49.0, height: 12.0) let image = NSImage.image(with: size) { rect in let path = NSBezierPath(rect: NSRect(x: 15.0, y: 5.0, width: 20.0, height: 1.0)) path.lineWidth = 2.0 if isSelect { KMAppearance.KM_273C62_ColorDarkChanged02().setStroke() } else { KMAppearance.Layout.h2Color().setStroke() } path.stroke() return true } return image } func borderStyleDashed(isSelect: Bool) -> NSImage { let size = NSSize(width: 49.0, height: 12.0) let image = NSImage(size: size) { rect in let path = NSBezierPath() path.move(to: NSPoint(x: 15.0, y: 5.0)) path.line(to: NSPoint(x: 19.0, y: 5.0)) path.move(to: NSPoint(x: 23.0, y: 5.0)) path.line(to: NSPoint(x: 27.0, y: 5.0)) path.move(to: NSPoint(x: 31.0, y: 5.0)) path.line(to: NSPoint(x: 35.0, y: 5.0)) path.lineWidth = 2.0 if isSelect { KMAppearance.KM_273C62_ColorDarkChanged02().setStroke() } else { KMAppearance.Layout.h2Color().setStroke() } path.stroke() return true } return image! } //MARK: Button Actions @IBAction func styleButtonAction(_ sender: NSButton) { var tableStyle: KMTableStyle = .default if let button = sender as? NSButton { switch button.tag { case 300: tableStyle = .default case 301: tableStyle = .style1 case 302: tableStyle = .style2 case 303: tableStyle = .style3 case 304: tableStyle = .style4 case 305: tableStyle = .style5 default: break } } annotation?.changeTableStyle(tableStyle) reloadData(with: point) pdfView?.needsDisplay = true } @IBAction func stepperAction(_ sender: Any) { guard let stepper = sender as? NSStepper else { return } var text: String switch stepper.tag { case 201: text = String(format: "%0.2f", self.cellWidthStepper.doubleValue * 0.04) self.cellWidthTextField.stringValue = text self.reloadDataStepper(self.cellWidthStepper) case 202: text = String(format: "%0.2f", self.cellHeightStepper.doubleValue * 0.04) self.cellHeightTextField.stringValue = text self.reloadDataStepper(self.cellHeightStepper) default: break } } @IBAction func colorWellAction(_ sender: Any) { guard let table = self.annotation else { return } table.borderWidth = CGFloat(self.widthSlider.floatValue) let sliderString = String(format: "%.1f pt", self.widthSlider.floatValue) if widthPopUpButton.itemTitles.contains(sliderString) { if let index = self.widthPopUpButton.itemTitles.firstIndex(of: sliderString) { self.widthPopUpButton.selectItem(at: index) } } table.color = self.colorWithCGColor(self.borderColorView.layer!.backgroundColor) if table.currentCell.row >= 0 && table.currentCell.column >= 0 { if self.backgroudColorBoxIsEnabled { if !self.notUpdateBackgroundColor { table.getCellData(withRow: table.currentCell.row, andColumn: table.currentCell.column).backgroundColor = self.colorWithCGColor(self.backgrourdColorView.layer?.backgroundColor) } else { var color = self.annotation?.getCellData(withRow: self.annotation!.currentCell.row, andColumn: self.annotation!.currentCell.column).backgroundColor if color == nil { color = NSColor(deviceRed: 1, green: 1, blue: 1, alpha: 1) } self.backgrourdColorView.layer?.backgroundColor = color?.cgColor } } } table.isAlternateColor = self.alternateColorButton.state == .on table.alternatingColor = self.colorWithCGColor(self.alternateColorView.layer!.backgroundColor)! table.writeFormDataToContents() if lineStyleCount == 1 { let lineType = table.dashPattern() if lineType.count == 0 { let number = NSNumber(value: Float(4)) table.setDashPattern([number]) } } table.setBorderStyle(CPDFBorderStyle(rawValue: lineStyleCount) ?? .solid) if self.notUpdateBackgroundColor { self.notUpdateBackgroundColor = false } pdfView?.setNeedsDisplayAnnotationViewFor(table.page) } @IBAction func titleEndTablePopUpButtonAction(_ sender: KMPopUpButton) { guard let table = self.annotation else { return } let bounds = self.annotation!.bounds guard let popButton = sender as? KMPopUpButton else { return } switch popButton.tag { case 100: let count = (Int(popButton.titleOfSelectedItem ?? "0") ?? 0) - table.sidebarCount() if count > 0 { for _ in 0.. 0 { for _ in 0.. 0 { for _ in 0.. 0 && width < cellWidthStepper.minValue { let text = String(format: "%0.2f", cellWidthStepper.minValue * 0.04) cellWidthTextField.stringValue = text cellWidthStepper.doubleValue = cellWidthStepper.minValue reloadDataStepper(cellWidthStepper) } else if width >= cellWidthStepper.minValue && width <= cellWidthStepper.maxValue { let text = String(format: "%0.2f", (textField.stringValue as NSString).doubleValue) cellWidthTextField.stringValue = text cellWidthStepper.doubleValue = width reloadDataStepper(cellWidthStepper) } else { let text = String(format: "%0.2f", cellWidthStepper.maxValue * 0.04) cellWidthTextField.stringValue = text cellWidthStepper.doubleValue = cellWidthStepper.maxValue reloadDataStepper(cellWidthStepper) } } else if textField == cellHeightTextField { let height = (textField.stringValue as NSString).doubleValue / 0.04 if height == cellHeightStepper.doubleValue { return } if height <= 0 { let text = String(format: "%0.2f", cellHeightStepper.doubleValue * 0.04) cellHeightTextField.stringValue = text } else if height > 0 && height < cellHeightStepper.minValue { let text = String(format: "%0.2f", cellHeightStepper.minValue * 0.04) cellHeightTextField.stringValue = text cellHeightStepper.doubleValue = cellHeightStepper.minValue reloadDataStepper(cellHeightStepper) } else { let text = String(format: "%0.2f", (textField.stringValue as NSString).doubleValue) cellHeightTextField.stringValue = text cellHeightStepper.doubleValue = height reloadDataStepper(cellHeightStepper) } } } @objc func themeChanged(_ notification: Notification) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in self?.updateViewColor() } } func updateViewColor() { if KMAppearance.isDarkMode() { widthPopUpButton.layer?.backgroundColor = NSColor(red: 57/255.0, green: 60/255.0, blue: 62/255.0, alpha: 1.0).cgColor cellWidthTextField.layer?.borderColor = NSColor(red: 86/255.0, green: 88/255.0, blue: 90/255.0, alpha: 1.0).cgColor cellHeightTextField.layer?.borderColor = NSColor(red: 86/255.0, green: 88/255.0, blue: 90/255.0, alpha: 1.0).cgColor sidebarPopUpButton.layer?.borderColor = NSColor(red: 86/255.0, green: 88/255.0, blue: 90/255.0, alpha: 1.0).cgColor widthPopUpButton.layer?.borderColor = NSColor(red: 86/255.0, green: 88/255.0, blue: 90/255.0, alpha: 1.0).cgColor headerPopUpButton.layer?.borderColor = NSColor(red: 86/255.0, green: 88/255.0, blue: 90/255.0, alpha: 1.0).cgColor footerPopUpButton.layer?.borderColor = NSColor(red: 86/255.0, green: 88/255.0, blue: 90/255.0, alpha: 1.0).cgColor } else { widthPopUpButton.layer?.backgroundColor = NSColor.white.cgColor cellWidthTextField.layer?.borderColor = NSColor(red: 218/255.0, green: 219/255.0, blue: 222/255.0, alpha: 1.0).cgColor cellHeightTextField.layer?.borderColor = NSColor(red: 218/255.0, green: 219/255.0, blue: 222/255.0, alpha: 1.0).cgColor sidebarPopUpButton.layer?.borderColor = NSColor(red: 218/255.0, green: 219/255.0, blue: 222/255.0, alpha: 1.0).cgColor widthPopUpButton.layer?.borderColor = NSColor(red: 218/255.0, green: 219/255.0, blue: 222/255.0, alpha: 1.0).cgColor headerPopUpButton.layer?.borderColor = NSColor(red: 218/255.0, green: 219/255.0, blue: 222/255.0, alpha: 1.0).cgColor footerPopUpButton.layer?.borderColor = NSColor(red: 218/255.0, green: 219/255.0, blue: 222/255.0, alpha: 1.0).cgColor } } }