+void wxToolBarMSW::Layout(void)
+{
+ m_currentRowsOrColumns = 0;
+ m_lastX = m_xMargin;
+ m_lastY = m_yMargin;
+ int maxToolWidth = 0;
+ int maxToolHeight = 0;
+ m_maxWidth = 0;
+ m_maxHeight = 0;
+
+ // Find the maximum tool width and height
+ wxNode *node = m_tools.First();
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+ if (tool->GetWidth() > maxToolWidth)
+ maxToolWidth = (int)tool->GetWidth();
+ if (tool->GetHeight() > maxToolHeight)
+ maxToolHeight = (int)tool->GetHeight();
+ node = node->Next();
+ }
+
+ int separatorSize = m_toolSeparation;
+
+ node = m_tools.First();
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+ if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR)
+ {
+ if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
+ {
+ if (m_currentRowsOrColumns >= m_maxCols)
+ m_lastY += separatorSize;
+ else
+ m_lastX += separatorSize;
+ }
+ else
+ {
+ if (m_currentRowsOrColumns >= m_maxRows)
+ m_lastX += separatorSize;
+ else
+ m_lastY += separatorSize;
+ }
+ }
+ else if (tool->m_toolStyle == wxTOOL_STYLE_BUTTON)
+ {
+ if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
+ {
+ if (m_currentRowsOrColumns >= m_maxCols)
+ {
+ m_currentRowsOrColumns = 0;
+ m_lastX = m_xMargin;
+ m_lastY += maxToolHeight + m_toolPacking;
+ }
+ tool->m_x = (long) (m_lastX + (maxToolWidth - tool->GetWidth())/2.0);
+ tool->m_y = (long) (m_lastY + (maxToolHeight - tool->GetHeight())/2.0);
+
+ m_lastX += maxToolWidth + m_toolPacking;
+ }
+ else
+ {
+ if (m_currentRowsOrColumns >= m_maxRows)
+ {
+ m_currentRowsOrColumns = 0;
+ m_lastX += (maxToolWidth + m_toolPacking);
+ m_lastY = m_yMargin;
+ }
+ tool->m_x = (long) (m_lastX + (maxToolWidth - tool->GetWidth())/2.0);
+ tool->m_y = (long) (m_lastY + (maxToolHeight - tool->GetHeight())/2.0);
+
+ m_lastY += maxToolHeight + m_toolPacking;
+ }
+ m_currentRowsOrColumns ++;
+ }
+
+ if (m_lastX > m_maxWidth)
+ m_maxWidth = m_lastX;
+ if (m_lastY > m_maxHeight)
+ m_maxHeight = m_lastY;
+
+ node = node->Next();
+ }
+ if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
+ m_maxWidth += maxToolWidth;
+ else
+ m_maxHeight += maxToolHeight;
+
+ m_maxWidth += m_xMargin;
+ m_maxHeight += m_yMargin;
+}
+
+