76 lines
1.6 KiB
Objective-C
76 lines
1.6 KiB
Objective-C
//
|
|
// MPPowerFunctionLayout.m
|
|
// MathKit
|
|
//
|
|
// Created by Kim Wittenburg on 30.09.14.
|
|
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
|
|
//
|
|
|
|
#import "MPPowerFunctionLayout.h"
|
|
|
|
#import "MPPowerFunction.h"
|
|
|
|
|
|
#define kPowerFunctionExponentXOffset 1
|
|
#define kPowerFunctionTrailingOffset 2
|
|
|
|
|
|
|
|
@implementation MPPowerFunctionLayout
|
|
|
|
- (NSRect)baseBounds
|
|
{
|
|
if (NSEqualRects(_baseBounds, NSZeroRect)) {
|
|
return NSMakeRect(0, kMPEmptyBoxYOrigin, 0, kMPEmptyBoxHeight);
|
|
}
|
|
return _baseBounds;
|
|
}
|
|
|
|
|
|
- (MPPowerFunction *)powerFunction
|
|
{
|
|
return (MPPowerFunction *)self.function;
|
|
}
|
|
|
|
|
|
- (NSIndexSet *)indexesOfRemainingChildren
|
|
{
|
|
return [NSIndexSet indexSetWithIndex:0];
|
|
}
|
|
|
|
|
|
#warning Broken Power Layout
|
|
- (NSPoint)offsetOfChildLayoutAtIndex:(NSUInteger)index
|
|
{
|
|
NSRect exponentBounds = [self childLayoutAtIndex:0].bounds;
|
|
CGFloat y = (self.baseBounds.size.height + self.baseBounds.origin.y) - ((exponentBounds.size.height + exponentBounds.origin.y) / 2);
|
|
return NSMakePoint(kPowerFunctionExponentXOffset, y);
|
|
}
|
|
|
|
|
|
- (BOOL)childAtIndexUsesSmallSize:(NSUInteger)index
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
|
|
- (NSIndexPath *)indexPathForLocalMousePoint:(NSPoint)point
|
|
{
|
|
return [[NSIndexPath indexPathWithIndex:0] indexPathByAddingIndex:0];
|
|
}
|
|
|
|
|
|
- (NSRect)generateBounds
|
|
{
|
|
NSRect exponentBounds = [self childLayoutAtIndex:0].bounds;
|
|
CGFloat height = [self offsetOfChildLayoutAtIndex:0].y + exponentBounds.size.height + exponentBounds.origin.y;
|
|
CGFloat width = kPowerFunctionExponentXOffset + exponentBounds.size.width + kPowerFunctionTrailingOffset;
|
|
return NSMakeRect(0, 0, width, height);
|
|
}
|
|
|
|
|
|
- (void)draw
|
|
{}
|
|
|
|
@end
|