1 #import "ITTSWBackgroundView.h"
7 @interface ITTSWBackgroundView (Private)
11 @implementation ITTSWBackgroundView
14 - (id)initWithFrame:(NSRect)frameRect
16 if ( (self = [super initWithFrame:frameRect]) ) {
17 _path = [[NSBezierPath bezierPath] retain];
18 _color = [[NSColor blueColor] retain];
19 _mode = ITTSWBackgroundApple;
25 - (void)drawRect:(NSRect)rect
27 float vh = NSHeight(rect);
28 float vw = NSWidth(rect);
31 if ( (_mode == ITTSWBackgroundReadable) || (_mode == ITTSWBackgroundColored) ) {
35 NSPoint pointA = NSMakePoint( ((vw - RADIUS) - indent) , (vh - indent) );
36 NSPoint pointB = NSMakePoint( (RADIUS + indent) , (vh - indent) );
37 NSPoint pointD = NSMakePoint( indent , (RADIUS + indent) );
38 NSPoint pointF = NSMakePoint( ((vw - RADIUS) - indent) , indent );
39 NSPoint pointH = NSMakePoint( (vw - indent) , ((vh - RADIUS) - indent) );
41 NSPoint ctrBC = NSMakePoint( (RADIUS + indent) , ((vh - RADIUS) - indent) );
42 NSPoint ctrDE = NSMakePoint( (RADIUS + indent) , (RADIUS + indent) );
43 NSPoint ctrFG = NSMakePoint( ((vw - RADIUS) - indent) , (RADIUS + indent) );
44 NSPoint ctrHA = NSMakePoint( ((vw - RADIUS) - indent) , ((vh - RADIUS) - indent) );
48 * +------------------------+
49 * C | * ctrCD ctrEF * | F
51 * B | * ctrAB ctrGH * | G
52 * +------------------------+
56 [_path removeAllPoints];
58 [_path moveToPoint:pointA]; // first point
59 [_path lineToPoint:pointB]; // top line
60 [_path appendBezierPathWithArcWithCenter:ctrBC // top-left curve
64 [_path lineToPoint:pointD]; // left line
65 [_path appendBezierPathWithArcWithCenter:ctrDE // bottom-left curve
69 [_path lineToPoint:pointF]; // top line
70 [_path appendBezierPathWithArcWithCenter:ctrFG // top-right curve
74 [_path lineToPoint:pointH]; // right line
75 [_path appendBezierPathWithArcWithCenter:ctrHA // bottom-right curve
80 if ( _mode == ITTSWBackgroundApple ) {
81 [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set];
82 } else if ( _mode == ITTSWBackgroundReadable ) {
83 [[NSColor colorWithCalibratedWhite:0.15 alpha:0.70] set];
84 } else if ( _mode == ITTSWBackgroundColored ) {
90 if ( (_mode == ITTSWBackgroundReadable) || (_mode == ITTSWBackgroundColored) ) {
91 [[NSColor colorWithCalibratedWhite:0.90 alpha:1.00] set];
92 [_path setLineWidth:3.0];
102 - (ITTSWBackgroundMode)backgroundMode
107 - (void)setBackgroundMode:(ITTSWBackgroundMode)newMode
110 [self setNeedsDisplay:YES];
113 - (NSColor *)backgroundColor
118 - (void)setBackgroundColor:(NSColor *)newColor
120 [_color autorelease];
121 _color = [newColor copy];
122 [self setNeedsDisplay:YES];