Display NSImage in NSImageView, which is inside NSScrollView
Display NSImage in NSImageView, which is inside NSScrollView
- Subject: Display NSImage in NSImageView, which is inside NSScrollView
- From: Jens Bauer <email@hidden>
- Date: Sat, 18 Jan 2003 00:16:35 +0100
Hi everyone,
Just like many other people, I've reached the point, where I want to
draw an image in a scrollable area.
If the window is sized so the entire image is visible, the image should
either stay in the topLeft corner, or be centered.
Now, the funny thing is that I've searched the archive, found a bunch
of good hints.
Unfortunately, they confused me, instead of helping me. :/
When I set isFlipped=YES in the following code, the image completely
disappears. I've tried adding 100 to the y coordinate, subtracting, but
I can't seem to find this image..
What really confuses me, is that NSFrameRect(rect) actually draws the
frame exactly as I want it, but compositeToPoint does not draw anything
at all!
When setting isFlipped=NO, and I resize the view, the image starts
moving down, when I resize the window, so the window is too small to
contain the entire image. (That's probably the most confusing part, it
moves in the oposite direction of the resizing-direction!)
I tried messing a lot with the image position, but realized that some
clipping will occur.
This is not the case with the frame. [more confused!]
-Is it supposed to be like this, so that outputting an image isn't
similar to drawing a rectangle? :)
@interface MyImageView : NSImageView
{
IBOutlet id scrollView;
NSImage *image;
}
@end
@implementation MyImageView
- (void)allocateImage
{
image = [NSImage imageNamed:@"jm-llama"];
}
- (void)drawRect:(NSRect)rect
{
NSFrameRect(rect);
[image compositeToPoint:NSZeroPoint fromRect:rect
operation:NSCompositeCopy];
}
- (BOOL)isFlipped
{
return(NO);
}
@end
Note: The image I'm using, was one, I just came across on Jeff Minter's
site... ;)
http://www.llamasoft.co.uk/yak_blogs/gif/jm-llama.gif
Love,
Jens
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.