]> git.saurik.com Git - wxWidgets.git/commitdiff
factored out CalculateHintRect() from DrawHintRect(); hint fix in auibook
authorBenjamin Williams <bwilliams@kirix.com>
Fri, 10 Nov 2006 15:17:11 +0000 (15:17 +0000)
committerBenjamin Williams <bwilliams@kirix.com>
Fri, 10 Nov 2006 15:17:11 +0000 (15:17 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43273 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/aui/framemanager.h
src/aui/auibook.cpp
src/aui/framemanager.cpp

index 84fc2bddf828de1ac7e95beb56a352989148ddd9..863bc7a7dc5f631163950b980fd6ed4dd9b985a9 100644 (file)
@@ -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();
 
index 6aa541bfa9b4b8d8e974e666b291d4620e19180f..a9c7f0a2f26e4b88201ef6d7951f2bc206a9e8af 100644 (file)
@@ -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);
index 18453eb82958e0fc52272e1d3da0feb20b56dcb3..e12eccf008ccde7b9be06f4f674cfecc966d0ed2 100644 (file)
@@ -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)