1 #import "ITBevelView.h"
4 @implementation ITBevelView
7 /*************************************************************************/
9 #pragma mark INITIALIZATION METHODS
10 /*************************************************************************/
12 - (id)initWithFrame:(NSRect)frameRect
14 if ( (self = [super initWithFrame:frameRect]) ) {
16 [self setAutoresizesSubviews:NO];
22 - (id)initWithCoder:(NSCoder *)coder
24 if ( ( self = [super initWithCoder:coder] ) ) {
26 [self setAutoresizesSubviews:NO];
33 /*************************************************************************/
35 #pragma mark ACCESSOR METHODS
36 /*************************************************************************/
43 - (void)setBevelDepth:(int)newDepth
45 _bevelDepth = newDepth;
46 [self setNeedsDisplay:YES];
50 /*************************************************************************/
52 #pragma mark INSTANCE METHODS
53 /*************************************************************************/
55 - (void)drawRect:(NSRect)aRect
57 NSRect frameRect = [self convertRect:[self frame] fromView:[self superview]];
58 NSRect innerRect = NSMakeRect( (frameRect.origin.x + _bevelDepth),
59 (frameRect.origin.y + _bevelDepth),
60 (frameRect.size.width - (_bevelDepth * 2)),
61 (frameRect.size.height - (_bevelDepth * 2)) );
63 NSBezierPath *leftEdge = [NSBezierPath bezierPath];
64 NSBezierPath *topEdge = [NSBezierPath bezierPath];
65 NSBezierPath *rightEdge = [NSBezierPath bezierPath];
66 NSBezierPath *bottomEdge = [NSBezierPath bezierPath];
68 [[[self subviews] objectAtIndex:0] setFrame:innerRect];
70 [leftEdge moveToPoint:frameRect.origin];
71 [leftEdge lineToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)];
72 [leftEdge lineToPoint:NSMakePoint( (frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth) )];
73 [leftEdge lineToPoint:NSMakePoint( (frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth) )];
75 [topEdge moveToPoint:NSMakePoint(frameRect.origin.x, frameRect.size.height)];
76 [topEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)];
77 [topEdge lineToPoint:NSMakePoint( (frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth) )];
78 [topEdge lineToPoint:NSMakePoint( (frameRect.origin.x + _bevelDepth), (frameRect.size.height - _bevelDepth) )];
80 [rightEdge moveToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)];
81 [rightEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.size.height)];
82 [rightEdge lineToPoint:NSMakePoint( (frameRect.size.width - _bevelDepth), (frameRect.size.height - _bevelDepth) )];
83 [rightEdge lineToPoint:NSMakePoint( (frameRect.size.width - _bevelDepth), (_bevelDepth) )];
85 [bottomEdge moveToPoint:frameRect.origin];
86 [bottomEdge lineToPoint:NSMakePoint(frameRect.size.width, frameRect.origin.y)];
87 [bottomEdge lineToPoint:NSMakePoint( (frameRect.size.width - _bevelDepth), (_bevelDepth) )];
88 [bottomEdge lineToPoint:NSMakePoint( (frameRect.origin.x + _bevelDepth), (frameRect.origin.y + _bevelDepth) )];
90 [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set];
92 [[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] set];
94 [[NSColor colorWithCalibratedWhite:0.5 alpha:0.5] set];
96 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.6] set];
99 [[[self subviews] objectAtIndex:0] setNeedsDisplay:YES];
102 - (BOOL)mouseDownCanMoveWindow
108 /*************************************************************************/
110 #pragma mark DEALLOCATION METHOD
111 /*************************************************************************/