#pragma implementation "app.h"
#endif
+#include "wx/window.h"
#include "wx/frame.h"
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/cursor.h"
+#include "wx/intl.h"
#include "wx/icon.h"
#include "wx/palette.h"
#include "wx/dc.h"
#include "wx/module.h"
#include "wx/memory.h"
#include "wx/tooltip.h"
+#include "wx/menu.h"
#if wxUSE_WX_RESOURCES
#include "wx/resource.h"
#endif
// mac
-#if __option(profile)
+#ifndef __UNIX__
+ #if __option(profile)
#include <profiler.h>
+ #endif
#endif
#include "apprsrc.h"
-#include <wx/mac/uma.h>
-#include <wx/mac/macnotfy.h>
+#include "wx/mac/uma.h"
+#include "wx/mac/macnotfy.h"
#if wxUSE_SOCKETS
-#include <OpenTransport.h>
-#include <OpenTptInternet.h>
+ #ifdef __APPLE__
+ #include <CoreServices/CoreServices.h>
+ #else
+ #include <OpenTransport.h>
+ #include <OpenTptInternet.h>
+ #endif
#endif
extern char *wxBuffer;
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
wxString wxApp::s_macHelpMenuTitleName = "&Help" ;
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long refcon )
+#else
pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
+#endif
{
wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ;
}
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon )
+#else
pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
+#endif
{
wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ;
}
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon )
+#else
pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
+#endif
{
wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ;
}
+#if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340)
+pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon )
+#else
pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , unsigned long refcon )
+#endif
{
wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
UMAInitToolbox( 4 ) ;
UMAShowWatchCursor() ;
- AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) , (long) wxTheApp , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) , (long) wxTheApp , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) , (long) wxTheApp , FALSE ) ;
- AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) , (long) wxTheApp , FALSE ) ;
+#ifdef __UNIX__
+ AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , AEHandleODoc ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , AEHandleOApp ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , AEHandlePDoc ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , AEHandleQuit ,
+ (long) wxTheApp , FALSE ) ;
+#else
+ AEInstallEventHandler( kCoreEventClass , kAEOpenDocuments , NewAEEventHandlerProc(AEHandleODoc) ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEOpenApplication , NewAEEventHandlerProc(AEHandleOApp) ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEPrintDocuments , NewAEEventHandlerProc(AEHandlePDoc) ,
+ (long) wxTheApp , FALSE ) ;
+ AEInstallEventHandler( kCoreEventClass , kAEQuitApplication , NewAEEventHandlerProc(AEHandleQuit) ,
+ (long) wxTheApp , FALSE ) ;
+#endif
+#ifndef __UNIX__
// test the minimal configuration necessary
+ #if !TARGET_CARBON
long theSystem ;
- long theMachine;
+ long theMachine;
if (Gestalt(gestaltMachineType, &theMachine) != noErr)
{
{
error = kMacSTROldSystem ;
}
- #if !TARGET_CARBON
else if ((long)GetApplLimit() - (long)ApplicationZone() < kMacMinHeap)
{
error = kMacSTRSmallSize;
}
}
*/
+#endif
// if we encountered any problems so far, give the error code and exit immediately
return FALSE ;
}
-#if __option(profile)
+#ifndef __UNIX__
+ #if __option(profile)
ProfilerInit( collectDetailed, bestTimeBase , 20000 , 40 ) ;
+ #endif
#endif
// now avoid exceptions thrown for new (bad_alloc)
+#ifndef __UNIX__
std::__throws_bad_alloc = FALSE ;
+#endif
s_macCursorRgn = ::NewRgn() ;
wxBitmap::InitStandardHandlers();
wxModule::RegisterModules();
- if (!wxModule::InitializeModules())
+ if (!wxModule::InitializeModules()) {
return FALSE;
+ }
wxWinMacWindowList = new wxList(wxKEY_INTEGER);
wxWinMacControlList = new wxList(wxKEY_INTEGER);
wxClassInfo::CleanUpClasses();
-#if __option(profile)
- ProfilerDump( "\papp.prof" ) ;
- ProfilerTerm() ;
+#ifndef __UNIX__
+ #if __option(profile)
+ ProfilerDump( "\papp.prof" ) ;
+ ProfilerTerm() ;
+ #endif
#endif
delete wxTheApp;
wxDebugContext::SetCheckpoint();
#endif
#endif
- if (!wxApp::Initialize())
+ if (!wxApp::Initialize()) {
return 0;
+ }
// create the application object or ensure that one already exists
if (!wxTheApp)
{
wxApp::CleanUp();
return retValue;
-};
+}
// Static member initialization
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
}
// Yield to other processes
+
+static bool gs_inYield = FALSE;
+
bool wxYield()
{
+#ifdef __WXDEBUG__
+ if (gs_inYield)
+ wxFAIL_MSG( wxT("wxYield called recursively" ) );
+#endif
+
+ gs_inYield = TRUE;
+
#if wxUSE_THREADS
- YieldToAnyThread() ;
+ YieldToAnyThread() ;
#endif
- EventRecord event ;
+ EventRecord event ;
long sleepTime = 0 ; //::GetCaretTime();
}
wxMacProcessNotifierAndPendingEvents() ;
- return TRUE;
+
+ gs_inYield = FALSE;
+
+ return TRUE;
+}
+
+// Yield to incoming messages; but fail silently if recursion is detected.
+bool wxYieldIfNeeded()
+{
+ if (gs_inYield)
+ return FALSE;
+
+ return wxYield();
}
// platform specifics
s_lastMouseDown = 0;
break;
case inGrow:
+ {
int growResult = GrowWindow(window , ev->where, &screenBits.bounds);
if (growResult != 0)
{
}
}
s_lastMouseDown = 0;
+ }
break;
case inZoomIn:
case inZoomOut:
case suspendResumeMessage :
{
bool isResuming = ev->message & resumeFlag ;
+#if !TARGET_CARBON
bool convertClipboard = ev->message & convertClipboardFlag ;
+#else
+ bool convertClipboard = false;
+#endif
bool doesActivate = UMAGetProcessModeDoesActivateOnFGSwitch() ;
if ( isResuming )
{
wxWindow* currentMouseWindow = NULL ;
- MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) , ¤tMouseWindow ) ;
+ wxWindow::MacGetWindowFromPoint( wxPoint( ev->where.h , ev->where.v ) ,
+ ¤tMouseWindow ) ;
if ( currentMouseWindow != wxWindow::s_lastMouseWindow )
{