Corrected MVC Implementation
This commit is contained in:
@@ -21,38 +21,17 @@
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
@class MPExpressionStorage
|
@class MPExpressionStorage
|
||||||
@abstract An expression storage manages the contents of an expression view
|
@abstract An expression storage manages the contents of an expression view.
|
||||||
and notifies it when the underlying expression changes.
|
|
||||||
*/
|
*/
|
||||||
@interface MPExpressionStorage : MPExpression
|
@interface MPExpressionStorage : MPExpression
|
||||||
|
|
||||||
/*!
|
|
||||||
@property expressionView
|
|
||||||
@abstract The receiver's expression view.
|
|
||||||
|
|
||||||
@discussion The expression view is the view that displays the contents of an
|
|
||||||
expression storage. Normally you should not call the setter of
|
|
||||||
this property. It is automatically assigned when the <code>@link
|
|
||||||
//apple_ref/occ/instp/MPExpressionView/expressionStorage@/link</code>
|
|
||||||
property of the respective <code>@link
|
|
||||||
//apple_ref/occ/cl/MPExpressionView@/link</code> instance is set.
|
|
||||||
|
|
||||||
When this property is set the receiver assumes that the
|
|
||||||
displaying expression view has changed (regardless of wether the
|
|
||||||
actual value of the property changed or not). It then adapts to
|
|
||||||
the properties of the new expression view and discards the
|
|
||||||
current root layout.
|
|
||||||
*/
|
|
||||||
@property (nonatomic, weak) MPExpressionView *expressionView;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@property rootLayout
|
@property rootLayout
|
||||||
@abstract The receiver's root layout.
|
@abstract The receiver's root layout.
|
||||||
|
|
||||||
@discussion The root layout is the root node of the layout tree that draws
|
@discussion The root layout is the root node of the layout tree that draws
|
||||||
the receiver's contents. For more information see the
|
the receiver's contents in an expression view. For more
|
||||||
documentation on the <code>@link
|
information see the documentation on the <code>@link
|
||||||
//apple_ref/occ/cl/MPLayout@/link</code> class.
|
//apple_ref/occ/cl/MPLayout@/link</code> class.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, strong) MPExpressionLayout *rootLayout;
|
@property (nonatomic, strong) MPExpressionLayout *rootLayout;
|
||||||
|
|||||||
@@ -37,14 +37,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)setExpressionView:(MPExpressionView *)expressionView
|
|
||||||
{
|
|
||||||
_expressionView = expressionView;
|
|
||||||
self.rootLayout = [[MPExpressionLayout alloc] initWithExpression:self parent:nil];
|
|
||||||
self.rootLayout.flipped = expressionView.flipped;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
- (void)changedElementsInRangePath:(MPRangePath *)rangePath
|
- (void)changedElementsInRangePath:(MPRangePath *)rangePath
|
||||||
replacementLength:(NSUInteger)replacementLength
|
replacementLength:(NSUInteger)replacementLength
|
||||||
{
|
{
|
||||||
@@ -58,8 +50,6 @@
|
|||||||
}
|
}
|
||||||
[current clearCacheInRange:rangePath.rangeAtLastIndex
|
[current clearCacheInRange:rangePath.rangeAtLastIndex
|
||||||
replacementLength:replacementLength];
|
replacementLength:replacementLength];
|
||||||
[self.expressionView invalidateIntrinsicContentSize];
|
|
||||||
self.expressionView.needsDisplay = YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -348,7 +348,7 @@
|
|||||||
{
|
{
|
||||||
// Setup the Expression Storage
|
// Setup the Expression Storage
|
||||||
MPExpressionStorage *expressionStorage = [[MPExpressionStorage alloc] init];
|
MPExpressionStorage *expressionStorage = [[MPExpressionStorage alloc] init];
|
||||||
expressionStorage.expressionView = self;
|
expressionStorage.rootLayout.expressionView = self;
|
||||||
_expressionStorage = expressionStorage;
|
_expressionStorage = expressionStorage;
|
||||||
|
|
||||||
[self initializeButtons];
|
[self initializeButtons];
|
||||||
@@ -472,9 +472,9 @@
|
|||||||
|
|
||||||
- (void)setExpressionStorage:(MPExpressionStorage *)expressionStorage
|
- (void)setExpressionStorage:(MPExpressionStorage *)expressionStorage
|
||||||
{
|
{
|
||||||
_expressionStorage.expressionView = nil;
|
_expressionStorage.rootLayout.expressionView = nil;
|
||||||
_expressionStorage = expressionStorage;;
|
_expressionStorage = expressionStorage;;
|
||||||
_expressionStorage.expressionView = self;
|
_expressionStorage.rootLayout.expressionView = self;
|
||||||
[self invalidateIntrinsicContentSize];
|
[self invalidateIntrinsicContentSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@class MPLayout, MPRangePath;
|
@class MPLayout, MPExpressionView, MPRangePath;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -149,6 +149,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@property expressionView
|
||||||
|
@abstract The receiver's expression view.
|
||||||
|
|
||||||
|
@discussion The expression view is the view in which the receivin
|
||||||
|
<code>MPLayout</code> instance draws itself into. Normally you
|
||||||
|
should not call the setter of this property. It is automatically
|
||||||
|
assigned when the <code>@link
|
||||||
|
//apple_ref/occ/instp/MPExpressionView/expressionStorage@/link</code>
|
||||||
|
property of the respective <code>@link
|
||||||
|
//apple_ref/occ/cl/MPExpressionView@/link</code> instance is set.
|
||||||
|
*/
|
||||||
|
@property (nonatomic, weak) MPExpressionView *expressionView;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@method font
|
@method font
|
||||||
@abstract Returns the receiver's context inferred font.
|
@abstract Returns the receiver's context inferred font.
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#import "MPLayout.h"
|
#import "MPLayout.h"
|
||||||
|
|
||||||
|
#import "MPExpressionView.h"
|
||||||
|
|
||||||
#import "MPRangePath.h"
|
#import "MPRangePath.h"
|
||||||
#import "NSIndexPath+MPAdditions.h"
|
#import "NSIndexPath+MPAdditions.h"
|
||||||
|
|
||||||
@@ -54,6 +56,14 @@
|
|||||||
#pragma mark Properties
|
#pragma mark Properties
|
||||||
|
|
||||||
|
|
||||||
|
- (void)setExpressionView:(MPExpressionView *)expressionView
|
||||||
|
{
|
||||||
|
self.flipped = expressionView.flipped;
|
||||||
|
[_cache removeAllObjects];
|
||||||
|
[self invalidate];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
- (NSFont *)normalFontWithSize:(CGFloat)size
|
- (NSFont *)normalFontWithSize:(CGFloat)size
|
||||||
{
|
{
|
||||||
return [NSFont fontWithName:@"CMU Serif"
|
return [NSFont fontWithName:@"CMU Serif"
|
||||||
@@ -135,6 +145,8 @@
|
|||||||
[_cache replaceObjectsInRange:range
|
[_cache replaceObjectsInRange:range
|
||||||
withObjectsFromArray:placeholders];
|
withObjectsFromArray:placeholders];
|
||||||
[self invalidate];
|
[self invalidate];
|
||||||
|
[self.expressionView invalidateIntrinsicContentSize];
|
||||||
|
self.expressionView.needsDisplay = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user