36 lines
1.2 KiB
Objective-C
36 lines
1.2 KiB
Objective-C
//
|
|
// 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
|