Fix recently broken (re-)layout in the listctrl sample

This completes changes of 0873abb836 which
replaced manual layout code with sizers, but broke layout after
recreating the control in the process.

This change notably fixes the control becoming invisible, due to having
the default too small size, in non-report modes.
This commit is contained in:
Vadim Zeitlin
2018-03-04 22:29:13 +01:00
parent c4a4d95ad1
commit 2881d9875a

View File

@@ -110,8 +110,6 @@ bool MyApp::OnInit()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_SIZE(MyFrame::OnSize)
EVT_MENU(LIST_QUIT, MyFrame::OnQuit) EVT_MENU(LIST_QUIT, MyFrame::OnQuit)
EVT_MENU(LIST_ABOUT, MyFrame::OnAbout) EVT_MENU(LIST_ABOUT, MyFrame::OnAbout)
EVT_MENU(LIST_LIST_VIEW, MyFrame::OnListView) EVT_MENU(LIST_LIST_VIEW, MyFrame::OnListView)
@@ -449,13 +447,23 @@ void MyFrame::RecreateList(long flags, bool withText)
(m_listCtrl->GetWindowStyleFlag() & wxLC_VIRTUAL)) ) (m_listCtrl->GetWindowStyleFlag() & wxLC_VIRTUAL)) )
#endif #endif
{ {
delete m_listCtrl; wxListCtrl* const old = m_listCtrl;
m_listCtrl = new MyListCtrl(m_panel, LIST_CTRL, m_listCtrl = new MyListCtrl(m_panel, LIST_CTRL,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
flags | flags |
wxBORDER_THEME | wxLC_EDIT_LABELS); wxBORDER_THEME | wxLC_EDIT_LABELS);
if ( old )
{
wxSizer* const sizer = m_panel->GetSizer();
sizer->Replace(old, m_listCtrl);
delete old;
sizer->Layout();
}
switch ( flags & wxLC_MASK_TYPE ) switch ( flags & wxLC_MASK_TYPE )
{ {
case wxLC_LIST: case wxLC_LIST: