I've got an NSTableColumn that uses a custom class for the table header cells which is inherited from an NSPopUpButtonCell. I list the code below how I create the table header cells and put them in the NSTableColumn's.
Attached are two images that show what my problem looks like. The 'cell-before' attachment shows what my table header looks like before I replace the cells with my own DataTableHeaderCell class (which is below). The 'cell-after' image is what it looks like after I've replaced the header cells w/ my DataTableHeaderCell class. In the 'cell-after' image, you can see that the table header cell is all white and even extends slightly into the gray area (which is an NSPathControl), and it's not a smooth line as shown i the 'cell-before' image. That's the problem I'm trying to fix. Here is how I create my table header cells, which, when run causes the 'cell-after' image problem. This is not run in the 'cell-before' image. for (i = 0; i < [columnItems count]; i++) { NSString *columnName = [columnItems objectAtIndex:i]; tableHeaderCell = [[DataTableHeaderCell alloc] initTextCell:columnName]; [tableHeaderCell setPullsDown:NO]; [tableHeaderCell setControlSize:NSMiniControlSize]; [tableHeaderCell setBordered:NO]; [tableHeaderCell setFont:[NSFont labelFontOfSize: [NSFont smallSystemFontSize]]]; column = [[DataTableColumn alloc] initWithIdentifier:[NSNumber numberWithInt:i]]; if (i == 0) { [tableHeaderCell setEditable:NO]; [column setWidth:40]; } else { [tableHeaderCell setEditable:YES]; [tableHeaderCell addItemWithTitle:@"col A"]; [tableHeaderCell addItemWithTitle:@"col B"]; [tableHeaderCell addItemWithTitle:@"col C"]; } [column setHeaderCell:tableHeaderCell]; ------- DataTableHeaderCell.h @interface DataTableHeaderCell : NSPopUpButtonCell { } - (id) initTextCell:(NSString *) string; - (void) drawInteriorWithFrame:(NSRect) cellFrame inView:(NSView *) controlView; @end ------- DataTableHeaderCell.m @implementation DataTableHeaderCell - (id) initTextCell:(NSString *) string { self = [super initTextCell:string]; if (!self) { return nil; } return self; } // This mostly just draws a bottom border on the cell. - (void) drawInteriorWithFrame:(NSRect) cellFrame inView:(NSView *) controlView { [[NSColor whiteColor] set]; [[NSBezierPath bezierPathWithRect:cellFrame] fill]; NSBezierPath *path = [NSBezierPath bezierPath]; [path moveToPoint:NSMakePoint(cellFrame.origin.x, cellFrame.size.height)]; [path lineToPoint:NSMakePoint(NSMaxX(cellFrame), NSMaxY(cellFrame))]; [[NSColor darkGrayColor] setStroke]; [path stroke]; [super drawInteriorWithFrame:cellFrame inView:controlView]; return; } @end
<<attachment: cell-before.tiff>>
<<attachment: cell-after.tiff>>
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com