From ce15b45fef3d8d62681f496b4e6e343af6d36031 Mon Sep 17 00:00:00 2001 From: Benjamin Williams Date: Fri, 10 Nov 2006 15:17:11 +0000 Subject: [PATCH] factored out CalculateHintRect() from DrawHintRect(); hint fix in auibook git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43273 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/aui/framemanager.h | 5 ++++ src/aui/auibook.cpp | 11 ++++++++ src/aui/framemanager.cpp | 53 +++++++++++++++++++++++++---------- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/include/wx/aui/framemanager.h b/include/wx/aui/framemanager.h index 84fc2bddf8..863bc7a7dc 100644 --- a/include/wx/aui/framemanager.h +++ b/include/wx/aui/framemanager.h @@ -476,9 +476,14 @@ public: public: virtual wxAuiFloatingFrame* CreateFloatingFrame(wxWindow* parent, const wxAuiPaneInfo& p); + wxRect CalculateHintRect(wxWindow* pane_window, + const wxPoint& pt, + const wxPoint& offset); + void DrawHintRect(wxWindow* pane_window, const wxPoint& pt, const wxPoint& offset); + virtual void ShowHint(const wxRect& rect); virtual void HideHint(); diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 6aa541bfa9..a9c7f0a2f2 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -3132,6 +3132,17 @@ void wxAuiNotebook::OnTabEndDrag(wxCommandEvent& command_evt) } else { + wxPoint zero(0,0); + wxRect rect = m_mgr.CalculateHintRect(m_dummy_wnd, + mouse_client_pt, + zero); + if (rect.IsEmpty()) + { + // there is no suitable drop location here, exit out + return; + } + + // If there is no tabframe at all, create one wxTabFrame* new_tabs = new wxTabFrame; new_tabs->SetTabCtrlHeight(m_tab_ctrl_height); diff --git a/src/aui/framemanager.cpp b/src/aui/framemanager.cpp index 18453eb829..e12eccf008 100644 --- a/src/aui/framemanager.cpp +++ b/src/aui/framemanager.cpp @@ -3035,15 +3035,19 @@ void wxAuiManager::HideHint() -// DrawHintRect() draws a drop hint rectangle. First calls DoDrop() to -// determine the exact position the pane would be at were if dropped. If -// the pame would indeed become docked at the specified drop point, -// DrawHintRect() then calls ShowHint() to indicate this drop rectangle. -// "pane_window" is the window pointer of the pane being dragged, pt is -// the mouse position, in client coordinates -void wxAuiManager::DrawHintRect(wxWindow* pane_window, - const wxPoint& pt, - const wxPoint& offset) + +// CalculateHintRect() calculates the drop hint rectangle. The method +// first calls DoDrop() to determine the exact position the pane would +// be at were if dropped. If the pane would indeed become docked at the +// specified drop point, the the rectangle hint will be returned in +// screen coordinates. Otherwise, an empty rectangle is returned. +// |pane_window| is the window pointer of the pane being dragged, |pt| is +// the mouse position, in client coordinates. |offset| describes the offset +// that the mouse is from the upper-left corner of the item being dragged + +wxRect wxAuiManager::CalculateHintRect(wxWindow* pane_window, + const wxPoint& pt, + const wxPoint& offset) { wxRect rect; @@ -3061,7 +3065,7 @@ void wxAuiManager::DrawHintRect(wxWindow* pane_window, hint.Show(); if (!hint.IsOk()) - return; + return rect; CopyDocksAndPanes(docks, panes, m_docks, m_panes); @@ -3080,8 +3084,7 @@ void wxAuiManager::DrawHintRect(wxWindow* pane_window, // find out where the new pane would be if (!DoDrop(docks, panes, hint, pt, offset)) { - HideHint(); - return; + return rect; } panes.Add(hint); @@ -3109,13 +3112,33 @@ void wxAuiManager::DrawHintRect(wxWindow* pane_window, if (rect.IsEmpty()) { - HideHint(); - return; + return rect; } // actually show the hint rectangle on the screen m_frame->ClientToScreen(&rect.x, &rect.y); - ShowHint(rect); + + return rect; +} + +// DrawHintRect() calculates the hint rectangle by calling +// CalculateHintRect(). If there is a rectangle, it shows it +// by calling ShowHint(), otherwise it hides any hint +// rectangle currently shown +void wxAuiManager::DrawHintRect(wxWindow* pane_window, + const wxPoint& pt, + const wxPoint& offset) +{ + wxRect rect = CalculateHintRect(pane_window, pt, offset); + + if (rect.IsEmpty()) + { + HideHint(); + } + else + { + ShowHint(rect); + } } void wxAuiManager::OnFloatingPaneMoveStart(wxWindow* wnd) -- 2.47.2