Archived
1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mathpad/MathPad/MPSumFunctionLayout.m
2014-04-23 03:14:59 +02:00

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