// // MPExpressionLayout.h // MathPad // // Created by Kim Wittenburg on 22.04.14. // Copyright (c) 2014 Kim Wittenburg. All rights reserved. // #import @class MPExpressionLayout, MPFunctionLayout, MPExpressionStorage, MPExpression; @interface MPExpressionLayout : NSObject { BOOL _valid; NSSize _cachedSize; NSMutableArray *_symbolCache; } #pragma mark Creation Methods // -init not supported - (id)initRootLayoutWithExpressionStorage:(MPExpressionStorage *)expressionStorage; - (id)initWithExpressionPath:(NSIndexPath *)expressionPath parent:(MPFunctionLayout *)parent; #pragma mark Properties @property (readonly, nonatomic, weak) MPFunctionLayout *parent; @property (readonly, nonatomic, weak) MPExpressionStorage *expressionStorage; @property (readonly, nonatomic, strong) NSIndexPath *expressionPath; - (MPExpression *)expression; // Convenience - (NSLayoutManager *)layoutManager; - (NSTextContainer *)textContainer; - (NSTextStorage *)textStorage; #pragma mark Cache Methods - (void)invalidate; - (void)expressionEditedInRange:(NSRange)range replacementLength:(NSUInteger)length; - (BOOL)hasCacheForSymbolAtIndex:(NSUInteger)index; - (MPFunctionLayout *)functionLayoutForFunctionAtIndex:(NSUInteger)index; - (NSSize)cachedSizeForSymbolAtIndex:(NSUInteger)index; - (void)cacheSize:(NSSize)size forSymbolAtIndex:(NSUInteger)index; #pragma mark Sizes Calculation Methods - (NSSize)sizeForAllSymbols; - (NSSize)sizeForSymbolAtIndex:(NSUInteger)index; - (NSSize)sizeForSymbolsInRange:(NSRange)range; #pragma mark Drawing Methods - (void)drawSymbolAtIndex:(NSUInteger)index atPoint:(NSPoint)point; - (void)drawSymbolsInRange:(NSRange)range atPoint:(NSPoint)point; - (void)drawAllSymbolsAtPoint:(NSPoint)point; @end