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/MPExpressionView.m
Kim Wittenburg 60760b8b3d Internal Redesign:
- Combined MPExpression and MPMutableExpression
- Abstracted children of MPExpression into MPExpressionElement protocol
- Abstracted most of MPExpressionLayout and MPFunctionLayout into common superclass MPLayout
2014-08-11 13:57:48 +02:00

83 lines
1.7 KiB
Objective-C

//
// MPExpressionView.m
// MathPad
//
// Created by Kim Wittenburg on 17.04.14.
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//
#import "MPExpressionView.h"
#import "MPExpressionStorage.h"
#import "MPExpressionLayout.h"
#import "MPSumFunction.h"
@interface MPExpressionView (MPCursor)
@property (nonatomic, strong) NSTimer *cursorTimer;
@end
@implementation MPExpressionView
#pragma mark Creation Methods
- (instancetype)init
{
self = [super init];
if (self) {
[self initializeObjects];
}
return self;
}
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initializeObjects];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
[self initializeObjects];
}
return self;
}
- (void)initializeObjects
{
MPExpressionStorage *expressionStorage = [[MPExpressionStorage alloc] initWithElements:@[@"12345", [[MPSumFunction alloc] init], [[MPSumFunction alloc] init]]];
_expressionStorage = expressionStorage;
}
#pragma mark Properties
- (BOOL)isFlipped
{
return NO;
}
- (void)setExpressionStorage:(MPExpressionStorage *)expressionStorage
{
_expressionStorage = expressionStorage;
}
#pragma mark Drawing Methods
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
[[NSColor whiteColor] set];
NSRectFill(self.bounds);
[[NSColor blackColor] set];
NSSize expressionSize = [self.expressionStorage.rootLayout size];
CGFloat y = (self.bounds.size.height - expressionSize.height) / 2;
NSPoint point = NSMakePoint(self.bounds.origin.x, self.bounds.origin.y + y);
[self.expressionStorage.rootLayout drawAtPoint:point];
}
@end