NSCell subclass text not changing attribute on selection?
NSCell subclass text not changing attribute on selection?
- Subject: NSCell subclass text not changing attribute on selection?
- From: "Mike Hanna" <email@hidden>
- Date: Tue, 14 Mar 2006 18:15:01 -0800
http://img489.imageshack.us/img489/3359/picture39bv.png
when clicked on, looks like this:
http://img489.imageshack.us/img489/4483/picture49cq.png
here is the drawWithFrame: inView:
I set the NSForegroundColorAttributeName attribute with a BOOL
instance called fWhiteText.
seems to draw 'fine' when not selected(even greenColor), but upon
selecting it.. its a uniform blue colour like in the screenshot.
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSString * string;
NSPoint pen;
NSMutableDictionary * attributes;
NSLog(@"whitetext %d", fWhiteText);
NSLog(@"fTaskString %@", fTaskString);
NSLog(@"fDetailString %@", fDetailString);
pen = cellFrame.origin;
float cellWidth = cellFrame.size.width;
attributes = [NSMutableDictionary dictionaryWithCapacity: 2];
[attributes setObject: fWhiteText ? [NSColor whiteColor] :
[NSColor blackColor] forKey: NSForegroundColorAttributeName];
[attributes setObject: [NSFont messageFontOfSize: 12.0]
forKey: NSFontAttributeName];
NSLog(@"attributes font colour %@", [attributes
objectForKey:NSForegroundColorAttributeName]);
pen.x += 27;
[fTaskString drawAtPoint: pen withAttributes: attributes];
[attributes setObject: [NSFont messageFontOfSize: 9.0]
forKey: NSFontAttributeName];
pen.y = 15;
[fDetailString drawAtPoint: pen withAttributes: attributes];
if (fFooImage != nil) {
NSSize imageSize;
NSRect imageFrame;
imageSize = [fFooImage size];
NSDivideRect(cellFrame, &imageFrame, &cellFrame, 3 +
imageSize.width, NSMinXEdge);
imageFrame.origin.x += 3;
imageFrame.size = imageSize;
if ([controlView isFlipped])
imageFrame.origin.y += ceil((cellFrame.size.height +
imageFrame.size.height) / 2);
else
imageFrame.origin.y += ceil((cellFrame.size.height -
imageFrame.size.height) / 2);
[fFooImage compositeToPoint:imageFrame.origin
operation:NSCompositeSourceOver];
}
[super drawWithFrame:cellFrame inView:controlView];
}
here is the tableviews - (void) tableView: (NSTableView *) t
willDisplayCell: (id) cell
forTableColumn: (NSTableColumn *) tableColumn row: (int) rowIndex
- (void) tableView: (NSTableView *) t willDisplayCell: (id) cell
forTableColumn: (NSTableColumn *) tableColumn row: (int) rowIndex
{
BOOL w;
w = [fWindow isKeyWindow] && rowIndex == [fFooTable selectedRow];
if( [[tableColumn identifier] isEqualToString: @"foo"] )
{
NSLog(@"found foo col cursor retain count %d", [cursor retainCount]);
[(YKKFooCell* )cell setRowValues: [cursor rowAtIndex: rowIndex] whiteText:w];
[(YKKFooCell* )cell setImage:[NSImage imageNamed:@"del"]];
}
}
any ideas why this isn't drawing white text?
Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden