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



#import "WBSplitView.h"



@implementation WBSplitView



- (CGFloat) dividerThickness;
{
	if ([self isVertical])
		return 2;
	else
		return [super dividerThickness];
}



- (void) drawDividerInRect: (NSRect) aRect;
{
	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: aRect];
}



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



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



#pragma mark Create and Destroy



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



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



@end


