diff --git a/ChangeLog b/ChangeLog index acf0662b..80f96231 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2004-03-20 12:07 Gregory John Casamento + + * ClassInformation.plist: Removed some methods which should + not have been in FirstResponder. + * Gorm.m: Added back in the ability to instantiate a NSFontManager. + Currently, IB adds a font manager for you when you add a NSMenu which + has connections to the font manager. Gorm, for the time being, + will simply allow the user to instantiate it directly. + * GormViewEditor.m: Removed _allsubviews: and associated fuctions. + * GormFunctions.m: Added allSubviews and associated functions here + so that they can be used application wide. + * GormObjectEditor.m: [GormObjectEditor deleteSelection]: Added + code to query the user before deletion of the main menu, so that + this doesn't happen by accident. Added code to delete the subviews + of a window from the document. + 2004-03-13 07:45 Gregory John Casamento * GormDocument.m: [GormDocument loadDocument:] added call to diff --git a/ClassInformation.plist b/ClassInformation.plist index 67de3617..af46923c 100644 --- a/ClassInformation.plist +++ b/ClassInformation.plist @@ -10,7 +10,6 @@ "cancel:", "capitalizeWord:", "changeColor:", - "changeFont:", "checkSpelling:", "close:", "complete:", @@ -68,7 +67,6 @@ "orderFront:", "orderFrontColorPanel:", "orderFrontDataLinkPanel:", - "orderFrontFontPanel:", "orderFrontHelpPanel:", "orderFrontStandardAboutPanel:", "orderFrontStandardInfoPanel:", diff --git a/Gorm.m b/Gorm.m index bc2bbd1a..d5be262c 100644 --- a/Gorm.m +++ b/Gorm.m @@ -1403,10 +1403,12 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification"; { return NO; } + /* else if([name isEqualToString: @"NSFontManager"]) { return NO; } + */ else if([name isEqualToString: @"NSHelpManager"]) { return NO; diff --git a/GormFunctions.h b/GormFunctions.h index 18bffed7..b782502b 100644 --- a/GormFunctions.h +++ b/GormFunctions.h @@ -36,6 +36,12 @@ NSArray* findAllSubmenus(NSArray *array); // find all items in the menu... NSArray* findAll(NSMenu *menu); +// all subviews for the view provided +void subviewsForView(NSView *view, NSMutableArray *array); + +// all subviews +NSArray *allSubviews(NSView *view); + // cut the file label to the appropriate length... NSString *cutFileLabelText(NSString *filename, id label, int length); diff --git a/GormFunctions.m b/GormFunctions.m index 086ffdd5..84d598b9 100644 --- a/GormFunctions.m +++ b/GormFunctions.m @@ -23,6 +23,7 @@ */ #include "GormFunctions.h" +#include "GormViewEditor.h" #include // find all subitems for the given items... @@ -68,6 +69,35 @@ NSArray* findAll(NSMenu *menu) return findAllSubmenus(items); } +void subviewsForView(NSView *view, NSMutableArray *array) +{ + if(view != nil) + { + NSArray *subviews = [view subviews]; + NSEnumerator *en = [subviews objectEnumerator]; + NSView *aView = nil; + + // if it's not me and it's not and editor, include it in the list of + // things to be deleted from the document. + if(![view isKindOfClass: [GormViewEditor class]]) + { + [array addObject: view]; + } + + while((aView = [en nextObject]) != nil) + { + subviewsForView( aView, array ); + } + } +} + +NSArray *allSubviews(NSView *view) +{ + NSMutableArray *views = [NSMutableArray array]; + subviewsForView( view, views ); + return views; +} + // cut the text... code taken from GWorkspace, by Enrico Sersale static inline NSString *cutText(NSString *filename, id label, int lenght) { diff --git a/GormObjectEditor.m b/GormObjectEditor.m index 68d5a1a3..5f8de9cc 100644 --- a/GormObjectEditor.m +++ b/GormObjectEditor.m @@ -135,9 +135,23 @@ static NSMapTable *docMap = 0; nc = [NSNotificationCenter defaultCenter]; + if ([selected isKindOfClass: [NSMenu class]] && + [[document nameForObject: selected] isEqual: @"NSMenu"] == YES) + { + NSString *title = _(@"Removing Main Menu"); + NSString *msg = _(@"Are you sure you want to do this?"); + int retval = NSRunAlertPanel(title, msg,_(@"OK"),_(@"Cancel"), nil, nil); + + // if the user *really* wants to delete the menu, do it. + if(retval != NSAlertDefaultReturn) + return; + } + [document detachObject: selected]; if ([selected isKindOfClass: [NSWindow class]] == YES) { + NSArray *subviews = allSubviews([selected contentView]); + [document detachObjects: subviews]; [selected close]; } @@ -146,7 +160,7 @@ static NSMapTable *docMap = 0; NSArray *items = findAll( selected ); NSEnumerator *en = [items objectEnumerator]; id obj = nil; - + while((obj = [en nextObject]) != nil) { [document detachObject: obj]; diff --git a/GormViewEditor.h b/GormViewEditor.h index 063709ff..c1cb523c 100644 --- a/GormViewEditor.h +++ b/GormViewEditor.h @@ -21,6 +21,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include + #ifndef INCLUDED_GormViewEditor_h #define INCLUDED_GormViewEditor_h diff --git a/GormViewEditor.m b/GormViewEditor.m index a2939c14..81620e5f 100644 --- a/GormViewEditor.m +++ b/GormViewEditor.m @@ -25,10 +25,10 @@ #include #include "GormPrivate.h" - #include "GormViewEditor.h" #include "GormViewWithSubviewsEditor.h" #include "GormPlacementInfo.h" +#include "GormFunctions.h" #include #include @@ -203,39 +203,9 @@ static BOOL currently_displaying = NO; return parent; } -- (void) _subviewsForView: (NSView *)view withArray: (NSMutableArray *)array -{ - if(view != nil) - { - NSArray *subviews = [view subviews]; - NSEnumerator *en = [subviews objectEnumerator]; - NSView *aView = nil; - - // if it's not me and it's not and editor, include it in the list of - // things to be deleted from the document. - if(view != self && ![view isKindOfClass: [GormViewEditor class]] && view != _editedObject) - { - [array addObject: view]; - } - - while((aView = [en nextObject]) != nil) - { - [self _subviewsForView: aView withArray: array]; - } - } -} - -- (NSArray *) _allsubviews -{ - NSMutableArray *views = [NSMutableArray array]; - [self _subviewsForView: self withArray: views]; - return views; -} - - - (void) detachSubviews { - NSArray *subviews = [self _allsubviews]; + NSArray *subviews = allSubviews([self editedObject]); [document detachObjects: subviews]; } diff --git a/Palettes/0Menus/GormMenuEditor.m b/Palettes/0Menus/GormMenuEditor.m index 1f424252..3b42b8d6 100644 --- a/Palettes/0Menus/GormMenuEditor.m +++ b/Palettes/0Menus/GormMenuEditor.m @@ -439,7 +439,7 @@ - (void) close { - NSAssert(isClosed == NO, NSInternalInconsistencyException); + // NSAssert(isClosed == NO, NSInternalInconsistencyException); isClosed = YES; [[NSNotificationCenter defaultCenter] removeObserver: self]; @@ -518,18 +518,18 @@ { if ([selection count] > 0) { - NSArray *s = [NSArray arrayWithArray: selection]; + NSArray *s = [NSArray arrayWithArray: selection]; NSEnumerator *e = [s objectEnumerator]; NSMenuItem *i; - NSArray *d = nil; - + NSArray *d = nil; + [self makeSelectionVisible: NO]; [self selectObjects: [NSArray array]]; - + // find all relavent objects. Remove them from the nameTable. d = findAllSubmenus( s ); [document detachObjects: d]; - + // remove the items from the menu... while ((i = [e nextObject]) != nil && [edited numberOfItems] > 1) {