Re: How to determine a toolbar's size?
Re: How to determine a toolbar's size?
- Subject: Re: How to determine a toolbar's size?
- From: Andreas Mayer <email@hidden>
- Date: Thu, 19 Sep 2002 19:12:52 +0200
Am Donnerstag, 19.09.02 um 18:55 Uhr schrieb Thilo Ettelt:
I would like to know the height of a toolbar but I can't find any
method. Do you know what to do?
Yes. Read the documentation:
----
Calculating a Toolbar's Height
NSToolbar does not currently provide a method for returning its height.
The following Objective-C function calculates the height of the toolbar
in a window, returning 0 if the toolbar is hidden:
float ToolbarHeightForWindow(NSWindow *window)
{
NSToolbar *toolbar;
float toolbarHeight = 0.0;
NSRect windowFrame;
toolbar = [window toolbar];
if(toolbar && [toolbar isVisible])
{
windowFrame = [NSWindow contentRectForFrameRect:[window frame]
styleMask:[window styleMask]];
toolbarHeight = NSHeight(windowFrame)
- NSHeight([[window contentView] frame]);
}
return toolbarHeight;
}
In Java, you can calculate a toolbar's height using the
ToolbarHeightForWindow static method in the following class:
public class ToolbarHeightCalculator
{
public static float ToolbarHeightForWindow(NSWindow window)
{
NSToolbar toolbar = window.toolbar();
float toolbarHeight = (float)0.0;
if(toolbar != null && toolbar.isVisible())
{
NSRect windowFrame = NSWindow.contentRectForFrameRect(
window.frame(), window.styleMask());
toolbarHeight = windowFrame.height()
- window.contentView().frame().height();
}
return toolbarHeight;
}
}
) 2002 Apple Computer, Inc. (Last Published June 4, 2002)
----
bye. Andreas.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.