#include <string.h>
// mac
-
+#if wxOSX_USE_CARBON
#include "wx/osx/uma.h"
+#else
+#include "wx/osx/private.h"
+#endif
-#ifdef __DARWIN__
-# include <CoreServices/CoreServices.h>
-# if defined(WXMAKINGDLL_CORE)
-# include <mach-o/dyld.h>
-# endif
+#if defined(WXMAKINGDLL_CORE)
+# include <mach-o/dyld.h>
#endif
// Keep linker from discarding wxStockGDIMac
// statics for implementation
static bool s_inYield = false;
static bool s_inReceiveEvent = false ;
+#if wxOSX_USE_COCOA_OR_CARBON
static EventTime sleepTime = kEventDurationNoWait ;
-
+#endif
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
bool wxApp::sm_isEmbedded = false; // Normally we're not a plugin
+#if wxOSX_USE_COCOA_OR_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 noErr ;
}
+#endif
+
//----------------------------------------------------------------------
// Support Routines linking the Mac...File Calls to the Document Manager
//----------------------------------------------------------------------
// if no native match they just return the passed-in id
+#if wxOSX_USE_CARBON
+
struct IdPair
{
UInt32 macId ;
return itemMenu ;
}
+#endif
+
//----------------------------------------------------------------------
// Carbon Event Handler
//----------------------------------------------------------------------
+#if wxOSX_USE_CARBON
+
static const EventTypeSpec eventList[] =
{
{ kEventClassCommand, kEventProcessCommand } ,
return eventNotHandledErr;
}
-#ifndef __LP64__
static pascal OSStatus
wxMacAppCommandEventHandler( EventHandlerCallRef WXUNUSED(handler) ,
EventRef event ,
}
return result ;
}
-#endif
static pascal OSStatus
wxMacAppApplicationEventHandler( EventHandlerCallRef WXUNUSED(handler) ,
}
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacAppEventHandler )
+#endif
-#ifdef __WXDEBUG__
+#if defined( __WXDEBUG__ ) && wxOSX_USE_COCOA_OR_CARBON
pascal static void
wxMacAssertOutputHandler(OSType WXUNUSED(componentSignature),
{
// Mac-specific
-#ifdef __WXDEBUG__
+#if defined( __WXDEBUG__ ) && wxOSX_USE_COCOA_OR_CARBON
InstallDebugAssertOutputHandler( NewDebugAssertOutputHandlerUPP( wxMacAssertOutputHandler ) );
#endif
- UMAInitToolbox( 4, sm_isEmbedded ) ;
-// TODO CHECK Can Be Removed SetEventMask( everyEvent ) ;
-
// Mac OS X passes a process serial number command line argument when
// the application is launched from the Finder. This argument must be
// removed from the command line arguments before being handled by the
return true;
}
-AEEventHandlerUPP sODocHandler = NULL ;
-AEEventHandlerUPP sGURLHandler = NULL ;
-AEEventHandlerUPP sOAppHandler = NULL ;
-AEEventHandlerUPP sPDocHandler = NULL ;
-AEEventHandlerUPP sRAppHandler = NULL ;
-AEEventHandlerUPP sQuitHandler = NULL ;
-
bool wxApp::OnInitGui()
{
if ( !wxAppBase::OnInitGui() )
return false ;
-#ifndef __LP64__
+#if wxOSX_USE_CARBON
InstallStandardEventHandler( GetApplicationEventTarget() ) ;
if (!sm_isEmbedded)
{
}
#endif
+#if wxOSX_USE_COCOA_OR_CARBON
if (!sm_isEmbedded)
{
sODocHandler = NewAEEventHandlerUPP(AEHandleODoc) ;
AEInstallEventHandler( kCoreEventClass , kAEQuitApplication ,
sQuitHandler , 0 , FALSE ) ;
}
-
+#endif
+#if wxOSX_USE_CARBON
if ( !wxMacInitCocoa() )
return false;
+#endif
return true ;
}
// One last chance for pending objects to be cleaned up
wxTheApp->DeletePendingObjects();
+#if wxOSX_USE_COCOA_OR_CARBON
+
if (!sm_isEmbedded)
RemoveEventHandler( (EventHandlerRef)(wxTheApp->m_macEventHandler) );
DisposeAEEventHandlerUPP( sQuitHandler ) ;
}
+#endif
+
wxAppBase::CleanUp();
}
// by definition yield should handle all non-processed events
+#if wxOSX_USE_COCOA_OR_CARBON
+
EventRef theEvent;
OSStatus status = noErr ;
ReleaseEvent(theEvent);
}
}
+
+#else
+
+#endif
s_inYield = false;
void wxApp::MacDoOneEvent()
{
+#if wxOSX_USE_COCOA_OR_CARBON
wxMacAutoreleasePool autoreleasepool;
EventRef theEvent;
break;
}
// repeaters
-
+#else
+#endif
DeletePendingObjects() ;
}
return array;
}
+//
+//
+//
+
+
+//
+//
+//
+
void wxApp::MacHandleOneEvent( WXEVENTREF evr )
{
+#if wxOSX_USE_COCOA_OR_CARBON
EventTargetRef theTarget;
theTarget = GetEventDispatcherTarget();
m_macCurrentEvent = evr ;
wxMutexGuiLeaveOrEnter();
#endif // wxUSE_THREADS
+#else
+ // TODO Threads
+#endif
+
+
CFArrayRemoveAllValues( GetAutoReleaseArray() );
}
CFArrayAppendValue( GetAutoReleaseArray(), cfrefobj );
}
+#if wxOSX_USE_COCOA_OR_CARBON
+
long wxMacTranslateKey(unsigned char key, unsigned char code)
{
long retval = key ;
return 0;
}
}
+#endif
wxMouseState wxGetMouseState()
{
wxMouseState ms;
+#if wxOSX_USE_COCOA_OR_CARBON
wxPoint pt = wxGetMousePosition();
ms.SetX(pt.x);
ms.SetAltDown(modifiers & optionKey);
ms.SetMetaDown(modifiers & cmdKey);
+#endif
return ms;
}
{
if ( !focus )
return false ;
-
wxKeyEvent event(wxEVT_CHAR) ;
MacCreateKeyEvent( event, focus , keymessage , modifiers , when , wherex , wherey , uniChar ) ;
long keyval = event.m_keyCode ;
bool handled = false ;
+#if wxOSX_USE_CARBON
wxNonOwnedWindow *tlw = focus->MacGetTopLevelWindow() ;
if (tlw)
}
// backdoor handler for default return and command escape
- if ( !handled && (!focus->IsKindOf(CLASSINFO(wxControl) ) || !focus->MacCanFocus() ) )
+ 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 = wxFindWinFromMacWindow( FrontWindow() ) ;
+ wxWindow* focus = wxNonOwnedWindow::GetFromWXWindow( (WXWindow) FrontWindow() ) ;
if ( focus )
{
if ( keyval == WXK_RETURN || keyval == WXK_NUMPAD_ENTER )
}
#endif
}
+#endif
return handled ;
}
// This method handles common code for SendKeyDown, SendKeyUp, and SendChar events.
void wxApp::MacCreateKeyEvent( wxKeyEvent& event, wxWindow* focus , long keymessage , long modifiers , long when , short wherex , short wherey , wxChar uniChar )
{
+#if wxOSX_USE_COCOA_OR_CARBON
short keycode, keychar ;
keychar = short(keymessage & charCodeMask);
event.m_y = wherey;
event.SetTimestamp(when);
event.SetEventObject(focus);
+#endif
}
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
}