git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45163
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
void OnTabEndDrag(wxCommandEvent& evt);
void OnTabButton(wxCommandEvent& evt);
void OnTabEndDrag(wxCommandEvent& evt);
void OnTabButton(wxCommandEvent& evt);
+ // set selection to the given window (which must be non-NULL and be one of
+ // our pages, otherwise an assert is raised)
+ void SetSelectionToWindow(wxWindow *win);
+ void SetSelectionToPage(const wxAuiNotebookPage& page)
+ {
+ SetSelectionToWindow(page.window);
+ }
+
protected:
wxAuiManager m_mgr;
protected:
wxAuiManager m_mgr;
int wxAuiTabContainer::GetIdxFromWindow(wxWindow* wnd) const
{
int wxAuiTabContainer::GetIdxFromWindow(wxWindow* wnd) const
{
- size_t i, page_count = m_pages.GetCount();
- for (i = 0; i < page_count; ++i)
+ const size_t page_count = m_pages.GetCount();
+ for ( size_t i = 0; i < page_count; ++i )
{
wxAuiNotebookPage& page = m_pages.Item(i);
if (page.window == wnd)
return i;
}
{
wxAuiNotebookPage& page = m_pages.Item(i);
if (page.window == wnd)
return i;
}
}
wxAuiNotebookPage& wxAuiTabContainer::GetPage(size_t idx)
}
wxAuiNotebookPage& wxAuiTabContainer::GetPage(size_t idx)
- int idx = m_tabs.GetIdxFromWindow(page);
- wxASSERT_MSG(idx != -1, wxT("Invalid Page index returned on wxAuiNotebook::InsertPage()"));
-
- SetSelection(idx);
+ SetSelectionToWindow(page);
if (new_active)
{
m_curpage = -1;
if (new_active)
{
m_curpage = -1;
- SetSelection(m_tabs.GetIdxFromWindow(new_active));
+ SetSelectionToWindow(new_active);
+void wxAuiNotebook::SetSelectionToWindow(wxWindow *win)
+{
+ const int idx = m_tabs.GetIdxFromWindow(win);
+ wxCHECK_RET( idx != wxNOT_FOUND, _T("invalid notebook page") );
+
+ SetSelection(idx);
+}
+
// GetPageCount() returns the total number of
// pages managed by the multi-notebook
size_t wxAuiNotebook::GetPageCount() const
// GetPageCount() returns the total number of
// pages managed by the multi-notebook
size_t wxAuiNotebook::GetPageCount() const
m_curpage = -1;
// set the active page to the one we just split off
m_curpage = -1;
// set the active page to the one we just split off
- int idx = m_tabs.GetIdxFromWindow(page_info.window);
- if ( idx != wxNOT_FOUND )
- {
- SetSelection(idx);
- }
- else
- {
- wxFAIL_MSG( _T("just inserted window not found") );
- }
+ SetSelectionToPage(page_info);
UpdateHintWindowSize();
}
UpdateHintWindowSize();
}
wxWindow* wnd = ctrl->GetWindowFromIdx(evt.GetSelection());
wxASSERT(wnd != NULL);
wxWindow* wnd = ctrl->GetWindowFromIdx(evt.GetSelection());
wxASSERT(wnd != NULL);
- int idx = m_tabs.GetIdxFromWindow(wnd);
- wxASSERT(idx != -1);
-
- SetSelection(idx);
+ SetSelectionToWindow(wnd);
}
void wxAuiNotebook::OnTabBeginDrag(wxCommandEvent&)
}
void wxAuiNotebook::OnTabBeginDrag(wxCommandEvent&)
// get main index of the page
int main_idx = m_tabs.GetIdxFromWindow(src_page);
// get main index of the page
int main_idx = m_tabs.GetIdxFromWindow(src_page);
+ wxCHECK_RET( main_idx != wxNOT_FOUND, _T("no source page?") );
+
// make a copy of the page info
// make a copy of the page info
- wxAuiNotebookPage page_info = m_tabs.GetPage((size_t)main_idx);
+ wxAuiNotebookPage page_info = m_tabs.GetPage(main_idx);
// remove the page from the source notebook
RemovePage(main_idx);
// remove the page from the source notebook
RemovePage(main_idx);
dest_tabs->Refresh();
// set the selection in the destination tab control
dest_tabs->Refresh();
// set the selection in the destination tab control
- nb->SetSelection(nb->m_tabs.GetIdxFromWindow(page_info.window));
+ nb->SetSelectionToPage(page_info);
m_curpage = -1;
// set the active page to the one we just split off
m_curpage = -1;
// set the active page to the one we just split off
- SetSelection(m_tabs.GetIdxFromWindow(page_info.window));
+ SetSelectionToPage(page_info);
UpdateHintWindowSize();
}
UpdateHintWindowSize();
}