+ wxDELETE(m_pToolTip);
+} // end of wxToolBar::~wxToolBar
+
+bool wxToolBar::Realize()
+{
+ int nMaxToolWidth = 0;
+ int nMaxToolHeight = 0;
+
+ m_nCurrentRowsOrColumns = 0;
+ m_vLastX = m_xMargin;
+ m_vLastY = m_yMargin;
+ m_vMaxWidth = 0;
+ m_vMaxHeight = 0;
+
+
+ //
+ // Find the maximum tool width and height
+ //
+ wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
+
+ while (node )
+ {
+ wxToolBarTool* pTool = (wxToolBarTool *)node->GetData();
+
+ if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().empty())
+ {
+ //
+ // Set the height according to the font and the border size
+ //
+ if (pTool->GetWidth() > m_vTextX)
+ nMaxToolWidth = pTool->GetWidth() + 4;
+ else
+ nMaxToolWidth = m_vTextX;
+ if (pTool->GetHeight() + m_vTextY > nMaxToolHeight)
+ nMaxToolHeight = pTool->GetHeight() + m_vTextY;
+ }
+ else
+ {
+ if (pTool->GetWidth() > nMaxToolWidth )
+ nMaxToolWidth = pTool->GetWidth() + 4;
+ if (pTool->GetHeight() > nMaxToolHeight)
+ nMaxToolHeight = pTool->GetHeight();
+ }
+ node = node->GetNext();
+ }
+
+ wxCoord vTbWidth = 0L;
+ wxCoord vTbHeight = 0L;
+
+ GetSize( &vTbWidth
+ ,&vTbHeight
+ );
+ if (vTbHeight < nMaxToolHeight)
+ {
+ SetSize( -1L
+ ,-1L
+ ,vTbWidth
+ ,nMaxToolHeight + 4
+ );
+ if (GetParent()->IsKindOf(CLASSINFO(wxFrame)))
+ {
+ wxFrame* pFrame = wxDynamicCast(GetParent(), wxFrame);
+
+ if (pFrame)
+ pFrame->PositionToolBar();
+ }
+ }
+
+ int nSeparatorSize = m_toolSeparation;
+
+ node = m_tools.GetFirst();
+ while (node)
+ {
+ wxToolBarTool* pTool = (wxToolBarTool *)node->GetData();
+
+ if (pTool->IsSeparator())
+ {
+ if (GetWindowStyleFlag() & (wxTB_TOP | wxTB_BOTTOM))
+ {
+ pTool->m_vX = m_vLastX + nSeparatorSize;
+ pTool->m_vHeight = m_defaultHeight + m_vTextY;
+ if (m_nCurrentRowsOrColumns >= m_maxCols)
+ m_vLastY += nSeparatorSize;
+ else
+ m_vLastX += nSeparatorSize * 4;
+ }
+ else
+ {
+ pTool->m_vY = m_vLastY + nSeparatorSize;
+ pTool->m_vHeight = m_defaultHeight + m_vTextY;
+ if (m_nCurrentRowsOrColumns >= m_maxRows)
+ m_vLastX += nSeparatorSize;
+ else
+ m_vLastY += nSeparatorSize * 4;
+ }
+ }
+ else if (pTool->IsButton())
+ {
+ if (GetWindowStyleFlag() & (wxTB_TOP | wxTB_BOTTOM))
+ {
+ if (m_nCurrentRowsOrColumns >= m_maxCols)
+ {
+ m_nCurrentRowsOrColumns = 0;
+ m_vLastX = m_xMargin;
+ m_vLastY += nMaxToolHeight + m_toolPacking;
+ }
+ pTool->m_vX = m_vLastX + (nMaxToolWidth - ((int)(nMaxToolWidth/2) + (int)(pTool->GetWidth()/2)));
+ if (HasFlag(wxTB_TEXT))
+ pTool->m_vY = m_vLastY + nSeparatorSize - 2; // just bit of adjustment
+ else
+ pTool->m_vY = m_vLastY + (nMaxToolHeight - (int)(pTool->GetHeight()/2));
+ m_vLastX += nMaxToolWidth + m_toolPacking + m_toolSeparation;
+ }
+ else
+ {
+ if (m_nCurrentRowsOrColumns >= m_maxRows)
+ {
+ m_nCurrentRowsOrColumns = 0;
+ m_vLastX += (nMaxToolWidth + m_toolPacking);
+ m_vLastY = m_yMargin;
+ }
+ pTool->m_vX = m_vLastX + pTool->GetWidth();
+ if ( HasFlag(wxTB_TEXT) && !pTool->GetLabel().empty() )
+ pTool->m_vY = m_vLastY + (nMaxToolHeight - m_vTextY) + m_toolPacking;
+ else
+ pTool->m_vY = m_vLastY + (nMaxToolHeight - (int)(pTool->GetHeight()/2));
+ m_vLastY += nMaxToolHeight + m_toolPacking + m_toolSeparation;
+ }
+ m_nCurrentRowsOrColumns++;
+ }
+ else
+ {
+ // TODO: support the controls
+ }
+
+ if (m_vLastX > m_maxWidth)
+ m_maxWidth = m_vLastX;
+ if (m_vLastY > m_maxHeight)
+ m_maxHeight = m_vLastY;
+
+ node = node->GetNext();
+ }