X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8907154c1a8a6882c6797d1f16393ddfb23e7f3a..e733c4ce1e24cf7e4b0b0d8362fc59aaa7a7641c:/src/os2/app.cpp diff --git a/src/os2/app.cpp b/src/os2/app.cpp index 55c540bcd5..002cf73d77 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -1,10 +1,9 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: app.cpp +// Name: src/os2/app.cpp // Purpose: wxApp // Author: David Webster // Modified by: // Created: 10/13/99 -// RCS-ID: $Id$ // Copyright: (c) David Webster // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,9 +11,11 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#include "wx/app.h" + #ifndef WX_PRECOMP + #include "wx/dynarray.h" #include "wx/frame.h" - #include "wx/app.h" #include "wx/utils.h" #include "wx/gdicmn.h" #include "wx/pen.h" @@ -26,15 +27,14 @@ #include "wx/dialog.h" #include "wx/msgdlg.h" #include "wx/intl.h" - #include "wx/dynarray.h" - #include "wx/wxchar.h" - #include "wx/icon.h" - #include "wx/stdpaths.h" - #include "wx/filename.h" + #include "wx/crt.h" + #include "wx/log.h" + #include "wx/module.h" #endif -#include "wx/log.h" -#include "wx/module.h" +#include "wx/stdpaths.h" +#include "wx/filename.h" +#include "wx/evtloop.h" #include "wx/os2/private.h" @@ -81,8 +81,7 @@ extern "C" int _System bsdselect(int, // global variables // --------------------------------------------------------------------------- -extern wxChar* wxBuffer; -extern wxList WXDLLEXPORT wxPendingDelete; +WXDLLEXPORT_DATA(wxChar*) wxBuffer; extern wxCursor* g_globalCursor; HAB vHabmain = NULLHANDLE; @@ -122,7 +121,7 @@ struct GsocketCallbackInfo{ void wxApp::HandleSockets() { - bool pendingEvent = FALSE; + bool pendingEvent = false; // Check whether it's time for Gsocket operation if (m_maxSocketHandles > 0 && m_maxSocketNr > 0) @@ -151,7 +150,7 @@ void wxApp::HandleSockets() if (r < m_maxSocketHandles) { CallbackInfo[r].proc(CallbackInfo[r].gsock); - pendingEvent = TRUE; + pendingEvent = true; } } if (FD_ISSET(i, &writefds)) @@ -164,7 +163,7 @@ void wxApp::HandleSockets() if (r < m_maxSocketHandles) { CallbackInfo[r].proc(CallbackInfo[r].gsock); - pendingEvent = TRUE; + pendingEvent = true; } } } @@ -228,16 +227,14 @@ bool wxApp::Initialize(int& argc, wxChar **argv) // TODO: at least give some error message here... wxAppBase::CleanUp(); - return FALSE; + return false; } wxBuffer = new wxChar[1500]; // FIXME; why? // Some people may wish to use this, but // probably it shouldn't be here by default. -#ifdef __WXDEBUG__ // wxRedirectIOToConsole(); -#endif wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100); @@ -252,7 +249,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv) RegisterWindowClasses(vHabmain); - return TRUE; + return true; } // end of wxApp::Initialize const char* CANTREGISTERCLASS = " Can't register Class "; @@ -260,12 +257,10 @@ const char* CANTREGISTERCLASS = " Can't register Class " // RegisterWindowClasses // --------------------------------------------------------------------------- -bool wxApp::RegisterWindowClasses( - HAB vHab -) +bool wxApp::RegisterWindowClasses( HAB vHab ) { - ERRORID vError = 0L; - wxString sError; + ERRORID vError = 0L; + wxString sError; if (!::WinRegisterClass( vHab ,(PSZ)wxFrameClassName @@ -277,7 +272,7 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } if (!::WinRegisterClass( vHab @@ -290,7 +285,7 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } if (!::WinRegisterClass( vHab @@ -303,7 +298,7 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } if (!::WinRegisterClass( vHab @@ -316,7 +311,7 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } if (!::WinRegisterClass( vHab @@ -329,7 +324,7 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } if (!::WinRegisterClass( vHab @@ -342,7 +337,7 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } if (!::WinRegisterClass( vHab @@ -355,7 +350,7 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } if (!::WinRegisterClass( vHab @@ -368,7 +363,7 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } if (!::WinRegisterClass( vHab ,(PSZ)wxCanvasClassNameNR @@ -380,9 +375,9 @@ bool wxApp::RegisterWindowClasses( vError = ::WinGetLastError(vHab); sError = wxPMErrorToStr(vError); wxLogLastError(sError.c_str()); - return FALSE; + return false; } - return TRUE; + return true; } // end of wxApp::RegisterWindowClasses // @@ -390,14 +385,13 @@ bool wxApp::RegisterWindowClasses( // void wxApp::CleanUp() { - delete[] wxBuffer; - wxBuffer = NULL; + wxDELETEA(wxBuffer); // // PM-SPECIFIC CLEANUP // - // wxSetKeyboardHook(FALSE); + // wxSetKeyboardHook(false); if (wxSTD_FRAME_ICON) ::WinFreeFileIcon(wxSTD_FRAME_ICON); @@ -418,8 +412,7 @@ void wxApp::CleanUp() // TODO: ::DeleteObject( wxDisableButtonBrush ); } - delete wxWinHandleHash; - wxWinHandleHash = NULL; + wxDELETE(wxWinHandleHash); // Delete Message queue if (wxTheApp->m_hMq) @@ -430,11 +423,11 @@ void wxApp::CleanUp() bool wxApp::OnInitGui() { - ERRORID vError; - wxString sError; + ERRORID vError; + wxString sError; if (!wxAppBase::OnInitGui()) - return FALSE; + return false; m_hMq = ::WinCreateMsgQueue(vHabmain, 0); if (!m_hMq) @@ -442,16 +435,14 @@ bool wxApp::OnInitGui() vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); wxLogDebug(sError); - return FALSE; + return false; } - return TRUE; + return true; } // end of wxApp::OnInitGui wxApp::wxApp() { - argc = 0; - argv = NULL; m_nPrintMode = wxPRINT_WINDOWS; m_hMq = 0; m_maxSocketHandles = 0; @@ -461,27 +452,12 @@ wxApp::wxApp() wxApp::~wxApp() { - // - // Delete command-line args - // -#if wxUSE_UNICODE - int i; - - for (i = 0; i < argc; i++) - { - delete[] argv[i]; - } - delete[] argv; -#endif } // end of wxApp::~wxApp -bool gbInOnIdle = FALSE; +bool gbInOnIdle = false; -void wxApp::OnIdle( - wxIdleEvent& rEvent -) +void wxApp::OnIdle( wxIdleEvent& WXUNUSED(rEvent) ) { - // // Avoid recursion (via ProcessEvent default case) // @@ -490,8 +466,6 @@ void wxApp::OnIdle( gbInOnIdle = true; - wxAppBase::OnIdle(rEvent); - #if wxUSE_DC_CACHEING // automated DC cache management: clear the cached DCs and bitmap // if it's likely that the app has finished with them, that is, we @@ -502,86 +476,29 @@ void wxApp::OnIdle( wxDC::ClearCache(); #endif // wxUSE_DC_CACHEING - gbInOnIdle = FALSE; + gbInOnIdle = false; } // end of wxApp::OnIdle void wxApp::OnEndSession( wxCloseEvent& WXUNUSED(rEvent)) { if (GetTopWindow()) - GetTopWindow()->Close(TRUE); + GetTopWindow()->Close(true); } // end of wxApp::OnEndSession // // Default behaviour: close the application with prompts. The // user can veto the close, and therefore the end session. // -void wxApp::OnQueryEndSession( - wxCloseEvent& rEvent -) +void wxApp::OnQueryEndSession( wxCloseEvent& rEvent ) { if (GetTopWindow()) { if (!GetTopWindow()->Close(!rEvent.CanVeto())) - rEvent.Veto(TRUE); + rEvent.Veto(true); } } // end of wxApp::OnQueryEndSession -// -// Yield to incoming messages -// -bool wxApp::Yield(bool onlyIfNeeded) -{ - static bool s_inYield = FALSE; - - if ( s_inYield ) - { - if ( !onlyIfNeeded ) - { - wxFAIL_MSG( _T("wxYield() called recursively") ); - } - - return FALSE; - } - - HAB vHab = 0; - QMSG vMsg; - - // - // Disable log flushing from here because a call to wxYield() shouldn't - // normally result in message boxes popping up &c - // - wxLog::Suspend(); - - s_inYield = TRUE; - - // - // We want to go back to the main message loop - // if we see a WM_QUIT. (?) - // - while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT) - { -#if wxUSE_THREADS - wxMutexGuiLeaveOrEnter(); -#endif // wxUSE_THREADS - if (!wxTheApp->Dispatch()) - break; - } - // - // If they are pending events, we must process them. - // - if (wxTheApp) - wxTheApp->ProcessPendingEvents(); - - HandleSockets(); - // - // Let the logs be flashed again - // - wxLog::Resume(); - s_inYield = FALSE; - return TRUE; -} // end of wxYield - int wxApp::AddSocketHandler(int handle, int mask, void (*callback)(void*), void * gsock) {