Implemented the Sum Function
This commit is contained in:
35
MathPad/MPSumFunctionLayout.m
Normal file
35
MathPad/MPSumFunctionLayout.m
Normal 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
|
||||
Reference in New Issue
Block a user