Re: Positioning document within gray area of a scroller
Re: Positioning document within gray area of a scroller
- Subject: Re: Positioning document within gray area of a scroller
- From: Quincey Morris <email@hidden>
- Date: Sun, 28 Jun 2009 15:33:02 -0700
On Jun 28, 2009, at 14:28, Development wrote:
We are working on a document based application which displays the
document view within a scroller area. Like most similar programs,
the user can zoom in and out off the document (ie. we change the
view size of the document view). If he zooms out enough, our
document view becomes smaller then the area that the scroller
encloses. No problems so far. The scroll view draws a grey region
outside the area of our document region, and everything works fine.
We do not have to code any of this. However, our now small document
view is pinned to the lower left of area being shown by the scroller
view, instead of the upper left.
Has anyone been able to program this?
We asked this question at WWDC, and stumped several of the
engineers. We have tried all sorts of variations of configuration
under Interface Builder. We have set the isFlipped: method to
different to change where the origin is, and nothing seems to work.
I know people have asked this question here before, but there has
never been a good answer.
Our client is insisting that the document view should pin to the
upper left hand corner. This is the way Mac applications did it
under OS 9.
As always, if we find the answer, we will post it here, but for such
a simple issue, this one has been driving us crazy.
Yes, it's doable several different ways. Here's one way:
-- Have your document view observe frame-size-changed notifications
for the scroll view's clip view. When you're notified of a change:
-- Recompute your document view's frame size to be *at least* as large
as the clip view.
-- Set your document view's bounds origin to center the drawn document
within the visible rect. You'll also set its size to according to the
current zoom level.
Obviously, this means changing your code to be aware that your view
includes the gray area. That sometimes has advantages, since sometimes
you want to draw in the gray area anyway (e.g. for a shadow, or for
guide extension lines that run to the clip view edges).
That's the most NSRuler-friendly approach I know of. If you don't care
about rulers, plan B might be to make the scroll view's documentView
be just a NSView, and make your real document view a subview of that.
You can then position your document view wherever you want within the
documentView. Again, you would observe clip view size changes so that
you can resize the documentView and reposition the document view as
necessary.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden