diff --git a/ChangeLog b/ChangeLog index e9e9ecc2..b43c09ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2004-01-17 23:07 Gregory John Casamento + + * GormViewEditor.[hm]: Addition of selection and makeSelectionVisible + methods to allow views to exist within a scrollview without a + containing NSView. + * GormViewWithContentViewEditor.m: Changed code in + groupSelectionInScrollView to not insert a NSView to contain the + subview being grouped in the case where there is only one + view selected. These fixes correct Report#6890. + +2004-01-14 10:26 Gregory John Casamento + + * ClassInformation.plist: Added submenuAction: to the NSMenu + class. + 2004-01-14 01:42 Gregory John Casamento * GormDocument.m: attachObject:toParent: when the connection diff --git a/ClassInformation.plist b/ClassInformation.plist index 3e178b94..d52d8ebd 100644 --- a/ClassInformation.plist +++ b/ClassInformation.plist @@ -378,6 +378,9 @@ }; NSMenu = { + Actions = ( + submenuAction: + ); Super = NSObject; }; diff --git a/GormControlEditor.m b/GormControlEditor.m index 0592c26f..de003798 100644 --- a/GormControlEditor.m +++ b/GormControlEditor.m @@ -603,7 +603,6 @@ } } - @end @implementation NSTextField (GormObjectAdditions) diff --git a/GormViewEditor.h b/GormViewEditor.h index fb46291c..10804d27 100644 --- a/GormViewEditor.h +++ b/GormViewEditor.h @@ -46,6 +46,8 @@ - (void) detachSubviews; - (void) postDraw: (NSRect) rect; - (id) parent; +- (NSArray *)selection; +- (void) makeSelectionVisible: (BOOL) value; @end @interface GormViewEditor (EditingAdditions) diff --git a/GormViewEditor.m b/GormViewEditor.m index b97c9e64..4ea7209a 100644 --- a/GormViewEditor.m +++ b/GormViewEditor.m @@ -1406,6 +1406,23 @@ static BOOL currently_displaying = NO; { return NO; } + +- (NSArray*) selection +{ + NSMutableArray *result = [NSMutableArray arrayWithCapacity: 1]; + + // add self to the result... + if ([self respondsToSelector: @selector(editedObject)]) + [result addObject: [self editedObject]]; + else + [result addObject: self]; + + return result; +} + +- (void) makeSelectionVisible: (BOOL) value +{ +} @end diff --git a/GormViewWithContentViewEditor.m b/GormViewWithContentViewEditor.m index 7dc534ba..b94385c5 100644 --- a/GormViewWithContentViewEditor.m +++ b/GormViewWithContentViewEditor.m @@ -1061,42 +1061,76 @@ 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; + + // 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]; + [scrollView setDocumentView: [subview editedObject]]; - [superview addSubview: scrollView]; - [scrollView setDocumentView: view]; - - - enumerator = [selection objectEnumerator]; - - while ((subview = [enumerator nextObject]) != nil) - { - NSPoint frameOrigin; - [view addSubview: [subview editedObject]]; + // set the origin.. frameOrigin = [[subview editedObject] frame].origin; frameOrigin.x -= rect.origin.x; frameOrigin.y -= rect.origin.y; [[subview editedObject] setFrameOrigin: frameOrigin]; [subview close]; } - + editor = [document editorForObject: scrollView inEditor: self create: YES];