Changeset 364 for trunk/Cocoa/Pester/Source/NJRTableView.m
- Timestamp:
- 11/28/07 01:29:26 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/NJRTableView.m
r102 r364 17 17 18 18 @implementation NJRTableView 19 20 - (id)initWithCoder:(NSCoder *)aDecoder;21 {22 if ( (self = [super initWithCoder: aDecoder]) != nil) {23 toolTipRegionList = [[NSMutableDictionary alloc] initWithCapacity: 20];24 }25 return self;26 }27 28 - (void)dealloc;29 {30 [toolTipRegionList release];31 [super dealloc];32 }33 34 #pragma mark tool tips35 36 - (void)reloadData;37 {38 [toolTipRegionList removeAllObjects];39 [self removeAllToolTips];40 [super reloadData];41 }42 43 - (void)noteNumberOfRowsChanged;44 {45 [toolTipRegionList removeAllObjects];46 [self removeAllToolTips];47 [super noteNumberOfRowsChanged];48 }49 50 - (NSString *)_keyForColumn:(int)columnIndex row:(int)rowIndex;51 {52 return [NSString stringWithFormat:@"%d,%d", rowIndex, columnIndex];53 }54 55 - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)data;56 {57 // ask our data source for the tool tip58 if ([[self dataSource] respondsToSelector: @selector(tableView:toolTipForTableColumn:row:)]) {59 if ([self rowAtPoint: point] >= 0) return [[self dataSource] tableView: self toolTipForTableColumn: [[self tableColumns] objectAtIndex: [self columnAtPoint: point]] row: [self rowAtPoint: point]];60 }61 return nil;62 }63 64 - (NSRect)frameOfCellAtColumn:(int)columnIndex row:(int)rowIndex;65 {66 // this cell is apparently displayed, so we need to add a region for it67 NSNumber *toolTipTag;68 NSRect result = [super frameOfCellAtColumn: columnIndex row: rowIndex];69 // check if cell is already in the list70 NSString *cellKey = [self _keyForColumn: columnIndex row: rowIndex];71 // remove old region72 if (toolTipTag = [toolTipRegionList objectForKey: cellKey])73 [self removeToolTip: [toolTipTag intValue]];74 // add new region75 [toolTipRegionList setObject: [NSNumber numberWithInt: [self addToolTipRect: result owner: self userData: cellKey]] forKey: cellKey];76 return [super frameOfCellAtColumn: columnIndex row: rowIndex];77 }78 19 79 20 #pragma mark type selection … … 162 103 } 163 104 164 #pragma mark row coloring165 166 - (void)drawGridInClipRect:(NSRect)rect;167 {168 NSRange columnRange = [self columnsInRect: rect];169 int i;170 // match iTunesÕ grid color171 [[[NSColor gridColor] blendedColorWithFraction: 0.70 ofColor: [NSColor whiteColor]] set];172 for (i = columnRange.location ; i < NSMaxRange(columnRange) ; i++) {173 NSRect colRect = [self rectOfColumn: i];174 int rightEdge = (int) 0.5 + colRect.origin.x + colRect.size.width;175 [NSBezierPath strokeLineFromPoint: NSMakePoint(-0.5 + rightEdge, -0.5 + rect.origin.y)176 toPoint: NSMakePoint(-0.5 + rightEdge, -0.5 + rect.origin.y + rect.size.height)];177 }178 }179 180 - (void)highlightSelectionInClipRect:(NSRect)clipRect;181 {182 NSColor *evenColor, *oddColor = [self backgroundColor];183 float cellHeight = [self cellHeight];184 NSRect visibleRect = [self visibleRect];185 NSRect highlightRect;186 187 if ([NSColor respondsToSelector: @selector(alternateSelectedControlColor)])188 evenColor = [[NSColor alternateSelectedControlColor] highlightWithLevel:0.90];189 else // match iTunesÕ row background color190 evenColor = [NSColor colorWithCalibratedRed: 0.929 green: 0.953 blue: 0.996 alpha:1.0];191 192 highlightRect.origin = NSMakePoint(NSMinX(visibleRect), (int)(NSMinY(clipRect) / cellHeight) * cellHeight);193 highlightRect.size = NSMakeSize(NSWidth(visibleRect), cellHeight);194 195 while (NSMinY(highlightRect) < NSMaxY(clipRect)) {196 NSRect clippedHighlightRect = NSIntersectionRect(highlightRect, clipRect);197 int row = (int)((NSMinY(highlightRect) + cellHeight / 2.0) / cellHeight);198 NSColor *rowColor = (row % 2 == 0) ? evenColor : oddColor;199 [rowColor set];200 NSRectFill(clippedHighlightRect);201 highlightRect.origin.y += cellHeight;202 }203 204 [super highlightSelectionInClipRect: clipRect];205 }206 207 105 @end
Note:
See TracChangeset
for help on using the changeset viewer.