1 #import "ITBevelView.h"
3 @implementation ITBevelView
5 - (id)initWithFrame:(NSRect)frameRect {
6 if ((self = [super initWithFrame:frameRect])) {
8 [self setAutoresizesSubviews:NO];
13 - (id)initWithCoder:(NSCoder *)coder {
14 if ((self = [super initWithCoder:coder])) {
16 [self setAutoresizesSubviews:NO];
25 - (void)setBevelDepth:(int)newDepth {
26 _bevelDepth = newDepth;
27 [self setNeedsDisplay:YES];
30 - (void)drawRect:(NSRect)aRect {
31 NSRect frameRect = [self convertRect:[self frame] fromView:[self superview]];
32 NSRect innerRect = NSMakeRect((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth), (frameRect.size.width - (_bevelDepth * 2)), (frameRect.size.height - (_bevelDepth * 2)));
34 NSBezierPath *leftEdge = [NSBezierPath bezierPath];
35 NSBezierPath *topEdge = [NSBezierPath bezierPath];
36 NSBezierPath *rightEdge = [NSBezierPath bezierPath];
37 NSBezierPath *bottomEdge = [NSBezierPath bezierPath];
39 [[[self subviews] objectAtIndex:0] setFrame:innerRect];
41 [leftEdge moveToPoint:frameRect.origin];
42 [leftEdge lineToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)];
43 [leftEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth))];
44 [leftEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth))];
46 [topEdge moveToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)];
47 [topEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)];
48 [topEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth))];
49 [topEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth))];
51 [rightEdge moveToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)];
52 [rightEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)];
53 [rightEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth))];
54 [rightEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), _bevelDepth)];
56 [bottomEdge moveToPoint:frameRect.origin];
57 [bottomEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)];
58 [bottomEdge lineToPoint:NSMakePoint((frameRect.size.width - _bevelDepth), _bevelDepth)];
59 [bottomEdge lineToPoint:NSMakePoint((frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth))];
61 [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set];
63 [[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] set];
65 [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set];
67 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.6] set];
70 [[[self subviews] objectAtIndex:0] setNeedsDisplay:YES];
73 - (BOOL)mouseDownCanMoveWindow {