+// Advances the selection, generation page selection events
+void wxAuiNotebook::AdvanceSelection(bool forward)
+{
+ if (GetPageCount() <= 1)
+ return;
+
+ int currentSelection = GetSelection();
+
+ if (forward)
+ {
+ if (currentSelection == (int) (GetPageCount() - 1))
+ return;
+ else if (currentSelection == -1)
+ currentSelection = 0;
+ else
+ currentSelection ++;
+ }
+ else
+ {
+ if (currentSelection <= 0)
+ return;
+ else
+ currentSelection --;
+ }
+
+ SetSelection(currentSelection);
+}
+
+// Shows the window menu
+bool wxAuiNotebook::ShowWindowMenu()
+{
+ wxAuiTabCtrl* tabCtrl = GetActiveTabCtrl();
+
+ int idx = tabCtrl->GetArtProvider()->ShowDropDown(tabCtrl, tabCtrl->GetPages(), tabCtrl->GetActivePage());
+
+ if (idx != -1)
+ {
+ wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, tabCtrl->GetId());
+ e.SetSelection(idx);
+ e.SetOldSelection(tabCtrl->GetActivePage());
+ e.SetEventObject(tabCtrl);
+ GetEventHandler()->ProcessEvent(e);
+
+ return true;
+ }
+ else
+ return false;
+}
+
+void wxAuiNotebook::Thaw()
+{
+ DoSizing();
+
+ wxControl::Thaw();
+}
+
+void wxAuiNotebook::SetPageSize (const wxSize& WXUNUSED(size))
+{
+ wxFAIL_MSG("Not implemented for wxAuiNotebook");
+}
+
+int wxAuiNotebook::HitTest (const wxPoint& WXUNUSED(pt), long* WXUNUSED(flags)) const
+{
+ wxFAIL_MSG("Not implemented for wxAuiNotebook");
+ return wxNOT_FOUND;
+}
+
+int wxAuiNotebook::GetPageImage(size_t WXUNUSED(n)) const
+{
+ wxFAIL_MSG("Not implemented for wxAuiNotebook");
+ return -1;
+}
+
+bool wxAuiNotebook::SetPageImage(size_t n, int imageId)
+{
+ return SetPageBitmap(n, GetImageList()->GetBitmap(imageId));
+}
+
+wxWindow* wxAuiNotebook::GetCurrentPage () const
+{
+ const int sel = GetSelection();
+
+ return sel == wxNOT_FOUND ? NULL : GetPage(sel);
+}
+
+int wxAuiNotebook::ChangeSelection(size_t n)
+{
+ return DoModifySelection(n, false);
+}
+
+bool wxAuiNotebook::AddPage(wxWindow *page, const wxString &text, bool select,
+ int imageId)
+{
+ if(HasImageList())
+ {
+ return AddPage(page, text, select, GetImageList()->GetBitmap(imageId));
+ }
+ else
+ {
+ return AddPage(page, text, select, wxNullBitmap);
+ }
+}
+
+bool wxAuiNotebook::DeleteAllPages()
+{
+ size_t count = GetPageCount();
+ for(size_t i = 0; i < count; i++)
+ {
+ DeletePage(0);
+ }
+ return true;
+}
+
+bool wxAuiNotebook::InsertPage(size_t index, wxWindow *page,
+ const wxString &text, bool select,
+ int imageId)
+{
+ if(HasImageList())
+ {
+ return InsertPage(index, page, text, select,
+ GetImageList()->GetBitmap(imageId));
+ }
+ else
+ {
+ return InsertPage(index, page, text, select, wxNullBitmap);
+ }
+}
+
+int wxAuiNotebook::DoModifySelection(size_t n, bool events)
+{
+ wxWindow* wnd = m_tabs.GetWindowFromIdx(n);
+ if (!wnd)
+ return m_curPage;
+
+ // don't change the page unless necessary;
+ // however, clicking again on a tab should give it the focus.
+ if ((int)n == m_curPage)
+ {
+ wxAuiTabCtrl* ctrl;
+ int ctrl_idx;
+ if (FindTab(wnd, &ctrl, &ctrl_idx))
+ {
+ if (FindFocus() != ctrl)
+ ctrl->SetFocus();
+ }
+ return m_curPage;
+ }
+
+ bool vetoed = false;
+
+ wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId);
+
+ if(events)
+ {
+ evt.SetSelection(n);
+ evt.SetOldSelection(m_curPage);
+ evt.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(evt);
+ vetoed = !evt.IsAllowed();
+ }
+
+ if (!vetoed)
+ {
+ int old_curpage = m_curPage;
+ m_curPage = n;
+
+ // program allows the page change
+ if(events)
+ {
+ evt.SetEventType(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED);
+ (void)GetEventHandler()->ProcessEvent(evt);
+ }
+
+
+ wxAuiTabCtrl* ctrl;
+ int ctrl_idx;
+ if (FindTab(wnd, &ctrl, &ctrl_idx))
+ {
+ m_tabs.SetActivePage(wnd);
+
+ ctrl->SetActivePage(ctrl_idx);
+ DoSizing();
+ ctrl->DoShowHide();
+
+ ctrl->MakeTabVisible(ctrl_idx, ctrl);
+
+ // set fonts
+ wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes();
+ size_t i, pane_count = all_panes.GetCount();
+ for (i = 0; i < pane_count; ++i)
+ {
+ wxAuiPaneInfo& pane = all_panes.Item(i);
+ if (pane.name == wxT("dummy"))
+ continue;
+ wxAuiTabCtrl* tabctrl = ((wxTabFrame*)pane.window)->m_tabs;
+ if (tabctrl != ctrl)
+ tabctrl->SetSelectedFont(m_normalFont);
+ else
+ tabctrl->SetSelectedFont(m_selectedFont);
+ tabctrl->Refresh();
+ }
+
+ // Set the focus to the page if we're not currently focused on the tab.
+ // This is Firefox-like behaviour.
+ if (wnd->IsShownOnScreen() && FindFocus() != ctrl)
+ wnd->SetFocus();
+
+ return old_curpage;
+ }
+ }
+
+ return m_curPage;
+}
+