pascal OSErr AEHandleODoc( const AppleEvent *event , AppleEvent *reply , long refcon )
{
- wxApp* app = (wxApp*) refcon ;
+ // GD: UNUSED wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEODoc( (AppleEvent*) event , reply) ;
}
pascal OSErr AEHandleOApp( const AppleEvent *event , AppleEvent *reply , long refcon )
{
- wxApp* app = (wxApp*) refcon ;
+ // GD: UNUSED wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEOApp( (AppleEvent*) event , reply ) ;
}
pascal OSErr AEHandlePDoc( const AppleEvent *event , AppleEvent *reply , long refcon )
{
- wxApp* app = (wxApp*) refcon ;
+ // GD: UNUSED wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEPDoc( (AppleEvent*) event , reply ) ;
}
pascal OSErr AEHandleQuit( const AppleEvent *event , AppleEvent *reply , long refcon )
{
- wxApp* app = (wxApp*) refcon ;
+ // GD: UNUSED wxApp* app = (wxApp*) refcon ;
return wxTheApp->MacHandleAEQuit( (AppleEvent*) event , reply) ;
}
int len = strlen ( p ) ;
wxMacConvertFromPC( ptr , ptr , len ) ;
- for ( int i = 0 ; i < strlen ( ptr ) ; i++ )
+ for ( unsigned int i = 0 ; i < strlen ( ptr ) ; i++ )
{
if ( ptr[i] == '&' && ptr[i]+1 != ' ' )
{
CopyCStringToPascal( from , to ) ;
}
}
+#ifdef WXMAKINGDLL
+#ifndef __DARWIN__
+// we know it's there ;-)
+WXIMPORT char std::__throws_bad_alloc ;
+#endif
+#endif
bool wxApp::Initialize()
{
if ( error )
{
+ wxStAppResource resload ;
short itemHit;
Str255 message;
#endif // wxUSE_LOG
#endif
+ wxWinMacWindowList = new wxList(wxKEY_INTEGER);
+ wxWinMacControlList = new wxList(wxKEY_INTEGER);
+
wxInitializeStockLists();
wxInitializeStockObjects();
return FALSE;
}
- wxWinMacWindowList = new wxList(wxKEY_INTEGER);
- wxWinMacControlList = new wxList(wxKEY_INTEGER);
-
wxMacCreateNotifierTable() ;
UMAShowArrowCursor() ;
// wxEntry
//----------------------------------------------------------------------
-int wxEntryStart( int argc, char *argv[] )
+short gCurrentResource = -1 ;
+
+wxStAppResource::wxStAppResource()
{
- return wxApp::Initialize();
+ m_currentRefNum = CurResFile() ;
+ if ( gCurrentResource != -1 )
+ {
+ UseResFile( gCurrentResource ) ;
+ }
}
+wxStAppResource::~wxStAppResource()
+{
+ if ( m_currentRefNum != -1 )
+ {
+ UseResFile( m_currentRefNum ) ;
+ }
+}
+
+#ifdef WXMAKINGDLL
+
+// for shared libraries we have to manually get the correct resource ref num upon
+// initializing and releasing when terminating, therefore the __wxinitialize and __wxterminate
+// must be used
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void __sinit(void); /* (generated by linker) */
+pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
+pascal void __terminate(void);
-int wxEntryInitGui()
+#ifdef __cplusplus
+}
+#endif
+
+pascal OSErr __wxinitialize(const CFragInitBlock *theInitBlock)
{
- return wxTheApp->OnInitGui();
+ gCurrentResource = -1;
+
+ if (theInitBlock->fragLocator.where == kDataForkCFragLocator) {
+ gCurrentResource =
+ FSpOpenResFile(theInitBlock->fragLocator.u.onDisk.fileSpec,
+ fsRdPerm);
+ }
+ return __initialize( theInitBlock ) ;
}
+pascal void __wxterminate(void)
+{
+ if (gCurrentResource != -1)
+ CloseResFile(gCurrentResource);
+ __terminate() ;
+}
+#endif
-void wxEntryCleanup()
+int WXDLLEXPORT wxEntryStart( int argc, char *argv[] )
{
- wxApp::CleanUp();
+ return wxApp::Initialize();
}
+int WXDLLEXPORT wxEntryInitGui()
+{
+ return wxTheApp->OnInitGui();
+}
+
+void WXDLLEXPORT wxEntryCleanup()
+{
+ wxApp::CleanUp();
+}
int wxEntry( int argc, char *argv[] , bool enterLoop )
{
+ gCurrentResource = CurResFile() ;
#ifdef __MWERKS__
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
// This seems to be necessary since there are 'rogue'
wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
-#ifndef __DARWIN__
+#ifdef __DARWIN__
+ // 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
+ // application (otherwise applications would need to handle it)
+
+ if (argc > 1) {
+ char buf[6] = "";
+ strncpy(buf, argv[1], 5);
+
+ if (strcmp(buf, "-psn_") == 0) {
+ // assume the argument is always the only one and remove it
+ --argc;
+ }
+ }
+#else
argc = 0 ; // currently we don't support files as parameters
#endif
// we could try to get the open apple events here to adjust argc and argv better
// GUI-specific initialization, such as creating an app context.
wxEntryInitGui();
-
// Here frames insert themselves automatically
// into wxTopLevelWindows by getting created
// in OnInit().
m_topWindow = NULL;
wxTheApp = this;
- m_wantDebugOutput = TRUE ;
+#if WXWIN_COMPATIBILITY_2_2
+ m_wantDebugOutput = TRUE;
+#endif
argc = 0;
argv = NULL;
}
}
-wxIcon
-wxApp::GetStdIcon(int which) const
-{
- switch(which)
- {
- case wxICON_INFORMATION:
- return wxIcon("wxICON_INFO");
-
- case wxICON_QUESTION:
- return wxIcon("wxICON_QUESTION");
-
- case wxICON_EXCLAMATION:
- return wxIcon("wxICON_WARNING");
-
- default:
- wxFAIL_MSG(wxT("requested non existent standard icon"));
- // still fall through
-
- case wxICON_HAND:
- return wxIcon("wxICON_ERROR");
- }
-}
-
void wxExit()
{
wxLogError(_("Fatal error: exiting"));
handled = focus->GetEventHandler()->ProcessEvent( event ) ;
if ( !handled )
{
- #if wxUSE_ACCEL
+#if wxUSE_ACCEL
if (!handled)
{
- wxWindow *ancestor = focus;
/*
+ wxWindow *ancestor = focus;
while (ancestor)
{
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
}
*/
}
- #endif // wxUSE_ACCEL
+#endif // wxUSE_ACCEL
}
if (!handled)
{
wxMouseEvent eventleave(event);
eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
wxWindow::s_lastMouseWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
+ eventleave.SetEventObject( wxWindow::s_lastMouseWindow ) ;
wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
}
wxMouseEvent evententer(event);
evententer.SetEventType( wxEVT_ENTER_WINDOW );
currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
-
+ evententer.SetEventObject( currentMouseWindow ) ;
currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
}
wxWindow::s_lastMouseWindow = currentMouseWindow ;