mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Attach menu items and menus.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21660 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
05a4b62108
commit
4258edcf1c
2 changed files with 44 additions and 18 deletions
|
@ -1,3 +1,8 @@
|
|||
2005-08-18 22:21 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormDocument.m: attachObject:toParent: added code to
|
||||
add menu items and submenus to document.
|
||||
|
||||
2005-08-18 21:32 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormDocument.m: attachObject:toParent code to add all
|
||||
|
|
|
@ -128,8 +128,6 @@ NSString *GSCustomClassMap = @"GSCustomClassMap";
|
|||
}
|
||||
@end
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Trivial classes for connections from objects to their editors, and from
|
||||
* child editors to their parents. This does nothing special, but we can
|
||||
|
@ -466,13 +464,9 @@ static NSImage *fileImage = nil;
|
|||
|
||||
// set the holder in the document.
|
||||
fontManager = (GormObjectProxy *)item;
|
||||
|
||||
// [selectionView selectCellWithTag: 0];
|
||||
[selectionBox setContentView: scrollView];
|
||||
[self changeToViewWithTag: 0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Attach anObject to the document with aParent.
|
||||
*/
|
||||
|
@ -544,7 +538,7 @@ static NSImage *fileImage = nil;
|
|||
[[self openEditorForObject: anObject] activate];
|
||||
}
|
||||
/*
|
||||
* Add the menu.
|
||||
* Determine what should be a top level object.
|
||||
*/
|
||||
else if((aParent == filesOwner || aParent == nil) &&
|
||||
[anObject isKindOfClass: [NSMenu class]] == NO)
|
||||
|
@ -570,35 +564,53 @@ static NSImage *fileImage = nil;
|
|||
// the proxy instead.
|
||||
[self _instantiateFontManager];
|
||||
}
|
||||
/*
|
||||
* Add the menu item.
|
||||
*/
|
||||
else if([anObject isKindOfClass: [NSMenuItem class]])
|
||||
{
|
||||
NSMenu *menu = [(NSMenuItem *)anObject submenu];
|
||||
[self attachObject: menu toParent: anObject];
|
||||
}
|
||||
/*
|
||||
* Add the current menu and any submenus.
|
||||
*/
|
||||
else if ([anObject isKindOfClass: [NSMenu class]] == YES)
|
||||
{
|
||||
BOOL isMainMenu = NO;
|
||||
NSMenu *menu = (NSMenu *)anObject;
|
||||
NSEnumerator *en = [[menu itemArray] objectEnumerator];
|
||||
id item = nil;
|
||||
|
||||
// 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];
|
||||
[topLevelObjects addObject: anObject];
|
||||
[self setName: @"NSMenu" forObject: menu];
|
||||
[objectsView addObject: menu];
|
||||
[topLevelObjects addObject: menu];
|
||||
isMainMenu = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
if([[anObject title] isEqual: @"Services"] && [self servicesMenu] == nil)
|
||||
if([[menu title] isEqual: @"Services"] && [self servicesMenu] == nil)
|
||||
{
|
||||
[self setServicesMenu: anObject];
|
||||
[self setServicesMenu: menu];
|
||||
}
|
||||
else if([[anObject title] isEqual: @"Windows"] && [self windowsMenu] == nil)
|
||||
else if([[menu title] isEqual: @"Windows"] && [self windowsMenu] == nil)
|
||||
{
|
||||
[self setWindowsMenu: anObject];
|
||||
[self setWindowsMenu: menu];
|
||||
}
|
||||
}
|
||||
|
||||
[[self openEditorForObject: anObject] activate];
|
||||
// add all of the items in the menu.
|
||||
while((item = [en nextObject]) != nil)
|
||||
{
|
||||
[self attachObject: item toParent: menu];
|
||||
}
|
||||
|
||||
// activate the editor...
|
||||
[[self openEditorForObject: menu] activate];
|
||||
|
||||
// If it's the main menu... locate it appropriately...
|
||||
if(isMainMenu)
|
||||
|
@ -609,7 +621,7 @@ static NSImage *fileImage = nil;
|
|||
origin.y += (frame.size.height + 150);
|
||||
|
||||
// Place the main menu appropriately...
|
||||
[[anObject window] setFrameTopLeftPoint: origin];
|
||||
[[menu window] setFrameTopLeftPoint: origin];
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
@ -1179,6 +1191,13 @@ static NSImage *fileImage = nil;
|
|||
- (NSArray *) retrieveObjectsForParent: (id)parent recursively: (BOOL)flag
|
||||
{
|
||||
NSMutableArray *result = [NSMutableArray array];
|
||||
|
||||
// If parent is nil, use file's owner.
|
||||
if(parent == nil)
|
||||
{
|
||||
parent = filesOwner;
|
||||
}
|
||||
|
||||
[self _retrieveObjectsForParent: parent intoArray: result recursively: flag];
|
||||
return result;
|
||||
}
|
||||
|
@ -2224,7 +2243,9 @@ static NSImage *fileImage = nil;
|
|||
*/
|
||||
ownerClass = [[c nameTable] objectForKey: @"NSOwner"];
|
||||
if (ownerClass)
|
||||
[filesOwner setClassName: ownerClass];
|
||||
{
|
||||
[filesOwner setClassName: ownerClass];
|
||||
}
|
||||
[[c nameTable] setObject: filesOwner forKey: @"NSOwner"];
|
||||
[[c nameTable] setObject: firstResponder forKey: @"NSFirst"];
|
||||
|
||||
|
|
Loading…
Reference in a new issue