relay out the control after deleting any page, not just the last one (#9684); also extract the size event sending code in a separate function to be able to replace it with something better easier later

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54605 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-07-13 18:01:12 +00:00
parent b8e57034a2
commit 905069b18f

View File

@@ -185,9 +185,11 @@ void wxListbook::OnSize(wxSizeEvent& event)
// under MSW, we'd finish with an ugly looking list control with both // under MSW, we'd finish with an ugly looking list control with both
// vertical and horizontal scrollbar (with one of them being added because // vertical and horizontal scrollbar (with one of them being added because
// the other one is not accounted for in client size computations) // the other one is not accounted for in client size computations)
wxListView *list = GetListView(); wxListView * const list = GetListView();
if (list) list->Arrange(); if ( list )
wxBookCtrlBase::OnSize(event); list->Arrange();
event.Skip();
} }
int wxListbook::HitTest(const wxPoint& pt, long *flags) const int wxListbook::HitTest(const wxPoint& pt, long *flags) const
@@ -247,6 +249,13 @@ wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const
return size; return size;
} }
void wxListbook::UpdateSize()
{
// we should find a more elegant way to force a layout than generating this
// dummy event
wxSizeEvent sz(GetSize(), GetId());
GetEventHandler()->ProcessEvent(sz);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// accessing the pages // accessing the pages
@@ -412,8 +421,7 @@ wxListbook::InsertPage(size_t n,
if ( selNew != -1 ) if ( selNew != -1 )
SetSelection(selNew); SetSelection(selNew);
wxSizeEvent sz(GetSize(), GetId()); UpdateSize();
GetEventHandler()->ProcessEvent(sz);
return true; return true;
} }
@@ -444,11 +452,7 @@ wxWindow *wxListbook::DoRemovePage(size_t page)
} }
GetListView()->Arrange(); GetListView()->Arrange();
if (GetPageCount() == 0) UpdateSize();
{
wxSizeEvent sz(GetSize(), GetId());
GetEventHandler()->ProcessEvent(sz);
}
} }
return win; return win;
@@ -463,8 +467,7 @@ bool wxListbook::DeleteAllPages()
m_selection = -1; m_selection = -1;
wxSizeEvent sz(GetSize(), GetId()); UpdateSize();
GetEventHandler()->ProcessEvent(sz);
return true; return true;
} }