Add changes to fix fontMenu issue

This commit is contained in:
Gregory John Casamento 2021-05-15 18:43:21 -04:00
parent 407a0403ad
commit f56cf39b0a
4 changed files with 79 additions and 9 deletions

View file

@ -1,3 +1,18 @@
2021-05-15 Gregory John Casamento <greg.casamento@gmail.com>
* English.lproj/Gorm.rtfd/TXT.rtf: Add help file
* GNUmakefile: Copy help file.
* GormCore/GormClassEditor.m
* GormCore/GormClassManager.m
* GormCore/GormConnectionInspector.m: Code cleanup.
* GormCore/GormDocument.h: Declaration of setFontMenu:/fontMenu
* GormCore/GormDocument.m: Add setFontMenu:/fontMenu methods.
Add outlet connector so that font menu us connected to the font
manager when the model is loaded.
* GormInfo.plist: Update version
* Palettes/0Menus/MenusPalette.m: Use auto variable to hold
the NSFontManager singleton.
2021-05-09 Gregory John Casamento <greg.casamento@gmail.com>
* GormCore/GormClassManager.m: Code cleanup

View file

@ -283,6 +283,16 @@
*/
- (NSMenu *) servicesMenu;
/**
* Set the font menu.
*/
- (void) setFontMenu: (NSMenu *)menu;
/**
* Returns the font menu for the document.
*/
- (NSMenu *) fontMenu;
/**
* Sets the windows menu.
*/

View file

@ -499,9 +499,12 @@ static NSImage *fileImage = nil;
if ([connections indexOfObjectIdenticalTo: aConnector] == NSNotFound)
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: IBWillAddConnectorNotification
object: aConnector];
[connections addObject: aConnector];
[nc postNotificationName: IBDidAddConnectorNotification
object: aConnector];
}
@ -521,6 +524,7 @@ static NSImage *fileImage = nil;
- (void) _instantiateFontManager
{
GSNibItem *item = nil;
NSMenu *fontMenu = nil;
item = [[GormObjectProxy alloc] initWithClassName: @"NSFontManager"];
@ -531,6 +535,17 @@ static NSImage *fileImage = nil;
// set the holder in the document.
fontManager = (GormObjectProxy *)item;
[self changeToViewWithTag: 0];
// Add the connection to the menu from the font manager, if the NSFontMenu exists...
fontMenu = [self fontMenu];
if (fontMenu != nil)
{
NSNibOutletConnector *con = [[NSNibOutletConnector alloc] init];
[con setSource: item];
[con setDestination: fontMenu];
[con setLabel: @"menu"];
[self addConnector: con];
}
}
/**
@ -629,6 +644,7 @@ static NSImage *fileImage = nil;
// the proxy instead.
[self _instantiateFontManager];
}
/*
* Add the menu items from the popup.
*/
@ -681,6 +697,10 @@ static NSImage *fileImage = nil;
{
[self setRecentDocumentsMenu: menu];
}
if([[menu title] isEqual: @"Font"] && [self fontMenu] == nil)
{
[self setFontMenu: menu];
}
// if it doesn't have a supermenu and it's owned by the file's owner, then it's a top level menu....
else if([menu supermenu] == nil && aParent == filesOwner)
{
@ -2038,6 +2058,7 @@ static void _real_close(GormDocument *self,
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
RETAIN(aConnector); // prevent it from being dealloc'd until the notification is done.
// issue pre notification..
[nc postNotificationName: IBWillRemoveConnectorNotification
object: aConnector];
@ -2045,10 +2066,12 @@ static void _real_close(GormDocument *self,
// mark the document as changed.
[self touch];
// issue post notification..
[connections removeObjectIdenticalTo: aConnector];
// issue post notification..
[nc postNotificationName: IBDidRemoveConnectorNotification
object: aConnector];
RELEASE(aConnector); // NOW we can dealloc it.
}
@ -2297,6 +2320,29 @@ static void _real_close(GormDocument *self,
return [nameTable objectForKey: @"NSServicesMenu"];
}
/**
* Set the object that will be the font menu in the app.
*/
- (void) setFontMenu: (NSMenu *)anObject
{
if(anObject != nil)
{
[nameTable setObject: anObject forKey: @"NSFontMenu"];
}
else
{
[nameTable removeObjectForKey: @"NSFontMenu"];
}
}
/**
* Return the object that will be the services menu.
*/
- (NSMenu *) fontMenu
{
return [nameTable objectForKey: @"NSFontMenu"];
}
/**
* Set the menu that will be the recent documents menu in the app.
*/

View file

@ -127,7 +127,6 @@
*/
fm = [NSFontManager sharedFontManager];
m = [GormNSMenu menuWithMenu: [fm fontMenu: YES]];
[fm setFontMenu: m];
// Other font menu items
[m addItemWithTitle: @"Underline"
@ -363,7 +362,7 @@
action: NULL
keyEquivalent: @""];
s = [GormNSMenu menuWithMenu: [[NSFontManager sharedFontManager] fontMenu: YES]];
s = [GormNSMenu menuWithMenu: [fm fontMenu: YES]];
// Other font menu items
[s addItemWithTitle: @"Underline"