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/MPRootFunctionLayout.m
2014-11-07 19:50:28 +01:00

83 lines
1.6 KiB
Objective-C

//
// MPRootFunctionLayout.m
// MathPad
//
// Created by Kim Wittenburg on 22.10.14.
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//
#import "MPRootFunctionLayout.h"
#define kRootFunctionSpaceBetweenRadicantAndExponent 5
@implementation MPRootFunctionLayout
- (MPRootFunction *)rootFunction
{
return (MPRootFunction *)self.function;
}
- (NSUInteger)indexOfLeadingChild
{
return 0;
}
- (NSUInteger)indexOfTrailingChild
{
return 1;
}
- (NSUInteger)indexOfChildAfterChildAtIndex:(NSUInteger)index
{
return index == 0 ? 1 : [super indexOfChildAfterChildAtIndex:index];
}
- (NSUInteger)indexOfChildBeforeChildAtIndex:(NSUInteger)index
{
return index == 1 ? 0 : [super indexOfChildBeforeChildAtIndex:index];
}
- (NSUInteger)indexOfChildBelowChildAtIndex:(NSUInteger)index
{
return 1;
}
- (NSUInteger)indexOfChildAboveChildAtIndex:(NSUInteger)index
{
return 0;
}
- (NSIndexSet *)indexesOfRemainingChildren
{
return [NSIndexSet indexSetWithIndex:1];
}
- (NSPoint)offsetOfChildLayoutAtIndex:(NSUInteger)index
{
NSRect exponentBounds = [self childLayoutAtIndex:0].bounds;
NSRect radicandBounds = [self childLayoutAtIndex:1].bounds;
if (index == 0) {
return NSMakePoint(0, (radicandBounds.size.height + radicandBounds.origin.y) / 2);
} else {
return NSMakePoint(exponentBounds.size.width + kRootFunctionSpaceBetweenRadicantAndExponent, 0);
}
}
- (BOOL)childAtIndexUsesSmallSize:(NSUInteger)index
{
return index == 0;
}
- (NSRect)generateBounds
{
return NSZeroRect;
}
- (void)draw
{
}
@end