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: Matt Neuburg <email@hidden>
- Date: Sun, 10 Dec 2006 14:20:17 -0800
- Thread-topic: Displaying 2 images in a single cell of nstableview
On Thu, 7 Dec 2006 19:48:18 +0530, "vibhatha v" <email@hidden> said:
>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?
By coincidence, I just finished writing an app that does this. Actually the
2 images also function as buttons, but the principle is the same.
To start with, I subclassed NSCell. In my subclass, there are two
NSButtonCell ivars; if you don't need the button functionality, then you
could skip that. Don't forget to implement copyWithZone! There are examples
on your hard disk that show you how.
The big work happens in drawWithFrame:. Here, I consult the cell's
objectValue. I've arranged for the table view's data source to provide an
objectValue that contains the info about what images to use. So by looking
in objectValue, I know what images to draw. Now I divide up the cellFrame
into drawing areas for the images and for anything else that I want to draw
(in this case, I also draw text). So now I what to draw and where to draw
it, and I do.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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