From 09c0ebcf968686864e2f14e0873764d77ff94a40 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 28 Nov 2011 12:47:26 +0000 Subject: [PATCH] Don't hardcode the number of toolbar tools in the toolbar sample. Use GetToolsCount() instead of the hardcoded 10 (which can be wrong if any tools were added or removed). See #13673. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69855 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/toolbar/toolbar.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index 53b7e27c59..734a3d39df 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -508,7 +508,8 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar) // the changes toolBar->Realize(); - toolBar->SetRows(!(toolBar->IsVertical()) ? m_rows : 10 / m_rows); + toolBar->SetRows(toolBar->IsVertical() ? toolBar->GetToolsCount() / m_rows + : m_rows); } // ---------------------------------------------------------------------------- @@ -762,7 +763,9 @@ void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event)) // m_rows may be only 1 or 2 m_rows = 3 - m_rows; - GetToolBar()->SetRows(!(GetToolBar()->IsVertical()) ? m_rows : 10 / m_rows); + wxToolBar* const toolBar = GetToolBar(); + toolBar->SetRows(toolBar->IsVertical() ? toolBar->GetToolsCount() / m_rows + : m_rows); //RecreateToolbar(); -- this is unneeded } -- 2.50.0