forked from thmghtd/InspectorKit.framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNSWindow+Geometry.m
31 lines (23 loc) · 872 Bytes
/
NSWindow+Geometry.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// SDPrefPanel.m
// Chatter
//
// Created by Steven on 12/5/08.
// Copyright 2008 Giant Robot Software. All rights reserved.
//
#import "NSWindow+Geometry.h"
@implementation NSWindow (SDResizableWindow)
- (void) setContentViewSize:(NSSize)newSize display:(BOOL)display animate:(BOOL)animate {
[self setFrame:[self windowFrameForNewContentViewSize:newSize] display:display animate:animate];
}
- (NSRect) windowFrameForNewContentViewSize:(NSSize)newSize {
NSRect windowFrame = [self frame];
windowFrame.size.width = newSize.width;
float titlebarAreaHeight = windowFrame.size.height - [[self contentView] frame].size.height;
float newHeight = newSize.height + titlebarAreaHeight;
float heightDifference = windowFrame.size.height - newHeight;
windowFrame.size.height = newHeight;
windowFrame.origin.y += heightDifference;
return windowFrame;
}
@end