83 lines
1.6 KiB
Objective-C
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
|