// // DSToolbarCategories.m // Shared categories // // Created by David Sinclair on Fri Oct 11 2002. // Copyright © 2002 - 2007 Dejal Systems, LLC. All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // Redistributions of source code must retain this list of conditions and the following disclaimer. // // The name of Dejal Systems, LLC may not be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR // PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS SOFTWARE. // #import "DSToolbarCategories.h" @implementation NSToolbar (DSToolbarCategories) + (float)toolbarHeightForWindow:(NSWindow *)window { NSToolbar *toolbar = [window toolbar]; float toolbarHeight = 0.0; NSRect windowFrame; if(toolbar && [toolbar isVisible]) { windowFrame = [NSWindow contentRectForFrameRect:[window frame] styleMask:[window styleMask]]; toolbarHeight = NSHeight(windowFrame) - NSHeight([[window contentView] frame]); } return toolbarHeight; } - (BOOL)alwaysCustomizableByDrag { return (BOOL)_tbFlags.clickAndDragPerformsCustomization; } - (void)setAlwaysCustomizableByDrag:(BOOL)flag { _tbFlags.clickAndDragPerformsCustomization = (unsigned int)flag & 1; } - (BOOL)showsContextMenu { return (BOOL)!_tbFlags.showsNoContextMenu; } - (void)setShowsContextMenu:(BOOL)flag { _tbFlags.showsNoContextMenu = (unsigned int)!flag & 1; } - (unsigned int)indexOfFirstMovableItem { return (unsigned int)_tbFlags.firstMoveableItemIndex; } - (void) setIndexOfFirstMovableItem:(unsigned int)anIndex { _tbFlags.firstMoveableItemIndex = (unsigned int) anIndex & 0x3F; } @end