new borderless wdef to bring in line with win32 windows. clean up mdef code to be in line with wdef code. r=saari/sr=sfraser bug# 61039

This commit is contained in:
pinkerton%netscape.com 2001-04-04 21:45:18 +00:00
parent 38b7661f86
commit 2bfe7f833d
4 changed files with 32 additions and 95 deletions

View File

@ -29,16 +29,17 @@
#include "nsIDOMNode.h"
#include "nsMenuBar.h"
#include "nsIMenuBar.h"
#include "DefProcFakery.h"
#include <Resources.h>
#include <MixedMode.h>
extern nsWeakPtr gMacMenubar;
extern Handle gSystemMDEFHandle;
// needed for CallMenuDefProc() to work correctly
#pragma options align=mac68k
RoutineDescriptorPtr gOriginaldesc;
RoutineDescriptorPtr gmdefUPP;
// Caching the Mac menu
nsVoidArray gPreviousMenuHandleStack; // hold MenuHandles
@ -259,11 +260,8 @@ pascal void nsDynamicMDEFMain(
// Force a size message next time we draw this menu
if(message == kMenuDrawMsg) {
#if !TARGET_CARBON
SInt8 state = ::HGetState((Handle)theMenu);
HLock((Handle)theMenu);
(**theMenu).menuWidth = -1;
(**theMenu).menuHeight = -1;
HSetState((Handle)theMenu, state);
#endif
}
}
@ -464,23 +462,17 @@ void nsCallSystemMDEF(
Point hitPt,
short * whichItem)
{
#if !TARGET_CARBON
SInt8 state = ::HGetState(gSystemMDEFHandle);
::HLock(gSystemMDEFHandle);
// extract the real system mdef out of the fake one we've stored in the menu
Handle fakedMDEF = (**theMenu).menuProc;
Handle systemDefProc = DefProcFakery::GetSystemDefProc ( fakedMDEF );
gmdefUPP = ::NewRoutineDescriptor( (ProcPtr)*gSystemMDEFHandle, uppMenuDefProcInfo, kM68kISA);
SInt8 state = ::HGetState(systemDefProc);
::HLock(systemDefProc);
CallMenuDefProc(
gmdefUPP,
message,
theMenu,
menuRect,
hitPt,
whichItem);
::DisposeRoutineDescriptor(gmdefUPP);
::HSetState(gSystemMDEFHandle, state);
#endif
// can't use NewMenuDefProc() here because the routine descriptor has to use kM68kISA
CallMenuDefProc((RoutineDescriptorPtr)*systemDefProc, message, theMenu, menuRect, hitPt, whichItem);
::HSetState(systemDefProc, state);
return;
}

View File

@ -112,6 +112,9 @@ public:
void SetIsActive(PRBool aActive);
protected:
void InstallBorderlessDefProc ( WindowPtr inWindow ) ;
void RemoveBorderlessDefProc ( WindowPtr inWindow ) ;
pascal static OSErr DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr theWindow,
void *handlerRefCon, DragReference theDrag );
pascal static OSErr DragReceiveHandler (WindowPtr theWindow,

View File

@ -270,13 +270,8 @@ NS_METHOD nsMenu::SetLabel(const nsAReadableString &aText)
mMacMenuIDCount++;
// Replace standard MDEF with our stub MDEF
if(mMacMenuHandle) {
SInt8 state = ::HGetState((Handle)mMacMenuHandle);
::HLock((Handle)mMacMenuHandle);
//gSystemMDEFHandle = (**mMacMenuHandle).menuProc;
if(mMacMenuHandle && gMDEF)
(**mMacMenuHandle).menuProc = gMDEF;
::HSetState((Handle)mMacMenuHandle, state);
}
}
return NS_OK;
@ -1412,13 +1407,8 @@ nsMenu::AttributeChanged(nsIDocument *aDocument, PRInt32 aNameSpaceID, nsIAtom *
mMacMenuHandle = NSStringNewMenu(mMacMenuID, mLabel);
// Replace standard MDEF with our stub MDEF
if(mMacMenuHandle) {
SInt8 state = ::HGetState((Handle)mMacMenuHandle);
::HLock((Handle)mMacMenuHandle);
//gSystemMDEFHandle = (**mMacMenuHandle).menuProc;
if(mMacMenuHandle && gMDEF)
(**mMacMenuHandle).menuProc = gMDEF;
::HSetState((Handle)mMacMenuHandle, state);
}
// Need to get the menuID of the next visible menu
SInt16 nextMenuID = -1; // default to the submenu case

View File

@ -52,15 +52,10 @@
#include <Appearance.h>
#include "nsMacResources.h"
#pragma options align=mac68k
typedef struct {
short jmpInstr;
Ptr jmpAddr;
} JmpRecord, *JmpPtr, **JmpHandle;
#pragma options align=reset
#include "DefProcFakery.h"
Handle gMDEF = nsnull;
Handle gSystemMDEFHandle = nsnull;
nsWeakPtr gMacMenubar;
nsWeakPtr gOriginalMenuBar;
bool gFirstMenuBar = true;
@ -106,10 +101,7 @@ nsMenuBar::nsMenuBar()
mParent = nsnull;
mIsMenuBarAdded = PR_FALSE;
mUnicodeTextRunConverter = nsnull;
MenuDefUPP mdef = NewMenuDefProc( nsDynamicMDEFMain );
InstallDefProc((short)nsMacResources::GetLocalResourceFile(), (ResType)'MDEF', (short)128, (Ptr) mdef );
mOriginalMacMBarHandle = nsnull;
mMacMBarHandle = nsnull;
mDocument = nsnull;
@ -304,53 +296,48 @@ nsMenuBar::MenuConstruct( const nsMenuEvent & aMenuEvent, nsIWidget* aParentWind
MenuHandle macMenuHandle = ::NewMenu(2, "\psubmenu");
if(macMenuHandle) {
// get our fake MDEF ready to be stashed into every menu that comes our way.
// if we fail creating it, we're probably so doomed there's no point in going
// on.
if ( !gMDEF ) {
MenuDefUPP mdef = NewMenuDefProc( nsDynamicMDEFMain );
Boolean success = DefProcFakery::CreateDefProc( mdef, (**macMenuHandle).menuProc, &gMDEF );
if ( !success )
::ExitToShell();
}
gLevel2HierMenu = macMenuHandle;
SInt8 state = ::HGetState((Handle)macMenuHandle);
::HLock((Handle)macMenuHandle);
gSystemMDEFHandle = (**macMenuHandle).menuProc;
(**macMenuHandle).menuProc = gMDEF;
(**macMenuHandle).menuWidth = -1;
(**macMenuHandle).menuHeight = -1;
::HSetState((Handle)macMenuHandle, state);
::InsertMenu(macMenuHandle, hierMenu);
}
macMenuHandle = ::NewMenu(3, "\psubmenu");
if(macMenuHandle) {
gLevel3HierMenu = macMenuHandle;
SInt8 state = ::HGetState((Handle)macMenuHandle);
::HLock((Handle)macMenuHandle);
gSystemMDEFHandle = (**macMenuHandle).menuProc;
(**macMenuHandle).menuProc = gMDEF;
(**macMenuHandle).menuWidth = -1;
(**macMenuHandle).menuHeight = -1;
::HSetState((Handle)macMenuHandle, state);
::InsertMenu(macMenuHandle, hierMenu);
}
macMenuHandle = ::NewMenu(4, "\psubmenu");
if(macMenuHandle) {
gLevel4HierMenu = macMenuHandle;
SInt8 state = ::HGetState((Handle)macMenuHandle);
::HLock((Handle)macMenuHandle);
gSystemMDEFHandle = (**macMenuHandle).menuProc;
(**macMenuHandle).menuProc = gMDEF;
(**macMenuHandle).menuWidth = -1;
(**macMenuHandle).menuHeight = -1;
::HSetState((Handle)macMenuHandle, state);
::InsertMenu(macMenuHandle, hierMenu);
}
macMenuHandle = ::NewMenu(5, "\psubmenu");
if(macMenuHandle) {
gLevel5HierMenu = macMenuHandle;
SInt8 state = ::HGetState((Handle)macMenuHandle);
::HLock((Handle)macMenuHandle);
gSystemMDEFHandle = (**macMenuHandle).menuProc;
(**macMenuHandle).menuProc = gMDEF;
(**macMenuHandle).menuWidth = -1;
(**macMenuHandle).menuHeight = -1;
::HSetState((Handle)macMenuHandle, state);
::InsertMenu(macMenuHandle, hierMenu);
}
} else {
@ -609,41 +596,6 @@ NS_METHOD nsMenuBar::Paint()
}
//-------------------------------------------------------------------------
void InstallDefProc(
short dpPath,
ResType dpType,
short dpID,
Ptr dpAddr)
{
JmpHandle jH;
short savePath;
savePath = CurResFile();
UseResFile(dpPath);
jH = (JmpHandle)GetResource(dpType, dpID);
DetachResource((Handle)jH);
gMDEF = (Handle) jH;
UseResFile(savePath);
if (!jH) /* is there no defproc resource? */\
{
#if DEBUG
DebugStr("\pStub Defproc Not Found!");
#endif
ExitToShell(); // bail
}
HNoPurge((Handle)jH); /* make this resource nonpurgeable */
(**jH).jmpAddr = dpAddr;
(**jH).jmpInstr = 0x4EF9;
//FlushCache();
HLockHi((Handle)jH);
}
#pragma mark -
//