
/*!
 Copyright 2009 Sun Microsystems, Inc.
 
 @author
 jak
 
 @class
 WBGrayTabView
 
 @abstract
 Implements the custom tabs. Tabs at the top of the tab view, pointing upwards.
 
 @ingroup
 Custom Tab Views
 */



#import "WBGrayTabView.h"
#import "WBGrayTabItem.h"
#import "CGColorUtilities.h"



@implementation WBGrayTabView



- (void) drawRect: (NSRect) rect;
{
  [super drawRect: rect];
  
  // fills area inside a tab
  [[NSColor colorWithCalibratedRed: 0.93
                             green: 0.93
                              blue: 0.93
                             alpha: 1] set];
  [NSBezierPath fillRect: rect];
}



- (CALayer*) shadowLayer;
{
	// Create a line between non-selected tabs and the tabviewcontants.
	CALayer* lineLayer = [CALayer layer];
	
	[lineLayer setBorderWidth: 1];
	CGColorRef c = WB_CGColorCreateCalibratedRGB(0.68, 0.68, 0.68, 1);
	[lineLayer setBorderColor: c];
	CGColorRelease(c);
	
	CGRect r = CGRectZero;
	r.origin.x = 0;
	r.origin.y = [[self layer] frame].size.height - [self tabAreaHeight];
	r.size.width = [[self layer] frame].size.width;
	r.size.height = 1;
	[lineLayer setFrame: r];
	[lineLayer setAutoresizingMask: (kCALayerWidthSizable | kCALayerMinYMargin)];
	
	[lineLayer setZPosition: -2];
	[[self layer] addSublayer: lineLayer];
	
	return lineLayer;
}



- (WBTabItem*) tabItemWithIdentifier: (id) identifier
							   label: (NSString*) label;
{
	WBTabItem* item = [WBGrayTabItem tabItemWithIdentifier: identifier
                                                   label: label];
	
	
	return item;
}



- (void) doCustomize;
{
	mTabPlacement = WBTabPlacementTop;
	mTabDirection = WBTabDirectionUp;
	mTabSize = WBTabSizeLarge;
	
	[super doCustomize];
  
  NSRect r = [mTabView frame];
  r = NSInsetRect(r, 5, 0);
  r.size.height -= 5;
  [mTabView setFrame: r];
}



@end


