
/*!
 Copyright 2009 Sun Microsystems, Inc.
 */



#import "WBPaletteContainer.h"
#import "CGColorUtilities.h"



@implementation WBPaletteContainer



- (void) drawRect: (NSRect) dirtyRect;
{
	[super drawRect: dirtyRect];
	
	NSColor* color;
	
	if (mEnabled) {
		color = [NSColor colorWithCalibratedRed: 0.52
																			green: 0.52
																			 blue: 0.52
																			alpha: 1];
	}
	else {
		color = [NSColor colorWithCalibratedRed: 0.8
																			green: 0.8
																			 blue: 0.8
																			alpha: 1];
	}
	
	[color set];
	[NSBezierPath fillRect: dirtyRect];
}



#pragma mark -



- (void) handleWindowDidBecomeMain: (id) aNotification;
{
	mEnabled = YES;
	[self setNeedsDisplay: YES];
}



- (void) handleWindowDidResignMain: (id) aNotification;
{
	mEnabled = NO;
	[self setNeedsDisplay: YES];
}



#pragma mark Creation and destruction



- (void) awakeFromNib;
{
	mEnabled = YES;
	
	// Set up notifications.
	NSNotificationCenter* dc = [NSNotificationCenter defaultCenter];
	[dc addObserver: self
				 selector: @selector(handleWindowDidBecomeMain:)
						 name: NSWindowDidBecomeMainNotification
					 object: [self window]];
	[dc addObserver: self
				 selector: @selector(handleWindowDidResignMain:)
						 name: NSWindowDidResignMainNotification
					 object: [self window]];
}



- (void) dealloc
{
	NSNotificationCenter* dc = [NSNotificationCenter defaultCenter];
	[dc removeObserver: self];
	
	[super dealloc];
}



@end


