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

Robin Dunn robin at alldunn.com
Fri Apr 13 10:18:58 PDT 2007


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 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.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wx-users mailing list