[wxMac 2.8x] wxWindow::DoGetBestSize bug still not solved

H H at h.com
Sat Apr 14 04:36:46 PDT 2007


In article <b-S_D.A.igK.IfBIGB at brage.sunsite.dk>,
 vadim at wxwindows.org (Vadim Zeitlin) wrote:

> On Fri, 13 Apr 2007 16:48:53 -0700 Robin Dunn <robin at alldunn.com> wrote:
> 
> RD> The code I was thinking of is at the end of wxWindowBase::DoGetBestSize, 
> 
>  Oops, yes, indeed, thanks, I remember now (I even seem to remember that I
> added it myself). Anyhow, looking at this code I understand even less how
> can we get (0, 0) best size: the client size may be (0, 0) but surely the
> full window size must be greater if scrollbars are shown. This really needs
> to be debugged but I won't have time for this today...
> 
> RD> and a quick test in PyCrust shows me that wxMac does adjust the client 
> RD> size when scrollbars are shown.  However that adjustment obviously only 
> RD> happens when the default DoGetBestSize is being used.  Other controls 
> RD> that may possibly have scrollbars and have their own DoGetBestSize will 
> RD> not get adjusted.
> 
>  Which would also be solved by having a DoGetBestClientSize() virtual which
> could be overridden if the default scrollbar handling logic is appropriate.
> 
>  Regards,
> VZ

Sorry, but I really do not understand the whole discussion.

If wxWindowBase::DoGetBestSize() is called and if there are only 
scrollbars present it will return wxSize(0, 0) as the best size, as 
Vadim and myself mentioned. And this cannot be correct because if 
wxDoGetBestSize() is used to set the window's size a call to 
GetClientSize() afterwards will return a negative size.
So, wxWindowBase::DoGetBestSize() is definitely buggy. This is the 
lowest base class and it should be fixed first. Then, we will see if 
other classes already implemented a workaround around this bug and might 
become buggy (this risk is quite low because the fix for 
wxWindowBase::DoGetBestSize will only make the best size larger and this 
is a safe - but perhaps ugly - direction).
As Robin mentioned there are a couple of classes that override 
wxWindowBase::DoGetBestSize() anyway (wxTextCtrl for example) and do not 
make use of the default method. This seems to be also a reason why this 
bug does not show up more often.

Hartwig






More information about the wx-users mailing list