// BTHTweakedTableView.m // // Created by Blain Hamon on 8/26/07. // Released as Public Domain #import "BTHTweakedTableView.h" @implementation BTHTweakedTableView - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code here. } return self; } #pragma mark isDrawDestination code #define BTHBORDERLINEWIDTH 3 - (void)drawRect: (NSRect)rect; { [super drawRect: rect]; // Drawing code here. if (isDragDestination) { [[NSColor selectedControlColor] setFill]; NSRect leftRightBounds = [self visibleRect]; NSRect topBottomBounds = leftRightBounds; topBottomBounds.size.height = BTHBORDERLINEWIDTH; NSRectFill(topBottomBounds); topBottomBounds.origin.y += leftRightBounds.size.height - BTHBORDERLINEWIDTH; NSRectFill(topBottomBounds); leftRightBounds.size.width = BTHBORDERLINEWIDTH; NSRectFill(leftRightBounds); leftRightBounds.origin.x += topBottomBounds.size.width - BTHBORDERLINEWIDTH; NSRectFill(leftRightBounds); } } - (void)setNeedsDisplayInRect:(NSRect)invalidRect; { if (isDragDestination) { [super setNeedsDisplayInRect:[self visibleRect]]; } else { [super setNeedsDisplayInRect:invalidRect]; } } - (BOOL)isDragDestination { return isDragDestination; } - (void)setIsDragDestination:(BOOL)value { if (isDragDestination != value) { isDragDestination = value; [self setNeedsDisplay]; } } #pragma mark Event handlers #define BTH_ADD_DELEGATE_HANDLER(methodName, argumentType, argumentName) \ - (void) methodName argumentType argumentName; \ { \ BOOL doSuperEvent = YES; \ id ourDelegate = [self delegate]; \ if ((ourDelegate != nil) && [ourDelegate respondsToSelector: \ @selector(tableView:methodName)]){ \ doSuperEvent = [ourDelegate tableView:self methodName argumentName]; \ } \ if (doSuperEvent) [super methodName argumentName]; \ } BTH_ADD_DELEGATE_HANDLER(mouseDown:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(rightMouseDown:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(otherMouseDown:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(mouseUp:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(rightMouseUp:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(otherMouseUp:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(mouseMoved:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(mouseDragged:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(scrollWheel:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(rightMouseDragged:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(otherMouseDragged:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(mouseExited:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(keyDown:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(keyUp:, (NSEvent*), theEvent) BTH_ADD_DELEGATE_HANDLER(flagsChanged:, (NSEvent*), theEvent) #pragma mark IBAction handlers BTH_ADD_DELEGATE_HANDLER(selectAll:, (id), sender) BTH_ADD_DELEGATE_HANDLER(deselectAll:, (id), sender) @end