Improved standalone view support.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21133 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-04-21 01:56:08 +00:00
parent 3b0820f7e3
commit d71b1e88b8
4 changed files with 54 additions and 13 deletions

View file

@ -1,3 +1,15 @@
2005-04-20 21:51 Gregory John Casamento <greg_casamento@yahoo.com>
* 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 <greg_casamento@yahoo.com>
* Palettes/2Controls/ControlsPalette.gorm: Corrected minor

View file

@ -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"])
{

View file

@ -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];
}
}

View file

@ -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