Drawing ImageCells in a NSView

flor

Registered
Hello,

I am relatively new to Cocoa Programming and i have this question.
I created an interface with a NSView on it.
I also have an Array of Cells witch contain an image.
What i would like to do now is draw each images from all the cells into the NSView.
This is what i have done, but nothing is shown in the view...
Can anyone help me with that?(Perhaps some source code...)
Thanks in advance.

int count = [records count];
for (i=0; i<count; i++) {
[[records objectAtIndex:i] drawWithFrame:theRect inView:testView];
[testView setNeedsDisplay:YES];
}
 
I assume you went through the work of stuffing an NSImage into each NSImageCell. Why not just draw each NSImage into that view like so:

NSArray * imageArray;
//put images in imageArray
NSEnumerator * imageEnumerator = [imageArray objectEnumerator];
NSImage * img;
[testView lockFocus];
while(img = [imageEnumerator nextObject])
{
[img compositeToPoint:theRect operation:NSCompositeSourceOver];
}
[testView unlockFocus];
[testView setNeedsDisplay:YES];

If you really must use NSImageCell, I think you might need to lockFocus on testView before drawing to it and unlockFocus afterwards. You also needn't call setNeedsDisplay: on each time through that loop.
 
Back
Top