12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- //
- // ASIntPropertyCell.swift
- // KdanAuto
- //
- // Created by 朱东勇 on 2023/4/17.
- //
- import Cocoa
- class ASRectPropertyCell: ASPropertyCell, NSTextFieldDelegate {
- @IBOutlet var m_titleLbl:NSTextField!
- @IBOutlet var m_xTF:NSTextField!
- @IBOutlet var m_yTF:NSTextField!
- @IBOutlet var m_wTF:NSTextField!
- @IBOutlet var m_hTF:NSTextField!
- override class func shared() -> ASPropertyCell? {
- var objects : NSArray!
-
- Bundle.main.loadNibNamed("ASRectPropertyCell", owner: nil, topLevelObjects: &objects)
-
- for tView in objects {
- if let tv = tView as? ASRectPropertyCell {
- 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 rectString = value as! String
- let rect = NSRectFromString(rectString);
-
- self.m_xTF.stringValue = "\(rect.origin.x)";
- self.m_yTF.stringValue = "\(rect.origin.y)";
- self.m_wTF.stringValue = "\(rect.size.width)";
- self.m_hTF.stringValue = "\(rect.size.height)";
- }
- }
-
- override func value() -> AnyObject {
- let rect = CGRectMake(CGFloat(NSString(string: self.m_xTF.stringValue).floatValue),
- CGFloat(NSString(string: self.m_yTF.stringValue).floatValue),
- CGFloat(NSString(string: self.m_wTF.stringValue).floatValue),
- CGFloat(NSString(string: self.m_hTF.stringValue).floatValue))
- return NSStringFromRect(rect) as AnyObject
- }
-
-
- override func setEnabled(_ enabled:Bool) {
- super.setEnabled(enabled)
-
- self.alphaValue = enabled ? 1 : 0.6
- self.m_xTF.isEnabled = enabled;
- self.m_yTF.isEnabled = enabled;
- self.m_wTF.isEnabled = enabled;
- self.m_hTF.isEnabled = enabled;
- }
-
- }
|