Remove wxOSX/Carbon support.
Cocoa has been the default toolkit in wxWidgets for a long time. There is really no good reason to use Carbon in 2016 and this removes a lot of unused and unmaintained code.
This commit is contained in:
@@ -44,11 +44,7 @@
|
||||
#include <string.h>
|
||||
|
||||
// mac
|
||||
#if wxOSX_USE_CARBON
|
||||
#include "wx/osx/uma.h"
|
||||
#else
|
||||
#include "wx/osx/private.h"
|
||||
#endif
|
||||
|
||||
#if defined(WXMAKINGDLL_CORE)
|
||||
# include <mach-o/dyld.h>
|
||||
@@ -75,214 +71,6 @@ wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ;
|
||||
|
||||
bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Core Apple Event Support
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
AEEventHandlerUPP sODocHandler = NULL ;
|
||||
AEEventHandlerUPP sGURLHandler = NULL ;
|
||||
AEEventHandlerUPP sOAppHandler = NULL ;
|
||||
AEEventHandlerUPP sPDocHandler = NULL ;
|
||||
AEEventHandlerUPP sRAppHandler = NULL ;
|
||||
AEEventHandlerUPP sQuitHandler = NULL ;
|
||||
|
||||
pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , SRefCon refcon ) ;
|
||||
pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , SRefCon refcon ) ;
|
||||
pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , SRefCon refcon ) ;
|
||||
pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , SRefCon refcon ) ;
|
||||
pascal OSErr AEHandleRApp( const AppleEvent *event , AppleEvent *reply , SRefCon refcon ) ;
|
||||
pascal OSErr AEHandleGURL( const AppleEvent *event , AppleEvent *reply , SRefCon refcon ) ;
|
||||
|
||||
pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , SRefCon WXUNUSED(refcon) )
|
||||
{
|
||||
return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ;
|
||||
}
|
||||
|
||||
pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , SRefCon WXUNUSED(refcon) )
|
||||
{
|
||||
return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ;
|
||||
}
|
||||
|
||||
pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , SRefCon WXUNUSED(refcon) )
|
||||
{
|
||||
return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ;
|
||||
}
|
||||
|
||||
pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , SRefCon WXUNUSED(refcon) )
|
||||
{
|
||||
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
|
||||
}
|
||||
|
||||
pascal OSErr AEHandleRApp( const AppleEvent *event , AppleEvent *reply , SRefCon WXUNUSED(refcon) )
|
||||
{
|
||||
return wxTheApp->MacHandleAERApp( (AppleEvent*) event , reply) ;
|
||||
}
|
||||
|
||||
pascal OSErr AEHandleGURL( const AppleEvent *event , AppleEvent *reply , SRefCon WXUNUSED(refcon) )
|
||||
{
|
||||
return wxTheApp->MacHandleAEGURL((WXEVENTREF *)event , reply) ;
|
||||
}
|
||||
|
||||
|
||||
// AEODoc Calls MacOpenFiles with all of the files passed
|
||||
|
||||
short wxApp::MacHandleAEODoc(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
|
||||
{
|
||||
AEDescList docList;
|
||||
AEKeyword keywd;
|
||||
DescType returnedType;
|
||||
Size actualSize;
|
||||
long itemsInList;
|
||||
OSErr err;
|
||||
short i;
|
||||
|
||||
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
err = AECountItems(&docList, &itemsInList);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
ProcessSerialNumber PSN ;
|
||||
PSN.highLongOfPSN = 0 ;
|
||||
PSN.lowLongOfPSN = kCurrentProcess ;
|
||||
SetFrontProcess( &PSN ) ;
|
||||
|
||||
wxString fName ;
|
||||
FSRef theRef ;
|
||||
|
||||
wxArrayString fileNames;
|
||||
for (i = 1; i <= itemsInList; i++)
|
||||
{
|
||||
err = AEGetNthPtr(
|
||||
&docList, i, typeFSRef, &keywd, &returnedType,
|
||||
(Ptr)&theRef, sizeof(theRef), &actualSize);
|
||||
|
||||
if ( err != noErr)
|
||||
return err;
|
||||
|
||||
fName = wxMacFSRefToPath( &theRef ) ;
|
||||
|
||||
fileNames.Add(fName);
|
||||
}
|
||||
|
||||
MacOpenFiles(fileNames);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
// AEODoc Calls MacOpenURL on the url passed
|
||||
|
||||
short wxApp::MacHandleAEGURL(const WXEVENTREF event, WXEVENTREF WXUNUSED(reply))
|
||||
{
|
||||
DescType returnedType;
|
||||
Size actualSize;
|
||||
char url[255];
|
||||
OSErr err = AEGetParamPtr((AppleEvent *)event, keyDirectObject, typeChar,
|
||||
&returnedType, url, sizeof(url)-1,
|
||||
&actualSize);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
url[actualSize] = '\0'; // Terminate the C string
|
||||
|
||||
ProcessSerialNumber PSN ;
|
||||
PSN.highLongOfPSN = 0 ;
|
||||
PSN.lowLongOfPSN = kCurrentProcess ;
|
||||
SetFrontProcess( &PSN ) ;
|
||||
|
||||
MacOpenURL(wxString(url, wxConvUTF8));
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
// AEPDoc Calls MacPrintFile on each of the files passed
|
||||
|
||||
short wxApp::MacHandleAEPDoc(const WXEVENTREF event , WXEVENTREF WXUNUSED(reply))
|
||||
{
|
||||
AEDescList docList;
|
||||
AEKeyword keywd;
|
||||
DescType returnedType;
|
||||
Size actualSize;
|
||||
long itemsInList;
|
||||
OSErr err;
|
||||
short i;
|
||||
|
||||
err = AEGetParamDesc((AppleEvent *)event, keyDirectObject, typeAEList,&docList);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
err = AECountItems(&docList, &itemsInList);
|
||||
if (err != noErr)
|
||||
return err;
|
||||
|
||||
ProcessSerialNumber PSN ;
|
||||
PSN.highLongOfPSN = 0 ;
|
||||
PSN.lowLongOfPSN = kCurrentProcess ;
|
||||
SetFrontProcess( &PSN ) ;
|
||||
|
||||
wxString fName ;
|
||||
FSRef theRef ;
|
||||
|
||||
wxArrayString fileNames;
|
||||
|
||||
for (i = 1; i <= itemsInList; i++)
|
||||
{
|
||||
err = AEGetNthPtr(
|
||||
&docList, i, typeFSRef, &keywd, &returnedType,
|
||||
(Ptr)&theRef, sizeof(theRef), &actualSize);
|
||||
|
||||
if ( err != noErr)
|
||||
return err;
|
||||
|
||||
fName = wxMacFSRefToPath( &theRef ) ;
|
||||
fileNames.Add( fName );
|
||||
}
|
||||
|
||||
MacPrintFiles(fileNames);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
// AEOApp calls MacNewFile
|
||||
|
||||
short wxApp::MacHandleAEOApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
|
||||
{
|
||||
MacNewFile() ;
|
||||
return noErr ;
|
||||
}
|
||||
|
||||
// AEQuit attempts to quit the application
|
||||
|
||||
short wxApp::MacHandleAEQuit(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
|
||||
{
|
||||
wxCloseEvent event(wxEVT_QUERY_END_SESSION, wxID_ANY);
|
||||
event.SetEventObject(this);
|
||||
event.SetCanVeto(true);
|
||||
ProcessEvent(event);
|
||||
if ( !event.GetVeto() )
|
||||
{
|
||||
wxCloseEvent event(wxEVT_END_SESSION, wxID_ANY);
|
||||
event.SetEventObject(this);
|
||||
event.SetCanVeto(false);
|
||||
ProcessEvent(event);
|
||||
}
|
||||
return noErr ;
|
||||
}
|
||||
|
||||
// AEROApp calls MacReopenApp
|
||||
|
||||
short wxApp::MacHandleAERApp(const WXEVENTREF WXUNUSED(event) , WXEVENTREF WXUNUSED(reply))
|
||||
{
|
||||
MacReopenApp() ;
|
||||
|
||||
return noErr ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Support Routines linking the Mac...File Calls to the Document Manager
|
||||
@@ -445,347 +233,6 @@ bool wxApp::OSXOnShouldTerminate()
|
||||
}
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Macintosh CommandID support - converting between native and wx IDs
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// if no native match they just return the passed-in id
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
|
||||
// platform specific static variables
|
||||
static const short kwxMacAppleMenuId = 1 ;
|
||||
|
||||
struct IdPair
|
||||
{
|
||||
UInt32 macId ;
|
||||
int wxId ;
|
||||
} ;
|
||||
|
||||
IdPair gCommandIds [] =
|
||||
{
|
||||
{ kHICommandCut , wxID_CUT } ,
|
||||
{ kHICommandCopy , wxID_COPY } ,
|
||||
{ kHICommandPaste , wxID_PASTE } ,
|
||||
{ kHICommandSelectAll , wxID_SELECTALL } ,
|
||||
{ kHICommandClear , wxID_CLEAR } ,
|
||||
{ kHICommandUndo , wxID_UNDO } ,
|
||||
{ kHICommandRedo , wxID_REDO } ,
|
||||
} ;
|
||||
|
||||
int wxMacCommandToId( UInt32 macCommandId )
|
||||
{
|
||||
int wxid = 0 ;
|
||||
|
||||
switch ( macCommandId )
|
||||
{
|
||||
case kHICommandPreferences :
|
||||
wxid = wxApp::s_macPreferencesMenuItemId ;
|
||||
break ;
|
||||
|
||||
case kHICommandQuit :
|
||||
wxid = wxApp::s_macExitMenuItemId ;
|
||||
break ;
|
||||
|
||||
case kHICommandAbout :
|
||||
wxid = wxApp::s_macAboutMenuItemId ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
{
|
||||
for ( size_t i = 0 ; i < WXSIZEOF(gCommandIds) ; ++i )
|
||||
{
|
||||
if ( gCommandIds[i].macId == macCommandId )
|
||||
{
|
||||
wxid = gCommandIds[i].wxId ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( wxid == 0 )
|
||||
wxid = (int) macCommandId ;
|
||||
|
||||
return wxid ;
|
||||
}
|
||||
|
||||
UInt32 wxIdToMacCommand( int wxId )
|
||||
{
|
||||
UInt32 macId = 0 ;
|
||||
|
||||
if ( wxId == wxApp::s_macPreferencesMenuItemId )
|
||||
macId = kHICommandPreferences ;
|
||||
else if (wxId == wxApp::s_macExitMenuItemId)
|
||||
macId = kHICommandQuit ;
|
||||
else if (wxId == wxApp::s_macAboutMenuItemId)
|
||||
macId = kHICommandAbout ;
|
||||
else
|
||||
{
|
||||
for ( size_t i = 0 ; i < WXSIZEOF(gCommandIds) ; ++i )
|
||||
{
|
||||
if ( gCommandIds[i].wxId == wxId )
|
||||
{
|
||||
macId = gCommandIds[i].macId ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( macId == 0 )
|
||||
macId = (int) wxId ;
|
||||
|
||||
return macId ;
|
||||
}
|
||||
|
||||
wxMenu* wxFindMenuFromMacCommand( const HICommand &command , wxMenuItem* &item )
|
||||
{
|
||||
wxMenu* itemMenu = NULL ;
|
||||
#ifndef __WXUNIVERSAL__
|
||||
int id = 0 ;
|
||||
|
||||
// for 'standard' commands which don't have a wx-menu
|
||||
if ( command.commandID == kHICommandPreferences || command.commandID == kHICommandQuit || command.commandID == kHICommandAbout )
|
||||
{
|
||||
id = wxMacCommandToId( command.commandID ) ;
|
||||
|
||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||
if ( mbar )
|
||||
item = mbar->FindItem( id , &itemMenu ) ;
|
||||
}
|
||||
else if ( command.commandID != 0 && command.menu.menuRef != 0 && command.menu.menuItemIndex != 0 )
|
||||
{
|
||||
id = wxMacCommandToId( command.commandID ) ;
|
||||
// make sure it is one of our own menus, or of the 'synthetic' apple and help menus , otherwise don't touch
|
||||
MenuItemIndex firstUserHelpMenuItem ;
|
||||
static MenuHandle helpMenuHandle = NULL ;
|
||||
if ( helpMenuHandle == NULL )
|
||||
{
|
||||
if ( UMAGetHelpMenuDontCreate( &helpMenuHandle , &firstUserHelpMenuItem) != noErr )
|
||||
helpMenuHandle = NULL ;
|
||||
}
|
||||
|
||||
// is it part of the application or the Help menu, then look for the id directly
|
||||
if ( ( GetMenuHandle( kwxMacAppleMenuId ) != NULL && command.menu.menuRef == GetMenuHandle( kwxMacAppleMenuId ) ) ||
|
||||
( helpMenuHandle != NULL && command.menu.menuRef == helpMenuHandle ) ||
|
||||
wxMenuBar::MacGetWindowMenuHMenu() != NULL && command.menu.menuRef == wxMenuBar::MacGetWindowMenuHMenu() )
|
||||
{
|
||||
wxMenuBar* mbar = wxMenuBar::MacGetInstalledMenuBar() ;
|
||||
if ( mbar )
|
||||
item = mbar->FindItem( id , &itemMenu ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
URefCon refCon = 0 ;
|
||||
|
||||
GetMenuItemRefCon( command.menu.menuRef , command.menu.menuItemIndex , &refCon ) ;
|
||||
itemMenu = wxFindMenuFromMacMenu( command.menu.menuRef ) ;
|
||||
if ( itemMenu != NULL && refCon != 0)
|
||||
item = (wxMenuItem*) refCon;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return itemMenu ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Carbon Event Handler
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
|
||||
static const EventTypeSpec eventList[] =
|
||||
{
|
||||
{ kEventClassCommand, kEventProcessCommand } ,
|
||||
{ kEventClassCommand, kEventCommandUpdateStatus } ,
|
||||
|
||||
{ kEventClassMenu, kEventMenuOpening },
|
||||
{ kEventClassMenu, kEventMenuClosed },
|
||||
{ kEventClassMenu, kEventMenuTargetItem },
|
||||
|
||||
{ kEventClassApplication , kEventAppActivated } ,
|
||||
{ kEventClassApplication , kEventAppDeactivated } ,
|
||||
// handling the quit event is not recommended by apple
|
||||
// rather using the quit apple event - which we do
|
||||
|
||||
{ kEventClassAppleEvent , kEventAppleEvent } ,
|
||||
|
||||
{ kEventClassMouse , kEventMouseDown } ,
|
||||
{ kEventClassMouse , kEventMouseMoved } ,
|
||||
{ kEventClassMouse , kEventMouseUp } ,
|
||||
{ kEventClassMouse , kEventMouseDragged } ,
|
||||
{ 'WXMC' , 'WXMC' }
|
||||
} ;
|
||||
|
||||
static pascal OSStatus
|
||||
wxMacAppMenuEventHandler( EventHandlerCallRef WXUNUSED(handler),
|
||||
EventRef event,
|
||||
void *WXUNUSED(data) )
|
||||
{
|
||||
wxMacCarbonEvent cEvent( event ) ;
|
||||
MenuRef menuRef = cEvent.GetParameter<MenuRef>(kEventParamDirectObject) ;
|
||||
#ifndef __WXUNIVERSAL__
|
||||
wxMenu* menu = wxFindMenuFromMacMenu( menuRef ) ;
|
||||
|
||||
if ( menu )
|
||||
{
|
||||
switch (GetEventKind(event))
|
||||
{
|
||||
case kEventMenuOpening:
|
||||
menu->HandleMenuOpened();
|
||||
break;
|
||||
|
||||
case kEventMenuClosed:
|
||||
menu->HandleMenuClosed();
|
||||
break;
|
||||
|
||||
case kEventMenuTargetItem:
|
||||
{
|
||||
HICommand command ;
|
||||
|
||||
command.menu.menuRef = menuRef;
|
||||
command.menu.menuItemIndex = cEvent.GetParameter<MenuItemIndex>(kEventParamMenuItemIndex,typeMenuItemIndex) ;
|
||||
command.commandID = cEvent.GetParameter<MenuCommand>(kEventParamMenuCommand,typeMenuCommand) ;
|
||||
if (command.commandID != 0)
|
||||
{
|
||||
wxMenuItem* item = NULL ;
|
||||
wxMenu* itemMenu = wxFindMenuFromMacCommand( command , item ) ;
|
||||
if ( itemMenu && item )
|
||||
itemMenu->HandleMenuItemHighlighted( item );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Unexpected menu event kind"));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
return eventNotHandledErr;
|
||||
}
|
||||
|
||||
static pascal OSStatus
|
||||
wxMacAppCommandEventHandler( EventHandlerCallRef WXUNUSED(handler) ,
|
||||
EventRef event ,
|
||||
void *WXUNUSED(data) )
|
||||
{
|
||||
OSStatus result = eventNotHandledErr ;
|
||||
|
||||
HICommand command ;
|
||||
|
||||
wxMacCarbonEvent cEvent( event ) ;
|
||||
cEvent.GetParameter<HICommand>(kEventParamDirectObject,typeHICommand,&command) ;
|
||||
|
||||
wxMenuItem* item = NULL ;
|
||||
wxMenu* itemMenu = wxFindMenuFromMacCommand( command , item ) ;
|
||||
|
||||
if ( item )
|
||||
{
|
||||
wxASSERT( itemMenu != NULL ) ;
|
||||
|
||||
switch ( cEvent.GetKind() )
|
||||
{
|
||||
case kEventProcessCommand :
|
||||
if ( itemMenu->HandleCommandProcess( item ) )
|
||||
result = noErr;
|
||||
break ;
|
||||
|
||||
case kEventCommandUpdateStatus:
|
||||
if ( itemMenu->HandleCommandUpdateStatus( item ) )
|
||||
result = noErr;
|
||||
break ;
|
||||
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
static pascal OSStatus
|
||||
wxMacAppApplicationEventHandler( EventHandlerCallRef WXUNUSED(handler) ,
|
||||
EventRef event ,
|
||||
void *WXUNUSED(data) )
|
||||
{
|
||||
OSStatus result = eventNotHandledErr ;
|
||||
switch ( GetEventKind( event ) )
|
||||
{
|
||||
case kEventAppActivated :
|
||||
if ( wxTheApp )
|
||||
wxTheApp->SetActive( true , NULL ) ;
|
||||
result = noErr ;
|
||||
break ;
|
||||
|
||||
case kEventAppDeactivated :
|
||||
if ( wxTheApp )
|
||||
wxTheApp->SetActive( false , NULL ) ;
|
||||
result = noErr ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
|
||||
{
|
||||
EventRef formerEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ;
|
||||
EventHandlerCallRef formerEventHandlerCallRef = (EventHandlerCallRef) wxTheApp->MacGetCurrentEventHandlerCallRef() ;
|
||||
wxTheApp->MacSetCurrentEvent( event , handler ) ;
|
||||
|
||||
OSStatus result = eventNotHandledErr ;
|
||||
switch ( GetEventClass( event ) )
|
||||
{
|
||||
#ifndef __LP64__
|
||||
case kEventClassCommand :
|
||||
result = wxMacAppCommandEventHandler( handler , event , data ) ;
|
||||
break ;
|
||||
#endif
|
||||
case kEventClassApplication :
|
||||
result = wxMacAppApplicationEventHandler( handler , event , data ) ;
|
||||
break ;
|
||||
#ifndef __LP64__
|
||||
case kEventClassMenu :
|
||||
result = wxMacAppMenuEventHandler( handler , event , data ) ;
|
||||
break ;
|
||||
|
||||
case kEventClassMouse :
|
||||
{
|
||||
wxMacCarbonEvent cEvent( event ) ;
|
||||
|
||||
WindowRef window ;
|
||||
Point screenMouseLocation = cEvent.GetParameter<Point>(kEventParamMouseLocation) ;
|
||||
::FindWindow(screenMouseLocation, &window);
|
||||
// only send this event in case it had not already been sent to a tlw, as we get
|
||||
// double events otherwise (in case event.skip) was called
|
||||
if ( window == NULL )
|
||||
result = wxMacTopLevelMouseEventHandler( handler , event , NULL ) ;
|
||||
}
|
||||
break ;
|
||||
#endif
|
||||
case kEventClassAppleEvent :
|
||||
result = AEProcessEvent(event);
|
||||
break ;
|
||||
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
|
||||
wxTheApp->MacSetCurrentEvent( formerEvent, formerEventHandlerCallRef ) ;
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacAppEventHandler )
|
||||
#endif
|
||||
|
||||
#if wxDEBUG_LEVEL && wxOSX_USE_COCOA_OR_CARBON
|
||||
|
||||
pascal static void
|
||||
@@ -895,14 +342,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
bool wxApp::CallOnInit()
|
||||
{
|
||||
wxMacAutoreleasePool autoreleasepool;
|
||||
return OnInit();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool wxApp::OnInitGui()
|
||||
{
|
||||
if ( !wxAppBase::OnInitGui() )
|
||||
@@ -926,77 +365,6 @@ int wxApp::OnRun()
|
||||
return wxAppBase::OnRun();
|
||||
}
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
bool wxApp::DoInitGui()
|
||||
{
|
||||
InstallStandardEventHandler( GetApplicationEventTarget() ) ;
|
||||
if (!sm_isEmbedded)
|
||||
{
|
||||
InstallApplicationEventHandler(
|
||||
GetwxMacAppEventHandlerUPP(),
|
||||
GetEventTypeCount(eventList), eventList, wxTheApp, (EventHandlerRef *)&(wxTheApp->m_macEventHandler));
|
||||
}
|
||||
|
||||
if (!sm_isEmbedded)
|
||||
{
|
||||
sODocHandler = NewAEEventHandlerUPP(AEHandleODoc) ;
|
||||
sGURLHandler = NewAEEventHandlerUPP(AEHandleGURL) ;
|
||||
sOAppHandler = NewAEEventHandlerUPP(AEHandleOApp) ;
|
||||
sPDocHandler = NewAEEventHandlerUPP(AEHandlePDoc) ;
|
||||
sRAppHandler = NewAEEventHandlerUPP(AEHandleRApp) ;
|
||||
sQuitHandler = NewAEEventHandlerUPP(AEHandleQuit) ;
|
||||
|
||||
AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments ,
|
||||
sODocHandler , 0 , FALSE ) ;
|
||||
AEInstallEventHandler( kInternetEventClass, kAEGetURL,
|
||||
sGURLHandler , 0 , FALSE ) ;
|
||||
AEInstallEventHandler( kCoreEventClass , kAEOpenApplication ,
|
||||
sOAppHandler , 0 , FALSE ) ;
|
||||
AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments ,
|
||||
sPDocHandler , 0 , FALSE ) ;
|
||||
AEInstallEventHandler( kCoreEventClass , kAEReopenApplication ,
|
||||
sRAppHandler , 0 , FALSE ) ;
|
||||
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
|
||||
sQuitHandler , 0 , FALSE ) ;
|
||||
}
|
||||
|
||||
if ( !wxMacInitCocoa() )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxApp::DoCleanUp()
|
||||
{
|
||||
if (!sm_isEmbedded)
|
||||
RemoveEventHandler( (EventHandlerRef)(wxTheApp->m_macEventHandler) );
|
||||
|
||||
if (!sm_isEmbedded)
|
||||
{
|
||||
AERemoveEventHandler( kCoreEventClass , kAEOpenDocuments ,
|
||||
sODocHandler , FALSE ) ;
|
||||
AERemoveEventHandler( kInternetEventClass, kAEGetURL,
|
||||
sGURLHandler , FALSE ) ;
|
||||
AERemoveEventHandler( kCoreEventClass , kAEOpenApplication ,
|
||||
sOAppHandler , FALSE ) ;
|
||||
AERemoveEventHandler( kCoreEventClass , kAEPrintDocuments ,
|
||||
sPDocHandler , FALSE ) ;
|
||||
AERemoveEventHandler( kCoreEventClass , kAEReopenApplication ,
|
||||
sRAppHandler , FALSE ) ;
|
||||
AERemoveEventHandler( kCoreEventClass , kAEQuitApplication ,
|
||||
sQuitHandler , FALSE ) ;
|
||||
|
||||
DisposeAEEventHandlerUPP( sODocHandler ) ;
|
||||
DisposeAEEventHandlerUPP( sGURLHandler ) ;
|
||||
DisposeAEEventHandlerUPP( sOAppHandler ) ;
|
||||
DisposeAEEventHandlerUPP( sPDocHandler ) ;
|
||||
DisposeAEEventHandlerUPP( sRAppHandler ) ;
|
||||
DisposeAEEventHandlerUPP( sQuitHandler ) ;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void wxApp::CleanUp()
|
||||
{
|
||||
wxMacAutoreleasePool autoreleasepool;
|
||||
@@ -1410,30 +778,6 @@ int wxMacKeyCodeToModifier(wxKeyCode key)
|
||||
|
||||
// defined in utils.mm
|
||||
|
||||
#elif wxOSX_USE_CARBON
|
||||
|
||||
wxMouseState wxGetMouseState()
|
||||
{
|
||||
wxMouseState ms;
|
||||
|
||||
wxPoint pt = wxGetMousePosition();
|
||||
ms.SetX(pt.x);
|
||||
ms.SetY(pt.y);
|
||||
|
||||
UInt32 buttons = GetCurrentButtonState();
|
||||
ms.SetLeftDown( (buttons & 0x01) != 0 );
|
||||
ms.SetMiddleDown( (buttons & 0x04) != 0 );
|
||||
ms.SetRightDown( (buttons & 0x02) != 0 );
|
||||
|
||||
UInt32 modifiers = GetCurrentKeyModifiers();
|
||||
ms.SetRawControlDown(modifiers & controlKey);
|
||||
ms.SetShiftDown(modifiers & shiftKey);
|
||||
ms.SetAltDown(modifiers & optionKey);
|
||||
ms.SetControlDown(modifiers & cmdKey);
|
||||
|
||||
return ms;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// TODO : once the new key/char handling is tested, move all the code to wxWindow
|
||||
@@ -1469,79 +813,6 @@ bool wxApp::MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers
|
||||
|
||||
bool handled = false ;
|
||||
|
||||
#if wxOSX_USE_CARBON
|
||||
long keyval = event.m_keyCode ;
|
||||
|
||||
{
|
||||
wxKeyEvent eventCharHook(wxEVT_CHAR_HOOK, event);
|
||||
handled = focus->HandleWindowEvent( eventCharHook );
|
||||
if ( handled && eventCharHook.IsNextEventAllowed() )
|
||||
handled = false ;
|
||||
}
|
||||
|
||||
if ( !handled )
|
||||
{
|
||||
handled = focus->HandleWindowEvent( event ) ;
|
||||
}
|
||||
|
||||
if ( !handled && (keyval == WXK_TAB) )
|
||||
{
|
||||
wxWindow* iter = focus->GetParent() ;
|
||||
while ( iter && !handled )
|
||||
{
|
||||
if ( iter->HasFlag( wxTAB_TRAVERSAL ) )
|
||||
{
|
||||
wxNavigationKeyEvent new_event;
|
||||
new_event.SetEventObject( focus );
|
||||
new_event.SetDirection( !event.ShiftDown() );
|
||||
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||
new_event.SetWindowChange( event.ControlDown() );
|
||||
new_event.SetCurrentFocus( focus );
|
||||
handled = focus->GetParent()->HandleWindowEvent( new_event );
|
||||
if ( handled && new_event.GetSkipped() )
|
||||
handled = false ;
|
||||
}
|
||||
|
||||
iter = iter->GetParent() ;
|
||||
}
|
||||
}
|
||||
|
||||
// backdoor handler for default return and command escape
|
||||
if ( !handled && (!focus->IsKindOf(CLASSINFO(wxControl) ) || !focus->AcceptsFocus() ) )
|
||||
{
|
||||
// if window is not having a focus still testing for default enter or cancel
|
||||
// TODO: add the UMA version for ActiveNonFloatingWindow
|
||||
#ifndef __LP64__
|
||||
wxWindow* focus = wxNonOwnedWindow::GetFromWXWindow( (WXWindow) FrontWindow() ) ;
|
||||
if ( focus )
|
||||
{
|
||||
if ( keyval == WXK_RETURN || keyval == WXK_NUMPAD_ENTER )
|
||||
{
|
||||
wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(focus), wxTopLevelWindow);
|
||||
if ( tlw && tlw->GetDefaultItem() )
|
||||
{
|
||||
wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
|
||||
if ( def && def->IsEnabled() )
|
||||
{
|
||||
wxCommandEvent event(wxEVT_BUTTON, def->GetId() );
|
||||
event.SetEventObject(def);
|
||||
def->Command(event);
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (keyval == WXK_ESCAPE || (keyval == '.' && modifiers & cmdKey ) )
|
||||
{
|
||||
// generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs)
|
||||
wxCommandEvent new_event(wxEVT_BUTTON,wxID_CANCEL);
|
||||
new_event.SetEventObject( focus );
|
||||
handled = focus->HandleWindowEvent( new_event );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
return handled ;
|
||||
}
|
||||
|
||||
@@ -1643,12 +914,4 @@ void wxApp::MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymess
|
||||
|
||||
void wxApp::MacHideApp()
|
||||
{
|
||||
#if wxOSX_USE_CARBON
|
||||
wxMacCarbonEvent event( kEventClassCommand , kEventCommandProcess );
|
||||
HICommand command;
|
||||
memset( &command, 0 , sizeof(command) );
|
||||
command.commandID = kHICommandHide ;
|
||||
event.SetParameter<HICommand>(kEventParamDirectObject, command );
|
||||
SendEventToApplication( event );
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user