X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e6d94998fcbdb3ce60774e38c0d4b6ee20c6798..6342bd1ab36c1957684c00d408d09fba65d33db6:/src/generic/notebook.cpp diff --git a/src/generic/notebook.cpp b/src/generic/notebook.cpp index cced371845..97019ea950 100644 --- a/src/generic/notebook.cpp +++ b/src/generic/notebook.cpp @@ -27,11 +27,12 @@ #pragma hdrstop #endif -#include -#include -#include -#include -#include +#include "wx/string.h" +#include "wx/log.h" +#include "wx/settings.h" +#include "wx/generic/imaglist.h" +#include "wx/notebook.h" +#include "wx/dcclient.h" // ---------------------------------------------------------------------------- // macros @@ -44,7 +45,6 @@ // event table // ---------------------------------------------------------------------------- -#if !USE_SHARED_LIBRARIES BEGIN_EVENT_TABLE(wxNotebook, wxControl) EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange) EVT_SIZE(wxNotebook::OnSize) @@ -52,12 +52,11 @@ BEGIN_EVENT_TABLE(wxNotebook, wxControl) EVT_MOUSE_EVENTS(wxNotebook::OnMouseEvent) EVT_SET_FOCUS(wxNotebook::OnSetFocus) EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) - EVT_IDLE(wxNotebook::OnIdle) +// EVT_IDLE(wxNotebook::OnIdle) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent) -#endif // ============================================================================ // implementation @@ -108,9 +107,11 @@ bool wxNotebook::Create(wxWindow *parent, m_windowId = id == -1 ? NewControlId() : id; // It's like a normal window... - if (!wxWindow::Create(parent, id, pos, size, style, name)) + if (!wxWindow::Create(parent, id, pos, size, style|wxNO_BORDER, name)) return FALSE; + SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); + SetTabView(new wxNotebookTabView(this)); return TRUE; @@ -143,10 +144,13 @@ int wxNotebook::SetSelection(int nPage) wxASSERT( IS_VALID_PAGE(nPage) ); +#if defined (__WIN16__) + m_tabView->SetTabSelection(nPage); +#else wxNotebookPage* pPage = GetPage(nPage); m_tabView->SetTabSelection((int) (long) pPage); - +#endif // TODO return 0; } @@ -164,7 +168,11 @@ void wxNotebook::AdvanceSelection(bool bForward) bool wxNotebook::SetPageText(int nPage, const wxString& strText) { wxASSERT( IS_VALID_PAGE(nPage) ); - +#if defined (__WIN16__) + m_tabView->SetTabText(nPage, strText); + Refresh(); + return TRUE; +#else wxNotebookPage* page = GetPage(nPage); if (page) { @@ -172,7 +180,7 @@ bool wxNotebook::SetPageText(int nPage, const wxString& strText) Refresh(); return TRUE; } - +#endif return FALSE; } @@ -180,11 +188,15 @@ wxString wxNotebook::GetPageText(int nPage) const { wxASSERT( IS_VALID_PAGE(nPage) ); +#if defined (__WIN16__) + return m_tabView->GetTabText(nPage); +#else wxNotebookPage* page = ((wxNotebook*)this)->GetPage(nPage); if (page) return m_tabView->GetTabText((int) (long) page); else return wxEmptyString; +#endif } int wxNotebook::GetPageImage(int nPage) const @@ -225,7 +237,11 @@ bool wxNotebook::DeletePage(int nPage) } wxNotebookPage* pPage = GetPage(nPage); +#if defined (__WIN16__) + m_tabView->RemoveTab(nPage); +#else m_tabView->RemoveTab((int) (long) pPage); +#endif delete m_aPages[nPage]; m_aPages.Remove(nPage); @@ -238,7 +254,11 @@ bool wxNotebook::DeletePage(int nPage) else if (m_nSelection > -1) { m_nSelection = -1; +#if defined (__WIN16__) + m_tabView->SetTabSelection(0, FALSE); +#else m_tabView->SetTabSelection((int) (long) GetPage(0), FALSE); +#endif if (m_nSelection != 0) ChangePage(-1, 0); } @@ -266,7 +286,11 @@ bool wxNotebook::RemovePage(int nPage) // m_aPages[nPage]->Lower(); wxNotebookPage* pPage = GetPage(nPage); +#if defined (__WIN16__) + m_tabView->RemoveTab(nPage); +#else m_tabView->RemoveTab((int) (long) pPage); +#endif m_aPages.Remove(nPage); @@ -354,7 +378,12 @@ bool wxNotebook::InsertPage(int nPage, wxASSERT( pPage != NULL ); wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE ); +// For 16 bit integers (tabs limited to 32768) +#if defined (__WIN16__) + m_tabView->AddTab(nPage, strText); +#else m_tabView->AddTab((int) (long) pPage, strText); +#endif if (!bSelect) pPage->Show(FALSE); @@ -364,7 +393,11 @@ bool wxNotebook::InsertPage(int nPage, if (bSelect) { // This will cause ChangePage to be called, via OnSelPage +#if defined (__WIN16__) + m_tabView->SetTabSelection(nPage, TRUE); +#else m_tabView->SetTabSelection((int) (long) pPage, TRUE); +#endif } // some page must be selected: either this one or the first one if there is @@ -444,7 +477,7 @@ bool wxNotebook::RefreshLayout(bool force) m_tabView->SetViewRect(rect); - m_tabView->Layout(); + m_tabView->LayoutTabs(); // Need to do it a 2nd time to get the tab height with // the new view width, since changing the view width changes the @@ -457,7 +490,7 @@ bool wxNotebook::RefreshLayout(bool force) m_tabView->SetViewRect(rect); - m_tabView->Layout(); + m_tabView->LayoutTabs(); if (!force && (rect == oldRect)) return FALSE; @@ -534,7 +567,7 @@ bool wxNotebook::DoPhase(int /* nPhase */) return TRUE; } -void wxNotebook::Command(wxCommandEvent& event) +void wxNotebook::Command(wxCommandEvent& WXUNUSED(event)) { wxFAIL_MSG("wxNotebook::Command not implemented"); } @@ -559,12 +592,12 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) wxRect clientRect = GetAvailableClientSize(); pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height); + Refresh(); + pPage->Show(TRUE); pPage->Raise(); pPage->SetFocus(); - Refresh(); - m_nSelection = nSel; } @@ -623,8 +656,17 @@ void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId) if (!m_notebook) return; +// Because of name truncation! +#if defined(__BORLANDC__) && defined(__WIN16__) + wxNotebookEvent event(wxEVT_COMMAND_NB_PAGE_CHANGED, m_notebook->GetId()); +#else wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId()); +#endif +#if defined (__WIN16__) + int activatePos = activateId; + int deactivatePos = deactivateId; +#else // Translate from wxTabView's ids (which aren't position-dependent) // to wxNotebook's (which are). wxNotebookPage* pActive = (wxNotebookPage*) activateId; @@ -633,6 +675,7 @@ void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId) int activatePos = m_notebook->FindPagePosition(pActive); int deactivatePos = m_notebook->FindPagePosition(pDeactive); +#endif event.SetEventObject(m_notebook); event.SetSelection(activatePos); event.SetOldSelection(deactivatePos);