X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4758baf5eb87bd1f1251a21e3fa8e5d658b9a3b6..c37b0f0907b07878551a00165b0ad323bd2ccdaf:/src/aui/auibook.cpp diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 3d423f25e6..fb3d540a84 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -24,7 +24,8 @@ #ifndef WX_PRECOMP #include "wx/settings.h" - #include "wx/clientdc.h" + #include "wx/dcclient.h" + #include "wx/dcmemory.h" #endif #include "wx/aui/tabmdi.h" @@ -37,22 +38,22 @@ WX_DEFINE_OBJARRAY(wxAuiNotebookPageArray) WX_DEFINE_OBJARRAY(wxAuiTabContainerButtonArray) -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_CANCEL_DRAG, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, wxAuiNotebookEvent); -wxDEFINE_EVENT(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_PAGE_CHANGING, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_BUTTON, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_BEGIN_DRAG, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_END_DRAG, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_CANCEL_DRAG, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_DRAG_MOTION, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_ALLOW_DND, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_BG_DCLICK, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_DRAG_DONE, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_TAB_RIGHT_UP, wxAuiNotebookEvent); +wxDEFINE_EVENT(wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN, wxAuiNotebookEvent); IMPLEMENT_CLASS(wxAuiNotebook, wxControl) IMPLEMENT_CLASS(wxAuiTabCtrl, wxControl) @@ -422,7 +423,7 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) size_t button_count = m_buttons.GetCount(); // create off-screen bitmap - bmp.Create(m_rect.GetWidth(), m_rect.GetHeight()); + bmp.Create(m_rect.GetWidth(), m_rect.GetHeight(),*raw_dc); dc.SelectObject(bmp); if (!dc.IsOk()) @@ -526,10 +527,8 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) int left_buttons_width = 0; int right_buttons_width = 0; - int offset = 0; - // draw the buttons on the right side - offset = m_rect.x + m_rect.width; + int offset = m_rect.x + m_rect.width; for (i = 0; i < button_count; ++i) { wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1); @@ -742,10 +741,8 @@ bool wxAuiTabContainer::IsTabVisible(int tabPage, int tabOffset, wxDC* dc, wxWin int left_buttons_width = 0; int right_buttons_width = 0; - int offset = 0; - // calculate size of the buttons on the right side - offset = m_rect.x + m_rect.width; + int offset = m_rect.x + m_rect.width; for (i = 0; i < button_count; ++i) { wxAuiTabContainerButton& button = m_buttons.Item(button_count - i - 1); @@ -924,7 +921,7 @@ bool wxAuiTabContainer::ButtonHitTest(int x, int y, static void ShowWnd(wxWindow* wnd, bool show) { #if wxUSE_MDI - if (wnd->IsKindOf(CLASSINFO(wxAuiMDIChildFrame))) + if (wxDynamicCast(wnd, wxAuiMDIChildFrame)) { wxAuiMDIChildFrame* cf = (wxAuiMDIChildFrame*)wnd; cf->DoShow(show); @@ -1049,10 +1046,10 @@ void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt) // wxAuiNotebooks always want to receive this event // even if the tab is already active, because they may // have multiple tab controls - if (new_selection != GetActivePage() || - GetParent()->IsKindOf(CLASSINFO(wxAuiNotebook))) + if ((new_selection != GetActivePage() || + wxDynamicCast(GetParent(), wxAuiNotebook)) && !m_hoverButton) { - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_PAGE_CHANGING, m_windowId); e.SetSelection(new_selection); e.SetOldSelection(GetActivePage()); e.SetEventObject(this); @@ -1079,7 +1076,7 @@ void wxAuiTabCtrl::OnCaptureLost(wxMouseCaptureLostEvent& WXUNUSED(event)) { m_isDragging = false; - wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_CANCEL_DRAG, m_windowId); + wxAuiNotebookEvent evt(wxEVT_AUINOTEBOOK_CANCEL_DRAG, m_windowId); evt.SetSelection(GetIdxFromWindow(m_clickTab)); evt.SetOldSelection(evt.GetSelection()); evt.SetEventObject(this); @@ -1096,11 +1093,11 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt) { m_isDragging = false; - wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, m_windowId); - evt.SetSelection(GetIdxFromWindow(m_clickTab)); - evt.SetOldSelection(evt.GetSelection()); - evt.SetEventObject(this); - GetEventHandler()->ProcessEvent(evt); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_END_DRAG, m_windowId); + e.SetSelection(GetIdxFromWindow(m_clickTab)); + e.SetOldSelection(e.GetSelection()); + e.SetEventObject(this); + GetEventHandler()->ProcessEvent(e); return; } @@ -1124,11 +1121,11 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt) if (!(m_pressedButton->curState & wxAUI_BUTTON_STATE_DISABLED)) { - wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, m_windowId); - evt.SetSelection(GetIdxFromWindow(m_clickTab)); - evt.SetInt(m_pressedButton->id); - evt.SetEventObject(this); - GetEventHandler()->ProcessEvent(evt); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_BUTTON, m_windowId); + e.SetSelection(GetIdxFromWindow(m_clickTab)); + e.SetInt(m_pressedButton->id); + e.SetEventObject(this); + GetEventHandler()->ProcessEvent(e); } m_pressedButton = NULL; @@ -1145,7 +1142,7 @@ void wxAuiTabCtrl::OnMiddleUp(wxMouseEvent& evt) if (!TabHitTest(evt.m_x, evt.m_y, &wnd)) return; - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP, m_windowId); e.SetEventObject(this); e.SetSelection(GetIdxFromWindow(wnd)); GetEventHandler()->ProcessEvent(e); @@ -1157,7 +1154,7 @@ void wxAuiTabCtrl::OnMiddleDown(wxMouseEvent& evt) if (!TabHitTest(evt.m_x, evt.m_y, &wnd)) return; - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN, m_windowId); e.SetEventObject(this); e.SetSelection(GetIdxFromWindow(wnd)); GetEventHandler()->ProcessEvent(e); @@ -1169,7 +1166,7 @@ void wxAuiTabCtrl::OnRightUp(wxMouseEvent& evt) if (!TabHitTest(evt.m_x, evt.m_y, &wnd)) return; - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_TAB_RIGHT_UP, m_windowId); e.SetEventObject(this); e.SetSelection(GetIdxFromWindow(wnd)); GetEventHandler()->ProcessEvent(e); @@ -1181,7 +1178,7 @@ void wxAuiTabCtrl::OnRightDown(wxMouseEvent& evt) if (!TabHitTest(evt.m_x, evt.m_y, &wnd)) return; - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN, m_windowId); e.SetEventObject(this); e.SetSelection(GetIdxFromWindow(wnd)); GetEventHandler()->ProcessEvent(e); @@ -1193,7 +1190,7 @@ void wxAuiTabCtrl::OnLeftDClick(wxMouseEvent& evt) wxAuiTabContainerButton* button; if (!TabHitTest(evt.m_x, evt.m_y, &wnd) && !ButtonHitTest(evt.m_x, evt.m_y, &button)) { - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_BG_DCLICK, m_windowId); e.SetEventObject(this); GetEventHandler()->ProcessEvent(e); } @@ -1236,17 +1233,31 @@ void wxAuiTabCtrl::OnMotion(wxMouseEvent& evt) } } +#if wxUSE_TOOLTIPS + wxWindow* wnd = NULL; + if (evt.Moving() && TabHitTest(evt.m_x, evt.m_y, &wnd)) + { + wxString tooltip(m_pages[GetIdxFromWindow(wnd)].tooltip); + + // If the text changes, set it else, keep old, to avoid + // 'moving tooltip' effect + if (GetToolTipText() != tooltip) + SetToolTip(tooltip); + } + else + UnsetToolTip(); +#endif // wxUSE_TOOLTIPS if (!evt.LeftIsDown() || m_clickPt == wxDefaultPosition) return; if (m_isDragging) { - wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, m_windowId); - evt.SetSelection(GetIdxFromWindow(m_clickTab)); - evt.SetOldSelection(evt.GetSelection()); - evt.SetEventObject(this); - GetEventHandler()->ProcessEvent(evt); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_DRAG_MOTION, m_windowId); + e.SetSelection(GetIdxFromWindow(m_clickTab)); + e.SetOldSelection(e.GetSelection()); + e.SetEventObject(this); + GetEventHandler()->ProcessEvent(e); return; } @@ -1257,11 +1268,11 @@ void wxAuiTabCtrl::OnMotion(wxMouseEvent& evt) if (abs(pos.x - m_clickPt.x) > drag_x_threshold || abs(pos.y - m_clickPt.y) > drag_y_threshold) { - wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, m_windowId); - evt.SetSelection(GetIdxFromWindow(m_clickTab)); - evt.SetOldSelection(evt.GetSelection()); - evt.SetEventObject(this); - GetEventHandler()->ProcessEvent(evt); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_BEGIN_DRAG, m_windowId); + e.SetSelection(GetIdxFromWindow(m_clickTab)); + e.SetOldSelection(e.GetSelection()); + e.SetEventObject(this); + GetEventHandler()->ProcessEvent(e); m_isDragging = true; } @@ -1306,7 +1317,7 @@ void wxAuiTabCtrl::OnButton(wxAuiNotebookEvent& event) if (idx != -1) { - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_PAGE_CHANGING, m_windowId); e.SetSelection(idx); e.SetOldSelection(GetActivePage()); e.SetEventObject(this); @@ -1442,7 +1453,7 @@ void wxAuiTabCtrl::OnChar(wxKeyEvent& event) if (newPage != -1) { - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_PAGE_CHANGING, m_windowId); e.SetSelection(newPage); e.SetOldSelection(newPage); e.SetEventObject(this); @@ -1531,7 +1542,10 @@ public: for (i = 0; i < page_count; ++i) { - int height = m_rect.height - m_tabCtrlHeight; + wxAuiNotebookPage& page = pages.Item(i); + int border_space = m_tabs->GetArtProvider()->GetAdditionalBorderSpace(page.window); + + int height = m_rect.height - m_tabCtrlHeight - border_space; if ( height < 0 ) { // avoid passing negative height to wxWindow::SetSize(), this @@ -1539,21 +1553,25 @@ public: height = 0; } - wxAuiNotebookPage& page = pages.Item(i); if (m_tabs->GetFlags() & wxAUI_NB_BOTTOM) { - page.window->SetSize(m_rect.x, m_rect.y, m_rect.width, height); + page.window->SetSize(m_rect.x + border_space, + m_rect.y + border_space, + m_rect.width - 2 * border_space, + height); } else //TODO: if (GetFlags() & wxAUI_NB_TOP) { - page.window->SetSize(m_rect.x, m_rect.y + m_tabCtrlHeight, - m_rect.width, height); + page.window->SetSize(m_rect.x + border_space, + m_rect.y + m_tabCtrlHeight, + m_rect.width - 2 * border_space, + height); } // TODO: else if (GetFlags() & wxAUI_NB_LEFT){} // TODO: else if (GetFlags() & wxAUI_NB_RIGHT){} #if wxUSE_MDI - if (page.window->IsKindOf(CLASSINFO(wxAuiMDIChildFrame))) + if (wxDynamicCast(page.window, wxAuiMDIChildFrame)) { wxAuiMDIChildFrame* wnd = (wxAuiMDIChildFrame*)page.window; wnd->ApplyMDIChildFrameRect(); @@ -1596,37 +1614,37 @@ BEGIN_EVENT_TABLE(wxAuiNotebook, wxControl) EVT_SIZE(wxAuiNotebook::OnSize) EVT_CHILD_FOCUS(wxAuiNotebook::OnChildFocusNotebook) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, + wxEVT_AUINOTEBOOK_PAGE_CHANGING, wxAuiNotebook::OnTabClicked) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG, + wxEVT_AUINOTEBOOK_BEGIN_DRAG, wxAuiNotebook::OnTabBeginDrag) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, + wxEVT_AUINOTEBOOK_END_DRAG, wxAuiNotebook::OnTabEndDrag) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_CANCEL_DRAG, + wxEVT_AUINOTEBOOK_CANCEL_DRAG, wxAuiNotebook::OnTabCancelDrag) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_DRAG_MOTION, + wxEVT_AUINOTEBOOK_DRAG_MOTION, wxAuiNotebook::OnTabDragMotion) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_BUTTON, + wxEVT_AUINOTEBOOK_BUTTON, wxAuiNotebook::OnTabButton) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, + wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN, wxAuiNotebook::OnTabMiddleDown) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, + wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP, wxAuiNotebook::OnTabMiddleUp) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, + wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN, wxAuiNotebook::OnTabRightDown) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, + wxEVT_AUINOTEBOOK_TAB_RIGHT_UP, wxAuiNotebook::OnTabRightUp) EVT_AUI_RANGE(wxAuiBaseTabCtrlId, wxAuiBaseTabCtrlId+500, - wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, + wxEVT_AUINOTEBOOK_BG_DCLICK, wxAuiNotebook::OnTabBgDClick) EVT_NAVIGATION_KEY(wxAuiNotebook::OnNavigationKeyNotebook) END_EVENT_TABLE() @@ -1972,7 +1990,7 @@ bool wxAuiNotebook::DeletePage(size_t page_idx) #if wxUSE_MDI // actually destroy the window now - if (wnd->IsKindOf(CLASSINFO(wxAuiMDIChildFrame))) + if (wxDynamicCast(wnd, wxAuiMDIChildFrame)) { // delete the child frame with pending delete, as is // customary with frame windows @@ -2125,6 +2143,37 @@ wxString wxAuiNotebook::GetPageText(size_t page_idx) const return page_info.caption; } +bool wxAuiNotebook::SetPageToolTip(size_t page_idx, const wxString& text) +{ + if (page_idx >= m_tabs.GetPageCount()) + return false; + + // update our own tab catalog + wxAuiNotebookPage& page_info = m_tabs.GetPage(page_idx); + page_info.tooltip = text; + + wxAuiTabCtrl* ctrl; + int ctrl_idx; + if (!FindTab(page_info.window, &ctrl, &ctrl_idx)) + return false; + + wxAuiNotebookPage& info = ctrl->GetPage(ctrl_idx); + info.tooltip = text; + + // NB: we don't update the tooltip if it is already being displayed, it + // typically never happens, no need to code that + return true; +} + +wxString wxAuiNotebook::GetPageToolTip(size_t page_idx) const +{ + if (page_idx >= m_tabs.GetPageCount()) + return wxString(); + + const wxAuiNotebookPage& page_info = m_tabs.GetPage(page_idx); + return page_info.tooltip; +} + bool wxAuiNotebook::SetPageBitmap(size_t page_idx, const wxBitmap& bitmap) { if (page_idx >= m_tabs.GetPageCount()) @@ -2433,10 +2482,21 @@ void wxAuiNotebook::OnTabClicked(wxAuiNotebookEvent& evt) SetSelectionToWindow(wnd); } -void wxAuiNotebook::OnTabBgDClick(wxAuiNotebookEvent& WXUNUSED(evt)) +void wxAuiNotebook::OnTabBgDClick(wxAuiNotebookEvent& evt) { + // select the tab ctrl which received the db click + int selection; + wxWindow* wnd; + wxAuiTabCtrl* ctrl = (wxAuiTabCtrl*)evt.GetEventObject(); + if ( (ctrl != NULL) + && ((selection = ctrl->GetActivePage()) != wxNOT_FOUND) + && ((wnd = ctrl->GetWindowFromIdx(selection)) != NULL)) + { + SetSelectionToWindow(wnd); + } + // notify owner that the tabbar background has been double-clicked - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_BG_DCLICK, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_BG_DCLICK, m_windowId); e.SetEventObject(this); GetEventHandler()->ProcessEvent(e); } @@ -2492,6 +2552,7 @@ void wxAuiNotebook::OnTabDragMotion(wxAuiNotebookEvent& evt) wxWindow* src_tab = dest_tabs->GetWindowFromIdx(src_idx); dest_tabs->MovePage(src_tab, dest_idx); + m_tabs.MovePage(m_tabs.GetPage(src_idx).window, dest_idx); dest_tabs->SetActivePage((size_t)dest_idx); dest_tabs->DoShowHide(); dest_tabs->Refresh(); @@ -2514,11 +2575,11 @@ void wxAuiNotebook::OnTabDragMotion(wxAuiNotebookEvent& evt) return; // make sure we are not over the hint window - if (!tab_ctrl->IsKindOf(CLASSINFO(wxFrame))) + if (!wxDynamicCast(tab_ctrl, wxFrame)) { while (tab_ctrl) { - if (tab_ctrl->IsKindOf(CLASSINFO(wxAuiTabCtrl))) + if (wxDynamicCast(tab_ctrl, wxAuiTabCtrl)) break; tab_ctrl = tab_ctrl->GetParent(); } @@ -2600,7 +2661,7 @@ void wxAuiNotebook::OnTabEndDrag(wxAuiNotebookEvent& evt) while (tab_ctrl) { - if (tab_ctrl->IsKindOf(CLASSINFO(wxAuiTabCtrl))) + if (wxDynamicCast(tab_ctrl, wxAuiTabCtrl)) break; tab_ctrl = tab_ctrl->GetParent(); } @@ -2613,7 +2674,7 @@ void wxAuiNotebook::OnTabEndDrag(wxAuiNotebookEvent& evt) { // find out from the destination control // if it's ok to drop this tab here - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_ALLOW_DND, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_ALLOW_DND, m_windowId); e.SetSelection(evt.GetSelection()); e.SetOldSelection(evt.GetSelection()); e.SetEventObject(this); @@ -2676,7 +2737,7 @@ void wxAuiNotebook::OnTabEndDrag(wxAuiNotebookEvent& evt) if (insert_idx == -1) insert_idx = dest_tabs->GetPageCount(); dest_tabs->InsertPage(page_info.window, page_info, insert_idx); - nb->m_tabs.AddPage(page_info.window, page_info); + nb->m_tabs.InsertPage(page_info.window, page_info, insert_idx); nb->DoSizing(); dest_tabs->DoShowHide(); @@ -2686,7 +2747,7 @@ void wxAuiNotebook::OnTabEndDrag(wxAuiNotebookEvent& evt) nb->SetSelectionToPage(page_info); // notify owner that the tab has been dragged - wxAuiNotebookEvent e2(wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, m_windowId); + wxAuiNotebookEvent e2(wxEVT_AUINOTEBOOK_DRAG_DONE, m_windowId); e2.SetSelection(evt.GetSelection()); e2.SetOldSelection(evt.GetSelection()); e2.SetEventObject(this); @@ -2795,7 +2856,7 @@ void wxAuiNotebook::OnTabEndDrag(wxAuiNotebookEvent& evt) } // notify owner that the tab has been dragged - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_DRAG_DONE, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_DRAG_DONE, m_windowId); e.SetSelection(evt.GetSelection()); e.SetOldSelection(evt.GetSelection()); e.SetEventObject(this); @@ -3038,7 +3099,7 @@ void wxAuiNotebook::OnTabButton(wxAuiNotebookEvent& evt) wxWindow* close_wnd = tabs->GetWindowFromIdx(selection); // ask owner if it's ok to close the tab - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_PAGE_CLOSE, m_windowId); e.SetSelection(m_tabs.GetIdxFromWindow(close_wnd)); const int idx = m_tabs.GetIdxFromWindow(close_wnd); e.SetSelection(idx); @@ -3050,7 +3111,7 @@ void wxAuiNotebook::OnTabButton(wxAuiNotebookEvent& evt) #if wxUSE_MDI - if (close_wnd->IsKindOf(CLASSINFO(wxAuiMDIChildFrame))) + if (wxDynamicCast(close_wnd, wxAuiMDIChildFrame)) { close_wnd->Close(); } @@ -3064,7 +3125,7 @@ void wxAuiNotebook::OnTabButton(wxAuiNotebookEvent& evt) } // notify owner that the tab has been closed - wxAuiNotebookEvent e2(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, m_windowId); + wxAuiNotebookEvent e2(wxEVT_AUINOTEBOOK_PAGE_CLOSED, m_windowId); e2.SetSelection(idx); e2.SetEventObject(this); GetEventHandler()->ProcessEvent(e2); @@ -3079,7 +3140,7 @@ void wxAuiNotebook::OnTabMiddleDown(wxAuiNotebookEvent& evt) wxAuiTabCtrl* tabs = (wxAuiTabCtrl*)evt.GetEventObject(); wxWindow* wnd = tabs->GetWindowFromIdx(evt.GetSelection()); - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_TAB_MIDDLE_DOWN, m_windowId); e.SetSelection(m_tabs.GetIdxFromWindow(wnd)); e.SetEventObject(this); GetEventHandler()->ProcessEvent(e); @@ -3095,7 +3156,7 @@ void wxAuiNotebook::OnTabMiddleUp(wxAuiNotebookEvent& evt) wxAuiTabCtrl* tabs = (wxAuiTabCtrl*)evt.GetEventObject(); wxWindow* wnd = tabs->GetWindowFromIdx(evt.GetSelection()); - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_TAB_MIDDLE_UP, m_windowId); e.SetSelection(m_tabs.GetIdxFromWindow(wnd)); e.SetEventObject(this); if (GetEventHandler()->ProcessEvent(e)) @@ -3118,7 +3179,7 @@ void wxAuiNotebook::OnTabRightDown(wxAuiNotebookEvent& evt) wxAuiTabCtrl* tabs = (wxAuiTabCtrl*)evt.GetEventObject(); wxWindow* wnd = tabs->GetWindowFromIdx(evt.GetSelection()); - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_TAB_RIGHT_DOWN, m_windowId); e.SetSelection(m_tabs.GetIdxFromWindow(wnd)); e.SetEventObject(this); GetEventHandler()->ProcessEvent(e); @@ -3130,7 +3191,7 @@ void wxAuiNotebook::OnTabRightUp(wxAuiNotebookEvent& evt) wxAuiTabCtrl* tabs = (wxAuiTabCtrl*)evt.GetEventObject(); wxWindow* wnd = tabs->GetWindowFromIdx(evt.GetSelection()); - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP, m_windowId); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_TAB_RIGHT_UP, m_windowId); e.SetSelection(m_tabs.GetIdxFromWindow(wnd)); e.SetEventObject(this); GetEventHandler()->ProcessEvent(e); @@ -3188,34 +3249,6 @@ int wxAuiNotebook::GetHeightForPageHeight(int pageHeight) return tabCtrlHeight + pageHeight + decorHeight; } -// 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() { @@ -3225,7 +3258,7 @@ bool wxAuiNotebook::ShowWindowMenu() if (idx != -1) { - wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, tabCtrl->GetId()); + wxAuiNotebookEvent e(wxEVT_AUINOTEBOOK_PAGE_CHANGING, tabCtrl->GetId()); e.SetSelection(idx); e.SetOldSelection(tabCtrl->GetActivePage()); e.SetEventObject(tabCtrl); @@ -3237,11 +3270,11 @@ bool wxAuiNotebook::ShowWindowMenu() return false; } -void wxAuiNotebook::Thaw() +void wxAuiNotebook::DoThaw() { DoSizing(); - wxControl::Thaw(); + wxBookCtrlBase::DoThaw(); } void wxAuiNotebook::SetPageSize (const wxSize& WXUNUSED(size)) @@ -3266,13 +3299,6 @@ 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); @@ -3338,7 +3364,7 @@ int wxAuiNotebook::DoModifySelection(size_t n, bool events) bool vetoed = false; - wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId); + wxAuiNotebookEvent evt(wxEVT_AUINOTEBOOK_PAGE_CHANGING, m_windowId); if(events) { @@ -3357,7 +3383,7 @@ int wxAuiNotebook::DoModifySelection(size_t n, bool events) // program allows the page change if(events) { - evt.SetEventType(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED); + evt.SetEventType(wxEVT_AUINOTEBOOK_PAGE_CHANGED); (void)GetEventHandler()->ProcessEvent(evt); }