diff --git a/GormCore/GormDocument.m b/GormCore/GormDocument.m index acfcc063..b3e66657 100644 --- a/GormCore/GormDocument.m +++ b/GormCore/GormDocument.m @@ -541,6 +541,13 @@ static NSImage *fileImage = nil; NSArray *old; BOOL newObject = NO; + if ([self containsObject: anObject] && + [anObject isKindOfClass: [NSWindow class]] == NO && + [anObject isKindOfClass: [NSPanel class]] == NO) + { + return; + } + // Modify the document whenever something is added... [self touch]; @@ -751,6 +758,7 @@ static NSImage *fileImage = nil; { // add all of the cells.... [self attachObjects: [anObject cells] toParent: anObject]; + [self attachObject: [anObject prototype] toParent: anObject]; } /* * If it's a simple NSView, add it and all of it's subviews. diff --git a/Palettes/2Controls/ControlsPalette.m b/Palettes/2Controls/ControlsPalette.m index 022d4ce2..ec71922f 100644 --- a/Palettes/2Controls/ControlsPalette.m +++ b/Palettes/2Controls/ControlsPalette.m @@ -77,7 +77,9 @@ - (void) willInspectObject: (NSNotification *)notification { id o = [notification object]; - if ([o respondsToSelector: @selector(prototype)] && [o prototype]) + + // [o respondsToSelector: @selector(prototype)] && [o prototype]) + if ([o isKindOfClass: [NSMatrix class]]) { id prototype = [o prototype]; NSString *ident = NSStringFromClass([prototype class]); diff --git a/Palettes/2Controls/GNUmakefile b/Palettes/2Controls/GNUmakefile index e9b57405..c127bb4f 100644 --- a/Palettes/2Controls/GNUmakefile +++ b/Palettes/2Controls/GNUmakefile @@ -31,6 +31,7 @@ PALETTE_NAME = 2Controls GormButtonAttributesInspector.m \ GormBoxAttributesInspector.m \ GormCellAttributesInspector.m \ + GormCellSizeInspector.m \ GormColorWellAttributesInspector.m \ GormFormAttributesInspector.m \ GormPopUpButtonAttributesInspector.m \ @@ -51,6 +52,7 @@ PALETTE_NAME = 2Controls GormNSBoxInspector.gorm \ GormNSButtonInspector.gorm \ GormNSCellInspector.gorm \ + GormCellSizeInspector.gorm \ GormNSFormInspector.gorm \ GormNSMatrixInspector.gorm \ GormNSPopUpButtonInspector.gorm \ diff --git a/Palettes/2Controls/GormCellSizeInspector.gorm/data.classes b/Palettes/2Controls/GormCellSizeInspector.gorm/data.classes new file mode 100644 index 00000000..05cb8a04 --- /dev/null +++ b/Palettes/2Controls/GormCellSizeInspector.gorm/data.classes @@ -0,0 +1,26 @@ +{ + "## Comment" = "Do NOT change this file, Gorm maintains it"; + FirstResponder = { + Actions = ( + "revert:", + "setObject:", + "touch:" + ); + Super = NSObject; + }; + GormCellSizeInspector = { + Actions = ( + ); + Outlets = ( + width, + height + ); + Super = IBInspector; + }; + IBInspector = { + Actions = ( + "setObject:" + ); + Super = NSObject; + }; +} \ No newline at end of file diff --git a/Palettes/2Controls/GormCellSizeInspector.gorm/data.info b/Palettes/2Controls/GormCellSizeInspector.gorm/data.info new file mode 100644 index 00000000..c2d6894a Binary files /dev/null and b/Palettes/2Controls/GormCellSizeInspector.gorm/data.info differ diff --git a/Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm b/Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm new file mode 100644 index 00000000..3015a8da Binary files /dev/null and b/Palettes/2Controls/GormCellSizeInspector.gorm/objects.gorm differ diff --git a/Palettes/2Controls/GormCellSizeInspector.h b/Palettes/2Controls/GormCellSizeInspector.h new file mode 100644 index 00000000..be5fddef --- /dev/null +++ b/Palettes/2Controls/GormCellSizeInspector.h @@ -0,0 +1,38 @@ +/* GormViewSizeInspector.m + * + * Copyright (C) 2021 Free Software Foundation, Inc. + * + * Author: Gregory John Casamento + +@interface GormCellSizeInspector : IBInspector +{ + NSTextField *width; + NSTextField *height; +} +@end + +#endif diff --git a/Palettes/2Controls/GormCellSizeInspector.m b/Palettes/2Controls/GormCellSizeInspector.m new file mode 100644 index 00000000..776be842 --- /dev/null +++ b/Palettes/2Controls/GormCellSizeInspector.m @@ -0,0 +1,124 @@ +/* GormCellSizeInspector.m + * + * Copyright (C) 2021 Free Software Foundation, Inc. + * + * Author: Gregory Casamento + * Date: 2021 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + */ + +#include +#include "GormCellSizeInspector.h" + +@implementation NSCell (IBObjectAdditions) +- (NSString *) sizeInspectorClassName +{ + return @"GormCellSizeInspector"; +} +@end + +@implementation GormCellSizeInspector + ++ (void) initialize +{ + if (self == [GormCellSizeInspector class]) + { + } +} + +- (void) dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver: self]; + RELEASE(window); + [super dealloc]; +} + +- (id) init +{ + self = [super init]; + if (self != nil) + { + if ([NSBundle loadNibNamed: @"GormCellSizeInspector" + owner: self] == NO) + { + NSLog(@"Could not open gorm GormViewSizeInspector"); + NSLog(@"self %@", self); + return nil; + } + + [[NSNotificationCenter defaultCenter] + addObserver: self + selector: @selector(controlTextDidEndEditing:) + name: NSControlTextDidEndEditingNotification + object: nil]; + + } + return self; +} + +- (void) ok: (id)sender +{ + id document = [(id)NSApp activeDocument]; + + id parent = [document parentOfObject: object]; + if ([parent respondsToSelector: @selector(cellSize)]) + { + NSSize size; + CGFloat w = [width doubleValue]; + CGFloat h = [height doubleValue]; + + size.width = w; + size.height = h; + [parent setCellSize: size]; + [parent sizeToCells]; + [parent setNeedsDisplay: YES]; + + // Update the document as edited... + [document touch]; + } +} + +- (void) revert: (id)sender +{ + NSLog(@"sender = %@",sender); +} + +- (void) controlTextDidEndEditing: (NSNotification*)aNotification +{ + id obj = [aNotification object]; + [super ok: obj]; +} + +- (void) setObject: (id)anObject +{ + if (anObject != nil && anObject != object) + { + id document = [(id)NSApp activeDocument]; + id parent = [document parentOfObject: anObject]; + + ASSIGN(object, anObject); + if ([parent respondsToSelector: @selector(cellSize)]) + { + NSSize size = [parent cellSize]; + [width setDoubleValue: size.width]; + [height setDoubleValue: size.height]; + } + } +} + +@end diff --git a/Palettes/2Controls/GormMatrixAttributesInspector.m b/Palettes/2Controls/GormMatrixAttributesInspector.m index d0092360..34d3f19a 100644 --- a/Palettes/2Controls/GormMatrixAttributesInspector.m +++ b/Palettes/2Controls/GormMatrixAttributesInspector.m @@ -104,6 +104,7 @@ NSUInteger colsStepperValue; /* Commit changes that the user makes in the Attributes Inspector */ - (void) ok: (id) sender { + id document = [(id)NSApp activeDocument]; if (sender == autosizeSwitch) { [object setAutosizesCells: ([sender state] == NSOnState)]; @@ -263,6 +264,9 @@ NSUInteger colsStepperValue; { [prototypeMatrix putCell: [object prototype] atRow:0 column:0]; } + + // [document detachObjects: [object cells]]; + [document attachObjects: [object cells] toParent: object]; [super ok:sender]; }