I'm having problems with code that works fine on Leopard, and broken in Snow Leopard. In Leopard the drawing of text in a selected cell with a colour label applied is drawing white instead of black, if the selected cell is the first in a list of items with a colour label applied.
Correct behaviour in: Leopard http://yvs.eu.com/files/Leopard.png http://yvs.eu.com/files/Leopard2.png Correct behaviour in Snow Leopard when it is not the first item with a colour label selected: http://yvs.eu.com/files/SnowLeopard2.png I have an NSOutlineView and I use a subclass of a view controller to control it and to be its delegate. I use a modified version of Apple's ImageAndTextCell class to draw each item in the single column outline view. The image and text cell class draws the image and a colour label where necessary like those applied in Finder and then asks super (NSTextCell) to draw the text. In the controller and delegate I have implemented the delegate method where I set the colour label if necessary: - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item { MYImageAndTextCell *imgTxtCell = cell; MyNode *myNode = item; // The if is strictly not necessary but highlights that the label name is NULL when there is no label. if ([myNode colourLabel]) [cell setLabelName:[myNode colourLabel]]; else [cell setLabelName:NULL]; } In the ImageAndTextCell I have gone over the top in trying to apply the correct background style when I have a colour label applied (NSBackgroundStyleLight which previously resulted in the text drawn black). I have overridden interiorBackgroundStyle drawWithFrame:cellFrame:inView and drawInteriorWithFrame:inView - (NSBackgroundStyle)interiorBackgroundStyle { if ([self labelName]) return NSBackgroundStyleLight; return [super interiorBackgroundStyle]; } - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { if ([self labelName]) { ... NSDrawThreePartImage(labelFrame, leftEndCapImage, middleImage, rightEndCapImage, FALSE, NSCompositeSourceOver, 1.0, TRUE); [self setBackgroundStyle:NSBackgroundStyleLight]; } // super will draw the text [super drawInteriorWithFrame:cellFrame inView:controlView]; } - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { // Carve up the cell so that part of the cell is the image, and the other part is the text cell. NSSize imageSize [[self image] size] ; NSRect imageFrame; NSRect textFrame; NSDivideRect(cellFrame, &imageFrame, &textFrame, 5 + imageSize.width, NSMinXEdge); [[self image] compositeToPoint:imageFrame.origin operation:NSCompositeSourceOver]; if ([self labelName]) [self setBackgroundStyle:NSBackgroundStyleLight]; [super drawWithFrame:textFrame inView:controlView]; } What changed in snow leopard to override setting the background style to NSBackgroundStyleLight for the first item? What am I doing wrong? ktam_______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
