Re: Centering a window ... not in the usual way!
Re: Centering a window ... not in the usual way!
- Subject: Re: Centering a window ... not in the usual way!
- From: Trygve Inda <email@hidden>
- Date: Wed, 13 May 2009 08:27:54 +0000
- Thread-topic: Centering a window ... not in the usual way!
> Hi,
>
> I'm working on an application that when first started you are
> presented with a small window showing a number of options. When any of
> these options are chosen, the window fades out the contentView whilst
> at the same time replacing it with and fading in the new view. The
> window also resizes to accommodate the new view. This is all achieved
> using NSViewAnimation and works and looks great. However, I have one
> small issue.
>
> What I'd like is for the resulting window (new size, containing new
> view) to be centered on the screen, in the sameplace as if I'd called
> [window center] on it.
>
> I currently have it centering using some calculations based on screen
> width/height and window width/height etc but this results in it being
> actually centered on the screen, not centered in which the above call
> does (They are different, honest, check them out).
>
> What I thought about doing was creating a transparent window using a
> border less mask, the same size as the resulting window, calling
> center on it, and then getting the frame rect. This could be done in
> awakeFromNib and then released and would be unknown to the user.
>
> However the issues here are that a border less window obviously has
> not title bar, so how can I take that in to account ? Also I would
> like the resulting window to have a toolbar, where as the small window
> first displayed doesn't, so again how can I take this in to account ?
> Are there standard sizes I can apply for title bars and toolbars, as
> these could be added to the border less window frame before calling
> center ?
>
> Any help would be greatly appreciated.
Can you not just create a normal window with title bar and set it's alpha to
0 to test the size form the OS?
If that messes up your window activation, maybe you could do it quickly and
invisibly at launch to get all the rects you need for your window's
different contents.
In the second case you may want to install a Display Configuration Callback
to be notified if the screen dimensions change.
Trygve
_______________________________________________
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