/*
 *	Filename: ArrowTableHeaderCell.m
 *	Created : Thu Nov 28 13:49:31 1996
 *	Author  : Vince DeMarco
 *	LastEditDate Was "Thu Nov 28 15:41:34 1996"
 */

#import "ArrowTableHeaderCell.h"
#import <AppKit/NSImage.h>
#import <AppKit/NSFont.h>

@implementation ArrowTableHeaderCell

-(void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
{
    if ([self state]){
	NSRect   newRectLeft;
	NSRect   newRectRight;
	NSImage *image;
	NSPoint  point;

	newRectLeft  = cellFrame;
	newRectRight = cellFrame;

	image = [NSImage imageNamed:@"ArrowTableIcon"];

	newRectRight.size.width = [image size].width;
	newRectLeft.size.width  = cellFrame.size.width - newRectRight.size.width;
	newRectRight.origin.x   = cellFrame.origin.x + newRectLeft.size.width;

	point.x = newRectRight.origin.x;

	if ([controlView isFlipped]){
	    NSRect   frame;

		/* the controlView is flipped so this stuff here need to happen */
	    frame   = [controlView frame];
	    point.y = frame.size.height - (newRectRight.origin.y + (newRectLeft.size.height - [image size].height)/2.0);
	}else{
	    point.y = (newRectRight.origin.y + (newRectLeft.size.height - [image size].height)/2.0);
	}

	[super drawInteriorWithFrame:newRectLeft inView:controlView];

	[controlView lockFocus];
	[image compositeToPoint:point operation:NSCompositeSourceOver];
	[controlView unlockFocus];
    }else{
	[super drawInteriorWithFrame:cellFrame inView:controlView];
    }
}

@end
