diff --git a/ChangeLog b/ChangeLog index bd852dd0..1f27ee11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-01-29 01:22 Gregory John Casamento + + * GormInternalViewEditor.m: Added code to -destroyAndListSubviews + to remove the view from the document as appropriate. + * GormSplitViewEditor.m: Same as above. + * GormViewEditor.m: Added methods to handle view when inside the + scroll view directly as opposed to being contained in the NSView. + * GormScrollViewEditor.m: Same as above. Also added code to + handle removal of single view from the scroll view. + * GormViewWithContentViewEditor.m: Removed some debug code and + added code in -groupSelectionInScrollView to add the view itself + if there is only one view selected. + 2004-01-29 12:09 Gregory John Casamento * Version 0.6.0 diff --git a/GNUmakefile b/GNUmakefile index 49154ab0..67ddf49b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -163,7 +163,6 @@ Gorm_HEADERS = \ GormSetNameController.h \ GormGeneralPref.h - Gorm_OBJC_FILES = \ Gorm.m \ GormDocument.m \ @@ -205,7 +204,7 @@ Gorm_OBJC_FILES = \ GormClassInspector.m \ GormFontViewController.m \ GormSetNameController.m \ - GormGeneralPref.m + GormGeneralPref.m -include GNUmakefile.preamble diff --git a/GormBoxEditor.m b/GormBoxEditor.m index fc112fbf..ba8680ab 100644 --- a/GormBoxEditor.m +++ b/GormBoxEditor.m @@ -35,20 +35,23 @@ @implementation NSBox (GormObjectAdditions) - (NSString*) editorClassName { + // if([[self superview] isKindOfClass: [NSClipView class]]) + // return @"GormInternalViewEditor"; + return @"GormBoxEditor"; } + - (NSFont *) font { return [self titleFont]; } + - (void) setFont: (NSFont *)aFont { [self setTitleFont: aFont]; } @end - - @implementation GormBoxEditor - (void) setOpened: (BOOL) flag diff --git a/GormInternalViewEditor.m b/GormInternalViewEditor.m index ec224824..6888b7df 100644 --- a/GormInternalViewEditor.m +++ b/GormInternalViewEditor.m @@ -921,7 +921,7 @@ static NSImage *horizontalImage; id thisView = [parent editedObject]; [parent close]; [thisView removeFromSuperview]; - + [document detachObject: thisView]; } return newSelection; diff --git a/GormScrollViewEditor.m b/GormScrollViewEditor.m index b26860fd..bcb3a421 100644 --- a/GormScrollViewEditor.m +++ b/GormScrollViewEditor.m @@ -167,28 +167,47 @@ - (NSArray *)destroyAndListSubviews { - id internalView = [[[_EO documentView] subviews] objectAtIndex: 0]; - NSEnumerator *enumerator = [[internalView subviews] objectEnumerator]; - GormViewEditor *subview; + id documentView = [_EO documentView]; + NSArray *subviews = [documentView subviews]; NSMutableArray *newSelection = [NSMutableArray array]; - - [parent makeSubeditorResign]; - while ((subview = [enumerator nextObject]) != nil) + + if([documentView conformsToProtocol: @protocol(IBEditors)] == YES) { - id v; - NSRect frame; - v = [subview editedObject]; - frame = [v frame]; - frame = [parent convertRect: frame fromView: _EO]; - [subview deactivate]; - [v setFrame: frame]; - [newSelection addObject: v]; + id internalView = [subviews objectAtIndex: 0]; + NSEnumerator *enumerator = [[internalView subviews] objectEnumerator]; + GormViewEditor *subview; + + [parent makeSubeditorResign]; + while ((subview = [enumerator nextObject]) != nil) + { + id v; + NSRect frame; + v = [subview editedObject]; + frame = [v frame]; + frame = [parent convertRect: frame fromView: _EO]; + [subview deactivate]; + [v setFrame: frame]; + [newSelection addObject: v]; + } } - + else + { + NSRect frame = [documentView frame]; + + // in this case the view editor is the documentView and + // we need to add the internal view back into the superview + frame = [parent convertRect: frame fromView: _EO]; + [documentView setFrame: frame]; + [newSelection addObject: documentView]; + [_EO setDocumentView: nil]; // remove any reference to the box. + // RELEASE(_EO); + } + { id thisView = [self editedObject]; [self close]; [thisView removeFromSuperview]; + [document detachObject: thisView]; } return newSelection; diff --git a/GormSplitViewEditor.m b/GormSplitViewEditor.m index 984d4892..6b8090ea 100644 --- a/GormSplitViewEditor.m +++ b/GormSplitViewEditor.m @@ -387,7 +387,7 @@ id thisView = [self editedObject]; [self close]; [thisView removeFromSuperview]; - + [document detachObject: thisView]; } return newSelection; } diff --git a/GormViewEditor.h b/GormViewEditor.h index 10804d27..063709ff 100644 --- a/GormViewEditor.h +++ b/GormViewEditor.h @@ -34,7 +34,6 @@ BOOL activated; BOOL closed; GormViewWithSubviewsEditor *parent; - } - (BOOL) activate; - (id) initWithObject: (id)anObject @@ -46,8 +45,11 @@ - (void) detachSubviews; - (void) postDraw: (NSRect) rect; - (id) parent; -- (NSArray *)selection; +- (NSArray *) selection; - (void) makeSelectionVisible: (BOOL) value; +- (BOOL) isOpened; +- (BOOL) canBeOpened; +- (void) setOpened: (BOOL) value; @end @interface GormViewEditor (EditingAdditions) diff --git a/GormViewEditor.m b/GormViewEditor.m index 4ea7209a..a2939c14 100644 --- a/GormViewEditor.m +++ b/GormViewEditor.m @@ -1423,6 +1423,28 @@ static BOOL currently_displaying = NO; - (void) makeSelectionVisible: (BOOL) value { } + +- (BOOL) canBeOpened +{ + return NO; +} + +- (BOOL) isOpened +{ + return NO; +} + +- (void) setOpened: (BOOL) value +{ + if (value == YES) + { + [document setSelectionFromEditor: self]; + } + else + { + [self setNeedsDisplay: YES]; + } +} @end diff --git a/GormViewWithContentViewEditor.m b/GormViewWithContentViewEditor.m index 7dc534ba..378ebf1e 100644 --- a/GormViewWithContentViewEditor.m +++ b/GormViewWithContentViewEditor.m @@ -924,7 +924,7 @@ int _sortViews(id view1, id view2, void *context) prevRect = currRect; } - NSLog(@"The vote is %d",count); + NSDebugLog(@"The vote is %d",count); if(count >= 0) vertical = YES; @@ -1061,42 +1061,80 @@ int _sortViews(id view1, id view2, void *context) return; } - enumerator = [selection objectEnumerator]; - - while ((subview = [enumerator nextObject]) != nil) + // if there is more than one view we must join them together. + if([selection count] > 1) { + // deactivate the editor for each subview. + enumerator = [selection objectEnumerator]; + while ((subview = [enumerator nextObject]) != nil) + { + superview = [subview superview]; + rect = NSUnionRect(rect, [subview frame]); + [subview deactivate]; + } + + // create the containing view. + view = [[NSView alloc] initWithFrame: + NSMakeRect(0, 0, rect.size.width, rect.size.height)]; + // create scroll view now. + scrollView = [[NSScrollView alloc] initWithFrame: rect]; + [scrollView setHasHorizontalScroller: YES]; + [scrollView setHasVerticalScroller: YES]; + [scrollView setBorderType: NSBezelBorder]; + + // attach the scroll view... + [document attachObject: scrollView + toParent: _editedObject]; + [superview addSubview: scrollView]; + [scrollView setDocumentView: view]; + + // add the views. + enumerator = [selection objectEnumerator]; + while ((subview = [enumerator nextObject]) != nil) + { + NSPoint frameOrigin; + [view addSubview: [subview editedObject]]; + frameOrigin = [[subview editedObject] frame].origin; + frameOrigin.x -= rect.origin.x; + frameOrigin.y -= rect.origin.y; + [[subview editedObject] setFrameOrigin: frameOrigin]; + [subview close]; + } + } + else if([selection count] == 1) + { + NSPoint frameOrigin; + id v = nil; + + // since we have one view, it will be used as the document view. + subview = [selection objectAtIndex: 0]; superview = [subview superview]; rect = NSUnionRect(rect, [subview frame]); [subview deactivate]; - } - view = [[NSView alloc] initWithFrame: - NSMakeRect(0, 0, rect.size.width, rect.size.height)]; - scrollView = [[NSScrollView alloc] initWithFrame: rect]; - [scrollView setHasHorizontalScroller: YES]; - [scrollView setHasVerticalScroller: YES]; - [scrollView setBorderType: NSBezelBorder]; + // create scroll view now. + scrollView = [[NSScrollView alloc] initWithFrame: rect]; + [scrollView setHasHorizontalScroller: YES]; + [scrollView setHasVerticalScroller: YES]; + [scrollView setBorderType: NSBezelBorder]; - [document attachObject: scrollView - toParent: _editedObject]; + // attach the scroll view... + [document attachObject: scrollView + toParent: _editedObject]; + [superview addSubview: scrollView]; - [superview addSubview: scrollView]; - [scrollView setDocumentView: view]; + // add the view + v = [subview editedObject]; + [scrollView setDocumentView: v]; - - enumerator = [selection objectEnumerator]; - - while ((subview = [enumerator nextObject]) != nil) - { - NSPoint frameOrigin; - [view addSubview: [subview editedObject]]; - frameOrigin = [[subview editedObject] frame].origin; + // set the origin.. + frameOrigin = [v frame].origin; frameOrigin.x -= rect.origin.x; frameOrigin.y -= rect.origin.y; - [[subview editedObject] setFrameOrigin: frameOrigin]; + [v setFrameOrigin: frameOrigin]; [subview close]; } - + editor = [document editorForObject: scrollView inEditor: self create: YES]; @@ -1115,11 +1153,11 @@ int _sortViews(id view1, id view2, void *context) if ([selection count] != 1) return; - NSLog(@"ungroup called"); + NSDebugLog(@"ungroup called"); toUngroup = [selection objectAtIndex: 0]; - NSLog(@"toUngroup = %@",[toUngroup description]); + NSDebugLog(@"toUngroup = %@",[toUngroup description]); if ([toUngroup isKindOfClass: [GormBoxEditor class]] || [toUngroup isKindOfClass: [GormSplitViewEditor class]] diff --git a/GormViewWithSubviewsEditor.h b/GormViewWithSubviewsEditor.h index 471de4e3..b29b0c03 100644 --- a/GormViewWithSubviewsEditor.h +++ b/GormViewWithSubviewsEditor.h @@ -29,20 +29,15 @@ @interface GormViewWithSubviewsEditor : GormViewEditor { BOOL _displaySelection; - BOOL opened; GormViewWithSubviewsEditor *openedSubeditor; NSMutableArray *selection; + BOOL opened; } -- (BOOL) isOpened; -- (BOOL) canBeOpened; - (void) setOpenedSubeditor: (GormViewWithSubviewsEditor *) newEditor; -- (void) setOpened: (BOOL) value; - (void) openParentEditor; - (void) makeSubeditorResign; - (void) silentlyResetSelection; -- (void) makeSelectionVisible: (BOOL) value; -- (NSArray*) selection; - (void) selectObjects: (NSArray *) objects; - (void) copySelection; - (void) deleteSelection; diff --git a/GormViewWithSubviewsEditor.m b/GormViewWithSubviewsEditor.m index 0207118f..861a97ef 100644 --- a/GormViewWithSubviewsEditor.m +++ b/GormViewWithSubviewsEditor.m @@ -80,7 +80,6 @@ } } - - (BOOL) canBeOpened { return YES;