virtual int GetMinWidth() const;
virtual int GetMinHeight() const;
+ // sends wxSizeEvent to itself (used after attaching xxxBar)
+ virtual void SendSizeEvent();
+
protected:
void OnSize(wxSizeEvent& event);
- // sends wxSizeEvent to itself (used after attaching xxxBar)
- void SendSizeEvent();
-
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoSetClientSize(int width, int height);
long numArg = -1,
const wxString& strArg = wxEmptyString);
virtual wxSize DoGetBestClientSize() const;
+ virtual void DoSetSize(int x, int y,
+ int width, int height,
+ int sizeFlags = wxSIZE_AUTO);
virtual void DoDraw(wxControlRenderer *renderer);
// get the bounding rect for the given tool
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
// ----------------------------------------------------------------------------