From: Benjamin Williams Date: Tue, 31 Oct 2006 10:16:39 +0000 (+0000) Subject: aui notebook pages can be moved around X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/2fadbbfd128f69cb9922a6938c893ad79b01e749?ds=inline aui notebook pages can be moved around git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42826 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index b0b075e684..3dbe91af3a 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -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); diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index acf1ee2b51..4b13ce2c71 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -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 {