-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBinaryOp.h
executable file
·68 lines (64 loc) · 2.66 KB
/
BinaryOp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// ##############################################################
// BinaryOp.h
// Magic Number Machine
//
// Created by Matt Gallagher on Sun May 04 2003.
// Copyright (c) 2003 Matt Gallagher. All rights reserved.
// ##############################################################
#import "Expression.h"
//
// About BinaryOp
//
// A binary operation is one that requires two inputs, typically one before the operator
// and one afterwards. Examples include +, -, and, x^y, etc.
//
// Most of this class exists to simply extend the default node behaviour to include a
// second child node.
//
// The particular difficulty with a this class is that there are really three types of binary
// operator that have been smushed (sure, that's a word) together: loosely binding (+, -),
// normal binding (*, /, and) and tightly binding (x^y). This different behaviour comes
// out of the "order of operations". As such, theses different behaviours should have
// been different classes. Oh well.
//
@interface BinaryOp : Expression
{
@protected
int op;
BOOL userSkippedLeft;
Expression *leftChild;
NSRect leftChildNaturalBounds;
NSRect leftChildDisplayBounds;
}
- (instancetype)initWithParent:(Expression*)newParent manager:(DataManager*)newManager
leftChild:(Expression*)newChild andOp:(int)newOp;
- (instancetype)initWithCoder:(NSCoder *)coder;
- (void)encodeWithCoder:(NSCoder *)coder;
- (void)appendDigit:(int)digit;
- (void)appendOpToPath:(NSBezierPath*)path atLevel:(int)level;
- (void)binaryOpPressed:(int)newOp;
- (void)bracketPressed;
- (void)childChanged:(Expression*)oldChild replacedWith:(Expression*)newChild;
- (void)childDeleted:(Expression*)oldChild;
- (void)constantPressed:(int)constant;
- (void)deleteDigit;
- (void)equalsPressed;
- (void)exponentPressed;
- (void)expressionInserted:(Expression*)newExpression;
@property (NS_NONATOMIC_IOSONLY, getter=getCaretPoint, readonly) NSPoint caretPoint;
@property (NS_NONATOMIC_IOSONLY, getter=getExpressionString, readonly, copy) NSString *expressionString;
@property (NS_NONATOMIC_IOSONLY, getter=getValue, readonly, strong) BigCFloat *value;
@property (NS_NONATOMIC_IOSONLY, readonly, strong) Expression *leftChild;
- (void)managerChanged:(DataManager*)newManager;
- (Expression*)nodeContainingPoint:(NSPoint)point;
- (NSBezierPath*)pathAtLevel:(int)level;
- (void)postOpPressed:(int)op;
- (void)preOpPressed:(int)op;
- (void)receiveBounds:(NSRect)bounds;
- (void)refresh;
- (void)replaceChild:(Expression*)oldChild withBinOp:(int)newOp;
- (void)replaceChild:(Expression*)node withPostOp:(int)newOp;
- (void)replaceChild:(Expression*)node withValue:(BigCFloat*)newOp;
- (void)userPointPressed;
- (void)valueInserted:(BigCFloat*)newValue;
@end