Added Lots of Documentation
Added some nice to haves Improved and Unified General Code Layout
This commit is contained in:
@@ -8,18 +8,21 @@
|
||||
|
||||
#import "MPFunctionsViewController.h"
|
||||
|
||||
#import "MPExpression.h"
|
||||
#import "NSString+MPExpressionElement.h"
|
||||
#import "MPFunction.h"
|
||||
#import "MPSumFunction.h"
|
||||
#import "MPFractionFunction.h"
|
||||
#import "MPParenthesisFunction.h"
|
||||
#import "MPPowerFunction.h"
|
||||
#import "MPFractionFunction.h"
|
||||
#import "MPSumFunction.h"
|
||||
|
||||
#import "MPFunctionLayout.h"
|
||||
|
||||
#import "NSString+MPExpressionElement.h"
|
||||
|
||||
|
||||
|
||||
@class MPFunctionsCollectionView, MPFunctionTemplateView, MPFunctionTemplateItem;
|
||||
|
||||
|
||||
@interface MPFunctionsCollectionView : NSCollectionView
|
||||
|
||||
@property (nonatomic, weak) MPFunctionTemplateItem *hoverItem;
|
||||
@@ -30,6 +33,7 @@
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface MPFunctionTemplateView : NSView
|
||||
|
||||
@property (nonatomic, strong) MPFunction *functionTemplate;
|
||||
@@ -42,16 +46,20 @@
|
||||
|
||||
|
||||
@interface MPFunctionTemplateItem : NSCollectionViewItem
|
||||
|
||||
@property (nonatomic, copy) NSString *templateName;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation MPFunctionsCollectionView
|
||||
|
||||
- (void)mouseDown:(NSEvent *)theEvent
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
- (void)mouseUp:(NSEvent *)theEvent
|
||||
{
|
||||
NSPoint pointInView = [self convertPoint:theEvent.locationInWindow
|
||||
@@ -87,25 +95,30 @@
|
||||
[super updateTrackingAreas];
|
||||
}
|
||||
|
||||
|
||||
- (void)mouseEntered:(NSEvent *)theEvent
|
||||
{
|
||||
self.mouseOver = YES;
|
||||
self.needsDisplay = YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)mouseExited:(NSEvent *)theEvent
|
||||
{
|
||||
self.mouseOver = NO;
|
||||
self.needsDisplay = YES;
|
||||
}
|
||||
|
||||
|
||||
- (void)setFunctionTemplate:(MPFunction *)functionTemplate
|
||||
{
|
||||
_functionTemplate = functionTemplate;
|
||||
_functionTemplateLayout = nil;
|
||||
}
|
||||
|
||||
|
||||
@synthesize functionTemplateLayout = _functionTemplateLayout;
|
||||
|
||||
- (MPFunctionLayout *)functionTemplateLayout
|
||||
{
|
||||
|
||||
@@ -117,16 +130,19 @@
|
||||
return _functionTemplateLayout;
|
||||
}
|
||||
|
||||
|
||||
- (NSSize)intrinsicContentSize
|
||||
{
|
||||
return [self.functionTemplateLayout bounds].size;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)isOpaque
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
- (void)drawRect:(NSRect)dirtyRect
|
||||
{
|
||||
if (self.mouseOver) {
|
||||
@@ -150,11 +166,13 @@
|
||||
|
||||
static void *MPFunctionTemplateViewMouseOverContext = @"MPFunctionTemplateViewMouseOverContext";
|
||||
|
||||
|
||||
- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder
|
||||
{
|
||||
return [super awakeAfterUsingCoder:aDecoder];
|
||||
}
|
||||
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||
ofObject:(id)object
|
||||
change:(NSDictionary *)change
|
||||
@@ -171,6 +189,7 @@ static void *MPFunctionTemplateViewMouseOverContext = @"MPFunctionTemplateViewMo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)setRepresentedObject:(id)representedObject
|
||||
{
|
||||
MPFunctionTemplateView *view = (MPFunctionTemplateView *)self.view;
|
||||
@@ -191,6 +210,8 @@ static void *MPFunctionTemplateViewMouseOverContext = @"MPFunctionTemplateViewMo
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation MPFunctionsViewController
|
||||
|
||||
- (id)init
|
||||
@@ -199,6 +220,7 @@ static void *MPFunctionTemplateViewMouseOverContext = @"MPFunctionTemplateViewMo
|
||||
bundle:[NSBundle bundleForClass:[self class]]];
|
||||
}
|
||||
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
MPFunction *sumFunction = [[MPSumFunction alloc] init];
|
||||
@@ -227,40 +249,45 @@ static void *MPFunctionTemplateViewMouseOverContext = @"MPFunctionTemplateViewMo
|
||||
forKeyPath:@"hoverItem"
|
||||
options:0
|
||||
context:MPCollectionViewHoverItemChangeContext];
|
||||
self.collectionView.target = self.target;
|
||||
self.collectionView.action = self.action;
|
||||
((MPFunctionsCollectionView *)self.collectionView).target = self.target;
|
||||
((MPFunctionsCollectionView *)self.collectionView).action = self.action;
|
||||
}
|
||||
|
||||
|
||||
static void *MPCollectionViewHoverItemChangeContext = @"MPCollectionViewHoverItemChangeContext";
|
||||
|
||||
|
||||
- (void)setView:(NSView *)view
|
||||
{
|
||||
[super setView:view];
|
||||
}
|
||||
|
||||
|
||||
- (void)setTarget:(id)target
|
||||
{
|
||||
_target = target;
|
||||
if (self.collectionView) {
|
||||
self.collectionView.target = target;
|
||||
((MPFunctionsCollectionView *)self.collectionView).target = target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)setAction:(SEL)action
|
||||
{
|
||||
_action = action;
|
||||
if (self.collectionView) {
|
||||
self.collectionView.action = action;
|
||||
((MPFunctionsCollectionView *)self.collectionView).action = action;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||
ofObject:(id)object
|
||||
change:(NSDictionary *)change
|
||||
context:(void *)context
|
||||
{
|
||||
if (context == MPCollectionViewHoverItemChangeContext) {
|
||||
self.currentDescription = self.collectionView.hoverItem.templateName;
|
||||
self.currentDescription = ((MPFunctionsCollectionView *)self.collectionView).hoverItem.templateName;
|
||||
} else {
|
||||
[super observeValueForKeyPath:keyPath
|
||||
ofObject:object
|
||||
|
||||
Reference in New Issue
Block a user