- 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 (m_tilingDirection == wxHORIZONTAL)
- {
- if (m_currentRowsOrColumns >= m_rowsOrColumns)
- m_lastY += separatorSize;
- else
- m_lastX += separatorSize;
- }
- else
- {
- if (m_currentRowsOrColumns >= m_rowsOrColumns)
- m_lastX += separatorSize;
- else
- m_lastY += separatorSize;
- }
- }
- else if (tool->m_toolStyle == wxTOOL_STYLE_BUTTON)
- {
- if (m_tilingDirection == wxHORIZONTAL)
- {
- if (m_currentRowsOrColumns >= m_rowsOrColumns)
- {
- 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_rowsOrColumns)
- {
- 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 (m_tilingDirection == wxVERTICAL)
- m_maxWidth += maxToolWidth;
- else
- m_maxHeight += maxToolHeight;
-
- m_maxWidth += m_xMargin;
- m_maxHeight += m_yMargin;