Reorganized File Structure
Added Documentation
This commit is contained in:
58
MathKit/MPExpressionStorage.m
Normal file
58
MathKit/MPExpressionStorage.m
Normal file
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// MPExpressionStorage.m
|
||||
// MathPad
|
||||
//
|
||||
// Created by Kim Wittenburg on 22.04.14.
|
||||
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPExpressionStorage.h"
|
||||
|
||||
#import "MPExpressionView.h"
|
||||
#import "MPLayout.h"
|
||||
#import "MPExpressionLayout.h"
|
||||
|
||||
#import "MPRangePath.h"
|
||||
|
||||
@interface MPExpressionStorage ()
|
||||
@property (nonatomic, strong) NSLayoutManager *layoutManager;
|
||||
@property (nonatomic, strong) NSTextContainer *textContainer;
|
||||
@property (nonatomic, strong) NSTextStorage *textStorage;
|
||||
@end
|
||||
|
||||
@implementation MPExpressionStorage
|
||||
|
||||
- (instancetype)initWithElements:(NSArray *)elements
|
||||
{
|
||||
self = [super initWithElements:elements];
|
||||
if (self) {
|
||||
_rootLayout = [[MPExpressionLayout alloc] initWithExpression:self parent:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setExpressionView:(MPExpressionView *)expressionView
|
||||
{
|
||||
_expressionView = expressionView;
|
||||
self.rootLayout = [[MPExpressionLayout alloc] initWithExpression:self parent:nil];
|
||||
self.rootLayout.flipped = expressionView.flipped;
|
||||
}
|
||||
|
||||
- (void)changedElementsInRangePath:(MPRangePath *)rangePath
|
||||
replacementLength:(NSUInteger)replacementLength
|
||||
{
|
||||
if (rangePath.location.length == 0) {
|
||||
return;
|
||||
}
|
||||
MPLayout *current = self.rootLayout;
|
||||
for (NSUInteger position = 0; position < rangePath.location.length-1; position++) {
|
||||
NSUInteger index = [rangePath.location indexAtPosition:position];
|
||||
current = [current childLayoutAtIndex:index];
|
||||
}
|
||||
[current clearCacheInRange:rangePath.rangeAtLastIndex
|
||||
replacementLength:replacementLength];
|
||||
[self.expressionView invalidateIntrinsicContentSize];
|
||||
self.expressionView.needsDisplay = YES;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user