]> git.saurik.com Git - wxWidgets.git/commitdiff
aui notebook pages can be moved around
authorBenjamin Williams <bwilliams@kirix.com>
Tue, 31 Oct 2006 10:16:39 +0000 (10:16 +0000)
committerBenjamin Williams <bwilliams@kirix.com>
Tue, 31 Oct 2006 10:16:39 +0000 (10:16 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42826 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index b0b075e68447eb41053a0cf2764cee9525219759..3dbe91af3a462229d691e69400ad44a84b8a140f 100644 (file)
@@ -209,6 +209,7 @@ public:
 
     bool AddPage(wxWindow* page, const wxAuiNotebookPage& info);
     bool InsertPage(wxWindow* page, const wxAuiNotebookPage& info, size_t idx);
+    bool MovePage(wxWindow* page, size_t new_idx);
     bool RemovePage(wxWindow* page);
     bool SetActivePage(wxWindow* page);
     bool SetActivePage(size_t page);
index acf1ee2b5154dea6250d41e91839d5545ccb2e0e..4b13ce2c719c57861ea7d73252fe4c45bf2a68f4 100644 (file)
@@ -477,6 +477,25 @@ bool wxAuiTabContainer::InsertPage(wxWindow* page,
     return true;
 }
 
+bool wxAuiTabContainer::MovePage(wxWindow* page,
+                                 size_t new_idx)
+{
+    int idx = GetIdxFromWindow(page);
+    if (idx == -1)
+        return false;
+    
+    // get page entry, make a copy of it
+    wxAuiNotebookPage p = GetPage(idx);
+    
+    // remove old page entry
+    RemovePage(page);
+    
+    // insert page where it should be
+    InsertPage(page, p, new_idx);
+        
+    return true;
+}
+
 bool wxAuiTabContainer::RemovePage(wxWindow* wnd)
 {
     size_t i, page_count = m_pages.GetCount();
@@ -1753,7 +1772,26 @@ void wxAuiMultiNotebook::OnTabEndDrag(wxCommandEvent& command_evt)
         dest_tabs = tab_frame->m_tabs;
 
         if (dest_tabs == src_tabs)
+        {
+            wxPoint pt = dest_tabs->ScreenToClient(mouse_screen_pt);
+            wxWindow* dest_location_tab;
+            
+            // -- this is an inner-tab drag/reposition
+            if (dest_tabs->TabHitTest(pt.x, pt.y, &dest_location_tab))
+            {
+                wxWindow* src_tab = src_tabs->GetWindowFromIdx(evt.GetSelection());
+                int dest_idx = dest_tabs->GetIdxFromWindow(dest_location_tab);
+                if (dest_idx != -1)
+                {
+                    dest_tabs->MovePage(src_tab, dest_idx);
+                    dest_tabs->SetActivePage((size_t)dest_idx);
+                    dest_tabs->DoShowHide();
+                    dest_tabs->Refresh();
+                }
+            }
+            
             return;
+        }
     }
      else
     {