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

H H at h.com
Fri Apr 13 15:29:43 PDT 2007


In article <461FBB82.3040604 at alldunn.com>,
 robin at alldunn.com (Robin Dunn) wrote:

> H wrote:
> > I already posted this a while ago but did not get an answer. Therefore, 
> > my next try.
> > This is the statement causing problems:
> > 
> >     else if ( !GetChildren().empty()
> > #ifdef __WXMAC__
> >               && wxHasRealChildren(this)
> > #endif
> >               )
> > 
> > There is also a remark related to "wxHasRealChildren" that "scrollbars 
> > are explicitely children" on the Mac (whatever it means).
> > 
> > Why is wxWindowBase::DoGetBestSize() returning wxSize(0, 0) if the 
> > window only has scrollbars? I thought it would at least return the size 
> > needed for the scrollbars.
> 
> The issue is that on the Mac the scrollbars are in the list of child 
> windows because wxScrollBars are used, but on the other platforms they 
> are not in the list because a raw native scrollbar is used instead.  So 
> any functionality that depends on there being children or not will need 
> to know that on Mac those wxScrollBars should not be counted.
> 
> In wxWindowBase::DoGetBestSize there is a specific set of states that 
> are checked, and each has a rule for what the best size of the window 
> will be.  IOW, if there is a sizer then use that, if there are 
> constraints then use them, if there are (real) children then the best 
> size is large enough to show all the children, if no (real) children 
> then use the min size as the best size if the min size is defined, 
> otherwise use the current size and set it as the min size for the next 
> time it is needed.
> 
> So the easiest solution for you will probably be to just set the minsize.
> 
> 
The issue is that "wxWindow::wxHasRealChildren" is only used in 
wxWindow::DoGetBestSize() and there it only causes troubles (may be that 
other classes also have a "wxHasRealChildren" or similar methods but I 
am not talking about these ones for the time being). If a Mac window has 
got only scrollbars the best size is currently (0, 0) - because of the 
cited program text lines (see above). And this is simply not correct 
because the scrollbars also need some space when they are not hidden.

> > The real problem is that some modules (example: wxTreebook) assume that 
> > a window's client size is zero or larger. But with this implementation 
> > of DoGetBestSize() this is not the case anymore, it becomes negative!
> 
> Which window's best size is the problem for you?  The tree?  The 
> treebook?  Each of these have their own DoGetBestSize method.

The tree's window is the problem. You can see the bug when running the 
notebook sample. Choose the treebook and you will see that the tree's 
window is not correctly sized. The root of the bug is 
wxWindow::DoGetBestSize returning (0, 0) instead of taking the 
scrollbars into account when initializing/determining the initial size 
of the tree's window.
By changing the size of the frame the problem will disappear.

Hartwig






More information about the wx-users mailing list