Applied patch #809019 (Adds embedded/plugin capabilities to wxMac).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24651 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Dimitri Schoolwerth 2003-11-24 14:25:05 +00:00
parent 144cf6da64
commit e128397f93
6 changed files with 178 additions and 95 deletions

View File

@ -80,6 +80,7 @@ protected:
// where overriden
public:
static bool sm_isEmbedded;
// Implementation
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
@ -142,6 +143,10 @@ public:
void MacDoOneEvent() ;
WXEVENTREF MacGetCurrentEvent() { return m_macCurrentEvent ; }
void MacHandleOneEvent( WXEVENTREF ev ) ;
// For embedded use. By default does nothing.
virtual void MacHandleUnhandledEvent( WXEVENTREF ev );
#if !TARGET_CARBON
virtual void MacHandleMenuSelect( int menuid , int menuitem ) ;
virtual void MacHandleMouseUpEvent( WXEVENTREF ev ) ;

View File

@ -14,7 +14,7 @@
#include "wx/mac/private.h"
void UMAInitToolbox( UInt16 inMoreMastersCalls) ;
void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded) ;
void UMACleanupToolbox() ;
long UMAGetSystemVersion() ;
bool UMAHasAppearance() ;

View File

@ -110,6 +110,8 @@ long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ;
long wxApp::s_macExitMenuItemId = wxID_EXIT ;
wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ;
// Normally we're not a plugin
bool wxApp::sm_isEmbedded = false;
//----------------------------------------------------------------------
// Core Apple Event Support
//----------------------------------------------------------------------
@ -521,7 +523,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
// Mac-specific
UMAInitToolbox( 4 ) ;
UMAInitToolbox( 4, sm_isEmbedded ) ;
SetEventMask( everyEvent ) ;
UMAShowWatchCursor() ;
@ -638,38 +640,44 @@ bool wxApp::OnInitGui()
#if TARGET_CARBON
InstallStandardEventHandler( GetApplicationEventTarget() ) ;
InstallApplicationEventHandler(
GetwxAppEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, wxTheApp, (EventHandlerRef *)&(wxTheApp->m_macEventHandler));
if (!sm_isEmbedded)
{
InstallApplicationEventHandler(
GetwxAppEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, wxTheApp, (EventHandlerRef *)&(wxTheApp->m_macEventHandler));
}
#endif
if (!sm_isEmbedded)
{
#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
NewAEEventHandlerUPP(AEHandleODoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
NewAEEventHandlerUPP(AEHandleOApp) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
NewAEEventHandlerUPP(AEHandlePDoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
NewAEEventHandlerUPP(AEHandleQuit) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
NewAEEventHandlerUPP(AEHandleODoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
NewAEEventHandlerUPP(AEHandleOApp) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
NewAEEventHandlerUPP(AEHandlePDoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
NewAEEventHandlerUPP(AEHandleQuit) ,
0 , FALSE ) ;
#else
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
NewAEEventHandlerProc(AEHandleODoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
NewAEEventHandlerProc(AEHandleOApp) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
NewAEEventHandlerProc(AEHandlePDoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
NewAEEventHandlerProc(AEHandleQuit) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
NewAEEventHandlerProc(AEHandleODoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
NewAEEventHandlerProc(AEHandleOApp) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
NewAEEventHandlerProc(AEHandlePDoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
NewAEEventHandlerProc(AEHandleQuit) ,
0 , FALSE ) ;
#endif
}
return TRUE ;
}
@ -1274,7 +1282,7 @@ void wxApp::MacDoOneEvent()
::IdleControls( window ) ;
if ( wxTheApp->ProcessIdle() )
sleepTime = 0 ;
sleepTime = kEventDurationNoWait;
else
sleepTime = GetCaretTime() / 2 ;
}
@ -1287,13 +1295,22 @@ void wxApp::MacDoOneEvent()
wxMacProcessNotifierAndPendingEvents() ;
}
/*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr )
{
// Override to process unhandled events as you please
}
void wxApp::MacHandleOneEvent( WXEVENTREF evr )
{
#if TARGET_CARBON
EventTargetRef theTarget;
theTarget = GetEventDispatcherTarget();
m_macCurrentEvent = evr ;
SendEventToEventTarget ((EventRef) evr , theTarget);
OSStatus status = SendEventToEventTarget ((EventRef) evr , theTarget);
if(status == eventNotHandledErr)
{
MacHandleUnhandledEvent(evr);
}
#else
EventRecord* ev = (EventRecord*) evr ;
m_macCurrentEvent = ev ;
@ -1325,6 +1342,10 @@ void wxApp::MacHandleOneEvent( WXEVENTREF evr )
MacHandleActivateEvent( ev ) ;
break;
case updateEvt:
// In embedded mode we first let the UnhandledEvent function
// try to handle the update event. If we handle it ourselves
// first and then pass it on, the host's windows won't update.
MacHandleUnhandledEvent(ev);
MacHandleUpdateEvent( ev ) ;
break;
case keyDown:

View File

@ -110,6 +110,8 @@ long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ;
long wxApp::s_macExitMenuItemId = wxID_EXIT ;
wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ;
// Normally we're not a plugin
bool wxApp::sm_isEmbedded = false;
//----------------------------------------------------------------------
// Core Apple Event Support
//----------------------------------------------------------------------
@ -521,7 +523,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
// Mac-specific
UMAInitToolbox( 4 ) ;
UMAInitToolbox( 4, sm_isEmbedded ) ;
SetEventMask( everyEvent ) ;
UMAShowWatchCursor() ;
@ -638,38 +640,44 @@ bool wxApp::OnInitGui()
#if TARGET_CARBON
InstallStandardEventHandler( GetApplicationEventTarget() ) ;
InstallApplicationEventHandler(
GetwxAppEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, wxTheApp, (EventHandlerRef *)&(wxTheApp->m_macEventHandler));
if (!sm_isEmbedded)
{
InstallApplicationEventHandler(
GetwxAppEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, wxTheApp, (EventHandlerRef *)&(wxTheApp->m_macEventHandler));
}
#endif
if (!sm_isEmbedded)
{
#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
NewAEEventHandlerUPP(AEHandleODoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
NewAEEventHandlerUPP(AEHandleOApp) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
NewAEEventHandlerUPP(AEHandlePDoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
NewAEEventHandlerUPP(AEHandleQuit) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
NewAEEventHandlerUPP(AEHandleODoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
NewAEEventHandlerUPP(AEHandleOApp) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
NewAEEventHandlerUPP(AEHandlePDoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
NewAEEventHandlerUPP(AEHandleQuit) ,
0 , FALSE ) ;
#else
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
NewAEEventHandlerProc(AEHandleODoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
NewAEEventHandlerProc(AEHandleOApp) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
NewAEEventHandlerProc(AEHandlePDoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
NewAEEventHandlerProc(AEHandleQuit) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
NewAEEventHandlerProc(AEHandleODoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
NewAEEventHandlerProc(AEHandleOApp) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
NewAEEventHandlerProc(AEHandlePDoc) ,
0 , FALSE ) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
NewAEEventHandlerProc(AEHandleQuit) ,
0 , FALSE ) ;
#endif
}
return TRUE ;
}
@ -1274,7 +1282,7 @@ void wxApp::MacDoOneEvent()
::IdleControls( window ) ;
if ( wxTheApp->ProcessIdle() )
sleepTime = 0 ;
sleepTime = kEventDurationNoWait;
else
sleepTime = GetCaretTime() / 2 ;
}
@ -1287,13 +1295,22 @@ void wxApp::MacDoOneEvent()
wxMacProcessNotifierAndPendingEvents() ;
}
/*virtual*/ void wxApp::MacHandleUnhandledEvent( WXEVENTREF evr )
{
// Override to process unhandled events as you please
}
void wxApp::MacHandleOneEvent( WXEVENTREF evr )
{
#if TARGET_CARBON
EventTargetRef theTarget;
theTarget = GetEventDispatcherTarget();
m_macCurrentEvent = evr ;
SendEventToEventTarget ((EventRef) evr , theTarget);
OSStatus status = SendEventToEventTarget ((EventRef) evr , theTarget);
if(status == eventNotHandledErr)
{
MacHandleUnhandledEvent(evr);
}
#else
EventRecord* ev = (EventRecord*) evr ;
m_macCurrentEvent = ev ;
@ -1325,6 +1342,10 @@ void wxApp::MacHandleOneEvent( WXEVENTREF evr )
MacHandleActivateEvent( ev ) ;
break;
case updateEvt:
// In embedded mode we first let the UnhandledEvent function
// try to handle the update event. If we handle it ourselves
// first and then pass it on, the host's windows won't update.
MacHandleUnhandledEvent(ev);
MacHandleUpdateEvent( ev ) ;
break;
case keyDown:

View File

@ -45,6 +45,8 @@ static long sUMAAppearanceVersion = 0 ;
static long sUMASystemVersion = 0 ;
static bool sUMAHasAquaLayout = false ;
static bool sUMAHasInittedAppearance = false;
extern int gAGABackgroundColor ;
bool UMAHasAppearance() { return sUMAHasAppearance ; }
long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; }
@ -60,7 +62,7 @@ bool UMAHasAquaLayout() { return sUMAHasAquaLayout ; }
void UMACleanupToolbox()
{
if ( sUMAHasAppearance )
if (sUMAHasInittedAppearance)
{
UnregisterAppearanceClient() ;
}
@ -71,26 +73,29 @@ void UMACleanupToolbox()
if ( TXNTerminateTextension != (void*) kUnresolvedCFragSymbolAddress )
TXNTerminateTextension( ) ;
}
void UMAInitToolbox( UInt16 inMoreMastersCalls )
void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded )
{
#if !TARGET_CARBON
::MaxApplZone();
for (long i = 1; i <= inMoreMastersCalls; i++)
::MoreMasters();
::InitGraf(&qd.thePort);
::InitFonts();
::InitMenus();
::TEInit();
::InitDialogs(0L);
::FlushEvents(everyEvent, 0);
::InitCursor();
if (!isEmbedded)
{
::InitGraf(&qd.thePort);
::InitFonts();
::InitMenus();
::TEInit();
::InitDialogs(0L);
::FlushEvents(everyEvent, 0);
}
long total,contig;
PurgeSpace(&total, &contig);
#else
InitCursor();
#endif
::InitCursor();
if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr)
sUMASystemVersion = 0x0000 ;
@ -98,7 +103,17 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
{
sUMAHasAppearance = true ;
RegisterAppearanceClient();
OSStatus status = RegisterAppearanceClient();
// If status equals appearanceProcessRegisteredErr it means the
// appearance client already was registered (For example if we run
// embedded, the host might have registered it). In such a case
// we don't unregister it later on.
if (status != appearanceProcessRegisteredErr)
{
// Appearance client wasn't registered yet.
sUMAHasInittedAppearance = true;
}
if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
{
sUMAAppearanceVersion = theAppearance ;
@ -116,10 +131,13 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
#if TARGET_CARBON
// Call currently implicitely done : InitFloatingWindows() ;
#else
if ( sUMAHasWindowManager )
InitFloatingWindows() ;
else
InitWindows();
if (!isEmbedded)
{
if ( sUMAHasWindowManager )
InitFloatingWindows() ;
else
InitWindows();
}
#endif
if ( NavServicesAvailable() )
@ -143,7 +161,7 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
TXNMacOSPreferredFontDescription fontDescriptions[] =
{
{ fontId , (fontSize << 16) ,kTXNDefaultFontStyle, kTXNSystemDefaultEncoding } ,
{ fontId , (fontSize << 16) ,kTXNDefaultFontStyle, kTXNSystemDefaultEncoding }
} ;
int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ;
#if 0 // TARGET_CARBON

View File

@ -45,6 +45,8 @@ static long sUMAAppearanceVersion = 0 ;
static long sUMASystemVersion = 0 ;
static bool sUMAHasAquaLayout = false ;
static bool sUMAHasInittedAppearance = false;
extern int gAGABackgroundColor ;
bool UMAHasAppearance() { return sUMAHasAppearance ; }
long UMAGetAppearanceVersion() { return sUMAAppearanceVersion ; }
@ -60,7 +62,7 @@ bool UMAHasAquaLayout() { return sUMAHasAquaLayout ; }
void UMACleanupToolbox()
{
if ( sUMAHasAppearance )
if (sUMAHasInittedAppearance)
{
UnregisterAppearanceClient() ;
}
@ -71,26 +73,29 @@ void UMACleanupToolbox()
if ( TXNTerminateTextension != (void*) kUnresolvedCFragSymbolAddress )
TXNTerminateTextension( ) ;
}
void UMAInitToolbox( UInt16 inMoreMastersCalls )
void UMAInitToolbox( UInt16 inMoreMastersCalls, bool isEmbedded )
{
#if !TARGET_CARBON
::MaxApplZone();
for (long i = 1; i <= inMoreMastersCalls; i++)
::MoreMasters();
::InitGraf(&qd.thePort);
::InitFonts();
::InitMenus();
::TEInit();
::InitDialogs(0L);
::FlushEvents(everyEvent, 0);
::InitCursor();
if (!isEmbedded)
{
::InitGraf(&qd.thePort);
::InitFonts();
::InitMenus();
::TEInit();
::InitDialogs(0L);
::FlushEvents(everyEvent, 0);
}
long total,contig;
PurgeSpace(&total, &contig);
#else
InitCursor();
#endif
::InitCursor();
if ( Gestalt(gestaltSystemVersion, &sUMASystemVersion) != noErr)
sUMASystemVersion = 0x0000 ;
@ -98,7 +103,17 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
if ( Gestalt( gestaltAppearanceAttr, &theAppearance ) == noErr )
{
sUMAHasAppearance = true ;
RegisterAppearanceClient();
OSStatus status = RegisterAppearanceClient();
// If status equals appearanceProcessRegisteredErr it means the
// appearance client already was registered (For example if we run
// embedded, the host might have registered it). In such a case
// we don't unregister it later on.
if (status != appearanceProcessRegisteredErr)
{
// Appearance client wasn't registered yet.
sUMAHasInittedAppearance = true;
}
if ( Gestalt( gestaltAppearanceVersion, &theAppearance ) == noErr )
{
sUMAAppearanceVersion = theAppearance ;
@ -116,10 +131,13 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
#if TARGET_CARBON
// Call currently implicitely done : InitFloatingWindows() ;
#else
if ( sUMAHasWindowManager )
InitFloatingWindows() ;
else
InitWindows();
if (!isEmbedded)
{
if ( sUMAHasWindowManager )
InitFloatingWindows() ;
else
InitWindows();
}
#endif
if ( NavServicesAvailable() )
@ -143,7 +161,7 @@ void UMAInitToolbox( UInt16 inMoreMastersCalls )
TXNMacOSPreferredFontDescription fontDescriptions[] =
{
{ fontId , (fontSize << 16) ,kTXNDefaultFontStyle, kTXNSystemDefaultEncoding } ,
{ fontId , (fontSize << 16) ,kTXNDefaultFontStyle, kTXNSystemDefaultEncoding }
} ;
int noOfFontDescriptions = sizeof( fontDescriptions ) / sizeof(TXNMacOSPreferredFontDescription) ;
#if 0 // TARGET_CARBON