Archived
1

Implemented the Sum Function

This commit is contained in:
Kim Wittenburg
2014-04-23 03:14:59 +02:00
parent 636921b9dc
commit cf13399747
4 changed files with 191 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
//
// MPSumFunctionLayout.m
// MathPad
//
// Created by Kim Wittenburg on 23.04.14.
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//
#import "MPSumFunctionLayout.h"
#import "MPSumFunction.h"
@implementation MPSumFunctionLayout
- (MPSumFunction *)sumFunction
{
return (MPSumFunction *)self.function;
}
- (NSSize)calculateSize
{
NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"∑" attributes:@{NSFontAttributeName: [NSFont fontWithName:@"HelveticaNeue" size:50.0]}];
[self.textStorage setAttributedString: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];
}
@end