contentRectForFrameRect:
解説
ウインドウの内容矩形のスクリーン座標とサイズを返します。
frameRectと返される値はスクリーン座標。
引数
( NSRect )frameRect
フレームワーク
ApplicationKit
クラス
NSWindow
使用可能
10.3
参照
-frameRectForContentRect:
- contentRectForFrameRect:styleMask:
+contentRectForFrameRect:styleMask:
例文
NSRect contentRect; contentRect = [[sender window] contentRectForFrameRect:NSMakeRect(0.0,0.0,300.0,300.0) ]; NSLog([NSString stringWithFormat:@"%.1f,%.1f,%.1f,%.1f",contentRect.origin.x,contentRect.origin.y,contentRect.size.width,contentRect.size.height]);
//NSWindow contentRectForFrameRect @IBAction func function038(sender: AnyObject) { var windowRect : NSRect = NSMakeRect(100.0, 0.0, 300.0, 200.0) NSLog("windowRect %.2f,%.2f,%.2f,%.2f", Float(windowRect.origin.x), Float(windowRect.origin.y), Float(windowRect.size.width), Float(windowRect.size.height)) //->100.00,0.00,300.00,200.00 var aWindow : NSWindow = NSWindow(contentRect: windowRect, styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask, backing: .Buffered, defer: false) windowArray.addObject(aWindow) //ウインドウを保持するための配列に追加。アプリ終了時に配列は破棄 aWindow.setDynamicDepthLimit(true ) aWindow.center()//ウインドウをスクリーンの中心に aWindow.title = "ウインドウタイトル"//タイトル設定 aWindow.orderFront(self)//前面に aWindow.makeKeyAndOrderFront(self)//表示 var contentRect : NSRect = aWindow.contentRectForFrameRect(windowRect) NSLog("contentRect %.2f,%.2f,%.2f,%.2f", Float(contentRect.origin.x), Float(contentRect.origin.y), Float(contentRect.size.width), Float(contentRect.size.height)) //->100.00,0.00,300.00,178.00 }