From e8e536c06aff7e4c210c65c8c3483ad82c44f996 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Fri, 11 Aug 2023 11:44:08 -0400 Subject: [PATCH] Update styleMask code, add autoresizeMask --- GormCore/Plugins/Xib/GormXIBModelGenerator.m | 38 ++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/GormCore/Plugins/Xib/GormXIBModelGenerator.m b/GormCore/Plugins/Xib/GormXIBModelGenerator.m index 632f43b7..51a215ef 100644 --- a/GormCore/Plugins/Xib/GormXIBModelGenerator.m +++ b/GormCore/Plugins/Xib/GormXIBModelGenerator.m @@ -248,6 +248,7 @@ static NSUInteger _count = INT_MAX; @"NSUInteger", @"alignment", @"NSUInteger", @"bezelStyle", @"BOOL", @"isBordered", + @"NSUInteger", @"autoresizingMask", nil]; } } @@ -589,7 +590,7 @@ static NSUInteger _count = INT_MAX; if (mask | NSWindowStyleMaskTitled) { - attr = [NSXMLNode attributeWithName: @"windowed" stringValue: @"YES"]; + attr = [NSXMLNode attributeWithName: @"titled" stringValue: @"YES"]; [styleMaskElem addAttribute: attr]; } if (mask | NSWindowStyleMaskClosable) @@ -608,6 +609,9 @@ static NSUInteger _count = INT_MAX; [styleMaskElem addAttribute: attr]; } + attr = [NSXMLNode attributeWithName: @"key" stringValue: @"styleMask"]; + [styleMaskElem addAttribute: attr]; + [elem addChild: styleMaskElem]; } @@ -707,6 +711,30 @@ static NSUInteger _count = INT_MAX; } } +- (void) _addAutoresizingMask: (NSAutoresizingMaskOptions)m toElement: (NSXMLElement *)elem +{ + if (m != 0) + { + NSXMLElement *autoresizingMaskElem = [NSXMLNode elementWithName: @"autoresizingMask"]; + NSXMLNode *attr = nil; + + if (m | NSViewWidthSizable) + { + attr = [NSXMLNode attributeWithName: @"flexibleMaxX" stringValue: @"YES"]; + } + if (m | NSViewHeightSizable) + { + attr = [NSXMLNode attributeWithName: @"flexibleMaxY" stringValue: @"YES"]; + } + + [autoresizingMaskElem addAttribute: attr]; + attr = [NSXMLNode attributeWithName: @"key" stringValue: @"autoresizeMask"]; + [autoresizingMaskElem addAttribute: attr]; + + [elem addChild: autoresizingMaskElem]; + } +} + - (void) _addProperty: (NSString *)name withType: (NSString *)type toElem: (NSXMLElement *)elem @@ -734,7 +762,13 @@ static NSUInteger _count = INT_MAX; NSString *buttonTypeString = [obj buttonTypeString]; [self _addButtonType: buttonTypeString toElement: elem]; - } + } + else if ([name isEqualToString: @"autoresizingMask"]) + { + NSAutoresizingMaskOptions m = [obj autoresizingMask]; + [self _addAutoresizingMask: m + toElement: elem]; + } else if ([name isEqualToString: @"alignment"] && [obj respondsToSelector: @selector(cell)] == NO) { [self _addAlignment: [obj alignment]