// // 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