table header cells not on even lines
table header cells not on even lines
- Subject: table header cells not on even lines
- From: Shane <email@hidden>
- Date: Sat, 31 Jul 2010 23:52:36 -0500
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
Description: TIFF image
Attachment:
cell-after.tiff
Description: TIFF image
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden