• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Resizing view content
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resizing view content


  • Subject: Re: Resizing view content
  • From: "Alastair J.Houghton" <email@hidden>
  • Date: Wed, 22 Oct 2003 18:03:48 +0100

On Wednesday, October 22, 2003, at 05:10 pm, John Timmer wrote:

I've got an NSScroll view that I'd like to scale the contents of to fit a
specific size. I've found that getting the document view and calling:

[thePrintView scaleUnitSquareToSize: NSMakeSize( 0.63, 0.63)];

Scales it down nicely, but now there's a lot of white space at the bottom.
I've tried resetting the bottom of the bounds origin (to 0- .37 * the
previous height), but I still wind up with white space (now, both on the top
and the bottom). I'm not going to try resizing the containing view until I
actually get my view down to the bottom of it first, but I assume I won't
get that right immediately, too.

Is there a better way to scale the contents? Any examples?

I'm not sure exactly what you want to do. Without a clearer description of what you want and what you are seeing at the moment, it's hard to help in any specific way.

Incidentally, I can't find a cogent description of the difference between
the bounds and the frame of a view, which might help me sort this out on my
own.

"bounds" are the limits of the view's own co-ordinate space (the co-ordinate space used by calls in your -drawRect: method). The "frame" is the co-ordinates of the view *in its superview's co-ordinate space*; i.e. it says where the view is in the containing view. e.g.

+-----------------------------------------------------+
| Containing View |
| (A) |
| |
| +----------------------+..... |
| | Contained View ^ | ^ |
| 30 | (B) | | | |
|<---->|<-------- 24 -------->| | |
| | | | | |
| | | | | |
| | 13 | 65 |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | v | v |
| +----------------------+..... |
| : : ^ |
| :<-------- 120 ------->: | 15 |
| v |
+-----------------------------------------------------+

The bounds of (B) are:

origin.x = 0.0;
origin.y = 0.0;
size.width = 24.0;
size.height = 13.0;

whereas the frame of (B) is

origin.x = 30.0;
origin.y = 15.0;
size.width = 120.0;
size.height = 65.0;

Note that in the above diagram, I (deliberately) made (A)'s co-ordinates have roughly five times the resolution of (B)'s, to illustrate the difference when one or other of the co-ordinate systems is scaled. (The diagram isn't really to scale, as that isn't possible in ASCII-art ;->).

Kind regards,

Alastair.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Resizing view content
      • From: John Timmer <email@hidden>
References: 
 >Resizing view content (From: John Timmer <email@hidden>)

  • Prev by Date: Re: Way to get IB to always be aware of my constantly used classes?
  • Next by Date: Re: The cocoaBB has launched!!!
  • Previous by thread: Resizing view content
  • Next by thread: Re: Resizing view content
  • Index(es):
    • Date
    • Thread