X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b94ae1ea10f3794b36e8ad554381124ee9ec296b..2035e10e83324c6925d12725b842768f6e2b00a2:/src/msw/window.cpp?ds=sidebyside diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 0be7635f72..9e92ac4db2 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -129,10 +129,6 @@ wxWindow *wxFindWinFromHandle(WXHWND hWnd); // mouse clicks static void TranslateKbdEventToMouse(wxWindow *win, int *x, int *y, WPARAM *flags); -// get the current state of SHIFT/CTRL keys -static inline bool IsShiftDown() { return (GetKeyState(VK_SHIFT) & 0x100) != 0; } -static inline bool IsCtrlDown() { return (GetKeyState(VK_CONTROL) & 0x100) != 0; } - // --------------------------------------------------------------------------- // event tables // --------------------------------------------------------------------------- @@ -274,7 +270,8 @@ wxWindow::~wxWindow() if ( m_hWnd ) { - if (::IsWindow(GetHwnd())) + // VZ: test temp removed to understand what really happens here + //if (::IsWindow(GetHwnd())) { if ( !::DestroyWindow(GetHwnd()) ) wxLogLastError("DestroyWindow"); @@ -368,6 +365,10 @@ bool wxWindow::Enable(bool enable) if ( hWnd ) ::EnableWindow(hWnd, (BOOL)enable); + // VZ: no, this is a bad idea: imagine that you have a dialog with some + // disabled controls and disable it - you really wouldn't like the + // disabled controls eb reenabled too when you reenable the dialog! +#if 0 wxWindowList::Node *node = GetChildren().GetFirst(); while ( node ) { @@ -376,6 +377,7 @@ bool wxWindow::Enable(bool enable) node = node->GetNext(); } +#endif // 0 return TRUE; } @@ -480,7 +482,7 @@ bool wxWindow::SetCursor(const wxCursor& cursor) ::GetWindowRect(hWnd, &rect); if ( ::PtInRect(&rect, point) && !wxIsBusy() ) - ::SetCursor((HCURSOR)m_cursor.GetHCURSOR()); + ::SetCursor(GetHcursorOf(m_cursor)); return TRUE; } @@ -973,9 +975,9 @@ void wxWindow::OnIdle(wxIdleEvent& event) // by the time the OnIdle function is called, so 'state' may be // meaningless. int state = 0; - if ( ::GetKeyState(VK_SHIFT) != 0 ) + if ( wxIsShiftDown() ) state |= MK_SHIFT; - if ( ::GetKeyState(VK_CONTROL) != 0 ) + if ( wxIsCtrlDown() ) state |= MK_CONTROL; wxMouseEvent event(wxEVT_LEAVE_WINDOW); @@ -1482,8 +1484,8 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) if ( bProcess ) { - bool bCtrlDown = IsCtrlDown(); - bool bShiftDown = IsShiftDown(); + bool bCtrlDown = wxIsCtrlDown(); + bool bShiftDown = wxIsShiftDown(); // WM_GETDLGCODE: ask the control if it wants the key for itself, // don't process it if it's the case (except for Ctrl-Tab/Enter @@ -1598,7 +1600,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) // don't process system keys here if ( !(HIWORD(msg->lParam) & KF_ALTDOWN) ) { - if ( (msg->wParam == VK_TAB) && IsCtrlDown() ) + if ( (msg->wParam == VK_TAB) && wxIsCtrlDown() ) { // find the first notebook parent and change its page wxWindow *win = this; @@ -1611,7 +1613,7 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg) if ( nbook ) { - bool forward = !IsShiftDown(); + bool forward = !wxIsShiftDown(); nbook->AdvanceSelection(forward); } @@ -2664,54 +2666,46 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd, short nHitTest, int WXUNUSED(mouseMsg)) { - // don't set cursor for other windows, only for this one: this prevents - // children of this window from getting the same cursor as the parent has - // (don't forget that this message is propagated by default up the window - // parent-child hierarchy) - if ( GetHWND() == hWnd ) - { - // don't set cursor when the mouse is not in the client part - if ( nHitTest == HTCLIENT || nHitTest == HTERROR ) - { - HCURSOR hcursor = 0; - if ( wxIsBusy() ) - { - // from msw\utils.cpp - extern HCURSOR gs_wxBusyCursor; - - hcursor = gs_wxBusyCursor; - } - else - { - wxCursor *cursor = NULL; + // the logic is as follows: + // 1. if we have the cursor set it unless wxIsBusy() + // 2. if we're a top level window, set some cursor anyhow + // 3. if wxIsBusy(), set the busy cursor, otherwise the global one - if ( m_cursor.Ok() ) - { - cursor = &m_cursor; - } - else - { - // from msw\data.cpp - extern wxCursor *g_globalCursor; - - if ( g_globalCursor && g_globalCursor->Ok() ) - cursor = g_globalCursor; - } - - if ( cursor ) - hcursor = (HCURSOR)cursor->GetHCURSOR(); - } + HCURSOR hcursor = 0; + bool isBusy = wxIsBusy(); + if ( m_cursor.Ok() ) + { + hcursor = GetHcursorOf(m_cursor); + } - if ( hcursor ) + if ( !GetParent() ) + { + if ( isBusy ) + { + hcursor = wxGetCurrentBusyCursor(); + } + else if ( !hcursor ) + { + const wxCursor *cursor = wxGetGlobalCursor(); + if ( cursor && cursor->Ok() ) { - ::SetCursor(hcursor); - - return TRUE; + hcursor = GetHcursorOf(*cursor); } } } - return FALSE; + if ( hcursor ) + { + ::SetCursor(hcursor); + + // cursor set, stop here + return TRUE; + } + else + { + // pass up the window chain + return FALSE; + } } // --------------------------------------------------------------------------- @@ -3020,13 +3014,14 @@ bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) return popupMenu->MSWCommand(cmd, id); } - wxWindow *win; + wxWindow *win = (wxWindow*) NULL; if ( cmd == 0 || cmd == 1 ) // menu or accel - use id { // must cast to a signed type before comparing with other ids! win = FindItem((signed short)id); } - else + + if (!win && control) { // find it from HWND - this works even with the broken programs using // the same ids for different controls @@ -3166,8 +3161,8 @@ wxKeyEvent wxWindow::CreateKeyEvent(wxEventType evType, { wxKeyEvent event(evType); event.SetId(GetId()); - event.m_shiftDown = IsShiftDown(); - event.m_controlDown = IsCtrlDown(); + event.m_shiftDown = wxIsShiftDown(); + event.m_controlDown = wxIsCtrlDown(); event.m_altDown = (HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN; event.m_eventObject = (wxWindow *)this; // const_cast @@ -3721,8 +3716,8 @@ wxKeyboardHook(int nCode, WORD wParam, DWORD lParam) event.m_eventObject = NULL; event.m_keyCode = id; - event.m_shiftDown = IsShiftDown(); - event.m_controlDown = IsCtrlDown(); + event.m_shiftDown = wxIsShiftDown(); + event.m_controlDown = wxIsCtrlDown(); event.SetTimestamp(s_currentMsg.time); wxWindow *win = wxGetActiveWindow(); @@ -4174,9 +4169,9 @@ static void TranslateKbdEventToMouse(wxWindow *win, int *x, int *y, WPARAM *flag WPARAM& fwKeys = *flags; fwKeys = MK_RBUTTON; - if ( (::GetKeyState(VK_CONTROL) & 0x100) != 0 ) + if ( wxIsCtrlDown() ) fwKeys |= MK_CONTROL; - if ( (::GetKeyState(VK_SHIFT) & 0x100) != 0 ) + if ( wxIsShiftDown() ) fwKeys |= MK_SHIFT; // simulate right mouse button click