/* PTableView.m - NSTableView subclass for Popup.app Copyright (C) 2003, 2004 Rob Burns This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02111, USA. */ #include "PTableView.h" #ifdef __APPLE__ #define STRIPE_RED (237.0 / 255.0) #define STRIPE_GREEN (243.0 / 255.0) #define STRIPE_BLUE (254.0 / 255.0) static NSColor *stripeColor = nil; #endif @implementation PTableView #ifndef __APPLE__ - (NSImage *) dragImageForRows: (NSArray *) dragRows event: (NSEvent *) dragEvent dragImageOffset: (NSPoint *) dragImageOffset { if( [dragRows count] == 1 ) return [NSImage imageNamed: @"DraggedCard"]; else return [NSImage imageNamed: @"DraggedCards"]; } #endif #ifdef __APPLE__ - (void) highlightSelectionInClipRect:(NSRect)rect { NSRect stripeRect; float fullRowHeight = [self rowHeight] + [self intercellSpacing].height; float clipBottom = NSMaxY(rect); int firstStripe = rect.origin.y / fullRowHeight; if (firstStripe % 2 == 0) firstStripe++; // we're only interested in drawing the stripes // set up first rect stripeRect.origin.x = rect.origin.x; stripeRect.origin.y = firstStripe * fullRowHeight; stripeRect.size.width = rect.size.width; stripeRect.size.height = fullRowHeight; // set the color if (stripeColor == nil) stripeColor = [[NSColor colorWithCalibratedRed:STRIPE_RED green:STRIPE_GREEN blue:STRIPE_BLUE alpha:1.0] retain]; [stripeColor set]; // and draw the stripes while (stripeRect.origin.y < clipBottom) { NSRectFill(stripeRect); stripeRect.origin.y += fullRowHeight * 2.0; } [super highlightSelectionInClipRect:rect]; } #endif @end