X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/10d1f4131db5405eaee6a49d3a96dd0ca4706294..aa57eeea83fac24e9d188fa800bdc96c95f5bbeb:/src/generic/notebook.cpp diff --git a/src/generic/notebook.cpp b/src/generic/notebook.cpp index e64231b122..719d8bba0d 100644 --- a/src/generic/notebook.cpp +++ b/src/generic/notebook.cpp @@ -16,10 +16,14 @@ // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "notebook.h" #endif +#ifdef __VMS +#pragma message disable unscomzer +#endif + // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -56,7 +60,6 @@ BEGIN_EVENT_TABLE(wxNotebook, wxControl) EVT_MOUSE_EVENTS(wxNotebook::OnMouseEvent) EVT_SET_FOCUS(wxNotebook::OnSetFocus) EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) -// EVT_IDLE(wxNotebook::OnIdle) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) @@ -130,8 +133,7 @@ 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|wxNO_BORDER, name)) + if (!wxControl::Create(parent, id, pos, size, style|wxNO_BORDER, wxDefaultValidator, name)) return FALSE; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); @@ -156,20 +158,14 @@ int wxNotebook::GetRowCount() const return 0; } -int wxNotebook::SetSelection(int nPage) +int wxNotebook::SetSelection(size_t nPage) { - if (nPage == -1) - return 0; - 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; } @@ -186,14 +182,10 @@ void wxNotebook::AdvanceSelection(bool bForward) } #endif -bool wxNotebook::SetPageText(int nPage, const wxString& strText) +bool wxNotebook::SetPageText(size_t 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) { @@ -201,26 +193,22 @@ bool wxNotebook::SetPageText(int nPage, const wxString& strText) Refresh(); return TRUE; } -#endif + return FALSE; } -wxString wxNotebook::GetPageText(int nPage) const +wxString wxNotebook::GetPageText(size_t 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 +int wxNotebook::GetPageImage(size_t nPage) const { wxASSERT( IS_VALID_PAGE(nPage) ); @@ -228,7 +216,7 @@ int wxNotebook::GetPageImage(int nPage) const return 0; } -bool wxNotebook::SetPageImage(int nPage, int nImage) +bool wxNotebook::SetPageImage(size_t nPage, int nImage) { wxASSERT( IS_VALID_PAGE(nPage) ); @@ -259,7 +247,7 @@ void wxNotebook::SetTabSize(const wxSize& sz) // ---------------------------------------------------------------------------- // remove one page from the notebook and delete it -bool wxNotebook::DeletePage(int nPage) +bool wxNotebook::DeletePage(size_t nPage) { wxCHECK( IS_VALID_PAGE(nPage), FALSE ); @@ -270,11 +258,8 @@ bool wxNotebook::DeletePage(int nPage) } wxNotebookPage* pPage = GetPage(nPage); -#if defined (__WIN16__) - m_tabView->RemoveTab(nPage); -#else + m_tabView->RemoveTab((int) (long) pPage); -#endif m_pages.Remove(pPage); delete pPage; @@ -287,11 +272,9 @@ 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); } @@ -310,8 +293,13 @@ bool wxNotebook::DeletePage(wxNotebookPage* page) return FALSE; } +bool wxNotebook::RemovePage(size_t nPage) +{ + return DoRemovePage(nPage) != NULL; +} + // remove one page from the notebook -bool wxNotebook::RemovePage(int nPage) +wxWindow* wxNotebook::DoRemovePage(size_t nPage) { wxCHECK( IS_VALID_PAGE(nPage), FALSE ); @@ -319,11 +307,8 @@ bool wxNotebook::RemovePage(int nPage) // m_pages[nPage]->Lower(); wxNotebookPage* pPage = GetPage(nPage); -#if defined (__WIN16__) - m_tabView->RemoveTab(nPage); -#else + m_tabView->RemoveTab((int) (long) pPage); -#endif m_pages.Remove(pPage); @@ -336,25 +321,25 @@ bool wxNotebook::RemovePage(int nPage) { // Only change the selection if the page we // deleted was the selection. - if (nPage == m_nSelection) + if (nPage == (size_t)m_nSelection) { m_nSelection = -1; // Select the first tab. Generates a ChangePage. - m_tabView->SetTabSelection((int) (long) GetPage(0), TRUE); + m_tabView->SetTabSelection(0, TRUE); } else { // We must adjust which tab we think is selected. // If greater than the page we deleted, it must be moved down // a notch. - if (m_nSelection > nPage) + if (size_t(m_nSelection) > nPage) m_nSelection -- ; } } RefreshLayout(FALSE); - return TRUE; + return pPage; } bool wxNotebook::RemovePage(wxNotebookPage* page) @@ -369,8 +354,8 @@ bool wxNotebook::RemovePage(wxNotebookPage* page) // Find the position of the wxNotebookPage, -1 if not found. int wxNotebook::FindPagePosition(wxNotebookPage* page) const { - int nPageCount = GetPageCount(); - int nPage; + size_t nPageCount = GetPageCount(); + size_t nPage; for ( nPage = 0; nPage < nPageCount; nPage++ ) if (m_pages[nPage] == page) return nPage; @@ -382,8 +367,8 @@ bool wxNotebook::DeleteAllPages() { m_tabView->ClearTabs(TRUE); - int nPageCount = GetPageCount(); - int nPage; + size_t nPageCount = GetPageCount(); + size_t nPage; for ( nPage = 0; nPage < nPageCount; nPage++ ) delete m_pages[nPage]; @@ -393,7 +378,7 @@ bool wxNotebook::DeleteAllPages() } // same as AddPage() but does it at given position -bool wxNotebook::InsertPage(int nPage, +bool wxNotebook::InsertPage(size_t nPage, wxNotebookPage *pPage, const wxString& strText, bool bSelect, @@ -402,12 +387,8 @@ 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); @@ -417,11 +398,8 @@ 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 @@ -457,8 +435,11 @@ void wxNotebook::OnSize(wxSizeEvent& event) // This was supposed to cure the non-display of the notebook // until the user resizes the window. // What's going on? -void wxNotebook::OnIdle(wxIdleEvent& event) +void wxNotebook::OnInternalIdle() { + wxWindow::OnInternalIdle(); + +#if 0 static bool s_bFirstTime = TRUE; if ( s_bFirstTime ) { /* @@ -478,7 +459,7 @@ void wxNotebook::OnIdle(wxIdleEvent& event) */ s_bFirstTime = FALSE; } - event.Skip(); +#endif } // Implementation: calculate the layout of the view rect @@ -521,8 +502,8 @@ bool wxNotebook::RefreshLayout(bool force) // fit the notebook page to the tab control's display area - unsigned int nCount = m_pages.Count(); - for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) { + size_t nCount = m_pages.Count(); + for ( size_t nPage = 0; nPage < nCount; nPage++ ) { wxNotebookPage *pPage = m_pages[nPage]; wxRect clientRect = GetAvailableClientSize(); if (pPage->IsShown()) @@ -531,13 +512,6 @@ bool wxNotebook::RefreshLayout(bool force) if ( pPage->GetAutoLayout() ) pPage->Layout(); } - // MBN: this is probably just hiding a problem under the carpet, - // but: with OpenMotif 2.2 (not Lesstif), not moving the window - // may cause the tabs to be not clickable. - else - { - pPage->Move(clientRect.x, clientRect.y); - } } Refresh(); } @@ -600,7 +574,7 @@ bool wxNotebook::DoPhase(int /* nPhase */) void wxNotebook::Command(wxCommandEvent& WXUNUSED(event)) { - wxFAIL_MSG("wxNotebook::Command not implemented"); + wxFAIL_MSG(wxT("wxNotebook::Command not implemented")); } // ---------------------------------------------------------------------------- @@ -689,10 +663,6 @@ void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId) wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId()); -#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; @@ -701,7 +671,6 @@ 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); @@ -717,10 +686,6 @@ bool wxNotebookTabView::OnTabPreActivate(int activateId, int deactivateId) { wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_notebook->GetId()); -#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; @@ -729,7 +694,6 @@ bool wxNotebookTabView::OnTabPreActivate(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);