From: Jaakko Salli Date: Thu, 25 Sep 2008 17:19:49 +0000 (+0000) Subject: AddPage(), InsertPage() now return page ptr instead of index X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9288df34010ff5dfab0e618081945e6729e2ebf6 AddPage(), InsertPage() now return page ptr instead of index git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55882 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/propgrid/manager.h b/include/wx/propgrid/manager.h index ceb1e62899..544cb0c17d 100644 --- a/include/wx/propgrid/manager.h +++ b/include/wx/propgrid/manager.h @@ -277,18 +277,20 @@ public: @param pageObj wxPropertyGridPage instance. Manager will take ownership of this object. NULL indicates that a default page instance should be created. + @return - Returns index to the page created. + Returns pointer to created page. + @remarks If toolbar is used, it is highly recommended that the pages are added when the toolbar is not turned off using window style flag switching. */ - int AddPage( const wxString& label = wxEmptyString, - const wxBitmap& bmp = wxPG_NULL_BITMAP, - wxPropertyGridPage* pageObj = (wxPropertyGridPage*) NULL ) + wxPropertyGridPage* AddPage( const wxString& label = wxEmptyString, + const wxBitmap& bmp = wxPG_NULL_BITMAP, + wxPropertyGridPage* pageObj = NULL ) { - return InsertPage(-1,label,bmp,pageObj); + return InsertPage(-1, label, bmp, pageObj); } void ClearModifiedStatus ( wxPGPropArg id ); @@ -445,13 +447,6 @@ public: return GetPage(m_selPage); } - /** Returns last page. - */ - wxPropertyGridPage* GetLastPage() const - { - return GetPage(m_arrPages.size()-1); - } - /** Returns page object for given page index. */ wxPropertyGridPage* GetPage( unsigned int ind ) const @@ -519,13 +514,14 @@ public: @param pageObj wxPropertyGridPage instance. Manager will take ownership of this object. If NULL, default page object is constructed. + @return - Returns index to the page created. + Returns pointer to created page. */ - virtual int InsertPage( int index, - const wxString& label, - const wxBitmap& bmp = wxNullBitmap, - wxPropertyGridPage* pageObj = NULL ); + virtual wxPropertyGridPage* InsertPage( int index, + const wxString& label, + const wxBitmap& bmp = wxNullBitmap, + wxPropertyGridPage* pageObj = NULL ); /** Returns true if any property on any page has been modified by the user. diff --git a/interface/wx/propgrid/manager.h b/interface/wx/propgrid/manager.h index 7cf20d0ab7..5d926bef75 100644 --- a/interface/wx/propgrid/manager.h +++ b/interface/wx/propgrid/manager.h @@ -171,8 +171,7 @@ public: wxPropertyGridPage* page; - pgMan->AddPage(wxT("First Page")); - page = pgMan->GetLastPage(); + page = pgMan->AddPage(wxT("First Page")); page->Append( new wxPropertyCategory(wxT("Category A1")) ); @@ -180,8 +179,7 @@ public: page->Append( new wxColourProperty(wxT("Colour"),wxPG_LABEL,*wxWHITE) ); - pgMan->AddPage(wxT("Second Page")); - page = pgMan->GetLastPage(); + page = pgMan->AddPage(wxT("Second Page")); page->Append( wxT("Text"),wxPG_LABEL,wxT("(no text)") ); @@ -220,18 +218,15 @@ public: wxPropertyGridPage instance. Manager will take ownership of this object. NULL indicates that a default page instance should be created. - @return Returns index to the page created. + @return Returns pointer to created property grid page. @remarks If toolbar is used, it is highly recommended that the pages are added when the toolbar is not turned off using window style flag switching. Otherwise toolbar buttons might not be added properly. */ - int AddPage( const wxString& label = wxEmptyString, - const wxBitmap& bmp = wxPG_NULL_BITMAP, - wxPropertyGridPage* pageObj = (wxPropertyGridPage*) NULL ) - { - return InsertPage(-1,label,bmp,pageObj); - } + wxPropertyGridPage* AddPage( const wxString& label = wxEmptyString, + const wxBitmap& bmp = wxPG_NULL_BITMAP, + wxPropertyGridPage* pageObj = NULL ); void ClearModifiedStatus( wxPGPropArg id ); @@ -350,14 +345,6 @@ public: */ wxPropertyGridPage* GetCurrentPage() const; - /** - Returns last page. - */ - wxPropertyGridPage* GetLastPage() const - { - return GetPage(m_arrPages.size()-1); - } - /** Returns page object for given page index. */ @@ -429,11 +416,11 @@ public: wxPropertyGridPage instance. Manager will take ownership of this object. If NULL, default page object is constructed. - @return Returns index to the page created. + @return Returns pointer to created page. */ - virtual int InsertPage( int index, const wxString& label, - const wxBitmap& bmp = wxNullBitmap, - wxPropertyGridPage* pageObj = NULL ); + virtual wxPropertyGridPage* InsertPage( int index, const wxString& label, + const wxBitmap& bmp = wxNullBitmap, + wxPropertyGridPage* pageObj = NULL ); /** Returns @true if any property on any page has been modified by the user. diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 5253c01369..649cee07f0 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -705,13 +705,15 @@ size_t wxPropertyGridManager::GetPageCount() const // ----------------------------------------------------------------------- -int wxPropertyGridManager::InsertPage( int index, const wxString& label, - const wxBitmap& bmp, wxPropertyGridPage* pageObj ) +wxPropertyGridPage* wxPropertyGridManager::InsertPage( int index, + const wxString& label, + const wxBitmap& bmp, + wxPropertyGridPage* pageObj ) { if ( index < 0 ) index = GetPageCount(); - wxCHECK_MSG( (size_t)index == GetPageCount(), -1, + wxCHECK_MSG( (size_t)index == GetPageCount(), NULL, wxT("wxPropertyGridManager currently only supports appending pages (due to wxToolBar limitation).")); bool needInit = true; @@ -826,7 +828,7 @@ int wxPropertyGridManager::InsertPage( int index, const wxString& label, wxASSERT( pageObj->GetGrid() ); - return index; + return pageObj; } // -----------------------------------------------------------------------