]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/app.cpp
Also update focus rect when changing selection in single selection mode, fixes #11332
[wxWidgets.git] / src / msw / app.cpp
index 342045001abe0e0c4be0d9ec8e2268f72ccbbeab..0e79d4627f32896f9f4b52139eb8d21b15c85f3d 100644 (file)
@@ -122,7 +122,7 @@ extern void wxSetKeyboardHook(bool doIt);
 struct ClassRegInfo
 {
     // the base name of the class: this is used to construct the unique name in
-    // RegisterClassWithUniqueNames()
+    // wxApp::GetRegisteredClassName()
     wxString basename;
 
     // the name of the registered class with and without CS_[HV]REDRAW styles
@@ -200,11 +200,6 @@ void *wxGUIAppTraits::BeforeChildWaitLoop()
     return new ChildWaitLoopData(wd, winActive);
 }
 
-void wxGUIAppTraits::AlwaysYield()
-{
-    wxYield();
-}
-
 void wxGUIAppTraits::AfterChildWaitLoop(void *dataOrig)
 {
     wxEndBusyCursor();
@@ -337,7 +332,7 @@ public:
         {
             if ( !::FreeConsole() )
             {
-                wxLogLastError(_T("FreeConsole"));
+                wxLogLastError(wxT("FreeConsole"));
             }
         }
     }
@@ -396,7 +391,7 @@ private:
     GetConsoleCommandHistory_t m_pfnGetConsoleCommandHistory;
     GetConsoleCommandHistoryLength_t m_pfnGetConsoleCommandHistoryLength;
 
-    DECLARE_NO_COPY_CLASS(wxConsoleStderr)
+    wxDECLARE_NO_COPY_CLASS(wxConsoleStderr);
 };
 
 bool wxConsoleStderr::DoInit()
@@ -406,7 +401,7 @@ bool wxConsoleStderr::DoInit()
     if ( hStderr == INVALID_HANDLE_VALUE || !hStderr )
         return false;
 
-    if ( !m_dllKernel32.Load(_T("kernel32.dll")) )
+    if ( !m_dllKernel32.Load(wxT("kernel32.dll")) )
         return false;
 
     typedef BOOL (WINAPI *AttachConsole_t)(DWORD dwProcessId);
@@ -439,7 +434,7 @@ bool wxConsoleStderr::DoInit()
 
     if ( !::GetConsoleScreenBufferInfo(m_hStderr, &csbi) )
     {
-        wxLogLastError(_T("GetConsoleScreenBufferInfo"));
+        wxLogLastError(wxT("GetConsoleScreenBufferInfo"));
         return false;
     }
 
@@ -456,7 +451,7 @@ bool wxConsoleStderr::DoInit()
         if ( !::ReadConsoleOutputCharacterA(m_hStderr, buf, WXSIZEOF(buf),
                                             pos, &ret) )
         {
-            wxLogLastError(_T("ReadConsoleOutputCharacterA"));
+            wxLogLastError(wxT("ReadConsoleOutputCharacterA"));
             return false;
         }
     } while ( wxStrncmp("    ", buf, WXSIZEOF(buf)) != 0 );
@@ -471,7 +466,7 @@ bool wxConsoleStderr::DoInit()
         if ( !::ReadConsoleOutputCharacterA(m_hStderr, m_data.data(), m_dataLen,
                                             pos, &ret) )
         {
-            wxLogLastError(_T("ReadConsoleOutputCharacterA"));
+            wxLogLastError(wxT("ReadConsoleOutputCharacterA"));
             return false;
         }
     }
@@ -482,7 +477,7 @@ bool wxConsoleStderr::DoInit()
 int wxConsoleStderr::GetCommandHistory(wxWxCharBuffer& buf) const
 {
     // these functions are internal and may only be called by cmd.exe
-    static const wxChar *CMD_EXE = _T("cmd.exe");
+    static const wxChar *CMD_EXE = wxT("cmd.exe");
 
     const int len = m_pfnGetConsoleCommandHistoryLength(CMD_EXE);
     if ( len )
@@ -499,7 +494,7 @@ int wxConsoleStderr::GetCommandHistory(wxWxCharBuffer& buf) const
 
         if ( len2 != len )
         {
-            wxFAIL_MSG( _T("failed getting history?") );
+            wxFAIL_MSG( wxT("failed getting history?") );
         }
     }
 
@@ -508,7 +503,7 @@ int wxConsoleStderr::GetCommandHistory(wxWxCharBuffer& buf) const
 
 bool wxConsoleStderr::IsHistoryUnchanged() const
 {
-    wxASSERT_MSG( m_ok == 1, _T("shouldn't be called if not initialized") );
+    wxASSERT_MSG( m_ok == 1, wxT("shouldn't be called if not initialized") );
 
     // get (possibly changed) command history
     wxWxCharBuffer history;
@@ -522,13 +517,13 @@ bool wxConsoleStderr::IsHistoryUnchanged() const
 bool wxConsoleStderr::Write(const wxString& text)
 {
     wxASSERT_MSG( m_hStderr != INVALID_HANDLE_VALUE,
-                    _T("should only be called if Init() returned true") );
+                    wxT("should only be called if Init() returned true") );
 
     // get current position
     CONSOLE_SCREEN_BUFFER_INFO csbi;
     if ( !::GetConsoleScreenBufferInfo(m_hStderr, &csbi) )
     {
-        wxLogLastError(_T("GetConsoleScreenBufferInfo"));
+        wxLogLastError(wxT("GetConsoleScreenBufferInfo"));
         return false;
     }
 
@@ -538,21 +533,21 @@ bool wxConsoleStderr::Write(const wxString& text)
 
     if ( !::SetConsoleCursorPosition(m_hStderr, csbi.dwCursorPosition) )
     {
-        wxLogLastError(_T("SetConsoleCursorPosition"));
+        wxLogLastError(wxT("SetConsoleCursorPosition"));
         return false;
     }
 
     DWORD ret;
-    if ( !::FillConsoleOutputCharacter(m_hStderr, _T(' '), m_dataLen,
+    if ( !::FillConsoleOutputCharacter(m_hStderr, wxT(' '), m_dataLen,
                                        csbi.dwCursorPosition, &ret) )
     {
-        wxLogLastError(_T("FillConsoleOutputCharacter"));
+        wxLogLastError(wxT("FillConsoleOutputCharacter"));
         return false;
     }
 
     if ( !::WriteConsole(m_hStderr, text.wx_str(), text.length(), &ret, NULL) )
     {
-        wxLogLastError(_T("WriteConsole"));
+        wxLogLastError(wxT("WriteConsole"));
         return false;
     }
 
@@ -825,6 +820,10 @@ void wxApp::WakeUpIdle()
             }
         }
     }
+#if wxUSE_THREADS
+    else
+        wxWakeUpMainThread();
+#endif // wxUSE_THREADS
 }
 
 // ----------------------------------------------------------------------------
@@ -891,7 +890,7 @@ int CallDllGetVersion(wxDynamicLibrary& dll)
     HRESULT hr = (*pfnDllGetVersion)(&dvi);
     if ( FAILED(hr) )
     {
-        wxLogApiError(_T("DllGetVersion"), hr);
+        wxLogApiError(wxT("DllGetVersion"), hr);
 
         return 0;
     }
@@ -919,7 +918,7 @@ int wxApp::GetComCtl32Version()
         // depending on the OS version and the presence of the manifest, it can
         // be either v5 or v6 and instead of trying to guess it just get the
         // handle of the already loaded version
-        wxLoadedDLL dllComCtl32(_T("comctl32.dll"));
+        wxLoadedDLL dllComCtl32(wxT("comctl32.dll"));
         if ( !dllComCtl32.IsLoaded() )
         {
             s_verComCtl32 = 0;
@@ -934,7 +933,7 @@ int wxApp::GetComCtl32Version()
         if ( !s_verComCtl32 )
         {
             // InitCommonControlsEx is unique to 4.70 and later
-            void *pfn = dllComCtl32.GetSymbol(_T("InitCommonControlsEx"));
+            void *pfn = dllComCtl32.GetSymbol(wxT("InitCommonControlsEx"));
             if ( !pfn )
             {
                 // not found, must be 4.00
@@ -944,7 +943,7 @@ int wxApp::GetComCtl32Version()
             {
                 // many symbols appeared in comctl32 4.71, could use any of
                 // them except may be DllInstall()
-                pfn = dllComCtl32.GetSymbol(_T("InitializeFlatSB"));
+                pfn = dllComCtl32.GetSymbol(wxT("InitializeFlatSB"));
                 if ( !pfn )
                 {
                     // not found, must be 4.70
@@ -971,7 +970,7 @@ int wxApp::GetShell32Version()
         // we're prepared to handle the errors
         wxLogNull noLog;
 
-        wxDynamicLibrary dllShell32(_T("shell32.dll"), wxDL_VERBATIM);
+        wxDynamicLibrary dllShell32(wxT("shell32.dll"), wxDL_VERBATIM);
         if ( dllShell32.IsLoaded() )
         {
             s_verShell32 = CallDllGetVersion(dllShell32);
@@ -1011,177 +1010,6 @@ int wxApp::GetShell32Version()
 
 #endif // !__WXWINCE__
 
-// ----------------------------------------------------------------------------
-// Yield to incoming messages
-// ----------------------------------------------------------------------------
-
-WX_DECLARE_OBJARRAY(MSG, wxMSGArray);
-
-#include <wx/arrimpl.cpp>
-WX_DEFINE_OBJARRAY(wxMSGArray);
-
-static wxMSGArray g_arrMSG;
-
-bool wxApp::DoYield(bool onlyIfNeeded, long eventsToProcess)
-{
-    if ( m_isInsideYield )
-    {
-        if ( !onlyIfNeeded )
-        {
-            wxFAIL_MSG( wxT("wxYield called recursively" ) );
-        }
-
-        return false;
-    }
-
-    // set the flag and don't forget to reset it before returning
-    m_isInsideYield = true;
-    m_eventsToProcessInsideYield = eventsToProcess;
-
-    wxON_BLOCK_EXIT_SET(m_isInsideYield, 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();
-
-    // ensure the logs will be flashed again when we exit
-    wxON_BLOCK_EXIT0(wxLog::Resume);
-#endif // wxUSE_LOG
-
-    // we don't want to process WM_QUIT from here - it should be processed in
-    // the main event loop in order to stop it
-    wxEventLoopGuarantor dummyLoopIfNeeded;
-    MSG msg;
-    while ( PeekMessage(&msg, (HWND)0, 0, 0, PM_NOREMOVE) &&
-            msg.message != WM_QUIT )
-    {
-#if wxUSE_THREADS
-        wxMutexGuiLeaveOrEnter();
-#endif // wxUSE_THREADS
-
-        if (msg.message == WM_PAINT)
-        {
-            // WM_PAINT messages are the last ones of the queue...
-            break;
-        }
-
-        // choose a wxEventCategory for this Windows message
-        wxEventCategory cat;
-        switch (msg.message)
-        {
-            case WM_NCMOUSEMOVE:
-            case WM_NCLBUTTONDOWN:
-            case WM_NCLBUTTONUP:
-            case WM_NCLBUTTONDBLCLK:
-            case WM_NCRBUTTONDOWN:
-            case WM_NCRBUTTONUP:
-            case WM_NCRBUTTONDBLCLK:
-            case WM_NCMBUTTONDOWN:
-            case WM_NCMBUTTONUP:
-            case WM_NCMBUTTONDBLCLK:
-
-            case WM_KEYDOWN:
-            case WM_KEYUP:
-            case WM_CHAR:
-            case WM_DEADCHAR:
-            case WM_SYSKEYDOWN:
-            case WM_SYSKEYUP:
-            case WM_SYSCHAR:
-            case WM_SYSDEADCHAR:
-#ifdef WM_UNICHAR
-            case WM_UNICHAR:
-#endif
-            case WM_HOTKEY:
-            case WM_IME_STARTCOMPOSITION:
-            case WM_IME_ENDCOMPOSITION:
-            case WM_IME_COMPOSITION:
-            case WM_COMMAND:
-            case WM_SYSCOMMAND:
-
-            case WM_IME_SETCONTEXT:
-            case WM_IME_NOTIFY:
-            case WM_IME_CONTROL:
-            case WM_IME_COMPOSITIONFULL:
-            case WM_IME_SELECT:
-            case WM_IME_CHAR:
-            case WM_IME_KEYDOWN:
-            case WM_IME_KEYUP:
-
-            case WM_MOUSEHOVER:
-#ifdef WM_NCMOUSELEAVE
-            case WM_NCMOUSELEAVE:
-#endif
-            case WM_MOUSELEAVE:
-
-            case WM_CUT:
-            case WM_COPY:
-            case WM_PASTE:
-            case WM_CLEAR:
-            case WM_UNDO:
-
-            case WM_MOUSEMOVE:
-            case WM_LBUTTONDOWN:
-            case WM_LBUTTONUP:
-            case WM_LBUTTONDBLCLK:
-            case WM_RBUTTONDOWN:
-            case WM_RBUTTONUP:
-            case WM_RBUTTONDBLCLK:
-            case WM_MBUTTONDOWN:
-            case WM_MBUTTONUP:
-            case WM_MBUTTONDBLCLK:
-            case WM_MOUSEWHEEL:
-                cat = wxEVT_CATEGORY_USER_INPUT;
-                break;
-
-            case WM_TIMER:
-                cat = wxEVT_CATEGORY_TIMER;
-                break;
-
-            default:
-                if (msg.message < WM_USER)
-                {
-                    // 0;WM_USER-1 is the range of message IDs reserved for use
-                    // by the system.
-
-                    // there are too many of these types of messages to handle
-                    // them in this switch
-                    cat = wxEVT_CATEGORY_UI;
-                }
-                else
-                    cat = wxEVT_CATEGORY_UNKNOWN;
-        }
-
-        // should we process this event now?
-        if (cat & eventsToProcess)
-        {
-            if ( !wxTheApp->Dispatch() )
-                break;
-        }
-        else
-        {
-            // remove the message and store it
-            ::GetMessage(&msg, NULL, 0, 0);
-            g_arrMSG.Add(msg);
-        }
-    }
-
-    // if there are pending events, we must process them.
-    ProcessPendingEvents();
-
-    // put back unprocessed events in the queue
-    DWORD id = GetCurrentThreadId();
-    for (size_t i=0; i<g_arrMSG.GetCount(); i++)
-    {
-        PostThreadMessage(id, g_arrMSG[i].message,
-                          g_arrMSG[i].wParam, g_arrMSG[i].lParam);
-    }
-
-    g_arrMSG.Clear();
-
-    return true;
-}
-
 #if wxUSE_EXCEPTIONS
 
 // ----------------------------------------------------------------------------
@@ -1196,10 +1024,10 @@ bool wxApp::OnExceptionInMainLoop()
             ::MessageBox
               (
                 NULL,
-                _T("An unhandled exception occurred. Press \"Abort\" to \
+                wxT("An unhandled exception occurred. Press \"Abort\" to \
 terminate the program,\r\n\
 \"Retry\" to exit the program normally and \"Ignore\" to try to continue."),
-                _T("Unhandled exception"),
+                wxT("Unhandled exception"),
                 MB_ABORTRETRYIGNORE |
                 MB_ICONERROR|
                 MB_TASKMODAL
@@ -1210,7 +1038,7 @@ terminate the program,\r\n\
             throw;
 
         default:
-            wxFAIL_MSG( _T("unexpected MessageBox() return code") );
+            wxFAIL_MSG( wxT("unexpected MessageBox() return code") );
             // fall through
 
         case IDRETRY: