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: Ronny Reichmann <email@hidden>
- Date: Thu, 7 Dec 2006 16:15:18 +0100
Hello,
my idea of solving this problem is as follows:
First of all: create a NSView subclass that is able to draw your
images both (next to each other or like you want) - of course inside
the drawRect: method. Then draw these view to an image. If you don't
know how to do this - here is how:
Create a offscreen window programmatically:
NSWindow *hiddenWindow = [[NSWindow alloc]
initWithContentRect:
NSMakeRect( -1000,-1000,width,height )
styleMask: NSTitledWindowMask|NSClosableWindowMask
backing:NSBackingStoreNonretained
defer:NO];
Add your custom view to the window:
[[hiddenWindow contentView] addSubview:myCustomView];
Then do the following:
NSBitmapImageRep *rep = [button
bitmapImageRepForCachingDisplayInRect:»the bounds of your images«];
[myCustomView cacheDisplayInRect:»the bounds of your images«
toBitmapImageRep:rep];
NSImage *resultImage = [[[NSImage alloc] init] autorelease];
[resultImage addRepresentation:rep];
Now you can add the » resultImage« to your cell. This will work since
10.4. There is another way described in the cocoa documentation that
works for pre 10.4 systems, but does only draw without alpha (alpha
areas of your images will show the window background). This way looks
something like that:
[myCustomView lockFocus];
NSBitmapImageRep *rep = [[[NSBitmapImageRep alloc]
initWithFocusedViewRect:»the bounds of your images«] autorelease];
[myCustomView unlockFocus];
NSImage * resultImage = [[[NSImage alloc] init] autorelease];
[resultImage addRepresentation:rep];
I hope I could help you,
ron
Am 07.12.2006 um 15:18 schrieb vibhatha v:
Hi,
i have to display 2 images in a single cell of an nstableview.
To display 1 image i am using tableview willdisplay cell function.
Any suggestions as to how can display 2 images in a single table cell?
Thanks and Regards,
Vibhatha.
_______________________________________________
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
_______________________________________________
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