several notebook bugs fixed:

1. deleting the last page sets selection to -1
2. deleting the selected page unselects it first
3. adding page calls Layout() on it


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2888 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-06-24 21:27:52 +00:00
parent b1cf23dc26
commit 96d3780753
3 changed files with 42 additions and 4 deletions

View File

@@ -162,6 +162,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_BUTTON(ID_DELETE_PAGE, MyFrame::OnDeletePage)
EVT_BUTTON(ID_ADD_PAGE, MyFrame::OnAddPage)
EVT_SIZE(MyFrame::OnSize)
EVT_IDLE(MyFrame::OnIdle)
END_EVENT_TABLE()
MyFrame::MyFrame(wxFrame* parent, const wxWindowID id, const wxString& title,
@@ -183,17 +184,17 @@ void MyFrame::OnAddPage(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnDeletePage(wxCommandEvent& WXUNUSED(event))
{
m_notebook->DeletePage( m_notebook->GetPageCount()-1 );
m_notebook->DeletePage( m_notebook->GetPageCount()-1 );
}
void MyFrame::OnOK(wxCommandEvent& WXUNUSED(event) )
{
this->Destroy();
Destroy();
}
void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event) )
{
this->Destroy();
Destroy();
}
void MyFrame::Init(void)
@@ -229,3 +230,21 @@ void MyFrame::OnSize(wxSizeEvent& event)
m_panel->Layout();
}
void MyFrame::OnIdle(wxIdleEvent& WXUNUSED(event))
{
static int s_nPages = -1;
static int s_nSel = -1;
int nPages = m_notebook->GetPageCount();
int nSel = m_notebook->GetSelection();
if ( nPages != s_nPages || nSel != s_nSel )
{
s_nPages = nPages;
s_nSel = nSel;
wxString title;
title.Printf("Notebook (%d pages, selection: %d)", nPages, nSel);
SetTitle(title);
}
}