//
//  ControllerButtonCell.m
//  VH7PC_Controller
//
//  Created by nya on Thu Aug 14 2003.
//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
//

#import "ControllerButtonCell.h"


@implementation ControllerButtonCell
/*
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{
    if(![self isHighlighted]){
        [self drawInteriorWithFrame:cellFrame inView:controlView];
    }else{
        NSRect r;
        NSImage *i=[[NSImage alloc] initWithSize:[self cellSize]];
        NSPoint p;
    
        [i lockFocus];
        r.origin=NSZeroPoint;
        r.size=[self cellSize];
        //[[NSColor clearColor] set];
        //[NSBezierPath fillRect:r];
        [[self highlightColorWithFrame:cellFrame inView:controlView] set];
        [NSBezierPath fillRect:r];
        [i unlockFocus];
        
        p.x=cellFrame.origin.x;
        p.y=cellFrame.origin.y+([controlView isFlipped]?[self cellSize].height:0);
        //[i dissolveToPoint:p fraction:0.5];
        [[self image] dissolveToPoint:p fraction:1];
        [i compositeToPoint:p operation:NSCompositeSourceAtop fraction:0.5];
        [i release];
    }
}
*/
-(void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{
    NSPoint p;
    NSImage *img;
    
    if(!(img=[self image])) return;
    p.x=cellFrame.origin.x;
    p.y=cellFrame.origin.y+([controlView isFlipped]?[img size].height:0);
    
    if(![self isHighlighted]){
        [img dissolveToPoint:p fraction:1];
    }else{
        NSRect r;
        NSImage *i=[[NSImage alloc] initWithSize:[self cellSize]];
        NSImage *i2=[[NSImage alloc] initWithSize:[self cellSize]];
    
        [i lockFocus];
        r.origin=NSZeroPoint;
        r.size=[self cellSize];
        [[self highlightColorWithFrame:cellFrame inView:controlView] set];
        [NSBezierPath fillRect:r];
        [i unlockFocus];
        
        [i2 lockFocus];
        [img dissolveToPoint:NSZeroPoint fraction:1];
        [i compositeToPoint:NSZeroPoint operation:NSCompositeSourceAtop fraction:0.5];
        [i2 unlockFocus];
        
        [i2 dissolveToPoint:p fraction:1];
        [i release];
        [i2 release];
    }
}

@end
