#include "wx/univ/renderer.h"
+#include "wx/frame.h"
#include "wx/toolbar.h"
#include "wx/image.h"
#include "wx/log.h"
wxToolBar::~wxToolBar()
{
+ // Make sure the toolbar is removed from the parent.
+ SetSize(0,0);
}
void wxToolBar::SetMargins(int x, int y)
return wxSize(m_maxWidth, m_maxHeight);
}
+void wxToolBar::DoSetSize(int x, int y, int width, int height, int sizeFlags)
+{
+ int old_width, old_height;
+ GetSize(&old_width, &old_height);
+
+ wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags);
+
+ // Correct width and height if needed.
+ if ( width == -1 || height == -1 )
+ {
+ int tmp_width, tmp_height;
+ GetSize(&tmp_width, &tmp_height);
+
+ if ( width == -1 )
+ width = tmp_width;
+ if ( height == -1 )
+ height = tmp_height;
+ }
+
+ // We must refresh the frame size when the toolbar changes size
+ // otherwise the toolbar can be shown incorrectly
+ if ( old_width != width || old_height != height )
+ {
+ // But before we send the size event check it
+ // we have a frame that is not being deleted.
+ wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
+ if ( frame && !frame->IsBeingDeleted() )
+ {
+ frame->SendSizeEvent();
+ }
+ }
+}
+
// ----------------------------------------------------------------------------
// wxToolBar drawing
// ----------------------------------------------------------------------------
m_winCapture = NULL;
}
- if ( tool == m_toolCapture )
- consumer->PerformAction( wxACTION_BUTTON_TOGGLE, m_toolCapture->GetId() );
- else
- consumer->PerformAction( wxACTION_TOOLBAR_LEAVE, m_toolCapture->GetId() );
+ if (m_toolCapture)
+ {
+ if ( tool == m_toolCapture )
+ consumer->PerformAction( wxACTION_BUTTON_TOGGLE, m_toolCapture->GetId() );
+ else
+ consumer->PerformAction( wxACTION_TOOLBAR_LEAVE, m_toolCapture->GetId() );
+ }
m_toolCapture = NULL;