// // ASIntPropertyCell.swift // KdanAuto // // Created by 朱东勇 on 2023/4/17. // import Cocoa class ASSizePropertyCell: ASPropertyCell, NSTextFieldDelegate { @IBOutlet var m_titleLbl:NSTextField! @IBOutlet var m_wTF:NSTextField! @IBOutlet var m_hTF:NSTextField! override class func shared() -> ASPropertyCell? { var objects : NSArray! Bundle.main.loadNibNamed("ASSizePropertyCell", owner: nil, topLevelObjects: &objects) for tView in objects { if let tv = tView as? ASSizePropertyCell { return tv } } return nil } /// Setter override func setPropertyInfo(_ info:NSDictionary) { super.setPropertyInfo(info) self.m_titleLbl.stringValue = "\(info.value(forKey: "Name") ?? ""):" setValue((info.value(forKey: "DefaultValue") ?? "0") as AnyObject) } override func setValue(_ value:AnyObject) { super.setValue(value) if (value as? String) != nil { let sizeString = value as! String let size = NSSizeFromString(sizeString); self.m_wTF.stringValue = "\(size.width)"; self.m_hTF.stringValue = "\(size.height)"; } } override func value() -> AnyObject { let size = CGSizeMake(CGFloat(NSString(string: self.m_wTF.stringValue).floatValue), CGFloat(NSString(string: self.m_hTF.stringValue).floatValue)) return NSStringFromSize(size) as AnyObject } override func setEnabled(_ enabled:Bool) { super.setEnabled(enabled) self.alphaValue = enabled ? 1 : 0.6 self.m_wTF.isEnabled = enabled; self.m_hTF.isEnabled = enabled; } }