From 6a82a0d0414f3a83f921ddd0d565dc820bf7a32f Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 18 May 2006 09:53:19 +0000 Subject: [PATCH] Selection should be set to -1 if all pages are deleted, or the next insertion will try to set the selection to 1. Fixed lack of initial controller resize when first page is added, though I think the listctrl should probably always have a decent initial height even when empty. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/listbkg.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp index a0e5073a9c..f7f480980c 100644 --- a/src/generic/listbkg.cpp +++ b/src/generic/listbkg.cpp @@ -301,7 +301,14 @@ wxListbook::InsertPage(size_t n, SetSelection(selNew); InvalidateBestSize(); + // GetListView()->InvalidateBestSize(); GetListView()->Arrange(); + + if (GetPageCount() == 1) + { + wxSizeEvent sz(GetSize(), GetId()); + ProcessEvent(sz); + } return true; } @@ -331,6 +338,11 @@ wxWindow *wxListbook::DoRemovePage(size_t page) } GetListView()->Arrange(); + if (GetPageCount() == 0) + { + wxSizeEvent sz(GetSize(), GetId()); + ProcessEvent(sz); + } } return win; @@ -340,7 +352,15 @@ wxWindow *wxListbook::DoRemovePage(size_t page) bool wxListbook::DeleteAllPages() { GetListView()->DeleteAllItems(); - return wxBookCtrlBase::DeleteAllPages(); + if (!wxBookCtrlBase::DeleteAllPages()) + return false; + + m_selection = -1; + + wxSizeEvent sz(GetSize(), GetId()); + ProcessEvent(sz); + + return true; } // ----------------------------------------------------------------------------