Re: How to manage different display resolutions
Re: How to manage different display resolutions
- Subject: Re: How to manage different display resolutions
- From: Ricky Sharp <email@hidden>
- Date: Thu, 18 Nov 2004 13:26:16 -0600
On Thursday, November 18, 2004, at 01:01PM, <email@hidden> wrote:
>Hi,
>
>I am writing an application and it has some NSWwindow objects which at a display
>resolution of 1280x1024 are displayed just fine. But when I change my display
>resolution to say 1024x768, these windows are displayed in such a way that I
>can NOT see their bottom edges and only part of their width is displayed (the
>other part is hidden to the left of my display and also to the right and if I
>need to see their left and right borders I need to click on the title of the
>Windows and drag them to the right or to the left.
>
>I am sure there is a way to know beforehand the resolution being used at the
>moment my application gets loaded and also the size of my display. Having said
>that, my questions are:
>
>1 - How can I, programmatically, change the coordinates and size of my NSWindow
>object(built with Interface Builder) at the moment my application is loaded?
Check out NSScreen. Specifically, look at the visibleFrame method which returns the maximum sized area your window should occupy. It accounts for menu bar and the Dock.
You'll then want to listen for NSApplicationDidChangeScreenParametersNotification notifications from the default notification center. Basically, if the user changes resolutions (or the less frequent case of attaching/removing a device), your app is notified and you can do the right thing.
>2 - On my Window's content view I have an object which is a subclass of an
>NSView class and its size is based on my Window size. If I, programmatically,
>change my Window's coordinates and size, will its coordinates and size be
>changed too, in order to reflect the new display resolution?
Yes. That's the whole purpose of the autosizing attributes in IB.
>3 - What about some buttons which are displayed on my Window's content view? How
>can I change their coordinates and sizes programmatically in order to reflect
>the new display resolution?
You need to set up appropriate autosizing rules for all your UI elements. Some things (e.g. group boxes) will probably always be fixed size. But things like table views or lists can grow/shrink to reveal more/less information as the window size changes. You should also look into specifying the minimum size your window can be to still show a decent layout.
Finally, while you're at it, you may want to ensure that your app can work correctly with multiple devices. It may be the case where your users have two or more monitors each at their own resolution. You can use the NSScreen APIs to discover all the connected devices.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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