What's the replacement for GetMBarHeight?
-
Hi,
The Xcode 3 OSX 10.5 documentation for GetMBarHeight fails to explain
what should be called in its place, or that it's not available 64-
bit. I need to avoid putting windows where they shouldn't be, and my
code is being called from code that isn't pure Cocoa, but I can call
Cocoa from where I can figure this out. What do I call?
Please point me in the right direction, thanks,
-Brian -
Hi Brian,
On 2008-02-09, at 13:35, Brian Arnold wrote:> The Xcode 3 OSX 10.5 documentation for GetMBarHeight fails to
> explain what should be called in its place
Probably -[NSMenu menuBarHeight].
Jonathon Mah
<me...> -
On Feb 8, 2008, at 7:05 PM, Brian Arnold wrote:> The Xcode 3 OSX 10.5 documentation for GetMBarHeight fails to
> explain what should be called in its place, or that it's not
> available 64-bit. I need to avoid putting windows where they
> shouldn't be, and my code is being called from code that isn't pure
> Cocoa, but I can call Cocoa from where I can figure this out. What
> do I call?
>
> Please point me in the right direction, thanks,
How about something like [[NSScreen mainScreen] visibleFrame]?
To paraphrase the docs: -[visibleFrame] returns a rectangle
containing current location and dimensions of the visible screen.
This is the rectangle defining the portion of the screen in which it
is currently safe to draw your application content based on the
current user-interface settings and does not include the area
currently occupied by the dock and menu bar. Because it is based on
the current user -interface settings, the returned rectangle can
change between calls and should not be cached.
To be 100% correct, you could iterate over all the screens, for those
folks with more than one screen.
steve -
Calling [[NSApp mainMenu] menuBarHeight] did the trick. Thanks!
On Feb 9, 2008, at 12:27 AM, Jonathon Mah wrote:> Hi Brian,
>
> On 2008-02-09, at 13:35, Brian Arnold wrote:
>
>> The Xcode 3 OSX 10.5 documentation for GetMBarHeight fails to
>> explain what should be called in its place
>
>
> Probably -[NSMenu menuBarHeight].
>
>
>
> Jonathon Mah
> <me...>
>
> -
On 9 Feb 2008 07:38:53 -0800 Steve Christensen <punster...> wrote:> On Feb 8, 2008, at 7:05 PM, Brian Arnold wrote:
>
>> The Xcode 3 OSX 10.5 documentation for GetMBarHeight fails to
>> explain what should be called in its place, or that it's not
>> available 64-bit. I need to avoid putting windows where they
>> shouldn't be, and my code is being called from code that isn't pure
>> Cocoa, but I can call Cocoa from where I can figure this out. What
>> do I call?
>>
>> Please point me in the right direction, thanks,
>
> How about something like [[NSScreen mainScreen] visibleFrame]?
>
> To paraphrase the docs: -[visibleFrame] returns a rectangle
> containing current location and dimensions of the visible screen.
> This is the rectangle defining the portion of the screen in which it
> is currently safe to draw your application content based on the
> current user-interface settings and does not include the area
> currently occupied by the dock and menu bar. Because it is based on
> the current user -interface settings, the returned rectangle can
> change between calls and should not be cached.
>
> To be 100% correct, you could iterate over all the screens, for those
> folks with more than one screen.
>
> steve
And, On 9 Feb 2008 11:03:02 -0500 Brian Arnold <Brian.Arnold...>> wrote:> Calling [[NSApp mainMenu] menuBarHeight] did the trick. Thanks!
>
> On Feb 9, 2008, at 12:27 AM, Jonathon Mah wrote:
>
>> Hi Brian,
>>
>> On 2008-02-09, at 13:35, Brian Arnold wrote:
>>
>>> The Xcode 3 OSX 10.5 documentation for GetMBarHeight fails to
>>> explain what should be called in its place
>>
>> Probably -[NSMenu menuBarHeight].
>>
>> Jonathon Mah
>> <me...>
Just my two cents, but if you're positioning a window, you shouldn't
only be concerned with the top of the window. In that case, Steve's
solution is the right one.
I keep my Dock along the left edge of my screen, and it bugs me when
an application puts the left edge of its new or zoomed windows behind
it.
Cheers,
Mike Wright
http://www.idata3.com/
http://www.raccoonbend.com/ -
On 8 Feb '08, at 7:05 PM, Brian Arnold wrote:> The Xcode 3 OSX 10.5 documentation for GetMBarHeight fails to
> explain what should be called in its place, or that it's not
> available 64-bit. I need to avoid putting windows where they
> shouldn't be, and my code is being called from code that isn't pure
> Cocoa, but I can call Cocoa from where I can figure this out. What
> do I call?
Use the NSScreen class to find the display(s). Their -visibleFrame
rects give the areas that are OK to put windows in, avoiding both the
menu bar and the Dock (if it's in always-visible mode.)
But if your windows are regular NSWindows with title bars, then you
don't need to worry about this â NSWindow itself adjusts the window
frame to keep it out of the menu bar or Dock.
âJens


