X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a95e38c03464c854af73b960b17db12624bd8f8c..7ef53f2dc59c8593285dfeb0365416fe437a037f:/src/msw/window.cpp?ds=sidebyside diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 3f8c4085f7..ab88ef0080 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -302,7 +302,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id, if ( style & wxTHICK_FRAME ) msflags |= WS_THICKFRAME; - msflags |= WS_CHILD | WS_VISIBLE; + msflags |= WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE; if ( style & wxCLIP_CHILDREN ) msflags |= WS_CLIPCHILDREN; @@ -365,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 ) { @@ -373,6 +377,7 @@ bool wxWindow::Enable(bool enable) node = node->GetNext(); } +#endif // 0 return TRUE; } @@ -464,20 +469,20 @@ bool wxWindow::SetCursor(const wxCursor& cursor) return FALSE; } - wxASSERT_MSG( m_cursor.Ok(), - wxT("cursor must be valid after call to the base version")); - - HWND hWnd = GetHwnd(); + if ( m_cursor.Ok() ) + { + HWND hWnd = GetHwnd(); - // Change the cursor NOW if we're within the correct window - POINT point; - ::GetCursorPos(&point); + // Change the cursor NOW if we're within the correct window + POINT point; + ::GetCursorPos(&point); - RECT rect; - ::GetWindowRect(hWnd, &rect); + RECT rect; + ::GetWindowRect(hWnd, &rect); - if ( ::PtInRect(&rect, point) && !wxIsBusy() ) - ::SetCursor(GetHcursorOf(m_cursor)); + if ( ::PtInRect(&rect, point) && !wxIsBusy() ) + ::SetCursor(GetHcursorOf(m_cursor)); + } return TRUE; } @@ -2349,7 +2354,11 @@ bool wxWindow::MSWCreate(int id, { int controlId = 0; if ( style & WS_CHILD ) + { controlId = id; + // all child windows should clip their siblings + style |= WS_CLIPSIBLINGS; + } wxString className(wclass); if ( GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE ) @@ -2662,29 +2671,70 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd, int WXUNUSED(mouseMsg)) { // the logic is as follows: + // -1. don't set cursor for non client area, including but not limited to + // the title bar, scrollbars, &c + // 0. allow the user to override default behaviour by using EVT_SET_CURSOR // 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 ( nHitTest != HTCLIENT ) + { + return FALSE; + } + HCURSOR hcursor = 0; - bool isBusy = wxIsBusy(); - if ( m_cursor.Ok() ) + + // first ask the user code - it may wish to set the cursor in some very + // specific way (for example, depending on the current position) + POINT pt; +#ifdef __WIN32__ + if ( !::GetCursorPos(&pt) ) + { + wxLogLastError("GetCursorPos"); + } +#else + // In WIN16 it doesn't return a value. + ::GetCursorPos(&pt); +#endif + + int x = pt.x, + y = pt.y; + ScreenToClient(&x, &y); + wxSetCursorEvent event(x, y); + + bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); + if ( processedEvtSetCursor && event.HasCursor() ) { - hcursor = GetHcursorOf(m_cursor); + hcursor = GetHcursorOf(event.GetCursor()); } - if ( !GetParent() ) + if ( !hcursor ) { - if ( isBusy ) + bool isBusy = wxIsBusy(); + + // the test for processedEvtSetCursor is here to prevent using m_cursor + // if the user code caught EVT_SET_CURSOR() and returned nothing from + // it - this is a way to say that our cursor shouldn't be used for this + // point + if ( !processedEvtSetCursor && m_cursor.Ok() ) { - hcursor = wxGetCurrentBusyCursor(); + hcursor = GetHcursorOf(m_cursor); } - else if ( !hcursor ) + + if ( !GetParent() ) { - const wxCursor *cursor = wxGetGlobalCursor(); - if ( cursor && cursor->Ok() ) + if ( isBusy ) { - hcursor = GetHcursorOf(*cursor); + hcursor = wxGetCurrentBusyCursor(); + } + else if ( !hcursor ) + { + const wxCursor *cursor = wxGetGlobalCursor(); + if ( cursor && cursor->Ok() ) + { + hcursor = GetHcursorOf(*cursor); + } } } }