Burninate GrowlThreadedView.
authorPeter Hosey <hg@boredzo.org>
Thu Oct 22 03:08:43 2009 -0700 (2009-10-22)
changeset 45419a290d3de636
parent 4540 0d3b2dbc6706
child 4542 15cfd9b13707
Burninate GrowlThreadedView.

We weren't actually using the threading feature anywhere, and, as far as I can tell, it didn't work. Furthermore, all of these displays should someday switch to NSViewAnimation, whereupon they should only draw once each anyway. So, out it goes.
Core/Source/GHA-Stubs.h
Core/Source/GHA-Stubs.m
Growl.xcodeproj/project.pbxproj
Plugins/Displays/Bezel/GrowlBezelWindowView.m
Plugins/Displays/Brushed/GrowlBrushedWindowView.m
Plugins/Displays/Bubbles/GrowlBubblesWindowView.m
Plugins/Displays/GrowlNotificationView.h
Plugins/Displays/GrowlThreadedView.h
Plugins/Displays/GrowlThreadedView.m
Plugins/Displays/MusicVideo/GrowlMusicVideoWindowView.m
Plugins/Displays/Smoke/GrowlSmokeWindowView.m
Plugins/Displays/iCal/GrowliCalWindowView.m
     1.1 --- a/Core/Source/GHA-Stubs.h	Thu Oct 22 02:25:49 2009 -0700
     1.2 +++ b/Core/Source/GHA-Stubs.h	Thu Oct 22 03:08:43 2009 -0700
     1.3 @@ -37,10 +37,6 @@
     1.4  }
     1.5  @end
     1.6  
     1.7 -@interface GrowlThreadedView : NSView {
     1.8 -}
     1.9 -@end
    1.10 -
    1.11  @interface GrowlApplicationController: GrowlAbstractSingletonObject <GrowlApplicationBridgeDelegate>{
    1.12  }
    1.13  @end
     2.1 --- a/Core/Source/GHA-Stubs.m	Thu Oct 22 02:25:49 2009 -0700
     2.2 +++ b/Core/Source/GHA-Stubs.m	Thu Oct 22 03:08:43 2009 -0700
     2.3 @@ -11,9 +11,6 @@
     2.4  @implementation GrowlApplicationController
     2.5  @end
     2.6  
     2.7 -@implementation GrowlThreadedView
     2.8 -@end
     2.9 -
    2.10  @implementation GrowlWindowTransition
    2.11  @end
    2.12  
     3.1 --- a/Growl.xcodeproj/project.pbxproj	Thu Oct 22 02:25:49 2009 -0700
     3.2 +++ b/Growl.xcodeproj/project.pbxproj	Thu Oct 22 03:08:43 2009 -0700
     3.3 @@ -367,7 +367,6 @@
     3.4  		E144111D0A9408840063C4DC /* GrowliCalPrefsController.m in Sources */ = {isa = PBXBuildFile; fileRef = E14411150A9408840063C4DC /* GrowliCalPrefsController.m */; };
     3.5  		E144111E0A9408840063C4DC /* GrowliCalWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = E14411170A9408840063C4DC /* GrowliCalWindowController.m */; };
     3.6  		E144111F0A9408840063C4DC /* GrowliCalWindowView.m in Sources */ = {isa = PBXBuildFile; fileRef = E14411190A9408840063C4DC /* GrowliCalWindowView.m */; };
     3.7 -		EE17E56D08EFFCDB0086F0C3 /* GrowlThreadedView.m in Sources */ = {isa = PBXBuildFile; fileRef = EE17E56B08EFFCDB0086F0C3 /* GrowlThreadedView.m */; };
     3.8  		EE1AF8D70897DA9400F486FD /* GrowlWindowTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = EE1AF8D00897DA9400F486FD /* GrowlWindowTransition.m */; };
     3.9  		EE1AF8D90897DA9400F486FD /* GrowlFadingWindowTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = EE1AF8D30897DA9400F486FD /* GrowlFadingWindowTransition.m */; };
    3.10  		EE88147C08EE836E005D5380 /* GrowlSlidingWindowTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = EE88147A08EE836E005D5380 /* GrowlSlidingWindowTransition.m */; };
    3.11 @@ -894,7 +893,6 @@
    3.12  		5286205606DC4C2F00D3A356 /* GrowlPluginController.m */ = {isa = PBXFileReference; fileEncoding = 4; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = GrowlPluginController.m; path = Core/Source/GrowlPluginController.m; sourceTree = "<group>"; };
    3.13  		63C92DD406D05D22007368FA /* Growl.sdef */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; name = Growl.sdef; path = Bindings/applescript/Growl.sdef; sourceTree = "<group>"; };
    3.14  		63C92DD706D05D22007368FA /* GrowlScripting.r */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.rez; name = GrowlScripting.r; path = Bindings/applescript/GrowlScripting.r; sourceTree = "<group>"; };
    3.15 -		740CC038093A4F1000092801 /* GrowlThreadedView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = GrowlThreadedView.h; path = Plugins/Displays/GrowlThreadedView.h; sourceTree = "<group>"; };
    3.16  		740CC06F093A508100092801 /* GrowlNotificationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GrowlNotificationView.h; path = Plugins/Displays/GrowlNotificationView.h; sourceTree = "<group>"; };
    3.17  		740CC070093A508100092801 /* GrowlNotificationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GrowlNotificationView.m; path = Plugins/Displays/GrowlNotificationView.m; sourceTree = "<group>"; };
    3.18  		743EDE0509273C8A002A9670 /* GrowlWebKitPluginHandler.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = GrowlWebKitPluginHandler.h; path = Plugins/Displays/WebKit/GrowlWebKitPluginHandler.h; sourceTree = "<group>"; };
    3.19 @@ -1146,7 +1144,6 @@
    3.20  		E14411180A9408840063C4DC /* GrowliCalWindowView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = GrowliCalWindowView.h; path = Plugins/Displays/iCal/GrowliCalWindowView.h; sourceTree = "<group>"; };
    3.21  		E14411190A9408840063C4DC /* GrowliCalWindowView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = GrowliCalWindowView.m; path = Plugins/Displays/iCal/GrowliCalWindowView.m; sourceTree = "<group>"; };
    3.22  		E144111A0A9408840063C4DC /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; name = Info.plist; path = Plugins/Displays/iCal/Info.plist; sourceTree = "<group>"; };
    3.23 -		EE17E56B08EFFCDB0086F0C3 /* GrowlThreadedView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = GrowlThreadedView.m; path = Plugins/Displays/GrowlThreadedView.m; sourceTree = "<group>"; };
    3.24  		EE1AF8CF0897DA9400F486FD /* GrowlWindowTransition.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GrowlWindowTransition.h; sourceTree = "<group>"; };
    3.25  		EE1AF8D00897DA9400F486FD /* GrowlWindowTransition.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = GrowlWindowTransition.m; sourceTree = "<group>"; };
    3.26  		EE1AF8D20897DA9400F486FD /* GrowlFadingWindowTransition.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GrowlFadingWindowTransition.h; sourceTree = "<group>"; };
    3.27 @@ -1381,8 +1378,6 @@
    3.28  		070B86360A0881CF0093150E /* Views */ = {
    3.29  			isa = PBXGroup;
    3.30  			children = (
    3.31 -				740CC038093A4F1000092801 /* GrowlThreadedView.h */,
    3.32 -				EE17E56B08EFFCDB0086F0C3 /* GrowlThreadedView.m */,
    3.33  				740CC06F093A508100092801 /* GrowlNotificationView.h */,
    3.34  				740CC070093A508100092801 /* GrowlNotificationView.m */,
    3.35  			);
    3.36 @@ -3082,7 +3077,6 @@
    3.37  				95E2457408EEAC510092EAAC /* GrowlPlugin.m in Sources */,
    3.38  				95E2457A08EEAC630092EAAC /* GrowlDisplayPlugin.m in Sources */,
    3.39  				95E2458408EEAC8F0092EAAC /* GrowlNotificationDisplayBridge.m in Sources */,
    3.40 -				EE17E56D08EFFCDB0086F0C3 /* GrowlThreadedView.m in Sources */,
    3.41  				745352AF09313ABA0000B26A /* GrowlWebKitPrefsController.m in Sources */,
    3.42  				745352B009313ABB0000B26A /* GrowlWebKitPluginHandler.m in Sources */,
    3.43  				745352B109313ABD0000B26A /* GrowlWebKitDisplayPlugin.m in Sources */,
     4.1 --- a/Plugins/Displays/Bezel/GrowlBezelWindowView.m	Thu Oct 22 02:25:49 2009 -0700
     4.2 +++ b/Plugins/Displays/Bezel/GrowlBezelWindowView.m	Thu Oct 22 03:08:43 2009 -0700
     4.3 @@ -53,161 +53,158 @@
     4.4  
     4.5  - (void) drawRect:(NSRect)rect {
     4.6  #pragma unused(rect)
     4.7 -	//Make sure that we don't draw in the main thread
     4.8 -	//if ([super dispatchDrawingToThread:rect]) {
     4.9 -		NSRect b = [self bounds];
    4.10 -		CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
    4.11 -
    4.12 -		CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    4.13 -
    4.14 -		addRoundedRectToPath(context, bounds, BORDER_RADIUS);
    4.15 -
    4.16 -		CGFloat opacityPref = BEZEL_OPACITY_DEFAULT;
    4.17 -		READ_GROWL_PREF_FLOAT(BEZEL_OPACITY_PREF, GrowlBezelPrefDomain, &opacityPref);
    4.18 -		CGFloat alpha = opacityPref * 0.01;
    4.19 -
    4.20 -		int style = 0;
    4.21 -		READ_GROWL_PREF_INT(BEZEL_STYLE_PREF, GrowlBezelPrefDomain, &style);
    4.22 -		switch (style) {
    4.23 -			default:
    4.24 -			case 0:
    4.25 -				// default style
    4.26 -				[[backgroundColor colorWithAlphaComponent:alpha] set];
    4.27 -				CGContextFillPath(context);
    4.28 -				break;
    4.29 -			case 1:
    4.30 -				// charcoal
    4.31 -				CGContextSaveGState(context);
    4.32 -				CGContextClip(context);
    4.33 -
    4.34 -				struct CGFunctionCallbacks callbacks = { 0U, CharcoalShadeInterpolate, NULL };
    4.35 -				CGFunctionRef function = CGFunctionCreate( &alpha,
    4.36 -														   1U,
    4.37 -														   /*domain*/ NULL,
    4.38 -														   4U,
    4.39 -														   /*range*/ NULL,
    4.40 -														   &callbacks );
    4.41 -				CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
    4.42 -				CGPoint src, dst;
    4.43 -				src.x = CGRectGetMinX(bounds);
    4.44 -				src.y = CGRectGetMinY(bounds);
    4.45 -				dst.x = CGRectGetMaxX(bounds);
    4.46 -				dst.y = src.y;
    4.47 -				CGShadingRef shading = CGShadingCreateAxial(cspace, src, dst,
    4.48 -															function, false, false);
    4.49 -
    4.50 -				CGContextDrawShading(context, shading);
    4.51 -
    4.52 -				CGShadingRelease(shading);
    4.53 -				CGColorSpaceRelease(cspace);
    4.54 -				CGFunctionRelease(function);
    4.55 -
    4.56 -				CGContextRestoreGState(context);
    4.57 -				break;
    4.58 -		}
    4.59 -
    4.60 -		int sizePref = BEZEL_SIZE_NORMAL;
    4.61 -		READ_GROWL_PREF_INT(BEZEL_SIZE_PREF, GrowlBezelPrefDomain, &sizePref);
    4.62 -
    4.63 -		// rects
    4.64 -		NSRect titleRect, textRect;
    4.65 -		NSPoint iconPoint;
    4.66 -		int maxRows;
    4.67 -		NSSize maxIconSize;
    4.68 -		if (sizePref == BEZEL_SIZE_NORMAL) {
    4.69 -			titleRect.origin.x = 12.0;
    4.70 -			titleRect.origin.y = 90.0;
    4.71 -			titleRect.size.width = 187.0;
    4.72 -			titleRect.size.height = 30.0;
    4.73 -			textRect.origin.x = 12.0;
    4.74 -			textRect.origin.y = 4.0;
    4.75 -			textRect.size.width = 187.0;
    4.76 -			textRect.size.height = 80.0;
    4.77 -			maxRows = 4;
    4.78 -			maxIconSize.width = 72.0;
    4.79 -			maxIconSize.height = 72.0;
    4.80 -			iconPoint.x = 70.0;
    4.81 -			iconPoint.y = 120.0;
    4.82 -		} else {
    4.83 -			titleRect.origin.x = 8.0;
    4.84 -			titleRect.origin.y = 52.0;
    4.85 -			titleRect.size.width = 143.0;
    4.86 -			titleRect.size.height = 24.0;
    4.87 -			textRect.origin.x = 8.0;
    4.88 -			textRect.origin.y = 4.0;
    4.89 -			textRect.size.width = 143.0;
    4.90 -			textRect.size.height = 49.0;
    4.91 -			maxRows = 2;
    4.92 -			maxIconSize.width = 48.0;
    4.93 -			maxIconSize.height = 48.0;
    4.94 -			iconPoint.x = 57.0;
    4.95 -			iconPoint.y = 83.0;
    4.96 -		}
    4.97 -
    4.98 -		NSShadow *textShadow = [[NSShadow alloc] init];
    4.99 -		NSSize shadowSize = {0.0, -2.0};
   4.100 -		[textShadow setShadowOffset:shadowSize];
   4.101 -		[textShadow setShadowBlurRadius:3.0];
   4.102 -		[textShadow setShadowColor:[NSColor blackColor]];
   4.103 -
   4.104 -		// Draw the title, resize if text too big
   4.105 -		CGFloat titleFontSize = 20.0;
   4.106 -		NSMutableParagraphStyle *parrafo = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
   4.107 -		[parrafo setAlignment:NSCenterTextAlignment];
   4.108 -		NSMutableDictionary *titleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
   4.109 -			textColor,                                   NSForegroundColorAttributeName,
   4.110 -			parrafo,                                     NSParagraphStyleAttributeName,
   4.111 -			[NSFont boldSystemFontOfSize:titleFontSize], NSFontAttributeName,
   4.112 -			textShadow,                                  NSShadowAttributeName,
   4.113 -			nil];
   4.114 -		CGFloat accumulator = 0.0;
   4.115 -		BOOL minFontSize = NO;
   4.116 -		NSSize titleSize = [title sizeWithAttributes:titleAttributes];
   4.117 -
   4.118 -		while (titleSize.width > (NSWidth(titleRect) - (titleSize.height * 0.5))) {
   4.119 -			minFontSize = ( titleFontSize < 12.9 );
   4.120 -			if (minFontSize)
   4.121 -				break;
   4.122 -			titleFontSize -= 1.9;
   4.123 -			accumulator += 0.5;
   4.124 -			[titleAttributes setObject:[NSFont boldSystemFontOfSize:titleFontSize] forKey:NSFontAttributeName];
   4.125 -			titleSize = [title sizeWithAttributes:titleAttributes];
   4.126 -		}
   4.127 -
   4.128 -		titleRect.origin.y += GrowlCGFloatCeiling(accumulator);
   4.129 -		titleRect.size.height = titleSize.height;
   4.130 -
   4.131 +	NSRect b = [self bounds];
   4.132 +	CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
   4.133 +
   4.134 +	CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   4.135 +
   4.136 +	addRoundedRectToPath(context, bounds, BORDER_RADIUS);
   4.137 +
   4.138 +	CGFloat opacityPref = BEZEL_OPACITY_DEFAULT;
   4.139 +	READ_GROWL_PREF_FLOAT(BEZEL_OPACITY_PREF, GrowlBezelPrefDomain, &opacityPref);
   4.140 +	CGFloat alpha = opacityPref * 0.01;
   4.141 +
   4.142 +	int style = 0;
   4.143 +	READ_GROWL_PREF_INT(BEZEL_STYLE_PREF, GrowlBezelPrefDomain, &style);
   4.144 +	switch (style) {
   4.145 +		default:
   4.146 +		case 0:
   4.147 +			// default style
   4.148 +			[[backgroundColor colorWithAlphaComponent:alpha] set];
   4.149 +			CGContextFillPath(context);
   4.150 +			break;
   4.151 +		case 1:
   4.152 +			// charcoal
   4.153 +			CGContextSaveGState(context);
   4.154 +			CGContextClip(context);
   4.155 +
   4.156 +			struct CGFunctionCallbacks callbacks = { 0U, CharcoalShadeInterpolate, NULL };
   4.157 +			CGFunctionRef function = CGFunctionCreate( &alpha,
   4.158 +													   1U,
   4.159 +													   /*domain*/ NULL,
   4.160 +													   4U,
   4.161 +													   /*range*/ NULL,
   4.162 +													   &callbacks );
   4.163 +			CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
   4.164 +			CGPoint src, dst;
   4.165 +			src.x = CGRectGetMinX(bounds);
   4.166 +			src.y = CGRectGetMinY(bounds);
   4.167 +			dst.x = CGRectGetMaxX(bounds);
   4.168 +			dst.y = src.y;
   4.169 +			CGShadingRef shading = CGShadingCreateAxial(cspace, src, dst,
   4.170 +														function, false, false);
   4.171 +
   4.172 +			CGContextDrawShading(context, shading);
   4.173 +
   4.174 +			CGShadingRelease(shading);
   4.175 +			CGColorSpaceRelease(cspace);
   4.176 +			CGFunctionRelease(function);
   4.177 +
   4.178 +			CGContextRestoreGState(context);
   4.179 +			break;
   4.180 +	}
   4.181 +
   4.182 +	int sizePref = BEZEL_SIZE_NORMAL;
   4.183 +	READ_GROWL_PREF_INT(BEZEL_SIZE_PREF, GrowlBezelPrefDomain, &sizePref);
   4.184 +
   4.185 +	// rects
   4.186 +	NSRect titleRect, textRect;
   4.187 +	NSPoint iconPoint;
   4.188 +	int maxRows;
   4.189 +	NSSize maxIconSize;
   4.190 +	if (sizePref == BEZEL_SIZE_NORMAL) {
   4.191 +		titleRect.origin.x = 12.0;
   4.192 +		titleRect.origin.y = 90.0;
   4.193 +		titleRect.size.width = 187.0;
   4.194 +		titleRect.size.height = 30.0;
   4.195 +		textRect.origin.x = 12.0;
   4.196 +		textRect.origin.y = 4.0;
   4.197 +		textRect.size.width = 187.0;
   4.198 +		textRect.size.height = 80.0;
   4.199 +		maxRows = 4;
   4.200 +		maxIconSize.width = 72.0;
   4.201 +		maxIconSize.height = 72.0;
   4.202 +		iconPoint.x = 70.0;
   4.203 +		iconPoint.y = 120.0;
   4.204 +	} else {
   4.205 +		titleRect.origin.x = 8.0;
   4.206 +		titleRect.origin.y = 52.0;
   4.207 +		titleRect.size.width = 143.0;
   4.208 +		titleRect.size.height = 24.0;
   4.209 +		textRect.origin.x = 8.0;
   4.210 +		textRect.origin.y = 4.0;
   4.211 +		textRect.size.width = 143.0;
   4.212 +		textRect.size.height = 49.0;
   4.213 +		maxRows = 2;
   4.214 +		maxIconSize.width = 48.0;
   4.215 +		maxIconSize.height = 48.0;
   4.216 +		iconPoint.x = 57.0;
   4.217 +		iconPoint.y = 83.0;
   4.218 +	}
   4.219 +
   4.220 +	NSShadow *textShadow = [[NSShadow alloc] init];
   4.221 +	NSSize shadowSize = {0.0, -2.0};
   4.222 +	[textShadow setShadowOffset:shadowSize];
   4.223 +	[textShadow setShadowBlurRadius:3.0];
   4.224 +	[textShadow setShadowColor:[NSColor blackColor]];
   4.225 +
   4.226 +	// Draw the title, resize if text too big
   4.227 +	CGFloat titleFontSize = 20.0;
   4.228 +	NSMutableParagraphStyle *parrafo = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
   4.229 +	[parrafo setAlignment:NSCenterTextAlignment];
   4.230 +	NSMutableDictionary *titleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
   4.231 +		textColor,                                   NSForegroundColorAttributeName,
   4.232 +		parrafo,                                     NSParagraphStyleAttributeName,
   4.233 +		[NSFont boldSystemFontOfSize:titleFontSize], NSFontAttributeName,
   4.234 +		textShadow,                                  NSShadowAttributeName,
   4.235 +		nil];
   4.236 +	CGFloat accumulator = 0.0;
   4.237 +	BOOL minFontSize = NO;
   4.238 +	NSSize titleSize = [title sizeWithAttributes:titleAttributes];
   4.239 +
   4.240 +	while (titleSize.width > (NSWidth(titleRect) - (titleSize.height * 0.5))) {
   4.241 +		minFontSize = ( titleFontSize < 12.9 );
   4.242  		if (minFontSize)
   4.243 -			[parrafo setLineBreakMode:NSLineBreakByTruncatingTail];
   4.244 -		[title drawInRect:titleRect withAttributes:titleAttributes];
   4.245 -		[titleAttributes release];
   4.246 -
   4.247 -		NSFont *textFont = [NSFont systemFontOfSize:14.0];
   4.248 -		NSMutableDictionary *textAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
   4.249 -			textColor,  NSForegroundColorAttributeName,
   4.250 -			parrafo,    NSParagraphStyleAttributeName,
   4.251 -			textFont,   NSFontAttributeName,
   4.252 -			textShadow, NSShadowAttributeName,
   4.253 -			nil];
   4.254 -		[textShadow release];
   4.255 -		[parrafo release];
   4.256 -
   4.257 -		CGFloat height = [self descriptionHeight:text attributes:textAttributes width:textRect.size.width];
   4.258 -		CGFloat lineHeight = [layoutManager defaultLineHeightForFont:textFont];
   4.259 -		NSInteger rowCount = height / lineHeight;
   4.260 -
   4.261 -		if (rowCount > maxRows)
   4.262 -			[textAttributes setObject:[NSFont systemFontOfSize:12.0] forKey:NSFontAttributeName];
   4.263 -		[text drawInRect:textRect withAttributes:textAttributes];
   4.264 -		[textAttributes release];
   4.265 -
   4.266 -		NSRect iconRect;
   4.267 -		iconRect.origin = iconPoint;
   4.268 -		iconRect.size = maxIconSize;
   4.269 -		[icon setFlipped:NO];
   4.270 -		[icon drawScaledInRect:iconRect operation:NSCompositeSourceOver fraction:1.0];
   4.271 -		[super drawRect:rect];
   4.272 -	//}
   4.273 +			break;
   4.274 +		titleFontSize -= 1.9;
   4.275 +		accumulator += 0.5;
   4.276 +		[titleAttributes setObject:[NSFont boldSystemFontOfSize:titleFontSize] forKey:NSFontAttributeName];
   4.277 +		titleSize = [title sizeWithAttributes:titleAttributes];
   4.278 +	}
   4.279 +
   4.280 +	titleRect.origin.y += GrowlCGFloatCeiling(accumulator);
   4.281 +	titleRect.size.height = titleSize.height;
   4.282 +
   4.283 +	if (minFontSize)
   4.284 +		[parrafo setLineBreakMode:NSLineBreakByTruncatingTail];
   4.285 +	[title drawInRect:titleRect withAttributes:titleAttributes];
   4.286 +	[titleAttributes release];
   4.287 +
   4.288 +	NSFont *textFont = [NSFont systemFontOfSize:14.0];
   4.289 +	NSMutableDictionary *textAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
   4.290 +		textColor,  NSForegroundColorAttributeName,
   4.291 +		parrafo,    NSParagraphStyleAttributeName,
   4.292 +		textFont,   NSFontAttributeName,
   4.293 +		textShadow, NSShadowAttributeName,
   4.294 +		nil];
   4.295 +	[textShadow release];
   4.296 +	[parrafo release];
   4.297 +
   4.298 +	CGFloat height = [self descriptionHeight:text attributes:textAttributes width:textRect.size.width];
   4.299 +	CGFloat lineHeight = [layoutManager defaultLineHeightForFont:textFont];
   4.300 +	NSInteger rowCount = height / lineHeight;
   4.301 +
   4.302 +	if (rowCount > maxRows)
   4.303 +		[textAttributes setObject:[NSFont systemFontOfSize:12.0] forKey:NSFontAttributeName];
   4.304 +	[text drawInRect:textRect withAttributes:textAttributes];
   4.305 +	[textAttributes release];
   4.306 +
   4.307 +	NSRect iconRect;
   4.308 +	iconRect.origin = iconPoint;
   4.309 +	iconRect.size = maxIconSize;
   4.310 +	[icon setFlipped:NO];
   4.311 +	[icon drawScaledInRect:iconRect operation:NSCompositeSourceOver fraction:1.0];
   4.312 +	[super drawRect:rect];
   4.313  }
   4.314  
   4.315  - (void) setIcon:(NSImage *)anIcon {
     5.1 --- a/Plugins/Displays/Brushed/GrowlBrushedWindowView.m	Thu Oct 22 02:25:49 2009 -0700
     5.2 +++ b/Plugins/Displays/Brushed/GrowlBrushedWindowView.m	Thu Oct 22 03:08:43 2009 -0700
     5.3 @@ -63,74 +63,71 @@
     5.4  
     5.5  - (void) drawRect:(NSRect)rect {
     5.6  #pragma unused(rect)
     5.7 -	//Make sure that we don't draw in the main thread
     5.8 -	//if ([super dispatchDrawingToThread:rect]) {
     5.9 -		NSRect b = [self bounds];
    5.10 -		CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
    5.11 -
    5.12 -		CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    5.13 -
    5.14 -		// clear the window
    5.15 -		CGContextClearRect(context, bounds);
    5.16 -
    5.17 -		// calculate bounds based on icon-float pref on or off
    5.18 -		CGRect shadedBounds;
    5.19 -		BOOL floatIcon = GrowlBrushedFloatIconPrefDefault;
    5.20 -		READ_GROWL_PREF_BOOL(GrowlBrushedFloatIconPref, GrowlBrushedPrefDomain, &floatIcon);
    5.21 -		if (floatIcon) {
    5.22 -			CGFloat sizeReduction = GrowlBrushedPadding + iconSize + (GrowlBrushedIconTextPadding * 0.5);
    5.23 -
    5.24 -			shadedBounds = CGRectMake(bounds.origin.x + sizeReduction + 1.0,
    5.25 -									  bounds.origin.y + 1.0,
    5.26 -									  bounds.size.width - sizeReduction - 2.0,
    5.27 -									  bounds.size.height - 2.0);
    5.28 -		} else {
    5.29 -			shadedBounds = CGRectInset(bounds, 1.0, 1.0);
    5.30 -		}
    5.31 -
    5.32 -		// set up path for rounded corners
    5.33 -		addRoundedRectToPath(context, shadedBounds, GrowlBrushedBorderRadius);
    5.34 -		CGContextSetLineWidth(context, 2.0);
    5.35 -
    5.36 -		// draw background
    5.37 -		NSWindow *window = [self window];
    5.38 -		NSColor *bgColor = [window backgroundColor];
    5.39 -		CGPathDrawingMode drawingMode;
    5.40 -		if (mouseOver) {
    5.41 -			drawingMode = kCGPathFillStroke;
    5.42 -			[bgColor setFill];
    5.43 -			[[NSColor keyboardFocusIndicatorColor] setStroke];
    5.44 -		} else {
    5.45 -			drawingMode = kCGPathFill;
    5.46 -			[bgColor set];
    5.47 -		}
    5.48 -		CGContextDrawPath(context, drawingMode);
    5.49 -
    5.50 -		// draw the title and the text
    5.51 -		NSRect drawRect;
    5.52 -		drawRect.origin.x = GrowlBrushedPadding;
    5.53 -		drawRect.origin.y = GrowlBrushedPadding;
    5.54 -		drawRect.size.width = iconSize;
    5.55 -		drawRect.size.height = iconSize;
    5.56 -
    5.57 -		[icon setFlipped:YES];
    5.58 -		[icon drawScaledInRect:drawRect
    5.59 -					 operation:NSCompositeSourceOver
    5.60 -					  fraction:1.0];
    5.61 -
    5.62 -		drawRect.origin.x += iconSize + GrowlBrushedIconTextPadding;
    5.63 -
    5.64 -		if (haveTitle) {
    5.65 -			[titleLayoutManager drawGlyphsForGlyphRange:titleRange atPoint:drawRect.origin];
    5.66 -			drawRect.origin.y += titleHeight + GrowlBrushedTitleTextPadding;
    5.67 -		}
    5.68 -
    5.69 -		if (haveText)
    5.70 -			[textLayoutManager drawGlyphsForGlyphRange:textRange atPoint:drawRect.origin];
    5.71 -
    5.72 -		[window invalidateShadow];
    5.73 -		[super drawRect:rect];
    5.74 -	//}
    5.75 +	NSRect b = [self bounds];
    5.76 +	CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
    5.77 +
    5.78 +	CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    5.79 +
    5.80 +	// clear the window
    5.81 +	CGContextClearRect(context, bounds);
    5.82 +
    5.83 +	// calculate bounds based on icon-float pref on or off
    5.84 +	CGRect shadedBounds;
    5.85 +	BOOL floatIcon = GrowlBrushedFloatIconPrefDefault;
    5.86 +	READ_GROWL_PREF_BOOL(GrowlBrushedFloatIconPref, GrowlBrushedPrefDomain, &floatIcon);
    5.87 +	if (floatIcon) {
    5.88 +		CGFloat sizeReduction = GrowlBrushedPadding + iconSize + (GrowlBrushedIconTextPadding * 0.5);
    5.89 +
    5.90 +		shadedBounds = CGRectMake(bounds.origin.x + sizeReduction + 1.0,
    5.91 +								  bounds.origin.y + 1.0,
    5.92 +								  bounds.size.width - sizeReduction - 2.0,
    5.93 +								  bounds.size.height - 2.0);
    5.94 +	} else {
    5.95 +		shadedBounds = CGRectInset(bounds, 1.0, 1.0);
    5.96 +	}
    5.97 +
    5.98 +	// set up path for rounded corners
    5.99 +	addRoundedRectToPath(context, shadedBounds, GrowlBrushedBorderRadius);
   5.100 +	CGContextSetLineWidth(context, 2.0);
   5.101 +
   5.102 +	// draw background
   5.103 +	NSWindow *window = [self window];
   5.104 +	NSColor *bgColor = [window backgroundColor];
   5.105 +	CGPathDrawingMode drawingMode;
   5.106 +	if (mouseOver) {
   5.107 +		drawingMode = kCGPathFillStroke;
   5.108 +		[bgColor setFill];
   5.109 +		[[NSColor keyboardFocusIndicatorColor] setStroke];
   5.110 +	} else {
   5.111 +		drawingMode = kCGPathFill;
   5.112 +		[bgColor set];
   5.113 +	}
   5.114 +	CGContextDrawPath(context, drawingMode);
   5.115 +
   5.116 +	// draw the title and the text
   5.117 +	NSRect drawRect;
   5.118 +	drawRect.origin.x = GrowlBrushedPadding;
   5.119 +	drawRect.origin.y = GrowlBrushedPadding;
   5.120 +	drawRect.size.width = iconSize;
   5.121 +	drawRect.size.height = iconSize;
   5.122 +
   5.123 +	[icon setFlipped:YES];
   5.124 +	[icon drawScaledInRect:drawRect
   5.125 +				 operation:NSCompositeSourceOver
   5.126 +				  fraction:1.0];
   5.127 +
   5.128 +	drawRect.origin.x += iconSize + GrowlBrushedIconTextPadding;
   5.129 +
   5.130 +	if (haveTitle) {
   5.131 +		[titleLayoutManager drawGlyphsForGlyphRange:titleRange atPoint:drawRect.origin];
   5.132 +		drawRect.origin.y += titleHeight + GrowlBrushedTitleTextPadding;
   5.133 +	}
   5.134 +
   5.135 +	if (haveText)
   5.136 +		[textLayoutManager drawGlyphsForGlyphRange:textRange atPoint:drawRect.origin];
   5.137 +
   5.138 +	[window invalidateShadow];
   5.139 +	[super drawRect:rect];
   5.140  }
   5.141  
   5.142  - (void) setIcon:(NSImage *)anIcon {
     6.1 --- a/Plugins/Displays/Bubbles/GrowlBubblesWindowView.m	Thu Oct 22 02:25:49 2009 -0700
     6.2 +++ b/Plugins/Displays/Bubbles/GrowlBubblesWindowView.m	Thu Oct 22 03:08:43 2009 -0700
     6.3 @@ -97,93 +97,90 @@
     6.4  
     6.5  - (void) drawRect:(NSRect) rect {
     6.6  #pragma unused (rect)
     6.7 -	//Make sure that we don't draw in the main thread
     6.8 -	//if ([super dispatchDrawingToThread:rect]) {
     6.9 -		NSRect b = [self bounds];
    6.10 -		CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
    6.11 -		CGRect shape = CGRectInset(bounds, BORDER_WIDTH_PX*0.5, BORDER_WIDTH_PX*0.5);
    6.12 -
    6.13 -		CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    6.14 -
    6.15 -		// Create a path with enough room to strike the border and remain inside our frame.
    6.16 -		// Since the path is in the middle of the line, this means we must inset it by half the border width.
    6.17 -		addRoundedRectToPath(context, shape, BORDER_RADIUS_PX);
    6.18 -		CGContextSetLineWidth(context, BORDER_WIDTH_PX);
    6.19 -
    6.20 -		CGContextSaveGState(context);
    6.21 -		CGContextClip(context);
    6.22 -
    6.23 -		// Create a callback function to generate the
    6.24 -		// fill clipped graphics context with our gradient
    6.25 -		struct CGFunctionCallbacks callbacks = { 0U, GrowlBubblesShadeInterpolate, NULL };
    6.26 -		CGFloat colors[8];
    6.27 -
    6.28 -		[lightColor getRed:&colors[0]
    6.29 -					 green:&colors[1]
    6.30 -					  blue:&colors[2]
    6.31 -					 alpha:&colors[3]];
    6.32 -
    6.33 -		[bgColor getRed:&colors[4]
    6.34 -				  green:&colors[5]
    6.35 -				   blue:&colors[6]
    6.36 -				  alpha:&colors[7]];
    6.37 -
    6.38 -		CGFunctionRef function = CGFunctionCreate( (void *) colors,
    6.39 -												   1U,
    6.40 -												   /*domain*/ NULL,
    6.41 -												   4U,
    6.42 -												   /*range*/ NULL,
    6.43 -												   &callbacks );
    6.44 -		CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
    6.45 -
    6.46 -		CGPoint src, dst;
    6.47 -		src.x = CGRectGetMinX(bounds);
    6.48 -		src.y = CGRectGetMaxY(bounds);
    6.49 -		dst.x = src.x;
    6.50 -		dst.y = CGRectGetMinY(bounds);
    6.51 -		CGShadingRef shading = CGShadingCreateAxial(cspace, src, dst,
    6.52 -													function, false, false);
    6.53 -
    6.54 -		CGContextDrawShading(context, shading);
    6.55 -
    6.56 -		CGShadingRelease(shading);
    6.57 -		CGColorSpaceRelease(cspace);
    6.58 -		CGFunctionRelease(function);
    6.59 -
    6.60 -		CGContextRestoreGState(context);
    6.61 -
    6.62 -		addRoundedRectToPath(context, shape, BORDER_RADIUS_PX);
    6.63 -		CGContextSetLineWidth(context, BORDER_WIDTH_PX);
    6.64 -		if (mouseOver)
    6.65 -			[highlightColor set];
    6.66 -		else
    6.67 -			[borderColor set];
    6.68 -		CGContextStrokePath(context);
    6.69 -
    6.70 -		NSRect drawRect;
    6.71 -		drawRect.origin.x = PANEL_HSPACE_PX;
    6.72 -		drawRect.origin.y = PANEL_VSPACE_PX;
    6.73 -		drawRect.size.width = iconSize;
    6.74 -		drawRect.size.height = iconSize;
    6.75 -
    6.76 -		[icon setFlipped:YES];
    6.77 -		[icon drawScaledInRect:drawRect
    6.78 -					 operation:NSCompositeSourceOver
    6.79 -					  fraction:1.0];
    6.80 -
    6.81 -		drawRect.origin.x += iconSize + ICON_HSPACE_PX;
    6.82 -
    6.83 -		if (haveTitle) {
    6.84 -			[titleLayoutManager drawGlyphsForGlyphRange:titleRange atPoint:drawRect.origin];
    6.85 -			drawRect.origin.y += titleHeight + TITLE_VSPACE_PX;
    6.86 -		}
    6.87 -
    6.88 -		if (haveText)
    6.89 -			[textLayoutManager drawGlyphsForGlyphRange:textRange atPoint:drawRect.origin];
    6.90 -
    6.91 -		[[self window] invalidateShadow];
    6.92 -		[super drawRect:rect];
    6.93 -	//}
    6.94 +	NSRect b = [self bounds];
    6.95 +	CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
    6.96 +	CGRect shape = CGRectInset(bounds, BORDER_WIDTH_PX*0.5, BORDER_WIDTH_PX*0.5);
    6.97 +
    6.98 +	CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    6.99 +
   6.100 +	// Create a path with enough room to strike the border and remain inside our frame.
   6.101 +	// Since the path is in the middle of the line, this means we must inset it by half the border width.
   6.102 +	addRoundedRectToPath(context, shape, BORDER_RADIUS_PX);
   6.103 +	CGContextSetLineWidth(context, BORDER_WIDTH_PX);
   6.104 +
   6.105 +	CGContextSaveGState(context);
   6.106 +	CGContextClip(context);
   6.107 +
   6.108 +	// Create a callback function to generate the
   6.109 +	// fill clipped graphics context with our gradient
   6.110 +	struct CGFunctionCallbacks callbacks = { 0U, GrowlBubblesShadeInterpolate, NULL };
   6.111 +	CGFloat colors[8];
   6.112 +
   6.113 +	[lightColor getRed:&colors[0]
   6.114 +				 green:&colors[1]
   6.115 +				  blue:&colors[2]
   6.116 +				 alpha:&colors[3]];
   6.117 +
   6.118 +	[bgColor getRed:&colors[4]
   6.119 +			  green:&colors[5]
   6.120 +			   blue:&colors[6]
   6.121 +			  alpha:&colors[7]];
   6.122 +
   6.123 +	CGFunctionRef function = CGFunctionCreate( (void *) colors,
   6.124 +											   1U,
   6.125 +											   /*domain*/ NULL,
   6.126 +											   4U,
   6.127 +											   /*range*/ NULL,
   6.128 +											   &callbacks );
   6.129 +	CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
   6.130 +
   6.131 +	CGPoint src, dst;
   6.132 +	src.x = CGRectGetMinX(bounds);
   6.133 +	src.y = CGRectGetMaxY(bounds);
   6.134 +	dst.x = src.x;
   6.135 +	dst.y = CGRectGetMinY(bounds);
   6.136 +	CGShadingRef shading = CGShadingCreateAxial(cspace, src, dst,
   6.137 +												function, false, false);
   6.138 +
   6.139 +	CGContextDrawShading(context, shading);
   6.140 +
   6.141 +	CGShadingRelease(shading);
   6.142 +	CGColorSpaceRelease(cspace);
   6.143 +	CGFunctionRelease(function);
   6.144 +
   6.145 +	CGContextRestoreGState(context);
   6.146 +
   6.147 +	addRoundedRectToPath(context, shape, BORDER_RADIUS_PX);
   6.148 +	CGContextSetLineWidth(context, BORDER_WIDTH_PX);
   6.149 +	if (mouseOver)
   6.150 +		[highlightColor set];
   6.151 +	else
   6.152 +		[borderColor set];
   6.153 +	CGContextStrokePath(context);
   6.154 +
   6.155 +	NSRect drawRect;
   6.156 +	drawRect.origin.x = PANEL_HSPACE_PX;
   6.157 +	drawRect.origin.y = PANEL_VSPACE_PX;
   6.158 +	drawRect.size.width = iconSize;
   6.159 +	drawRect.size.height = iconSize;
   6.160 +
   6.161 +	[icon setFlipped:YES];
   6.162 +	[icon drawScaledInRect:drawRect
   6.163 +				 operation:NSCompositeSourceOver
   6.164 +				  fraction:1.0];
   6.165 +
   6.166 +	drawRect.origin.x += iconSize + ICON_HSPACE_PX;
   6.167 +
   6.168 +	if (haveTitle) {
   6.169 +		[titleLayoutManager drawGlyphsForGlyphRange:titleRange atPoint:drawRect.origin];
   6.170 +		drawRect.origin.y += titleHeight + TITLE_VSPACE_PX;
   6.171 +	}
   6.172 +
   6.173 +	if (haveText)
   6.174 +		[textLayoutManager drawGlyphsForGlyphRange:textRange atPoint:drawRect.origin];
   6.175 +
   6.176 +	[[self window] invalidateShadow];
   6.177 +	[super drawRect:rect];
   6.178  }
   6.179  
   6.180  #pragma mark -
     7.1 --- a/Plugins/Displays/GrowlNotificationView.h	Thu Oct 22 02:25:49 2009 -0700
     7.2 +++ b/Plugins/Displays/GrowlNotificationView.h	Thu Oct 22 03:08:43 2009 -0700
     7.3 @@ -8,7 +8,7 @@
     7.4  
     7.5  #import "GrowlThreadedView.h"
     7.6  
     7.7 -@interface GrowlNotificationView : GrowlThreadedView {
     7.8 +@interface GrowlNotificationView : NSView {
     7.9  	BOOL				initialDisplayTest;
    7.10  	BOOL				mouseOver;
    7.11  	BOOL				closeOnMouseExit;
     8.1 --- a/Plugins/Displays/GrowlThreadedView.h	Thu Oct 22 02:25:49 2009 -0700
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,31 +0,0 @@
     8.4 -//
     8.5 -//  GrowlThreadedView.h
     8.6 -//  Growl
     8.7 -//
     8.8 -//  Created by Ofri Wolfus on 01/10/05.
     8.9 -//  Copyright 2005-2006 Ofri Wolfus. All rights reserved.
    8.10 -//
    8.11 -
    8.12 -#import <Cocoa/Cocoa.h>
    8.13 -
    8.14 -
    8.15 -/*!	@class GrowlThreadedView
    8.16 - *	@abstract GrowlThreadedView is a subclass of NSView that can perform drawing on a secondary thread.
    8.17 - *	@discussion	When subclassing, in your -drawRect:, call [self dispatchDrawingToThread:] with the same rect that was passed to -drawRect:.
    8.18 - *  If the current thread is the main thread (as it will be when AppKit calls -drawRect:), -dispatchDrawingToThread: will dispatch a drawing thread with NSApplication (hence the name), and then it will return NO, indicating that you should simply return without doing anything further.
    8.19 - *  When the current thread is the drawing thread, -dispatchDrawingToThread: returns YES, indicating that you should now draw.
    8.20 - *  All of this is optional. If you want, you can omit the call to -dispatchDrawingToThread:, and simply draw on the main thread.
    8.21 - */
    8.22 -@interface GrowlThreadedView : NSView {
    8.23 -	NSThread *mainThread;
    8.24 -	unsigned numberOfThreads;
    8.25 -}
    8.26 -
    8.27 -/*!	@method	dispatchDrawingToThread:
    8.28 - *	@abstract	Used to execute -drawRect: in a drawing thread so that the main thread will not freeze.
    8.29 - *	@param	aRect	The rect that will be used by the threaded -drawRect:.
    8.30 - *	@result	Returns YES if it was called on a thread that is not the main thread, which means that you should draw (because you are on the drawing thread). Returns NO if it was called on the main thread, which means that the drawing thread has now been dispatched.
    8.31 - */
    8.32 -- (BOOL) dispatchDrawingToThread:(NSRect)aRect;
    8.33 -
    8.34 -@end
     9.1 --- a/Plugins/Displays/GrowlThreadedView.m	Thu Oct 22 02:25:49 2009 -0700
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,64 +0,0 @@
     9.4 -//
     9.5 -//  GrowlThreadedView.m
     9.6 -//  Growl
     9.7 -//
     9.8 -//  Created by Ofri Wolfus on 01/10/05.
     9.9 -//  Copyright 2005-2006 Ofri Wolfus. All rights reserved.
    9.10 -//
    9.11 -
    9.12 -#import "GrowlThreadedView.h"
    9.13 -#import "GrowlApplicationController.h"
    9.14 -
    9.15 -@interface GrowlThreadedView (PRIVATE)
    9.16 -- (void) threadedDrawRectWithRectValue:(NSValue *)aRect;
    9.17 -@end
    9.18 -
    9.19 -@implementation GrowlThreadedView
    9.20 -
    9.21 -//init and store the main thread
    9.22 -- (id) initWithFrame:(NSRect)frameRect {
    9.23 -	if ((self = [super initWithFrame:frameRect]))
    9.24 -		mainThread = [[[GrowlApplicationController sharedInstance] mainThread] retain];
    9.25 -
    9.26 -	return self;
    9.27 -}
    9.28 -
    9.29 -- (void) release {
    9.30 -	//only really release when we have no active threads. it would be Very Bad if we were released while things were happening.
    9.31 -	[NSObject cancelPreviousPerformRequestsWithTarget:self
    9.32 -											 selector:@selector(release)
    9.33 -											   object:nil];
    9.34 -	if (numberOfThreads) {
    9.35 -		NSLog(@"Tying again...");
    9.36 -		[self performSelector:@selector(release)
    9.37 -		           withObject:nil
    9.38 -		           afterDelay:0.1];
    9.39 -	} else {
    9.40 -		[super release];
    9.41 -	}
    9.42 -}
    9.43 -- (void) dealloc {
    9.44 -	[mainThread release];
    9.45 -	[super dealloc];
    9.46 -}
    9.47 -
    9.48 -- (BOOL) dispatchDrawingToThread:(NSRect)aRect {
    9.49 -	BOOL isMain = [NSThread currentThread] == mainThread;
    9.50 -	if (isMain) {
    9.51 -		++numberOfThreads;
    9.52 -		[NSApplication detachDrawingThread:@selector(threadedDrawRectWithRectValue:)
    9.53 -								  toTarget:self
    9.54 -								withObject:[NSValue valueWithRect:aRect]];
    9.55 -	}
    9.56 -	return !isMain;
    9.57 -}
    9.58 -
    9.59 -//Convert the value back to a rect, then lock focus (ordinarily done for us, but this is no ordinary view!) and draw. And unlock focus, of course.
    9.60 -- (void) threadedDrawRectWithRectValue:(NSValue *)aRect {
    9.61 -	[self lockFocus];
    9.62 -	[self drawRect:[aRect rectValue]];
    9.63 -	[self unlockFocus];
    9.64 -	--numberOfThreads;
    9.65 -}
    9.66 -
    9.67 -@end
    10.1 --- a/Plugins/Displays/MusicVideo/GrowlMusicVideoWindowView.m	Thu Oct 22 02:25:49 2009 -0700
    10.2 +++ b/Plugins/Displays/MusicVideo/GrowlMusicVideoWindowView.m	Thu Oct 22 03:08:43 2009 -0700
    10.3 @@ -39,109 +39,106 @@
    10.4  }
    10.5  
    10.6  - (void) drawRect:(NSRect)rect {
    10.7 -	//Make sure that we don't draw in the main thread
    10.8 -	//if ([super dispatchDrawingToThread:rect]) {
    10.9 -		NSGraphicsContext *context = [NSGraphicsContext currentContext];
   10.10 -		CGContextRef cgContext = [context graphicsPort];
   10.11 -		NSRect bounds = [self bounds];
   10.12 -		if (needsDisplay) {
   10.13 -			// rects and sizes
   10.14 -			int sizePref = 0;
   10.15 -			READ_GROWL_PREF_INT(MUSICVIDEO_SIZE_PREF, GrowlMusicVideoPrefDomain, &sizePref);
   10.16 -			NSRect titleRect, textRect;
   10.17 -			NSRect iconRect;
   10.18 -
   10.19 -			if (sizePref == MUSICVIDEO_SIZE_HUGE) {
   10.20 -				titleRect.origin.x = 192.0;
   10.21 -				titleRect.origin.y = NSHeight(bounds) - 72.0;
   10.22 -				titleRect.size.width = NSWidth(bounds) - 192.0 - 32.0;
   10.23 -				titleRect.size.height = 40.0;
   10.24 -				textRect.origin.y = NSHeight(bounds) - 176.0;
   10.25 -				textRect.size.height = 96.0;
   10.26 -				iconRect.origin.x = 32.0;
   10.27 -				iconRect.origin.y = NSHeight(bounds) - 160.0;
   10.28 -				iconRect.size.width = 128.0;
   10.29 -				iconRect.size.height = 128.0;
   10.30 -			} else {
   10.31 -				titleRect.origin.x = 96.0;
   10.32 -				titleRect.origin.y = NSHeight(bounds) - 36.0;
   10.33 -				titleRect.size.width = NSWidth(bounds) - 96.0 - 16.0;
   10.34 -				titleRect.size.height = 25.0;
   10.35 -				textRect.origin.y = NSHeight(bounds) - 88.0,
   10.36 -					textRect.size.height = 48.0;
   10.37 -				iconRect.origin.x = 8.0;
   10.38 -				iconRect.origin.y = NSHeight(bounds) - 88.0;
   10.39 -				iconRect.size.width = 80.0;
   10.40 -				iconRect.size.height = 80.0;
   10.41 -			}
   10.42 -			textRect.origin.x = titleRect.origin.x;
   10.43 -			textRect.size.width = titleRect.size.width;
   10.44 -
   10.45 -			//draw to cache
   10.46 -			if (CGLayerCreateWithContext) {
   10.47 -				if (!layer)
   10.48 -					layer = CGLayerCreateWithContext(cgContext, CGSizeMake(bounds.size.width, bounds.size.height), NULL);
   10.49 -				[NSGraphicsContext setCurrentContext:
   10.50 -					[NSGraphicsContext graphicsContextWithGraphicsPort:CGLayerGetContext(layer) flipped:NO]];
   10.51 -			} else {
   10.52 -				[cache lockFocus];
   10.53 -			}
   10.54 -
   10.55 -			[backgroundColor set];
   10.56 -			bounds.origin = NSZeroPoint;
   10.57 -			NSRectFill(bounds);
   10.58 -
   10.59 -			[title drawInRect:titleRect withAttributes:titleAttributes];
   10.60 -
   10.61 -			[text drawInRect:textRect withAttributes:textAttributes];
   10.62 -
   10.63 -			[icon setFlipped:NO];
   10.64 -			[icon drawScaledInRect:iconRect operation:NSCompositeSourceOver fraction:1.0];
   10.65 -
   10.66 -			if (CGLayerCreateWithContext)
   10.67 -				[NSGraphicsContext setCurrentContext:context];
   10.68 -			else
   10.69 -				[cache unlockFocus];
   10.70 -
   10.71 -			needsDisplay = NO;
   10.72 +	NSGraphicsContext *context = [NSGraphicsContext currentContext];
   10.73 +	CGContextRef cgContext = [context graphicsPort];
   10.74 +	NSRect bounds = [self bounds];
   10.75 +	if (needsDisplay) {
   10.76 +		// rects and sizes
   10.77 +		int sizePref = 0;
   10.78 +		READ_GROWL_PREF_INT(MUSICVIDEO_SIZE_PREF, GrowlMusicVideoPrefDomain, &sizePref);
   10.79 +		NSRect titleRect, textRect;
   10.80 +		NSRect iconRect;
   10.81 +
   10.82 +		if (sizePref == MUSICVIDEO_SIZE_HUGE) {
   10.83 +			titleRect.origin.x = 192.0;
   10.84 +			titleRect.origin.y = NSHeight(bounds) - 72.0;
   10.85 +			titleRect.size.width = NSWidth(bounds) - 192.0 - 32.0;
   10.86 +			titleRect.size.height = 40.0;
   10.87 +			textRect.origin.y = NSHeight(bounds) - 176.0;
   10.88 +			textRect.size.height = 96.0;
   10.89 +			iconRect.origin.x = 32.0;
   10.90 +			iconRect.origin.y = NSHeight(bounds) - 160.0;
   10.91 +			iconRect.size.width = 128.0;
   10.92 +			iconRect.size.height = 128.0;
   10.93 +		} else {
   10.94 +			titleRect.origin.x = 96.0;
   10.95 +			titleRect.origin.y = NSHeight(bounds) - 36.0;
   10.96 +			titleRect.size.width = NSWidth(bounds) - 96.0 - 16.0;
   10.97 +			titleRect.size.height = 25.0;
   10.98 +			textRect.origin.y = NSHeight(bounds) - 88.0,
   10.99 +				textRect.size.height = 48.0;
  10.100 +			iconRect.origin.x = 8.0;
  10.101 +			iconRect.origin.y = NSHeight(bounds) - 88.0;
  10.102 +			iconRect.size.width = 80.0;
  10.103 +			iconRect.size.height = 80.0;
  10.104  		}
  10.105 -
  10.106 -		// draw background
  10.107 -		[[NSColor clearColor] set];
  10.108 -		NSRectFill(rect);
  10.109 -
  10.110 -		// draw cache to screen
  10.111 -		NSRect imageRect = rect;
  10.112 -		int effect = MUSICVIDEO_EFFECT_SLIDE;
  10.113 -		READ_GROWL_PREF_INT(MUSICVIDEO_EFFECT_PREF, GrowlMusicVideoPrefDomain, &effect);
  10.114 -		if (effect == MUSICVIDEO_EFFECT_SLIDE) {
  10.115 -			if (CGLayerCreateWithContext)
  10.116 -				imageRect.origin.y = 0.0;
  10.117 -		} else if (effect == MUSICVIDEO_EFFECT_WIPE) {
  10.118 -			rect.size.height -= imageRect.origin.y;
  10.119 -			imageRect.size.height -= imageRect.origin.y;
  10.120 -			if (!CGLayerCreateWithContext)
  10.121 -				imageRect.origin.y = 0.0;
  10.122 -		} else if (effect == MUSICVIDEO_EFFECT_FADING) {
  10.123 -			if (CGLayerCreateWithContext)
  10.124 -				imageRect.origin.y = 0.0;		
  10.125 +		textRect.origin.x = titleRect.origin.x;
  10.126 +		textRect.size.width = titleRect.size.width;
  10.127 +
  10.128 +		//draw to cache
  10.129 +		if (CGLayerCreateWithContext) {
  10.130 +			if (!layer)
  10.131 +				layer = CGLayerCreateWithContext(cgContext, CGSizeMake(bounds.size.width, bounds.size.height), NULL);
  10.132 +			[NSGraphicsContext setCurrentContext:
  10.133 +				[NSGraphicsContext graphicsContextWithGraphicsPort:CGLayerGetContext(layer) flipped:NO]];
  10.134 +		} else {
  10.135 +			[cache lockFocus];
  10.136  		}
  10.137  
  10.138 -		if (CGLayerCreateWithContext) {
  10.139 -			CGRect cgRect;
  10.140 -			cgRect.origin.x = imageRect.origin.x;
  10.141 -			cgRect.origin.y = imageRect.origin.y;
  10.142 -			cgRect.size.width = rect.size.width;
  10.143 -			if (effect == MUSICVIDEO_EFFECT_WIPE) {
  10.144 -				cgRect.size.height = rect.size.height;
  10.145 -				CGContextClipToRect(cgContext, cgRect);
  10.146 -			}
  10.147 -			cgRect.size.height = bounds.size.height;
  10.148 -			CGContextDrawLayerInRect(cgContext, cgRect, layer);
  10.149 -		} else {
  10.150 -			[cache drawInRect:rect fromRect:imageRect operation:NSCompositeSourceOver fraction:1.0];
  10.151 +		[backgroundColor set];
  10.152 +		bounds.origin = NSZeroPoint;
  10.153 +		NSRectFill(bounds);
  10.154 +
  10.155 +		[title drawInRect:titleRect withAttributes:titleAttributes];
  10.156 +
  10.157 +		[text drawInRect:textRect withAttributes:textAttributes];
  10.158 +
  10.159 +		[icon setFlipped:NO];
  10.160 +		[icon drawScaledInRect:iconRect operation:NSCompositeSourceOver fraction:1.0];
  10.161 +
  10.162 +		if (CGLayerCreateWithContext)
  10.163 +			[NSGraphicsContext setCurrentContext:context];
  10.164 +		else
  10.165 +			[cache unlockFocus];
  10.166 +
  10.167 +		needsDisplay = NO;
  10.168 +	}
  10.169 +
  10.170 +	// draw background
  10.171 +	[[NSColor clearColor] set];
  10.172 +	NSRectFill(rect);
  10.173 +
  10.174 +	// draw cache to screen
  10.175 +	NSRect imageRect = rect;
  10.176 +	int effect = MUSICVIDEO_EFFECT_SLIDE;
  10.177 +	READ_GROWL_PREF_INT(MUSICVIDEO_EFFECT_PREF, GrowlMusicVideoPrefDomain, &effect);
  10.178 +	if (effect == MUSICVIDEO_EFFECT_SLIDE) {
  10.179 +		if (CGLayerCreateWithContext)
  10.180 +			imageRect.origin.y = 0.0;
  10.181 +	} else if (effect == MUSICVIDEO_EFFECT_WIPE) {
  10.182 +		rect.size.height -= imageRect.origin.y;
  10.183 +		imageRect.size.height -= imageRect.origin.y;
  10.184 +		if (!CGLayerCreateWithContext)
  10.185 +			imageRect.origin.y = 0.0;
  10.186 +	} else if (effect == MUSICVIDEO_EFFECT_FADING) {
  10.187 +		if (CGLayerCreateWithContext)
  10.188 +			imageRect.origin.y = 0.0;		
  10.189 +	}
  10.190 +
  10.191 +	if (CGLayerCreateWithContext) {
  10.192 +		CGRect cgRect;
  10.193 +		cgRect.origin.x = imageRect.origin.x;
  10.194 +		cgRect.origin.y = imageRect.origin.y;
  10.195 +		cgRect.size.width = rect.size.width;
  10.196 +		if (effect == MUSICVIDEO_EFFECT_WIPE) {
  10.197 +			cgRect.size.height = rect.size.height;
  10.198 +			CGContextClipToRect(cgContext, cgRect);
  10.199  		}
  10.200 -	//}
  10.201 +		cgRect.size.height = bounds.size.height;
  10.202 +		CGContextDrawLayerInRect(cgContext, cgRect, layer);
  10.203 +	} else {
  10.204 +		[cache drawInRect:rect fromRect:imageRect operation:NSCompositeSourceOver fraction:1.0];
  10.205 +	}
  10.206  }
  10.207  
  10.208  - (void) setIcon:(NSImage *)anIcon {
    11.1 --- a/Plugins/Displays/Smoke/GrowlSmokeWindowView.m	Thu Oct 22 02:25:49 2009 -0700
    11.2 +++ b/Plugins/Displays/Smoke/GrowlSmokeWindowView.m	Thu Oct 22 03:08:43 2009 -0700
    11.3 @@ -96,69 +96,66 @@
    11.4  
    11.5  - (void) drawRect:(NSRect)rect {
    11.6  #pragma unused(rect)
    11.7 -	//Make sure that we don't draw in the main thread
    11.8 -	//if ([super dispatchDrawingToThread:rect]) {
    11.9 -		NSRect b = [self bounds];
   11.10 -		CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
   11.11 -
   11.12 -		CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   11.13 -
   11.14 -		// calculate bounds based on icon-float pref on or off
   11.15 -		CGRect shadedBounds;
   11.16 -		BOOL floatIcon = GrowlSmokeFloatIconPrefDefault;
   11.17 -		READ_GROWL_PREF_BOOL(GrowlSmokeFloatIconPref, GrowlSmokePrefDomain, &floatIcon);
   11.18 -		if (floatIcon) {
   11.19 -			CGFloat sizeReduction = GrowlSmokePadding + iconSize + (GrowlSmokeIconTextPadding * 0.5);
   11.20 -
   11.21 -			shadedBounds = CGRectMake(bounds.origin.x + sizeReduction + 1.0,
   11.22 -									  bounds.origin.y + 1.0,
   11.23 -									  bounds.size.width - sizeReduction - 2.0,
   11.24 -									  bounds.size.height - 2.0);
   11.25 -		} else {
   11.26 -			shadedBounds = CGRectInset(bounds, 1.0, 1.0);
   11.27 -		}
   11.28 -
   11.29 -		// set up bezier path for rounded corners
   11.30 -		addRoundedRectToPath(context, shadedBounds, GrowlSmokeBorderRadius);
   11.31 -		CGContextSetLineWidth(context, 2.0);
   11.32 -
   11.33 -		// draw background
   11.34 -		CGPathDrawingMode drawingMode;
   11.35 -		if (mouseOver) {
   11.36 -			drawingMode = kCGPathFillStroke;
   11.37 -			[bgColor setFill];
   11.38 -			[textColor setStroke];
   11.39 -		} else {
   11.40 -			drawingMode = kCGPathFill;
   11.41 -			[bgColor set];
   11.42 -		}
   11.43 -		CGContextDrawPath(context, drawingMode);
   11.44 -
   11.45 -		// draw the title and the text
   11.46 -		NSRect drawRect;
   11.47 -		drawRect.origin.x = GrowlSmokePadding;
   11.48 -		drawRect.origin.y = GrowlSmokePadding;
   11.49 -		drawRect.size.width = iconSize;
   11.50 -		drawRect.size.height = iconSize;
   11.51 -
   11.52 -		[icon setFlipped:YES];
   11.53 -		[icon drawScaledInRect:drawRect
   11.54 -					 operation:NSCompositeSourceOver
   11.55 -					  fraction:1.0];
   11.56 -
   11.57 -		drawRect.origin.x += iconSize + GrowlSmokeIconTextPadding;
   11.58 -
   11.59 -		if (haveTitle) {
   11.60 -			[titleLayoutManager drawGlyphsForGlyphRange:titleRange atPoint:drawRect.origin];
   11.61 -			drawRect.origin.y += titleHeight + GrowlSmokeTitleTextPadding;
   11.62 -		}
   11.63 -
   11.64 -		if (haveText)
   11.65 -			[textLayoutManager drawGlyphsForGlyphRange:textRange atPoint:drawRect.origin];
   11.66 -
   11.67 -		[[self window] invalidateShadow];
   11.68 -		[super drawRect:rect];
   11.69 -	//}
   11.70 +	NSRect b = [self bounds];
   11.71 +	CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
   11.72 +
   11.73 +	CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   11.74 +
   11.75 +	// calculate bounds based on icon-float pref on or off
   11.76 +	CGRect shadedBounds;
   11.77 +	BOOL floatIcon = GrowlSmokeFloatIconPrefDefault;
   11.78 +	READ_GROWL_PREF_BOOL(GrowlSmokeFloatIconPref, GrowlSmokePrefDomain, &floatIcon);
   11.79 +	if (floatIcon) {
   11.80 +		CGFloat sizeReduction = GrowlSmokePadding + iconSize + (GrowlSmokeIconTextPadding * 0.5);
   11.81 +
   11.82 +		shadedBounds = CGRectMake(bounds.origin.x + sizeReduction + 1.0,
   11.83 +								  bounds.origin.y + 1.0,
   11.84 +								  bounds.size.width - sizeReduction - 2.0,
   11.85 +								  bounds.size.height - 2.0);
   11.86 +	} else {
   11.87 +		shadedBounds = CGRectInset(bounds, 1.0, 1.0);
   11.88 +	}
   11.89 +
   11.90 +	// set up bezier path for rounded corners
   11.91 +	addRoundedRectToPath(context, shadedBounds, GrowlSmokeBorderRadius);
   11.92 +	CGContextSetLineWidth(context, 2.0);
   11.93 +
   11.94 +	// draw background
   11.95 +	CGPathDrawingMode drawingMode;
   11.96 +	if (mouseOver) {
   11.97 +		drawingMode = kCGPathFillStroke;
   11.98 +		[bgColor setFill];
   11.99 +		[textColor setStroke];
  11.100 +	} else {
  11.101 +		drawingMode = kCGPathFill;
  11.102 +		[bgColor set];
  11.103 +	}
  11.104 +	CGContextDrawPath(context, drawingMode);
  11.105 +
  11.106 +	// draw the title and the text
  11.107 +	NSRect drawRect;
  11.108 +	drawRect.origin.x = GrowlSmokePadding;
  11.109 +	drawRect.origin.y = GrowlSmokePadding;
  11.110 +	drawRect.size.width = iconSize;
  11.111 +	drawRect.size.height = iconSize;
  11.112 +
  11.113 +	[icon setFlipped:YES];
  11.114 +	[icon drawScaledInRect:drawRect
  11.115 +				 operation:NSCompositeSourceOver
  11.116 +				  fraction:1.0];
  11.117 +
  11.118 +	drawRect.origin.x += iconSize + GrowlSmokeIconTextPadding;
  11.119 +
  11.120 +	if (haveTitle) {
  11.121 +		[titleLayoutManager drawGlyphsForGlyphRange:titleRange atPoint:drawRect.origin];
  11.122 +		drawRect.origin.y += titleHeight + GrowlSmokeTitleTextPadding;
  11.123 +	}
  11.124 +
  11.125 +	if (haveText)
  11.126 +		[textLayoutManager drawGlyphsForGlyphRange:textRange atPoint:drawRect.origin];
  11.127 +
  11.128 +	[[self window] invalidateShadow];
  11.129 +	[super drawRect:rect];
  11.130  }
  11.131  
  11.132  - (void) setIcon:(NSImage *)anIcon {
    12.1 --- a/Plugins/Displays/iCal/GrowliCalWindowView.m	Thu Oct 22 02:25:49 2009 -0700
    12.2 +++ b/Plugins/Displays/iCal/GrowliCalWindowView.m	Thu Oct 22 03:08:43 2009 -0700
    12.3 @@ -112,104 +112,101 @@
    12.4  
    12.5  - (void) drawRect:(NSRect) rect {
    12.6  #pragma unused(rect)
    12.7 -	//Make sure that we don't draw in the main thread
    12.8 -	//if ([super dispatchDrawingToThread:rect]) {
    12.9 -		NSRect b = [self bounds];
   12.10 -		CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
   12.11 -		CGRect shape = CGRectInset(bounds, BORDER_WIDTH_PX*0.5, BORDER_WIDTH_PX*0.5);
   12.12 -
   12.13 -		CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
   12.14 -
   12.15 -		// Create a path with enough room to strike the border and remain inside our frame.
   12.16 -		// Since the path is in the middle of the line, this means we must inset it by half the border width.
   12.17 -		addRoundedRectToPath(context, shape, BORDER_RADIUS_PX);
   12.18 -		CGContextSetLineWidth(context, BORDER_WIDTH_PX);
   12.19 -
   12.20 -		CGContextSaveGState(context);
   12.21 -		CGContextClip(context);
   12.22 -
   12.23 -		// Create a callback function to generate the
   12.24 -		// fill clipped graphics context with our gradient
   12.25 -		struct CGFunctionCallbacks callbacks = { 0U, GrowliCalShadeInterpolate, NULL };
   12.26 -		CGFloat colors[8];
   12.27 -
   12.28 -		[lightColor getRed:&colors[0]
   12.29 -					 green:&colors[1]
   12.30 -					  blue:&colors[2]
   12.31 -					 alpha:&colors[3]];
   12.32 -
   12.33 -		[bgColor getRed:&colors[4]
   12.34 -				  green:&colors[5]
   12.35 -				   blue:&colors[6]
   12.36 -				  alpha:&colors[7]];
   12.37 -
   12.38 -		CGFunctionRef function = CGFunctionCreate( (void *) colors,
   12.39 -												   1U,
   12.40 -												   /*domain*/ NULL,
   12.41 -												   4U,
   12.42 -												   /*range*/ NULL,
   12.43 -												   &callbacks );
   12.44 -		CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
   12.45 -
   12.46 -		CGPoint src, dst;
   12.47 -		src.x = CGRectGetMaxX(bounds);
   12.48 -		src.y = CGRectGetMaxY(bounds);
   12.49 -		dst.x = CGRectGetMinX(bounds);
   12.50 -		dst.y = src.y;
   12.51 -		CGShadingRef shading = CGShadingCreateAxial(cspace, dst, src,
   12.52 -													function, false, false);
   12.53 -
   12.54 -		CGContextDrawShading(context, shading);
   12.55 -
   12.56 -		CGShadingRelease(shading);
   12.57 -		CGFunctionRelease(function);
   12.58 -
   12.59 -		CGContextRestoreGState(context);
   12.60 -
   12.61 -		CGFloat tbcolor[4]; 
   12.62 -		tbcolor[0] = [borderColor redComponent];
   12.63 -		tbcolor[1] = [borderColor greenComponent];
   12.64 -		tbcolor[2] = [borderColor blueComponent];
   12.65 -		tbcolor[3] = [borderColor alphaComponent];
   12.66 -		CGColorRef barcolor = CGColorCreate(cspace,tbcolor);
   12.67 -		if (barcolor) {
   12.68 -			CGContextSetFillColorWithColor(context,barcolor);
   12.69 -			CFRelease(barcolor);
   12.70 -		}
   12.71 -		CGRect titlebar = CGRectMake(0,CGRectGetMinY(shape),CGRectGetWidth(shape),15);
   12.72 -		addTopRoundedRectToPath(context,titlebar,BORDER_RADIUS_PX);
   12.73 -		CGContextFillPath(context);
   12.74 -		CGColorSpaceRelease(cspace);
   12.75 -
   12.76 -		addRoundedRectToPath(context, shape, BORDER_RADIUS_PX);
   12.77 -		CGContextSetLineWidth(context, BORDER_WIDTH_PX);
   12.78 -		[borderColor set];
   12.79 -		CGContextStrokePath(context);
   12.80 -
   12.81 -		NSRect drawRect;
   12.82 -		drawRect.origin.x = CGRectGetMaxX(shape) - iconSize - ICON_HSPACE_PX;
   12.83 -		drawRect.origin.y = PANEL_VSPACE_PX;
   12.84 -		drawRect.size.width = iconSize;
   12.85 -		drawRect.size.height = iconSize;
   12.86 -
   12.87 -		[icon setFlipped:YES];
   12.88 -		[icon drawScaledInRect:drawRect
   12.89 -					 operation:NSCompositeSourceOver
   12.90 -					  fraction:1.0];
   12.91 -
   12.92 -		drawRect.origin.x = PANEL_HSPACE_PX;
   12.93 -
   12.94 -		if (haveTitle) {
   12.95 -			[titleLayoutManager drawGlyphsForGlyphRange:titleRange atPoint:drawRect.origin];
   12.96 -			drawRect.origin.y += titleHeight + TITLE_VSPACE_PX;
   12.97 -		}
   12.98 -
   12.99 -		if (haveText)
  12.100 -			[textLayoutManager drawGlyphsForGlyphRange:textRange atPoint:drawRect.origin];
  12.101 -
  12.102 -		[[self window] invalidateShadow];
  12.103 -		[super drawRect:rect];
  12.104 -	//}
  12.105 +	NSRect b = [self bounds];
  12.106 +	CGRect bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, b.size.height);
  12.107 +	CGRect shape = CGRectInset(bounds, BORDER_WIDTH_PX*0.5, BORDER_WIDTH_PX*0.5);
  12.108 +
  12.109 +	CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
  12.110 +
  12.111 +	// Create a path with enough room to strike the border and remain inside our frame.
  12.112 +	// Since the path is in the middle of the line, this means we must inset it by half the border width.
  12.113 +	addRoundedRectToPath(context, shape, BORDER_RADIUS_PX);
  12.114 +	CGContextSetLineWidth(context, BORDER_WIDTH_PX);
  12.115 +
  12.116 +	CGContextSaveGState(context);
  12.117 +	CGContextClip(context);
  12.118 +
  12.119 +	// Create a callback function to generate the
  12.120 +	// fill clipped graphics context with our gradient
  12.121 +	struct CGFunctionCallbacks callbacks = { 0U, GrowliCalShadeInterpolate, NULL };
  12.122 +	CGFloat colors[8];
  12.123 +
  12.124 +	[lightColor getRed:&colors[0]
  12.125 +				 green:&colors[1]
  12.126 +				  blue:&colors[2]
  12.127 +				 alpha:&colors[3]];
  12.128 +
  12.129 +	[bgColor getRed:&colors[4]
  12.130 +			  green:&colors[5]
  12.131 +			   blue:&colors[6]
  12.132 +			  alpha:&colors[7]];
  12.133 +
  12.134 +	CGFunctionRef function = CGFunctionCreate( (void *) colors,
  12.135 +											   1U,
  12.136 +											   /*domain*/ NULL,
  12.137 +											   4U,
  12.138 +											   /*range*/ NULL,
  12.139 +											   &callbacks );
  12.140 +	CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
  12.141 +
  12.142 +	CGPoint src, dst;
  12.143 +	src.x = CGRectGetMaxX(bounds);
  12.144 +	src.y = CGRectGetMaxY(bounds);
  12.145 +	dst.x = CGRectGetMinX(bounds);
  12.146 +	dst.y = src.y;
  12.147 +	CGShadingRef shading = CGShadingCreateAxial(cspace, dst, src,
  12.148 +												function, false, false);
  12.149 +
  12.150 +	CGContextDrawShading(context, shading);
  12.151 +
  12.152 +	CGShadingRelease(shading);
  12.153 +	CGFunctionRelease(function);
  12.154 +
  12.155 +	CGContextRestoreGState(context);
  12.156 +
  12.157 +	CGFloat tbcolor[4]; 
  12.158 +	tbcolor[0] = [borderColor redComponent];
  12.159 +	tbcolor[1] = [borderColor greenComponent];
  12.160 +	tbcolor[2] = [borderColor blueComponent];
  12.161 +	tbcolor[3] = [borderColor alphaComponent];
  12.162 +	CGColorRef barcolor = CGColorCreate(cspace,tbcolor);
  12.163 +	if (barcolor) {
  12.164 +		CGContextSetFillColorWithColor(context,barcolor);
  12.165 +		CFRelease(barcolor);
  12.166 +	}
  12.167 +	CGRect titlebar = CGRectMake(0,CGRectGetMinY(shape),CGRectGetWidth(shape),15);
  12.168 +	addTopRoundedRectToPath(context,titlebar,BORDER_RADIUS_PX);
  12.169 +	CGContextFillPath(context);
  12.170 +	CGColorSpaceRelease(cspace);
  12.171 +
  12.172 +	addRoundedRectToPath(context, shape, BORDER_RADIUS_PX);
  12.173 +	CGContextSetLineWidth(context, BORDER_WIDTH_PX);
  12.174 +	[borderColor set];
  12.175 +	CGContextStrokePath(context);
  12.176 +
  12.177 +	NSRect drawRect;
  12.178 +	drawRect.origin.x = CGRectGetMaxX(shape) - iconSize - ICON_HSPACE_PX;
  12.179 +	drawRect.origin.y = PANEL_VSPACE_PX;
  12.180 +	drawRect.size.width = iconSize;
  12.181 +	drawRect.size.height = iconSize;
  12.182 +
  12.183 +	[icon setFlipped:YES];
  12.184 +	[icon drawScaledInRect:drawRect
  12.185 +				 operation:NSCompositeSourceOver
  12.186 +				  fraction:1.0];
  12.187 +
  12.188 +	drawRect.origin.x = PANEL_HSPACE_PX;
  12.189 +
  12.190 +	if (haveTitle) {
  12.191 +		[titleLayoutManager drawGlyphsForGlyphRange:titleRange atPoint:drawRect.origin];
  12.192 +		drawRect.origin.y += titleHeight + TITLE_VSPACE_PX;
  12.193 +	}
  12.194 +
  12.195 +	if (haveText)
  12.196 +		[textLayoutManager drawGlyphsForGlyphRange:textRange atPoint:drawRect.origin];
  12.197 +
  12.198 +	[[self window] invalidateShadow];
  12.199 +	[super drawRect:rect];
  12.200  }
  12.201  
  12.202  #pragma mark -