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 // Draw special bezel, with a thickness of _bevelDepth.
58 NSRect innerRect = NSMakeRect( (aRect.origin.x + _bevelDepth),
59 (aRect.origin.y + _bevelDepth),
60 (aRect.size.width - (_bevelDepth * 2)),
61 (aRect.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:aRect.origin];
71 [leftEdge lineToPoint:NSMakePoint(aRect.origin.x, aRect.size.height)];
72 [leftEdge lineToPoint:NSMakePoint( (aRect.origin.x + _bevelDepth), (aRect.size.height - _bevelDepth) )];
73 [leftEdge lineToPoint:NSMakePoint( (aRect.origin.x + _bevelDepth), (aRect.origin.y + _bevelDepth) )];
75 [topEdge moveToPoint:NSMakePoint(aRect.origin.x, aRect.size.height)];
76 [topEdge lineToPoint:NSMakePoint(aRect.size.width, aRect.size.height)];
77 [topEdge lineToPoint:NSMakePoint( (aRect.size.width - _bevelDepth), (aRect.size.height - _bevelDepth) )];
78 [topEdge lineToPoint:NSMakePoint( (aRect.origin.x + _bevelDepth), (aRect.size.height - _bevelDepth) )];
80 [rightEdge moveToPoint:NSMakePoint(aRect.size.width, aRect.origin.y)];
81 [rightEdge lineToPoint:NSMakePoint(aRect.size.width, aRect.size.height)];
82 [rightEdge lineToPoint:NSMakePoint( (aRect.size.width - _bevelDepth), (aRect.size.height - _bevelDepth) )];
83 [rightEdge lineToPoint:NSMakePoint( (aRect.size.width - _bevelDepth), (_bevelDepth) )];
85 [bottomEdge moveToPoint:aRect.origin];
86 [bottomEdge lineToPoint:NSMakePoint(aRect.size.width, aRect.origin.y)];
87 [bottomEdge lineToPoint:NSMakePoint( (aRect.size.width - _bevelDepth), (_bevelDepth) )];
88 [bottomEdge lineToPoint:NSMakePoint( (aRect.origin.x + _bevelDepth), (aRect.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];
101 /*************************************************************************/
103 #pragma mark DEALLOCATION METHOD
104 /*************************************************************************/