+ const wxToolBarTool *tool = (wxToolBarTool *)toolBase;
+
+ wxRect rect;
+
+ wxCHECK_MSG( tool, rect, _T("GetToolRect: NULL tool") );
+
+ // ensure that we always have the valid tool position
+ if ( m_needsLayout )
+ {
+ wxConstCast(this, wxToolBar)->DoLayout();
+ }
+
+ rect.x = tool->m_x - m_xMargin;
+ rect.y = tool->m_y - m_yMargin;
+
+ if ( IsVertical() )
+ {
+ if (tool->IsButton())
+ {
+ if(!HasFlag(wxTB_TEXT))
+ {
+ rect.width = m_defaultWidth;
+ rect.height = m_defaultHeight;
+ }
+ else
+ {
+ rect.width = m_defaultWidth +
+ GetFont().GetPointSize() * tool->GetLabel().length();
+ rect.height = m_defaultHeight;
+ }
+ }
+ else if (tool->IsSeparator())
+ {
+ rect.width = m_defaultWidth;
+ rect.height = m_widthSeparator;
+ }
+ else // control
+ {
+ rect.width = tool->m_width;
+ rect.height = tool->m_height;
+ }
+ }
+ else // horizontal
+ {
+ if (tool->IsButton())
+ {
+ if(!HasFlag(wxTB_TEXT))
+ {
+ rect.width = m_defaultWidth;
+ rect.height = m_defaultHeight;
+ }
+ else
+ {
+ rect.width = m_defaultWidth +
+ GetFont().GetPointSize() * tool->GetLabel().length();
+ rect.height = m_defaultHeight;
+ }
+ }
+ else if (tool->IsSeparator())
+ {
+ rect.width = m_widthSeparator;
+ rect.height = m_defaultHeight;
+ }
+ else // control
+ {
+ rect.width = tool->m_width;
+ rect.height = tool->m_height;
+ }
+ }
+
+ rect.width += 2*m_xMargin;
+ rect.height += 2*m_yMargin;
+
+ return rect;
+}
+
+bool wxToolBar::Realize()
+{
+ if ( !wxToolBarBase::Realize() )
+ return false;
+
+ m_needsLayout = true;
+ DoLayout();
+
+ SetBestSize(wxDefaultSize);
+
+ return true;
+}
+
+void wxToolBar::SetWindowStyleFlag( long style )
+{
+ wxToolBarBase::SetWindowStyleFlag(style);
+
+ m_needsLayout = true;
+
+ Refresh();