Menu placement changes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19608 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-06-24 05:30:22 +00:00
parent c09f861b02
commit b42d75db38
2 changed files with 56 additions and 14 deletions

View file

@ -1,3 +1,12 @@
2004-06-24 01:33 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.m: Additions to [GormDocument attachObject:
withParent:], [GormDocument loadDocument:], [GormDocument
setupDefaults:] to move the main menu appropriately when
it is either added to the documnent, loaded, or added when
the user selects the "Application" type from the New menu.
This helps alleviate confusion when editing the menu.
2004-06-22 23:33 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.m: A fix in -[GormDocument pasteType:

View file

@ -64,7 +64,6 @@
}
@end
// Internal only
NSString *GSCustomClassMap = @"GSCustomClassMap";
@ -502,26 +501,41 @@ static NSImage *classesImage = nil;
*/
if ([anObject isKindOfClass: [NSMenu class]] == YES)
{
BOOL isMainMenu = NO;
// if there is no main menu and a menu gets added, it
// will become the main menu.
if([self objectForName: @"NSMenu"] == nil)
{
[self setName: @"NSMenu" forObject: anObject];
[objectsView addObject: anObject];
isMainMenu = YES;
}
else
{
if([[anObject title] isEqual: @"Services"])
if([[anObject title] isEqual: @"Services"] && [self servicesMenu] == nil)
{
[self setServicesMenu: anObject];
}
else if([[anObject title] isEqual: @"Windows"])
else if([[anObject title] isEqual: @"Windows"] && [self windowsMenu] == nil)
{
[self setWindowsMenu: anObject];
}
}
[[self openEditorForObject: anObject] activate];
// if it's the main menu... locate it appropriately...
if(isMainMenu)
{
NSRect frame = [window frame];
NSPoint origin = frame.origin;
origin.y += (frame.size.height + 150);
// place the main menu appropriately...
[[anObject window] setFrameTopLeftPoint: origin];
}
}
/*
@ -1771,17 +1785,18 @@ static NSImage *classesImage = nil;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSMutableDictionary *nt;
NSMutableDictionary *cc;
NSData *data;
NSData *data;
NSUnarchiver *u;
GSNibContainer *c;
GSNibContainer *c;
NSEnumerator *enumerator;
id <IBConnectors> con;
NSString *ownerClass, *key;
id <IBConnectors> con;
NSString *ownerClass, *key;
NSFileManager *mgr = [NSFileManager defaultManager];
BOOL isDir = NO;
NSDirectoryEnumerator *dirEnumerator;
BOOL repairFile = [[NSUserDefaults standardUserDefaults] boolForKey: @"GormRepairFileOnLoad"];
BOOL isDir = NO;
NSDirectoryEnumerator *dirEnumerator;
BOOL repairFile = [[NSUserDefaults standardUserDefaults] boolForKey: @"GormRepairFileOnLoad"];
NSMenu *mainMenu;
if ([mgr fileExistsAtPath: aFile isDirectory: &isDir])
{
// if the data is in a directory, then load from objects.gorm
@ -2017,7 +2032,22 @@ static NSImage *classesImage = nil;
[o awakeFromDocument: self];
}
}
// reposition the loaded menu appropriately...
mainMenu = [nameTable objectForKey: @"NSMenu"];
if(mainMenu != nil)
{
NSRect frame = [window frame];
NSPoint origin = frame.origin;
NSRect menuFrame = [[mainMenu window] frame];
// account for the height of the menu we're loading.
origin.y += (frame.size.height + menuFrame.size.height + 150);
// place the main menu appropriately...
[[mainMenu window] setFrameTopLeftPoint: origin];
}
// this is the last thing we should do...
[nc postNotificationName: IBDidOpenDocumentNotification
object: self];
@ -2296,10 +2326,14 @@ static NSImage *classesImage = nil;
{
NSMenu *aMenu;
NSWindow *aWindow;
NSRect winFrame = [window frame];
NSPoint origin = winFrame.origin;
NSRect frame = [[NSScreen mainScreen] frame];
unsigned style = NSTitledWindowMask | NSClosableWindowMask
| NSResizableWindowMask | NSMiniaturizableWindowMask;
origin.y += (winFrame.size.height + 150);
if ([NSMenu respondsToSelector: @selector(allocSubstitute)])
{
aMenu = [[NSMenu allocSubstitute] init];
@ -2343,8 +2377,7 @@ static NSImage *classesImage = nil;
[self setName: @"NSMenu" forObject: aMenu];
[self attachObject: aMenu toParent: nil];
[objectsView addObject: aMenu];
[[aMenu window] setFrameTopLeftPoint:
NSMakePoint(1, frame.size.height-200)];
[[aMenu window] setFrameTopLeftPoint: origin];
RELEASE(aMenu);
}
else if ([type isEqual: @"Inspector"] == YES)