Several important fixes. Document cleanup, menu management.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@18859 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-03-21 05:12:27 +00:00
parent 33bdeb15af
commit 52db475527
9 changed files with 80 additions and 41 deletions

View file

@ -1,3 +1,19 @@
2004-03-20 12:07 Gregory John Casamento <greg_casamento@yahoo.com>
* 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 <greg_casamento@yahoo.com>
* GormDocument.m: [GormDocument loadDocument:] added call to

View file

@ -10,7 +10,6 @@
"cancel:",
"capitalizeWord:",
"changeColor:",
"changeFont:",
"checkSpelling:",
"close:",
"complete:",
@ -68,7 +67,6 @@
"orderFront:",
"orderFrontColorPanel:",
"orderFrontDataLinkPanel:",
"orderFrontFontPanel:",
"orderFrontHelpPanel:",
"orderFrontStandardAboutPanel:",
"orderFrontStandardInfoPanel:",

2
Gorm.m
View file

@ -1403,10 +1403,12 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification";
{
return NO;
}
/*
else if([name isEqualToString: @"NSFontManager"])
{
return NO;
}
*/
else if([name isEqualToString: @"NSHelpManager"])
{
return NO;

View file

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

View file

@ -23,6 +23,7 @@
*/
#include "GormFunctions.h"
#include "GormViewEditor.h"
#include <AppKit/AppKit.h>
// 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)
{

View file

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

View file

@ -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 <InterfaceBuilder/InterfaceBuilder.h>
#ifndef INCLUDED_GormViewEditor_h
#define INCLUDED_GormViewEditor_h

View file

@ -25,10 +25,10 @@
#include <AppKit/AppKit.h>
#include "GormPrivate.h"
#include "GormViewEditor.h"
#include "GormViewWithSubviewsEditor.h"
#include "GormPlacementInfo.h"
#include "GormFunctions.h"
#include <math.h>
#include <stdlib.h>
@ -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];
}

View file

@ -439,7 +439,7 @@
- (void) close
{
NSAssert(isClosed == NO, NSInternalInconsistencyException);
// NSAssert(isClosed == NO, NSInternalInconsistencyException);
isClosed = YES;
[[NSNotificationCenter defaultCenter] removeObserver: self];
@ -518,10 +518,10 @@
{
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]];