ツールバーの高さの求め方

Cocoaに関するヌマタメモ
2008年11月29日 23:01

任意のウィンドウに対して、以下の関数を適用する。

float ToolbarHeightForWindow(NSWindow *window)  { 
    NSToolbar *toolbar = [window toolbar]; 
    float toolbarHeight = 0.0
    
    if (toolbar && [toolbar isVisible]) { 
        NSRect windowFrame = [NSWindow contentRectForFrameRect:[window frame]
                                                     styleMask:window styleMask]]; 
        toolbarHeight = NSHeight(windowFrame) - NSHeight([[window contentView] frame]); 
    } 
    
    return toolbarHeight; 
}

参考資料

file:///Developer/Documentation/Cocoa/TasksAndConcepts/ProgrammingTopics/Toolbars/Tasks/ToolbarHeight.html

コメントを書く


トラックバックはありません。

トラックバックURL: http://numata.designed.jp/mt-tb.cgi/59