Re: Re: Bounds questions
Re: Re: Bounds questions
- Subject: Re: Re: Bounds questions
- From: "Aychamo Aychamo" <email@hidden>
- Date: Mon, 13 Nov 2006 12:12:35 -0400
Hi Shawn,
I am using a full-screen, borderless window. I set the window's frame
to [[NSScreen mainScreen] frame]. I have hidden the dock and
menubar, so since my resolution is 1280x854, the window's frame rect
returns a size of 1280x854.
My window's contentView, mainView, is sized at 1280x854. I have
designed my application (a pretty lame graphical thing) to draw itself
within this mainView (there are other subviews within my mainView).
Now, what I want to do is be able to scale my mainView to fit whatever
size screen (ie, if the screen is 800x600, or 1980x1080 (or whatever
it is). I've found that I can use -setBoundsSize to scale the view.
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). Also, I've found that
I can scale my interface to fit larger resolution monitors by setting
setBoundsSize to something smaller than 1280x854.
(Additionally, I've set my monitor to other resolutions and scaled the
UI via setBoundsSize to fit it, so I know this process works, I just
dont understand how, or the relationship, because I just guess at the
numbers till it scales right.)
So what I'm not understanding is the relationship between three
things. 1. The frame size that my view is designed for, which is
1280x854. 2. The destination frame size (ie, the resolution the user
will be running their computer at) and 3. The necessary amount to
adjust the setBoundsSize by to make the 1280x854 frame scale to fit
their screen.
I've been trying to work out the math on a sheet of paper, but I can't
seem to find the relationship between the three sets of numbers
mentioned above.
It seems I should be able to come up with a "factor" that I multiply
my designed view size (1280x854) by to scale the view properly to fit
the screen size. Some kind of relationship between the designed view
size and the destination view size.
I guess in short, I've designed a view that goes in a full screen
window, and the view is custom designed to 1280x854, and I need to
figure out how to issue the setBoundsSize so that the view will scale
to fit whatever size screen I put it on (ie, on a larger resolution
monitor, it will get larger and fill the screen, and on a smaller
resolution monitor, it will get smaller and fill the screen.)
Thank you, and I hope this makes it more clear,
AA
On 11/13/06, Shawn Erickson <email@hidden> wrote:
I personally cannot follow the issue you are hitting... The numbers
you outlining make little sense given what you state is happening. It
may be best if you provide some example code and more information
about your application.
Important note for the future... views live in local coordinates
which are defined in points while windows and the screen live in a
coordinate space defined in pixels. So you must use the provided API
to convert between those two coordinate spaces. (see -[NSView
convertPoint:fromView:] and friends, -[NSWindow convertScreenToBase:]
and friends, etc.).
Some questions that come to mind...
1) Are you playing around with resolution scaling (via Quartz Debug,
aka resolution independent displays)?
2) You say you have a view that you set bounds on but views live in
windows... so how do you size your window and what type of window is it?
3) Are you attempting to cover the whole display? Did you capture the
display or are otherwise hiding the dock and menu bar?
4) Is the view you are sizing the content view of the window or some
subview? Can you outline your view hierarchy?
As a guess try something like the following...
NSRect screenFrame = [[window screen] frame];
// assuming your content view and subviews are set to autoresize
// then all you should need to do is the following...
[window setFrame:screenFrame display:YES];
... if not using auto resizing views then you may have to utilize
things like -[NSWindow contentRectForFrameRect:] (and the ones I
outlined in my second paragraph) to calculate what you need.
-Shawn
_______________________________________________
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