diff --git a/ChangeLog b/ChangeLog index 85b8458f..f623bac1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-04-20 21:51 Gregory John Casamento + + * GormCore/GormClassManager.m: Restrict instantiation of NSView and + subclasses using Command-Shift-I. This means that standalone views + can only be created from objects which are draggable from the palette. + * GormCore/GormViewEditor.m: Removed logging ever time a standalone + view is placed, as I don't consider the functionality experimental + at this point. + * GormCore/GormViewWindow.m: Size the window to accommodate the + view if it already has size, if it doesn't resize the view to the + window's dimensions. + 2005-04-20 06:27 Gregory John Casamento * Palettes/2Controls/ControlsPalette.gorm: Corrected minor diff --git a/GormCore/GormClassManager.m b/GormCore/GormClassManager.m index ecebe7ef..e3b5d8c0 100644 --- a/GormCore/GormClassManager.m +++ b/GormCore/GormClassManager.m @@ -1928,6 +1928,11 @@ { return NO; } + else if([self isSuperclass: @"NSView" linkedToClass: className] || + [className isEqualToString: @"NSView"]) + { + return NO; + } else if([self isSuperclass: @"NSWindow" linkedToClass: className] || [className isEqualToString: @"NSWindow"]) { diff --git a/GormCore/GormViewEditor.m b/GormCore/GormViewEditor.m index 758b092f..27498612 100644 --- a/GormCore/GormViewEditor.m +++ b/GormCore/GormViewEditor.m @@ -312,7 +312,7 @@ static BOOL currently_displaying = NO; // standalone view. if([anObject window] == nil) { - NSLog(@"#### Stand alone view: %@",_editedObject); + NSDebugLog(@"#### Stand alone view: %@",_editedObject); viewWindow = [[GormViewWindow alloc] initWithView: _editedObject]; } } diff --git a/GormCore/GormViewWindow.m b/GormCore/GormViewWindow.m index 383ba833..4a47df39 100644 --- a/GormCore/GormViewWindow.m +++ b/GormCore/GormViewWindow.m @@ -36,7 +36,7 @@ } - (id) initWithView: (NSView *)view; -- (void) resize; +- (void) initialResize; @end @implementation GormViewWindowDelegate @@ -46,28 +46,53 @@ if((self = [super init]) != nil) { _view = view; - [self resize]; + [self initialResize]; } return self; } -- (void) resize +- (void) initialResize { NSWindow *window = [_view window]; - NSRect newFrame = [window frame]; + NSRect windowFrame = [window frame]; + // if the view is uninitialized, it's new... give it size. + if(NSIsEmptyRect([_view frame])) + { + NSRect newFrame = windowFrame; + + newFrame.origin.x = 10; + newFrame.origin.y = 20; + newFrame.size.height -= 70; + newFrame.size.width -= 20; + [_view setFrame: newFrame]; + } + else // otherwise take size from it. + { + NSRect newFrame = [_view frame]; + + newFrame.origin.x = windowFrame.origin.x; + newFrame.origin.y = windowFrame.origin.y; + newFrame.size.height += 70; + newFrame.size.width += 20; + + [window setFrame: newFrame display: YES]; + } + + [window center]; +} + +- (void) windowDidResize: (NSNotification *)notification +{ + NSWindow *window = [_view window]; + NSRect windowFrame = [window frame]; + NSRect newFrame = windowFrame; + newFrame.origin.x = 10; newFrame.origin.y = 20; newFrame.size.height -= 70; newFrame.size.width -= 20; [_view setFrame: newFrame]; - - NSLog(@"Resized %@",NSStringFromRect(newFrame)); -} - -- (void) windowDidResize: (NSNotification *)notification -{ - [self resize]; } @end @@ -105,7 +130,6 @@ [[self contentView] addSubview: _view]; DESTROY(_delegate); [self setDelegate: [[GormViewWindowDelegate alloc] initWithView: _view]]; - [self center]; } - (NSView *) view