Re: Displaying 2 images in a single cell of nstableview
Re: Displaying 2 images in a single cell of nstableview
- Subject: Re: Displaying 2 images in a single cell of nstableview
- From: Erik Buck <email@hidden>
- Date: Thu, 7 Dec 2006 08:50:12 -0800 (PST)
Don't create explicit off-screen windows and unneeded views just to draw two images in one cell. That is all extremely bad advice.
Just subclass NSCell and implement drawWithFrame:inView: http://developer.apple.com/samplecode/Clock_Control/ .
Alternatively, use sub-cells as shown in http://www.stepwise.com/Articles/Technical/NSCell.html.
If you really want to create a third image that contains two original images, at least use NSImage to do it instead of explicitly creating useless new windows that may or may not be off screen and then using useless views that nobody will ever "view" because they are off screen.
// Create a third image large enough to contain both source images
NSAssert(nil != image1 && nil != image2, @"Invalid source image");
NSSize combinedSize = [image1 size];
combinedSize.width += [image2 size].width;
combinedSize.height = MAX(combinedSize.height, [image2 size].height);
NSImage *combinedImage = [[NSImage alloc] initWithSize:combinedSize];
// Draw both source images into the combined image
[combinedImage lockFocus];
[image1 compositeToPoint:NSZeroPoint operation:NSCompositeCopy];
[image2 compositeToPoint:NSMakePoint([image1 size].width, 0.0f) operation:NSCompositeCopy];
[combinedImage unlockFocus];
// Now use combinedImage as the image in the cell.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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