Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

transparency weirdness



I have this code for a subclass of NSBox.

@implementation MXMetalBox

- (void)drawRect:(NSRect)rect
{	
	if ([self boxType] == NSBoxSeparator) {
		NSRect __rect;
		float* __c = NULL;
		BOOL __increment = NO;
		
		if (rect.size.width < rect.size.height) {
			__rect = NSInsetRect(rect, 2.0, 0.0);
			__c = &__rect.origin.x;
			__increment = YES;
		}
		else {
			__rect = NSInsetRect(rect, 0.0, 2.0);
			__c = &__rect.origin.y;
		}
		
		[[NSColor colorWithCalibratedWhite:0.55 alpha:0.85] set];
		NSRectFill(__rect);
		
		if (__increment) {
			(*__c)++;
			[[NSColor colorWithCalibratedWhite:0.9 alpha:0.90] set];
		}
		else {
			(*__c)--;
			[[NSColor colorWithCalibratedWhite:1.0 alpha:0.90] set];
		}
		
		NSRectFill(__rect);
	}
	else {
		[super drawRect:rect];
	}
}

- (BOOL)isOpaque
{
	return NO;
}

@end

The problem is that when I draw in the main window view the alpha draws correctly, but when the drawing takes place in a modal sheet the alpha does not draw at all. I have tried replacing NSRectFill with NSBezierPath fill and NSRectFillUsingOperation and neither of those draw with alpha at all in any window... I've also tried setting [[NSGraphicsContext currentContext] setCompositingOperation:NSCompositeSourceOver]; but that doesn't seem to help either. What is so special about NSRectFill() that it works sometimes?

--
Michael

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.