Re: Old-style coordinates vs new
Re: Old-style coordinates vs new
- Subject: Re: Old-style coordinates vs new
- From: Uli Kusterer <email@hidden>
- Date: Sun, 11 Feb 2007 04:56:38 +0100
Am 09.02.2007 um 20:29 schrieb Scott Ribe:
I am trying to position a floating utility window near another
application's
front window. I use AppleScript to get the active window's bounds, in
old-style QuickDraw coordinates. Now I can figure out how to flip
those
around and calculate my window position just fine in the case of
one screen.
What I'm having trouble with is: assuming multiple screens, how to
figure
out which screen contains (most of) the other app's window? This
can't be
hard, but I'm drawing a blank at the moment. (Carbon APIs no problem.)
Can you elaborate what your problem is? The coordinate system
starts at 0,0, on the screen that contains the menu bar (Most people
would call that the "main screen", but since Cocoa uses mainScreen to
mean the one with a focused window, I'll not use that term here).
NSScreen lets you get a list of all screens and their rectangles in
that coordinate system.
Flipping the rects is done the same way as you'd do it with flipped
coordinates for drawing inside a particular view, you simply use the
menu bar screen as your "view". You can calculate the intersection of
your rect with each screen rect and pick the screen with the biggest
intersection rect.
And although you can get by with all-Cocoa, Carbon contains
functions to get the best GDHandle (which is QuickDraw's equivalent
to a screen) that contains most of a particular rect.
Is there anything in particular that causes you problems?
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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