Fix size calculation for multi-column vertical toolbars in wxMSW.
The width was calculated incorrectly in this case as we simply multiplied the width of the widest column by their number in this case, but actually each of them has its own width which needs to be calculated separately. See #13579. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76109 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
f8a7323cbb
commit
3772880ce6
@ -1828,13 +1828,37 @@ bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
|
||||
|
||||
// calculate our minor dimension ourselves - we're confusing the standard
|
||||
// logic (TB_AUTOSIZE) with our horizontal toolbars and other hacks
|
||||
// Find bounding box for any toolbar item.
|
||||
// Find bounding box for all rows.
|
||||
RECT r;
|
||||
::SetRectEmpty(&r);
|
||||
// Bounding box for single (current) row
|
||||
RECT rcRow;
|
||||
::SetRectEmpty(&rcRow);
|
||||
int rowPosX = INT_MIN;
|
||||
wxToolBarToolsList::compatibility_iterator node;
|
||||
int i = 0;
|
||||
for ( node = m_tools.GetFirst(); node; node = node->GetNext(), i++)
|
||||
{
|
||||
// Skip hidden buttons
|
||||
const RECT rcItem = wxGetTBItemRect(GetHwnd(), i);
|
||||
if ( ::IsRectEmpty(&rcItem) )
|
||||
continue;
|
||||
|
||||
if ( rcItem.top > rowPosX )
|
||||
{
|
||||
// We have the next row.
|
||||
rowPosX = rcItem.top;
|
||||
|
||||
// Shift origin to (0, 0) to make it the same as for the total rect.
|
||||
::OffsetRect(&rcRow, -rcRow.left, -rcRow.top);
|
||||
|
||||
// And update the bounding box for all rows.
|
||||
::UnionRect(&r, &r, &rcRow);
|
||||
|
||||
// Reset the current row bounding box for the next row.
|
||||
::SetRectEmpty(&rcRow);
|
||||
}
|
||||
|
||||
wxToolBarTool * const tool = (wxToolBarTool*)node->GetData();
|
||||
|
||||
// Separators shouldn't be taken into account as they are sometimes
|
||||
@ -1843,12 +1867,15 @@ bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
|
||||
// any case, so just skip them.
|
||||
if( !tool->IsSeparator() )
|
||||
{
|
||||
RECT ritem = wxGetTBItemRect(GetHwnd(), i);
|
||||
::OffsetRect(&ritem, -ritem.left, -ritem.top); // Shift origin to (0,0)
|
||||
::UnionRect(&r, &r, &ritem);
|
||||
// Update bounding box of current row
|
||||
::UnionRect(&rcRow, &rcRow, &rcItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Take into account the last row rectangle too.
|
||||
::OffsetRect(&rcRow, -rcRow.left, -rcRow.top);
|
||||
::UnionRect(&r, &r, &rcRow);
|
||||
|
||||
if ( !r.right )
|
||||
return false;
|
||||
|
||||
@ -1857,10 +1884,6 @@ bool wxToolBar::HandleSize(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam)
|
||||
if ( IsVertical() )
|
||||
{
|
||||
w = r.right - r.left;
|
||||
if ( m_maxRows )
|
||||
{
|
||||
w *= (m_nButtons + m_maxRows - 1)/m_maxRows;
|
||||
}
|
||||
h = HIWORD(lParam);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user