Re: Re: Bounds questions
Re: Re: Bounds questions
- Subject: Re: Re: Bounds questions
- From: "Stephen Deken" <email@hidden>
- Date: Mon, 13 Nov 2006 10:47:57 -0600
On 11/13/06, Aychamo Aychamo <email@hidden> wrote:
In my application, I've tested it, and found that if I set my
resolution of my screen to 800x600, that if I use setBoundsSize(2050,
1175), my interface scales to fit the screen nicely (even though my
interface is designed to fit a 1280x854 view).
Perhaps I'm misunderstanding your problem, but that's never stopped me
from dispensing advice! I suspect that the problem is that you are
not resizing the frame of your view.
If your interface is designed under the assumption that it will be
drawing into a 1280x854 pixel view, then you should just be able to
set the bounds to 1280x854 and the frame to the desired screen size.
Read this, which explains the difference between bounds and views:
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/Coordinates/chapter_3_section_3.html>
The important thing is that you set the bounds explicitly after
setting the frame size. So, for example, if you want to resize your
view to 800x600, this should suffice:
[myView setFrame:NSMakeRect(0,0,800,600)];
[myView setBounds:NSMakeRect(0,0,1280,854)];
I am given to understand that once the view's bounds have been set
explicitly like this, it does not change when the view is resized,
although I am unable to test that at the moment. Setting it whenever
the screen resolution changes would be sufficient.
FWIW, it seems as though the math you're looking for is something like this:
(original res * original res) / (new res)
So:
(1280 * 1280) / 800 = 2048 (you used 2050)
(1280 * 1280) / 640 = 2560
These numbers would work if you weren't resizing your view's frame to
fit the actual resolution -- 2048 'virtual' pixels distributed across
a view 1280 'real' pixels wide would result in 1280 'virtual' pixels
compressed into an 800 'real' pixel area, which is what is being shown
on the screen.
The need to do this calculation is removed if the view's frame is
resized to fit the screen.
Stephen Deken
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden