Don't override DoGetSize, just let the default return the real size of
the widget like normal. Since the former implementation used GetBestSize, which uses a DC, which on Mac calls window->GetSize, this resulted in an infinite recursion. Also use SetBestFittingSize in the ctor and move CacheBestSize to DoGetBestSize where it belongs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42409 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -133,7 +133,6 @@ protected:
|
|||||||
|
|
||||||
// Returns the best size for the window, which is the size needed
|
// Returns the best size for the window, which is the size needed
|
||||||
// to display the text label.
|
// to display the text label.
|
||||||
virtual void DoGetSize(int *width, int *height) const;
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
// creates a context menu with "Copy URL" menuitem
|
// creates a context menu with "Copy URL" menuitem
|
||||||
|
@@ -115,9 +115,7 @@ bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
f.SetUnderlined(true);
|
f.SetUnderlined(true);
|
||||||
SetFont(f);
|
SetFont(f);
|
||||||
|
|
||||||
CacheBestSize(DoGetBestSize());
|
SetBestFittingSize(size);
|
||||||
SetMinSize(GetBestSize());
|
|
||||||
SetSize (DoGetBestSize());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -130,14 +128,11 @@ wxSize wxHyperlinkCtrl::DoGetBestSize() const
|
|||||||
dc.SetFont(GetFont());
|
dc.SetFont(GetFont());
|
||||||
dc.GetTextExtent(GetLabel(), &w, &h);
|
dc.GetTextExtent(GetLabel(), &w, &h);
|
||||||
|
|
||||||
return wxSize(w, h);
|
wxSize best(w, h);
|
||||||
|
CacheBestSize(best);
|
||||||
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHyperlinkCtrl::DoGetSize(int *width, int *height) const
|
|
||||||
{
|
|
||||||
if (width) *width = GetBestSize().GetWidth();
|
|
||||||
if (height) *height = GetBestSize().GetHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxHyperlinkCtrl::SetNormalColour(const wxColour &colour)
|
void wxHyperlinkCtrl::SetNormalColour(const wxColour &colour)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user