Archived
1

Added Lots of Documentation

Added some nice to haves
Improved and Unified General Code Layout
This commit is contained in:
Kim Wittenburg
2015-01-04 02:54:27 +01:00
parent 152b981e24
commit 7438fd1f95
83 changed files with 2282 additions and 416 deletions

View File

@@ -9,21 +9,23 @@
#import "MPExpressionLayout.h"
#import "MPExpression.h"
#import "MPExpression.h"
#import "MPPowerFunction.h"
#import "MPFunction.h"
#import "MPFunctionLayout.h"
#import "MPPowerFunctionLayout.h"
#import "MPToken.h"
#import "NSIndexPath+MPAdditions.h"
@interface MPExpressionLayout (MPLineGeneration)
- (CTLineRef)lineForElementAtIndex:(NSUInteger)index;
@end
@implementation MPExpressionLayout (MPLineGeneration)
- (CTLineRef)lineForElementAtIndex:(NSUInteger)index
@@ -60,9 +62,13 @@
@end
@implementation MPExpressionLayout
# pragma mark Creation Methods
- (instancetype)initWithExpression:(MPExpression *)expression
parent:(MPFunctionLayout *)parent
{
@@ -73,12 +79,16 @@
return self;
}
#pragma mark Cache Methods
- (NSUInteger)numberOfChildren
{
return self.expression.countElements;
}
- (MPLayout *)childLayoutAtIndex:(NSUInteger)index
{
id cachedObject = [self cachableObjectForIndex:index generator:^id{
@@ -95,6 +105,7 @@
return nil;
}
- (NSRect)boundsOfElementAtIndex:(NSUInteger)index
{
id symbol = [self.expression elementAtIndex:index];
@@ -109,7 +120,10 @@
}
}
#pragma mark Drawing Methods
- (NSRect)generateBounds
{
if (self.expression.countElements == 0) {
@@ -125,6 +139,7 @@
return NSMakeRect(x, y, width, height);
}
- (NSRect)boundingRectForRange:(NSRange)range
{
NSUInteger startOffset;
@@ -184,6 +199,7 @@
return NSMakeRect(x, self.bounds.origin.y, width, self.bounds.size.height);
}
- (NSPoint)offsetOfChildLayoutAtIndex:(NSUInteger)index
{
CGFloat x = 0;
@@ -193,6 +209,7 @@
return NSMakePoint(x, 0);
}
- (NSIndexPath *)indexPathForMousePoint:(NSPoint)point
{
NSUInteger currentPosition = 0;
@@ -235,11 +252,13 @@
}
}
- (BOOL)drawsChildrenManually
{
return YES;
}
- (void)draw
{
// Get the current context