Disable stretchable spaces in multi-row toolbars in wxMSW.

Stretchable separators simply don't work correctly when the space they are
supposed to stretch onto is distributed across several different toolbar rows
or columns, so just disable them for multi-row (or column, for vertical
toolbars) case.

See #13579.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76107 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-03-09 20:58:15 +00:00
parent 2b5574c6ea
commit 8f4bd3dfd6

View File

@@ -1317,11 +1317,17 @@ void wxToolBar::UpdateStretchableSpacersSize()
// check if we have any stretchable spacers in the first place
unsigned numSpaces = 0;
wxToolBarToolsList::compatibility_iterator node;
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
int toolIndex = 0;
for ( node = m_tools.GetFirst(); node; node = node->GetNext(), toolIndex++ )
{
wxToolBarTool * const tool = (wxToolBarTool*)node->GetData();
if ( tool->IsStretchableSpace() )
numSpaces++;
{
// Count only enabled items
const RECT rcItem = wxGetTBItemRect(GetHwnd(), toolIndex);
if ( !::IsRectEmpty(&rcItem) )
numSpaces++;
}
}
if ( !numSpaces )
@@ -1344,7 +1350,7 @@ void wxToolBar::UpdateStretchableSpacersSize()
// move the controls manually ourselves to ensure they remain at the
// correct place
int offset = 0;
int toolIndex = 0;
toolIndex = 0;
for ( node = m_tools.GetFirst(); node; node = node->GetNext(), toolIndex++ )
{
wxToolBarTool * const tool = (wxToolBarTool*)node->GetData();
@@ -1564,6 +1570,26 @@ void wxToolBar::SetRows(int nRows)
m_maxRows = nRows;
// Enable stretchable spacers only for single-row horizontal toobar or
// single-column vertical toolbar, they don't work correctly when the extra
// space can be redistributed among multiple columns or rows at any moment.
const bool enable = (!IsVertical() && m_maxRows == 1) ||
(IsVertical() && (size_t)m_maxRows == m_nButtons);
const LPARAM state = MAKELONG(enable ? TBSTATE_ENABLED : TBSTATE_HIDDEN, 0);
wxToolBarToolsList::compatibility_iterator node;
for ( node = m_tools.GetFirst(); node; node = node->GetNext() )
{
wxToolBarTool * const tool = (wxToolBarTool*)node->GetData();
if ( tool->IsStretchableSpace() )
{
if ( !::SendMessage(GetHwnd(), TB_SETSTATE, tool->GetId(), state) )
{
wxLogLastError(wxT("TB_SETSTATE (stretchable spacer)"));
}
}
}
UpdateSize();
}
@@ -1894,6 +1920,11 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam)
// shorter than the full window size (at least under Windows 7)
// but we need to erase the full width/height below
RECT rcItem = wxGetTBItemRect(GetHwnd(), toolIndex);
// Skip hidden buttons
if ( ::IsRectEmpty(&rcItem) )
continue;
if ( IsVertical() )
{
rcItem.left = 0;