Re: Resolution Independent View?
Re: Resolution Independent View?
- Subject: Re: Resolution Independent View?
- From: Alastair Houghton <email@hidden>
- Date: Tue, 12 May 2009 11:35:24 +0100
On 12 May 2009, at 07:14, Chunk 1978 wrote:
Is it possible to have a view, say a simple square that is 5cm x 5cm,
always maintain it size regardless of the mac's resolution?
Yes.
it seems the only way possible to produce a square of 5cm x 5cm
programatically is to include the screens resolution into the
equation. but besides having different resolution settings on
different macs and setting up a resolution event listener, some
screens have different PPI than other screens (or so i assume?).
Well there are two perspectives on this, I suppose. The first is that
the default co-ordinate transforms in Cocoa are supposed to result in
a 1x1 rectangle being 1pt x 1pt in size. *However* this is predicated
on the assumption that the screen is 72dpi, so that 1pt x 1pt = 1px x
1px.
Plainly the 72dpi assumption is not really true for modern displays
(which are usually 100dpi or so), but it will mean that your app will
match others on the system.
If, however, you really want the display to physically show a 5cm x
5cm block, you can obtain the screen's actual dimensions in
millimeters from CGDisplayScreenSize() and then use those numbers in
conjunction with the pixel dimensions to calculate a suitable transform.
Please remember if you do something like this that some machines have
more than one display. You may not need to handle the case where your
window overlaps two displays at once (perhaps it's enough to just pick
one), but you do nevertheless need to be aware of the problem.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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