fixed AdvanceSelection() wrapping

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5833 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-02-04 13:49:12 +00:00
parent 58dd5b3b3e
commit 8712c6e799
2 changed files with 62 additions and 50 deletions

View File

@@ -365,13 +365,19 @@ void wxNotebook::AdvanceSelection( bool forward )
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") ); wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") );
int sel = GetSelection();
int max = GetPageCount(); int max = GetPageCount();
if ( !max )
{
// nothing to do with empty notebook
return;
}
int sel = GetSelection();
if (forward) if (forward)
SetSelection( sel == max ? 0 : sel + 1 ); SetSelection( sel == max - 1 ? 0 : sel + 1 );
else else
SetSelection( sel == 0 ? max-1 : sel - 1 ); SetSelection( sel == 0 ? max - 1 : sel - 1 );
} }
void wxNotebook::SetImageList( wxImageList* imageList ) void wxNotebook::SetImageList( wxImageList* imageList )

View File

@@ -365,13 +365,19 @@ void wxNotebook::AdvanceSelection( bool forward )
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") ); wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") );
int sel = GetSelection();
int max = GetPageCount(); int max = GetPageCount();
if ( !max )
{
// nothing to do with empty notebook
return;
}
int sel = GetSelection();
if (forward) if (forward)
SetSelection( sel == max ? 0 : sel + 1 ); SetSelection( sel == max - 1 ? 0 : sel + 1 );
else else
SetSelection( sel == 0 ? max-1 : sel - 1 ); SetSelection( sel == 0 ? max - 1 : sel - 1 );
} }
void wxNotebook::SetImageList( wxImageList* imageList ) void wxNotebook::SetImageList( wxImageList* imageList )