Improved nib2cib support for windows (min/max size, correct autoresize mask, flipped Y coordinate)

This commit is contained in:
Tom Robinson
2008-12-04 22:13:41 -08:00
parent 10db0dab7e
commit 3516e026d0
2 changed files with 25 additions and 16 deletions
+15 -10
View File
@@ -35,8 +35,10 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
if (self)
{
_minSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMinSizeKey];
_maxSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMaxSizeKey];
if ([aCoder containsValueForKey:_CPCibWindowTemplateMinSizeKey])
_minSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMinSizeKey];
if ([aCoder containsValueForKey:_CPCibWindowTemplateMaxSizeKey])
_maxSize = [aCoder decodeSizeForKey:_CPCibWindowTemplateMaxSizeKey];
_viewClass = [aCoder decodeObjectForKey:_CPCibWindowTemplateViewClassKey];
@@ -53,8 +55,10 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeSize:_minSize forKey:_CPCibWindowTemplateMinSizeKey];
[aCoder encodeSize:_maxSize forKey:_CPCibWindowTemplateMaxSizeKey];
if (_minSize)
[aCoder encodeSize:_minSize forKey:_CPCibWindowTemplateMinSizeKey];
if (_maxSize)
[aCoder encodeSize:_maxSize forKey:_CPCibWindowTemplateMaxSizeKey];
[aCoder encodeObject:_viewClass forKey:_CPCibWindowTemplateViewClassKey];
@@ -74,12 +78,13 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey",
[NSException raise:NSInvalidArgumentException format:@"Unable to locate NSWindow class %@, using NSWindow",_windowClass];
class=[NSWindow class];*/
var theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:CPHUDBackgroundWindowMask | CPClosableWindowMask];//styleMask:_windowStyleMask];
// alert(CPStringFromRect(_windowRect));
// alert(CPStringFromSize(_minSize));
// alert(CPStringFromSize(_maxSize));
//[theWindow setMinSize:_minSize];
//[theWindow setMaxSize:_maxSize];
_windowStyleMask = (CPHUDBackgroundWindowMask | CPClosableWindowMask | CPResizableWindowMask);
var theWindow = [[windowClass alloc] initWithContentRect:_windowRect styleMask:_windowStyleMask];
if (_minSize)
[theWindow setMinSize:_minSize];
if (_maxSize)
[theWindow setMaxSize:_maxSize];
[theWindow setLevel:CPFloatingWindowLevel];
//[result setHidesOnDeactivate:(_wtFlags&0x80000000)?YES:NO];
+10 -6
View File
@@ -30,9 +30,12 @@
self = [super init];
if (self)
{
_minSize = [aCoder decodeSizeForKey:@"NSMinSize"];
_maxSize = [aCoder decodeSizeForKey:@"NSMaxSize"];
{
if ([aCoder containsValueForKey:@"NSMinSize"])
_minSize = [aCoder decodeSizeForKey:@"NSMinSize"];
if ([aCoder containsValueForKey:@"NSMaxSize"])
_maxSize = [aCoder decodeSizeForKey:@"NSMaxSize"];
_screenRect = [aCoder decodeRectForKey:@"NSScreenRect"]; // screen created on
_viewClass = [aCoder decodeObjectForKey:@"NSViewClass"];
_wtFlags = [aCoder decodeIntForKey:@"NSWTFlags"];
@@ -46,9 +49,10 @@
_windowTitle = [aCoder decodeObjectForKey:@"NSWindowTitle"];
_windowView = [aCoder decodeObjectForKey:@"NSWindowView"];
/*
_windowRect.origin.y -= _screenRect.size.height - [[NSScreen mainScreen] frame].size.height;
if (![_windowClass isEqualToString:@"NSPanel"])
// Flip Y coordinate
_windowRect.origin.y = _screenRect.size.height - _windowRect.origin.y - _windowRect.size.height;
/*if (![_windowClass isEqualToString:@"NSPanel"])
_windowRect.origin.y -= [NSMainMenuView menuHeight]; // compensation for the additional menu bar
*/
}