diff --git a/cmd/macfe/sharemnu/LMenuSharing.cp b/cmd/macfe/sharemnu/LMenuSharing.cp index 46056a4c42d9..9260bd7a3794 100644 --- a/cmd/macfe/sharemnu/LMenuSharing.cp +++ b/cmd/macfe/sharemnu/LMenuSharing.cp @@ -43,17 +43,32 @@ static pascal void EventFilter (EventRecord *ev) // =========================================================================== // LMenuSharing.cp // =========================================================================== -// MenuShring class. Based upon Frontier and draper@usis.com code - +// MenuSharing class. Based upon Frontier and draper@usis.com code + +Int16 LMenuSharingAttachment::sInsertAfterMenuID = 0; +Int16 LMenuSharingAttachment::sNextPluginMenuID = 20000; + LMenuSharingAttachment::LMenuSharingAttachment( MessageT inMessage, Boolean inExecuteHost,Int16 resIDofLastMenu) : LAttachment(inMessage, inExecuteHost) { mCanMenuShare = ::InitSharedMenus (ErrorDialog, EventFilter); - mInsertAfterMenuID = resIDofLastMenu + 1; + sInsertAfterMenuID = resIDofLastMenu + 1; } +Int16 LMenuSharingAttachment::AllocatePluginMenuID(Boolean isSubmenu) +{ + // force the menus to be recreated. + DisposeSharedMenus(); + if (isSubmenu) { + // this needs to take a menu ID out of the space used by MenuSharing. + return sInsertAfterMenuID++; + } else { + // these can come out of a different range, because they aren't hierarchical. + return sNextPluginMenuID++; + } +} void LMenuSharingAttachment::ExecuteSelf( MessageT inMessage, void* ioParam) { @@ -74,8 +89,7 @@ void LMenuSharingAttachment::ExecuteSelf( MessageT inMessage, void* ioParam) Int16 part; LCommander* commander; - - CheckSharedMenus(mInsertAfterMenuID); + CheckSharedMenus(sInsertAfterMenuID); if (ev->what== mouseDown) { @@ -96,7 +110,7 @@ void LMenuSharingAttachment::ExecuteSelf( MessageT inMessage, void* ioParam) mExecuteHost = false; if (command != cmd_Nothing) { - if (LCommander::IsSyntheticCommand(command,menuId, menuItem)) + if (LCommander::IsSyntheticCommand(command, menuId, menuItem)) { if (SharedMenuHit (menuId, menuItem)) { diff --git a/cmd/macfe/sharemnu/LMenuSharing.h b/cmd/macfe/sharemnu/LMenuSharing.h index 0c682f04c621..5f863edc0c44 100644 --- a/cmd/macfe/sharemnu/LMenuSharing.h +++ b/cmd/macfe/sharemnu/LMenuSharing.h @@ -24,19 +24,19 @@ // =========================================================================== -class LMenuSharingAttachment : public LAttachment -{ - +class LMenuSharingAttachment : public LAttachment { public: - LMenuSharingAttachment(MessageT inMessage, + LMenuSharingAttachment(MessageT inMessage, Boolean inExecuteHost, Int16 resIDofLastMenu); // resIDofLastMenu is the id of the menu that shared menus will // will be inserted after. + + static Int16 AllocatePluginMenuID(Boolean isSubmenu); + protected: -virtual void ExecuteSelf(MessageT inMessage, void *ioParam); -Boolean mCanMenuShare; -Int16 mInsertAfterMenuID; + virtual void ExecuteSelf(MessageT inMessage, void *ioParam); + Boolean mCanMenuShare; + static Int16 sInsertAfterMenuID; + static Int16 sNextPluginMenuID; }; - -