2010-07-09 02:40:04 +00:00
|
|
|
//
|
|
|
|
// CurveView.m
|
|
|
|
// 2Term
|
|
|
|
//
|
|
|
|
// Created by Kelvin Sherlock on 7/8/2010.
|
|
|
|
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "CurveView.h"
|
2010-12-18 17:40:58 +00:00
|
|
|
#import "ScanLineFilter.h"
|
2010-07-09 02:40:04 +00:00
|
|
|
|
|
|
|
@implementation CurveView
|
|
|
|
|
|
|
|
@synthesize color = _color;
|
|
|
|
|
|
|
|
- (id)initWithFrame:(NSRect)frame {
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
if (self) {
|
|
|
|
// Initialization code here.
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-02-14 16:34:05 +00:00
|
|
|
-(void)awakeFromNib
|
|
|
|
{
|
|
|
|
_color = [[NSColor blackColor] retain];
|
|
|
|
}
|
2010-12-20 23:37:02 +00:00
|
|
|
|
2011-11-26 17:03:57 +00:00
|
|
|
/*
|
|
|
|
-(BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
*/
|
2010-12-18 17:40:58 +00:00
|
|
|
|
2011-11-26 17:03:57 +00:00
|
|
|
#define curveSize 5
|
2010-07-09 02:40:04 +00:00
|
|
|
|
|
|
|
- (void)drawRect:(NSRect)dirtyRect {
|
|
|
|
|
2011-11-26 17:03:57 +00:00
|
|
|
//NSGraphicsContext *nsgc = [NSGraphicsContext currentContext];
|
|
|
|
//CGContextRef ctx = [nsgc graphicsPort];
|
|
|
|
NSRect bounds = [self bounds];
|
|
|
|
|
|
|
|
//[super drawRect: dirtyRect];
|
2010-07-09 02:40:04 +00:00
|
|
|
|
2011-11-26 17:03:57 +00:00
|
|
|
#if 0
|
2010-07-09 02:40:04 +00:00
|
|
|
|
2011-11-26 17:03:57 +00:00
|
|
|
[[NSColor clearColor] setFill];
|
|
|
|
NSRectFill(dirtyRect);
|
2010-07-09 02:40:04 +00:00
|
|
|
|
|
|
|
[_color setFill];
|
|
|
|
|
|
|
|
|
|
|
|
CGContextMoveToPoint(ctx, 0, curveSize);
|
|
|
|
|
|
|
|
CGContextAddLineToPoint(ctx, 0, bounds.size.height - curveSize);
|
|
|
|
CGContextAddQuadCurveToPoint(ctx, 0, bounds.size.height, curveSize, bounds.size.height);
|
|
|
|
|
|
|
|
CGContextAddLineToPoint(ctx, bounds.size.width - curveSize, bounds.size.height);
|
|
|
|
CGContextAddQuadCurveToPoint(ctx, bounds.size.width, bounds.size.height, bounds.size.width, bounds.size.height - curveSize);
|
|
|
|
|
|
|
|
|
|
|
|
CGContextAddLineToPoint(ctx, bounds.size.width, curveSize);
|
|
|
|
CGContextAddQuadCurveToPoint(ctx, bounds.size.width, 0, bounds.size.width - curveSize, 0);
|
|
|
|
|
|
|
|
|
|
|
|
CGContextAddLineToPoint(ctx, curveSize, 0);
|
|
|
|
|
|
|
|
CGContextAddQuadCurveToPoint(ctx, 0, 0, 0, curveSize);
|
|
|
|
|
|
|
|
CGContextFillPath(ctx);
|
2011-11-26 17:03:57 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
NSBezierPath *path;
|
|
|
|
|
|
|
|
|
|
|
|
[[NSColor clearColor] set];
|
|
|
|
NSRectFill(dirtyRect);
|
|
|
|
|
|
|
|
|
|
|
|
path = [NSBezierPath bezierPathWithRoundedRect:bounds xRadius: curveSize yRadius: curveSize];
|
|
|
|
[path addClip];
|
|
|
|
//path = [NSBezierPath bezierPathWithRect: dirtyRect];
|
|
|
|
//[path addClip];
|
|
|
|
|
|
|
|
|
|
|
|
[_color set];
|
|
|
|
NSRectFill(dirtyRect);
|
|
|
|
|
|
|
|
#endif
|
2010-07-09 02:40:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setColor:(NSColor *)color
|
|
|
|
{
|
|
|
|
if (_color == color) return;
|
|
|
|
[_color release];
|
|
|
|
_color = [color retain];
|
|
|
|
[self setNeedsDisplay: YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
[_color release];
|
2012-08-01 23:56:56 +00:00
|
|
|
[super dealloc];
|
2010-07-09 02:40:04 +00:00
|
|
|
}
|
|
|
|
@end
|