Applied patch [ 657515 ] Widgets sample notebook out of range
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -134,6 +134,10 @@ protected:
|
|||||||
// get the numeric value of text ctrl
|
// get the numeric value of text ctrl
|
||||||
int GetTextValue(wxTextCtrl *text) const;
|
int GetTextValue(wxTextCtrl *text) const;
|
||||||
|
|
||||||
|
// is the value in range?
|
||||||
|
bool IsValidValue(int val) const
|
||||||
|
{ return (val >= 0) && (val < m_notebook->GetPageCount()); }
|
||||||
|
|
||||||
// the controls
|
// the controls
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
@@ -458,7 +462,7 @@ void NotebookWidgetsPage::OnButtonDeleteAll(wxCommandEvent& WXUNUSED(event))
|
|||||||
void NotebookWidgetsPage::OnButtonSelectPage(wxCommandEvent& event)
|
void NotebookWidgetsPage::OnButtonSelectPage(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
int pos = GetTextValue(m_textSelect);
|
int pos = GetTextValue(m_textSelect);
|
||||||
wxCHECK_RET( pos >= 0, _T("button should be disabled") );
|
wxCHECK_RET( IsValidValue(pos), _T("button should be disabled") );
|
||||||
|
|
||||||
m_notebook->SetSelection(pos);
|
m_notebook->SetSelection(pos);
|
||||||
}
|
}
|
||||||
@@ -472,7 +476,7 @@ void NotebookWidgetsPage::OnButtonAddPage(wxCommandEvent& WXUNUSED(event))
|
|||||||
void NotebookWidgetsPage::OnButtonInsertPage(wxCommandEvent& WXUNUSED(event))
|
void NotebookWidgetsPage::OnButtonInsertPage(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
int pos = GetTextValue(m_textInsert);
|
int pos = GetTextValue(m_textInsert);
|
||||||
wxCHECK_RET( pos >= 0, _T("button should be disabled") );
|
wxCHECK_RET( IsValidValue(pos), _T("button should be disabled") );
|
||||||
|
|
||||||
m_notebook->InsertPage(pos, CreateNewPage(), _T("Inserted page"), FALSE,
|
m_notebook->InsertPage(pos, CreateNewPage(), _T("Inserted page"), FALSE,
|
||||||
GetIconIndex());
|
GetIconIndex());
|
||||||
@@ -481,24 +485,24 @@ void NotebookWidgetsPage::OnButtonInsertPage(wxCommandEvent& WXUNUSED(event))
|
|||||||
void NotebookWidgetsPage::OnButtonRemovePage(wxCommandEvent& WXUNUSED(event))
|
void NotebookWidgetsPage::OnButtonRemovePage(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
int pos = GetTextValue(m_textRemove);
|
int pos = GetTextValue(m_textRemove);
|
||||||
wxCHECK_RET( pos >= 0, _T("button should be disabled") );
|
wxCHECK_RET( IsValidValue(pos), _T("button should be disabled") );
|
||||||
|
|
||||||
m_notebook->DeletePage(pos);
|
m_notebook->DeletePage(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookWidgetsPage::OnUpdateUISelectButton(wxUpdateUIEvent& event)
|
void NotebookWidgetsPage::OnUpdateUISelectButton(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
event.Enable( GetTextValue(m_textSelect) >= 0 );
|
event.Enable( IsValidValue(GetTextValue(m_textSelect)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookWidgetsPage::OnUpdateUIInsertButton(wxUpdateUIEvent& event)
|
void NotebookWidgetsPage::OnUpdateUIInsertButton(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
event.Enable( GetTextValue(m_textInsert) >= 0 );
|
event.Enable( IsValidValue(GetTextValue(m_textInsert)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookWidgetsPage::OnUpdateUIRemoveButton(wxUpdateUIEvent& event)
|
void NotebookWidgetsPage::OnUpdateUIRemoveButton(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
event.Enable( GetTextValue(m_textRemove) >= 0 );
|
event.Enable( IsValidValue(GetTextValue(m_textRemove)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotebookWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
void NotebookWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
||||||
|
Reference in New Issue
Block a user