NSClipView's -setBoundsSize changing the origin too?
NSClipView's -setBoundsSize changing the origin too?
- Subject: NSClipView's -setBoundsSize changing the origin too?
- From: Christopher B Hamlin <email@hidden>
- Date: Sun, 06 Jan 2002 15:35:00 -0500
Hi,
I'm trying to do zooming on a view that is in an NSScrollView. I
think I've got a decent idea: scale the content view's
bounds. But . . .
In the NSView documentation, it says:
You can also set the parts of the bounds rectangle independently,
using setBoundsOrigin: and setBoundsSize:.
So in my zooming-up action (where theScrollView is an outlet to
the NSScrollView) I did this:
-(IBAction)magUp:(id)sender
{
NSRect myBounds;
myBounds = [[theScrollView contentView] bounds];
if (1) NSLog (@"In magUp: content bounds is (%f,%f), %f wide, %f
high)\n",
myBounds.origin.x, myBounds.origin.y,
myBounds.size.width, myBounds.size.height);
[[theScrollView contentView]
setBoundsSize:NSMakeSize(0.8*myBounds.size.width,
0.8*myBounds.size.height)];
myBounds = [[theScrollView contentView] bounds];
if (1) NSLog (@"Out magUp: content bounds is (%f,%f), %f wide, %f
high)\n",
myBounds.origin.x, myBounds.origin.y,
myBounds.size.width, myBounds.size.height);
[theView setNeedsDisplay:YES];
return;
}
and got this:
2002-01-06 13:29:53.583 viewer[358] In magUp: content bounds
is (-670.000000,0.000000), 530.000000 wide, 405.000000 high)
2002-01-06 13:29:53.583 viewer[358] Out magUp: content bounds
is (-536.000000,0.000000), 424.000000 wide, 324.000000 high)
which seems to say that the origin has moved as well (by the same
factor).
The y coordinate changes too when it is non-zero. What I see when I
run the application is a moving origin. NSClipView doesn't say anything
about setBoundsSize being different from NSView.
If I save and reset the origin after the zoom then it works as I
expected.
The view is zoomed out or in with the upper-left corner point staying
put.
I feel I'm missing something easy, but have no idea what it could be.
Thanks,
Chris Hamlin