On Fri, Aug 8, 2008 at 9:52 AM, Johannes Fahrenkrug <[EMAIL PROTECTED]> wrote: > I'd like to display placeholder images until the table cell gets > displayed and then load the actual thumbnail, replacing the > placeholder image with the real thumbnail once it has loaded. > What would be the best way to do this? I'm thinking of something on > the lines of a proxy object...
Are you using the NSTableView data source API? I think that would be easier for what you want to do. I'd create a placeholder NSImage at first, and when I'm asked for the data for my NSImage column, if I haven't yet finished downloading the image for that particular row, give the NSTableView my placeholder image. Then, once the image has finished downloading, call [myTableView setNeedsDisplayInRect:NSIntersectionRect([myTableView rectForColumn:indexOfImageColumn], [myTableView rectForRow:rowOfUpdatedItem])]. Remember that the rows of an NSTableView don't actually exist as one large dataset, so there isn't a one-to-one table cell to NSCell correspondence. Instead, each NSTableColumn has its own cell, that it uses like a rubber stamp. When a region of the table is marked as dirty (setNeedsDisplay:/setNeedsDisplayInRect:), the table view figures out which columns are affected, and tells them to draw themselves. Each column then asks for the data for each table cell that needs to be redrawn, and passes this value off to the NSCell assigned to that column, which does the real drawing. So your image column has an NSImageCell. When you start scrolling, the NSTableView figures out which logical row and column numbers have just been revealed by your scrolling maneuver, and kicks off the above process. Your data source is asked "alright, row 12 column 2 needs to be painted, gimme the data", and then hands that data off to the cell belonging to the column. The dirty little secret is that from the table view's perspective, there aren't actually any rows at all; it just does a bunch of math based on where the scroll point is located to convert graphics coordinates to logical rows. Your data source is none the wiser. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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]