+
+ // deal with the flags
+ int flags = 0;
+
+ if ( tool->IsEnabled() )
+ {
+ // the toolbars without wxTB_FLAT don't react to the mouse hovering
+ if ( HasFlag(wxTB_FLAT) && (tool == m_toolCurrent) )
+ flags |= wxCONTROL_CURRENT;
+ }
+ else // disabled tool
+ {
+ flags |= wxCONTROL_DISABLED;
+ }
+
+ if ( tool == m_toolPressed )
+ flags |= wxCONTROL_FOCUSED;
+
+ if ( ((wxToolBarTool *)tool)->IsPressed() )
+ flags |= wxCONTROL_PRESSED;
+
+ wxString label;
+ wxBitmap bitmap;
+ if ( !tool->IsSeparator() )
+ {
+ label = tool->GetLabel();
+ bitmap = tool->GetBitmap();
+ }
+ //else: leave both the label and the bitmap invalid to draw a separator
+
+ rend->DrawToolBarButton(dc, label, bitmap, rectTool, flags);
+ }
+}
+
+// ----------------------------------------------------------------------------
+// wxToolBar actions
+// ----------------------------------------------------------------------------
+
+void wxToolBar::Press()
+{
+ wxCHECK_RET( m_toolCurrent, _T("no tool to press?") );
+
+ wxLogTrace(_T("toolbar"),
+ _T("Button '%s' pressed."),
+ m_toolCurrent->GetShortHelp().c_str());
+
+ // this is the tool whose state is going to change
+ m_toolPressed = (wxToolBarTool *)m_toolCurrent;
+
+ // we must toggle it regardless of whether it is a checkable tool or not,
+ // so use Invert() and not Toggle() here
+ m_toolPressed->Invert();
+
+ RefreshTool(m_toolPressed);
+}
+
+void wxToolBar::Release()
+{
+ wxCHECK_RET( m_toolPressed, _T("no tool to release?") );
+
+ wxLogTrace(_T("toolbar"),
+ _T("Button '%s' released."),
+ m_toolCurrent->GetShortHelp().c_str());
+
+ wxASSERT_MSG( m_toolPressed->IsInverted(), _T("release unpressed button?") );
+
+ m_toolPressed->Invert();
+
+ RefreshTool(m_toolPressed);
+}
+
+void wxToolBar::Toggle()
+{
+ m_toolCurrent = m_toolPressed;
+
+ Release();
+
+ Click();
+}
+
+void wxToolBar::Click()
+{
+ wxCHECK_RET( m_toolCurrent, _T("no tool to click?") );
+
+ bool isToggled;
+ if ( m_toolCurrent->CanBeToggled() )
+ {
+ m_toolCurrent->Toggle();
+
+ RefreshTool(m_toolCurrent);
+
+ isToggled = m_toolCurrent->IsToggled();