Interface Redesign to show evaluation results
This commit is contained in:
@@ -6,7 +6,9 @@
|
|||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="MPDocument">
|
<customObject id="-2" userLabel="File's Owner" customClass="MPDocument">
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="resultExpressionView" destination="lcd-Ip-jjR" id="1NN-l5-30k"/>
|
<outlet property="errorLabel" destination="fw3-bj-cPR" id="vaC-tD-zlq"/>
|
||||||
|
<outlet property="expressionView" destination="lcd-Ip-jjR" id="Vww-eh-hP7"/>
|
||||||
|
<outlet property="resultLabel" destination="B5H-rE-1e9" id="Z5D-Co-tV1"/>
|
||||||
<outlet property="window" destination="xOd-HO-29H" id="JIz-fz-R2o"/>
|
<outlet property="window" destination="xOd-HO-29H" id="JIz-fz-R2o"/>
|
||||||
</connections>
|
</connections>
|
||||||
</customObject>
|
</customObject>
|
||||||
@@ -22,28 +24,67 @@
|
|||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="lcd-Ip-jjR" customClass="MPExpressionView">
|
<customView translatesAutoresizingMaskIntoConstraints="NO" id="lcd-Ip-jjR" customClass="MPExpressionView">
|
||||||
<rect key="frame" x="20" y="61" width="467" height="170"/>
|
<rect key="frame" x="20" y="70" width="467" height="161"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
</customView>
|
</customView>
|
||||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lvU-8o-qPV">
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ar2-1O-Kl1">
|
||||||
<rect key="frame" x="207" y="13" width="93" height="32"/>
|
<rect key="frame" x="18" y="45" width="47" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<buttonCell key="cell" type="push" title="Evaluate" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Zda-mn-Rjr">
|
<constraints>
|
||||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
<constraint firstAttribute="width" constant="43" id="EI3-gZ-BdS"/>
|
||||||
|
</constraints>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Result:" id="lYc-e4-5j0">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
</buttonCell>
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
<connections>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
<action selector="evaluateExpressiom:" target="-2" id="jUp-32-wwK"/>
|
</textFieldCell>
|
||||||
</connections>
|
</textField>
|
||||||
</button>
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jQo-M8-to6">
|
||||||
|
<rect key="frame" x="18" y="20" width="40" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="width" constant="36" id="v3s-bP-5SY"/>
|
||||||
|
</constraints>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Error:" id="0q9-PK-glz">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="B5H-rE-1e9">
|
||||||
|
<rect key="frame" x="71" y="45" width="418" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" id="KBm-kx-spX">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="fw3-bj-cPR">
|
||||||
|
<rect key="frame" x="75" y="20" width="414" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" id="uaX-CN-Uoz">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="bottom" secondItem="lvU-8o-qPV" secondAttribute="bottom" constant="20" symbolic="YES" id="5ws-Hh-dXO"/>
|
<constraint firstItem="lcd-Ip-jjR" firstAttribute="top" secondItem="gIp-Ho-8D9" secondAttribute="top" constant="20" symbolic="YES" id="3g8-dx-OX8"/>
|
||||||
<constraint firstItem="lvU-8o-qPV" firstAttribute="top" secondItem="lcd-Ip-jjR" secondAttribute="bottom" constant="20" symbolic="YES" id="CEh-81-Hu6"/>
|
<constraint firstItem="B5H-rE-1e9" firstAttribute="trailing" secondItem="fw3-bj-cPR" secondAttribute="trailing" id="61b-ou-IhC"/>
|
||||||
<constraint firstItem="lcd-Ip-jjR" firstAttribute="top" secondItem="gIp-Ho-8D9" secondAttribute="top" constant="20" symbolic="YES" id="Raj-xq-imM"/>
|
<constraint firstItem="fw3-bj-cPR" firstAttribute="baseline" secondItem="jQo-M8-to6" secondAttribute="baseline" id="85V-7u-zhv"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="lcd-Ip-jjR" secondAttribute="trailing" constant="20" symbolic="YES" id="Xh2-Qb-urL"/>
|
<constraint firstItem="fw3-bj-cPR" firstAttribute="leading" secondItem="jQo-M8-to6" secondAttribute="trailing" constant="21" id="C53-c9-INb"/>
|
||||||
<constraint firstItem="lcd-Ip-jjR" firstAttribute="centerX" secondItem="lvU-8o-qPV" secondAttribute="centerX" id="pq6-dU-P1M"/>
|
<constraint firstItem="ar2-1O-Kl1" firstAttribute="baseline" secondItem="B5H-rE-1e9" secondAttribute="baseline" id="K1d-om-K23"/>
|
||||||
<constraint firstItem="lcd-Ip-jjR" firstAttribute="leading" secondItem="gIp-Ho-8D9" secondAttribute="leading" constant="20" symbolic="YES" id="wPr-ZO-8KR"/>
|
<constraint firstAttribute="bottom" secondItem="jQo-M8-to6" secondAttribute="bottom" constant="20" symbolic="YES" id="Oet-xR-WPz"/>
|
||||||
|
<constraint firstItem="jQo-M8-to6" firstAttribute="leading" secondItem="ar2-1O-Kl1" secondAttribute="leading" id="UyW-dW-kNf"/>
|
||||||
|
<constraint firstItem="B5H-rE-1e9" firstAttribute="trailing" secondItem="lcd-Ip-jjR" secondAttribute="trailing" id="VN8-ni-28x"/>
|
||||||
|
<constraint firstItem="ar2-1O-Kl1" firstAttribute="leading" secondItem="lcd-Ip-jjR" secondAttribute="leading" id="X5m-hl-tOG"/>
|
||||||
|
<constraint firstItem="jQo-M8-to6" firstAttribute="top" secondItem="ar2-1O-Kl1" secondAttribute="bottom" constant="8" symbolic="YES" id="Zv5-DC-xhH"/>
|
||||||
|
<constraint firstItem="B5H-rE-1e9" firstAttribute="leading" secondItem="ar2-1O-Kl1" secondAttribute="trailing" constant="10" id="a1q-H8-Mfg"/>
|
||||||
|
<constraint firstItem="ar2-1O-Kl1" firstAttribute="top" secondItem="lcd-Ip-jjR" secondAttribute="bottom" constant="8" symbolic="YES" id="bDG-CZ-mMi"/>
|
||||||
|
<constraint firstItem="lcd-Ip-jjR" firstAttribute="leading" secondItem="gIp-Ho-8D9" secondAttribute="leading" constant="20" symbolic="YES" id="kTW-r9-ulq"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="lcd-Ip-jjR" secondAttribute="trailing" constant="20" symbolic="YES" id="kl8-mR-t1l"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
<connections>
|
<connections>
|
||||||
|
|||||||
@@ -6,12 +6,14 @@
|
|||||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
@class MPDocument, MPExpressionView;
|
#import <MathKit/MathKit.h>
|
||||||
|
|
||||||
@interface MPDocument : NSDocument
|
@interface MPDocument : NSDocument
|
||||||
|
|
||||||
@property (weak) IBOutlet MPExpressionView *resultExpressionView;
|
@property (weak) IBOutlet MPExpressionView *expressionView;
|
||||||
|
@property (weak) IBOutlet NSTextField *resultLabel;
|
||||||
|
@property (weak) IBOutlet NSTextField *errorLabel;
|
||||||
|
|
||||||
- (IBAction)evaluateExpressiom:(id)sender;
|
- (IBAction)evaluateExpression:(id)sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "MPDocument.h"
|
#import "MPDocument.h"
|
||||||
#import "MPView.h"
|
|
||||||
|
|
||||||
@implementation MPDocument
|
@implementation MPDocument
|
||||||
|
|
||||||
@@ -30,6 +29,8 @@
|
|||||||
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
|
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
|
||||||
{
|
{
|
||||||
[super windowControllerDidLoadNib:aController];
|
[super windowControllerDidLoadNib:aController];
|
||||||
|
self.expressionView.target = self;
|
||||||
|
self.expressionView.action = @selector(evaluateExpression:);
|
||||||
// Add any code here that needs to be executed once the windowController has loaded the document's window.
|
// Add any code here that needs to be executed once the windowController has loaded the document's window.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,12 +59,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark Actions
|
#pragma mark Actions
|
||||||
- (IBAction)evaluateExpressiom:(id)sender {
|
- (IBAction)evaluateExpression:(id)sender {
|
||||||
NSError *error;
|
MPParseError *error;
|
||||||
NSLog(@"Result: %f", [self.resultExpressionView.expressionStorage evaluateExpression:&error]);
|
NSDecimalNumber *result = [self.expressionView.expressionStorage evaluateWithError:&error];
|
||||||
if (error) {
|
self.resultLabel.stringValue = result != nil ? result.description : @"Error!";
|
||||||
NSLog(@"Error: %@", error);
|
self.errorLabel.stringValue = error != nil ? error.description : @"No Error";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user