X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6aa89a22b8e47000c98bff05c6f545f331f1c353..139c5871c91e087972789526ac7e85a5f4e94ece:/src/generic/splitter.cpp diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 2927eacbdb..1e51050540 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -52,7 +52,7 @@ BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow) EVT_IDLE(wxSplitterWindow::OnIdle) EVT_MOUSE_EVENTS(wxSplitterWindow::OnMouseEvent) -#ifdef __WXMSW__ +#if defined( __WXMSW__ ) || defined( __WXMAC__) EVT_SET_CURSOR(wxSplitterWindow::OnSetCursor) #endif // wxMSW @@ -168,11 +168,8 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) int x = (int)event.GetX(), y = (int)event.GetY(); - // reset the cursor -#if defined( __WXMOTIF__ ) || defined( __WXGTK__ ) || defined( __WXMAC__ ) - SetCursor(* wxSTANDARD_CURSOR); -#elif defined(__WXMSW__) - SetCursor(wxCursor()); +#if defined(__WXMSW__) + // SetCursor(wxCursor()); // Is this required? #endif if (GetWindowStyle() & wxSP_NOSASH) @@ -188,9 +185,12 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) { if ( SashHitTest(x, y) ) { - CaptureMouse(); - + // Start the drag now m_dragMode = wxSPLIT_DRAG_DRAGGING; + + // Capture mouse and set the cursor + CaptureMouse(); + SetResizeCursor(); if ( !isLive ) { @@ -212,7 +212,10 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) { // We can stop dragging now and see what we've got. m_dragMode = wxSPLIT_DRAG_NONE; + + // Release mouse and unset the cursor ReleaseMouse(); + SetCursor(* wxSTANDARD_CURSOR); // exit if unsplit after doubleclick if ( !IsSplit() ) @@ -273,32 +276,14 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) } // left up && dragging else if (event.Moving() && !event.Dragging()) { - // Just change the cursor if required + // Just change the cursor as required if ( SashHitTest(x, y) ) - { SetResizeCursor(); - } -#if defined(__WXGTK__) || defined(__WXMSW__) || defined(__WXMAC__) else - { - // We must set the normal cursor in MSW, because - // if the child window doesn't have a cursor, the - // parent's (splitter window) will be used, and this - // must be the standard cursor. - - // where else do we unset the cursor? SetCursor(* wxSTANDARD_CURSOR); - } -#endif // __WXGTK__ } else if (event.Dragging() && (m_dragMode == wxSPLIT_DRAG_DRAGGING)) { -#if defined( __WXMSW__ ) || defined( __WXMAC__ ) - // Otherwise, the cursor sometimes reverts to the normal cursor - // during dragging. - SetResizeCursor(); -#endif // __WXMSW__ - int diff = m_splitMode == wxSPLIT_VERTICAL ? x - m_oldX : y - m_oldY; if ( !diff ) { @@ -358,7 +343,7 @@ void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) m_needUpdating = TRUE; } } - else if ( event.LeftDClick() ) + else if ( event.LeftDClick() && m_windowTwo ) { OnDoubleClickSash(x, y); } @@ -892,7 +877,7 @@ bool wxSplitterWindow::Unsplit(wxWindow *toRemove) return FALSE; } - OnUnsplit(win); + win->Show(FALSE); DoSetSashPosition(0); SizeWindows(); @@ -1062,6 +1047,8 @@ int wxSplitterWindow::OnSashPositionChanging(int newSashPosition) // the sash if the minimum pane size is zero. void wxSplitterWindow::OnDoubleClickSash(int x, int y) { + wxCHECK_RET(m_windowTwo, wxT("splitter: no window to remove")); + // new code should handle events instead of using the virtual functions wxSplitterEvent event(wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, this); event.m_data.pt.x = x; @@ -1070,7 +1057,9 @@ void wxSplitterWindow::OnDoubleClickSash(int x, int y) { if ( GetMinimumPaneSize() == 0 || m_permitUnsplitAlways ) { - Unsplit(); + wxWindow* win = m_windowTwo; + if (Unsplit(win)) + OnUnsplit(win); } } //else: blocked by user @@ -1087,7 +1076,7 @@ void wxSplitterWindow::OnUnsplit(wxWindow *winRemoved) (void)DoSendEvent(event); } -#ifdef __WXMSW__ +#if defined( __WXMSW__ ) || defined( __WXMAC__) // this is currently called (and needed) under MSW only... void wxSplitterWindow::OnSetCursor(wxSetCursorEvent& event)