Luky/Gui/RoundedView.m

00001 //
00002 //  RoundedView.m
00003 //  RoundedFloatingPanel
00004 //
00005 //  Created by Matt Gemmell on Thu Jan 08 2004.
00006 //  <http://iratescotsman.com/>
00007 //
00008 
00009 
00010 #import "RoundedView.h"
00011 
00012 @implementation RoundedView
00013 
00014 
00015 - (void)drawRect:(NSRect)rect
00016 {
00017     NSColor *bgColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.35];
00018     NSRect bgRect = rect;
00019     int minX = NSMinX(bgRect);
00020     int midX = NSMidX(bgRect);
00021     int maxX = NSMaxX(bgRect);
00022     int minY = NSMinY(bgRect);
00023     int midY = NSMidY(bgRect);
00024     int maxY = NSMaxY(bgRect);
00025     float radius = 25.0; // correct value to duplicate Panther's App Switcher
00026     NSBezierPath *bgPath = [NSBezierPath bezierPath];
00027     
00028     // Bottom edge and bottom-right curve
00029     [bgPath moveToPoint:NSMakePoint(midX, minY)];
00030     [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(maxX, minY) 
00031                                      toPoint:NSMakePoint(maxX, midY) 
00032                                       radius:radius];
00033     
00034     // Right edge and top-right curve
00035     [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(maxX, maxY) 
00036                                      toPoint:NSMakePoint(midX, maxY) 
00037                                       radius:radius];
00038     
00039     // Top edge and top-left curve
00040     [bgPath appendBezierPathWithArcFromPoint:NSMakePoint(minX, maxY) 
00041                                      toPoint:NSMakePoint(minX, midY) 
00042                                       radius:radius];
00043     
00044     // Left edge and bottom-left curve
00045     [bgPath appendBezierPathWithArcFromPoint:bgRect.origin 
00046                                      toPoint:NSMakePoint(midX, minY) 
00047                                       radius:radius];
00048     [bgPath closePath];
00049     
00050     [bgColor set];
00051     [bgPath fill];
00052 }
00053 
00054 
00055 @end

Generated on Sat Aug 26 21:14:16 2006 for MacTrek by  doxygen 1.4.7