X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b35191eb54e6f307de8406f4f246d8f386fac7bf..dd38c87578df7a24a491401c943988e2bc89b62b:/src/msw/app.cpp diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 8f9782d2d1..0cee8d9455 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -5,8 +5,8 @@ // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Copyright: (c) Julian Smart +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // =========================================================================== @@ -65,17 +65,13 @@ WX_DEFINE_OBJARRAY(wxMsgArray); #endif // wxUSE_THREADS -#if wxUSE_WX_RESOURCES - #include "wx/resource.h" -#endif - #if wxUSE_TOOLTIPS #include "wx/tooltip.h" #endif // wxUSE_TOOLTIPS // OLE is used for drag-and-drop, clipboard, OLE Automation..., but some // compilers don't support it (missing headers, libs, ...) -#if defined(__GNUWIN32_OLD__) || defined(__SC__) || defined(__SALFORDC__) +#if defined(__GNUWIN32_OLD__) || defined(__SYMANTEC__) || defined(__SALFORDC__) #undef wxUSE_OLE #define wxUSE_OLE 0 @@ -118,7 +114,8 @@ #endif #if _WIN32_IE >= 0x0300 && \ - (!defined(__MINGW32__) || wxCHECK_W32API_VERSION( 2, 0 )) + (!defined(__MINGW32__) || wxCHECK_W32API_VERSION( 2, 0 )) && \ + !defined(__CYGWIN__) #include #endif @@ -154,7 +151,11 @@ HICON wxDEFAULT_MDIPARENTFRAME_ICON = (HICON) NULL; HBRUSH wxDisableButtonBrush = (HBRUSH) 0; +#ifdef __DIGITALMARS__ +extern "C" LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM); +#else LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM); +#endif // FIXME wxUSE_ON_FATAL_EXCEPTION is only supported for VC++ now because it // needs compiler support for Win32 SEH. Others (especially Borland) @@ -190,7 +191,7 @@ END_EVENT_TABLE() bool wxApp::Initialize() { // the first thing to do is to check if we're trying to run an Unicode - // program under Win9x w/o MSLU emulation layer - if so, abort right now + // program under Win9x w/o MSLU emulation layer - if so, abort right now // as it has no chance to work #if wxUSE_UNICODE && !wxUSE_UNICODE_MSLU if ( wxGetOsVersion() != wxWINDOWS_NT ) @@ -224,10 +225,6 @@ bool wxApp::Initialize() wxInitializeStockLists(); wxInitializeStockObjects(); -#if wxUSE_WX_RESOURCES - wxInitializeResourceSystem(); -#endif - wxBitmap::InitStandardHandlers(); #if defined(__WIN95__) && !defined(__WXMICROWIN__) @@ -510,12 +507,6 @@ void wxApp::CleanUp() wxModule::CleanUpModules(); -#if wxUSE_WX_RESOURCES - wxCleanUpResourceSystem(); - - // wxDefaultResourceTable->ClearTable(); -#endif - wxDeleteStockObjects(); // Destroy all GDI lists, etc. @@ -573,13 +564,14 @@ void wxApp::CleanUp() #endif delete wxWinHandleHash; + wxWinHandleHash = NULL; // Set to null in case anything later tries to ref it. - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. delete wxPendingEvents; + wxPendingEvents = NULL; // Set to null because wxAppBase::wxEvtHandler is destroyed later. #if wxUSE_THREADS delete wxPendingEventsLocker; + wxPendingEventsLocker = NULL; // Set to null because wxAppBase::wxEvtHandler is destroyed later. // If we don't do the following, we get an apparent memory leak #if wxUSE_VALIDATORS ((wxEvtHandler&) wxDefaultValidator).ClearEventLocker(); @@ -700,8 +692,10 @@ int wxEntry(WXHINSTANCE hInstance, // we can't simply double-click on the error message and get to that // line in the source. So VC++ at least, let's have a sensible default. #ifdef __VISUALC__ +#if wxUSE_LOG wxLog::SetTimestamp(NULL); -#endif +#endif // wxUSE_LOG +#endif // __VISUALC__ // init the app int retValue = wxEntryInitGui() && wxTheApp->OnInit() ? 0 : -1; @@ -711,7 +705,7 @@ int wxEntry(WXHINSTANCE hInstance, if ( enterLoop ) { // run the main loop - retValue = wxTheApp->OnRun(); + wxTheApp->OnRun(); } else { @@ -738,7 +732,7 @@ int wxEntry(WXHINSTANCE hInstance, } } - wxTheApp->OnExit(); + retValue = wxTheApp->OnExit(); wxEntryCleanup(); @@ -1065,15 +1059,21 @@ bool wxApp::ProcessMessage(WXMSG *wxmsg) return FALSE; } +// this is a temporary hack and will be replaced by using wxEventLoop in the +// future +// +// it is needed to allow other event loops (currently only one: the modal +// dialog one) to reset the OnIdle() semaphore because otherwise OnIdle() +// wouldn't do anything while a modal dialog shown from OnIdle() call is shown. +bool wxIsInOnIdleFlag = FALSE; + void wxApp::OnIdle(wxIdleEvent& event) { - static bool s_inOnIdle = FALSE; - // Avoid recursion (via ProcessEvent default case) - if ( s_inOnIdle ) + if ( wxIsInOnIdleFlag ) return; - s_inOnIdle = TRUE; + wxIsInOnIdleFlag = TRUE; // If there are pending events, we must process them: pending events // are either events to the threads other than main or events posted @@ -1108,7 +1108,7 @@ void wxApp::OnIdle(wxIdleEvent& event) event.RequestMore(TRUE); } - s_inOnIdle = FALSE; + wxIsInOnIdleFlag = FALSE; } // Send idle event to all top-level windows @@ -1131,33 +1131,31 @@ bool wxApp::SendIdleEvents() // Send idle event to window and all subwindows bool wxApp::SendIdleEvents(wxWindow* win) { - bool needMore = FALSE; - wxIdleEvent event; event.SetEventObject(win); win->GetEventHandler()->ProcessEvent(event); - if (event.MoreRequested()) - needMore = TRUE; + bool needMore = event.MoreRequested(); - wxNode* node = win->GetChildren().First(); - while (node) + wxWindowList::Node *node = win->GetChildren().GetFirst(); + while ( node ) { - wxWindow* win = (wxWindow*) node->Data(); + wxWindow *win = node->GetData(); if (SendIdleEvents(win)) needMore = TRUE; - node = node->Next(); + node = node->GetNext(); } + return needMore; } void wxApp::DeletePendingObjects() { - wxNode *node = wxPendingDelete.First(); + wxNode *node = wxPendingDelete.GetFirst(); while (node) { - wxObject *obj = (wxObject *)node->Data(); + wxObject *obj = node->GetData(); delete obj; @@ -1166,7 +1164,7 @@ void wxApp::DeletePendingObjects() // Deleting one object may have deleted other pending // objects, so start from beginning of list again. - node = wxPendingDelete.First(); + node = wxPendingDelete.GetFirst(); } } @@ -1280,10 +1278,15 @@ int wxApp::GetComCtl32Version() void wxExit() { - wxLogError(_("Fatal error: exiting")); - - wxApp::CleanUp(); - exit(0); + if ( wxTheApp ) + { + wxTheApp->ExitMainLoop(); + } + else + { + // what else can we do? + exit(-1); + } } // Yield to incoming messages @@ -1293,9 +1296,11 @@ bool wxApp::Yield(bool onlyIfNeeded) // MT-FIXME static bool s_inYield = FALSE; +#if wxUSE_LOG // disable log flushing from here because a call to wxYield() shouldn't // normally result in message boxes popping up &c wxLog::Suspend(); +#endif // wxUSE_LOG if ( s_inYield ) { @@ -1326,8 +1331,10 @@ bool wxApp::Yield(bool onlyIfNeeded) // if there are pending events, we must process them. ProcessPendingEvents(); +#if wxUSE_LOG // let the logs be flashed again wxLog::Resume(); +#endif // wxUSE_LOG s_inYield = FALSE; @@ -1374,6 +1381,6 @@ void wxWakeUpIdle() // For some reason, with MSVC++ 1.5, WinMain isn't linked in properly // if in a separate file. So include it here to ensure it's linked. -#if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__TWIN32__) && !defined(WXMAKINGDLL)) +#if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__WINE__) && !defined(__TWIN32__) && !defined(WXMAKINGDLL)) #include "main.cpp" #endif