• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to determine a toolbar's size?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: How to determine a toolbar's size?
      • From: ber <email@hidden>
    • Re: How to determine a toolbar's size?
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: Re: Command-Period Key Equivalent - Bad Idea?
  • Next by Date: Re: UI: "Direct manipulation" is in conflict with "Forgiveness"
  • Previous by thread: Re(4): Preferences (was: UI: "Direct manipulation" is in conflict with "Forgiveness")
  • Next by thread: Re: How to determine a toolbar's size?
  • Index(es):
    • Date
    • Thread