Archived
1

Internal Redesign:

- Combined MPExpression and MPMutableExpression
- Abstracted children of MPExpression into MPExpressionElement protocol
- Abstracted most of MPExpressionLayout and MPFunctionLayout into common superclass MPLayout
This commit is contained in:
Kim Wittenburg
2014-08-11 13:57:48 +02:00
parent 740c3fd80a
commit 60760b8b3d
31 changed files with 1222 additions and 1343 deletions

View File

@@ -16,20 +16,21 @@
return (MPSumFunction *)self.function;
}
- (NSSize)calculateSize
- (NSBezierPath *)generateBezierPath
{
NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"∑" attributes:@{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:50.0]}];
[self.textStorage setAttributedString:text];
NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"∑"
attributes:@{NSFontAttributeName: [NSFont fontWithName:@"Lucida Grande" size:18.0]}];
self.textStorage.attributedString = text;
NSRange glyphRange = [self.layoutManager glyphRangeForTextContainer:self.textContainer];
return [self.layoutManager boundingRectForGlyphRange:glyphRange inTextContainer:self.textContainer].size;
}
- (void)drawFunctionAtPoint:(NSPoint)point
{
NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"∑" attributes:@{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:50.0]}];
[self.textStorage setAttributedString:text];
NSRange glyphRange = [self.layoutManager glyphRangeForTextContainer:self.textContainer];
[self.layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:point];
NSGlyph glyphs[glyphRange.length+1];
NSUInteger actualGylphCount = [self.layoutManager getGlyphs:glyphs
range:glyphRange];
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint:NSZeroPoint];
[path appendBezierPathWithGlyphs:glyphs
count:actualGylphCount
inFont:[NSFont fontWithName:@"Lucida Grande" size:18.0]];
return path;
}
@end