diff --git a/AppKit/Cib/_CPCibWindowTemplate.j b/AppKit/Cib/_CPCibWindowTemplate.j index a9a168d4e..31d9ce3a1 100644 --- a/AppKit/Cib/_CPCibWindowTemplate.j +++ b/AppKit/Cib/_CPCibWindowTemplate.j @@ -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]; diff --git a/Tools/nib2cib/NSWindowTemplate.j b/Tools/nib2cib/NSWindowTemplate.j index 42537c657..9063c18a9 100644 --- a/Tools/nib2cib/NSWindowTemplate.j +++ b/Tools/nib2cib/NSWindowTemplate.j @@ -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 */ }