wxSize wxWindowBase::DoGetBorderSize() const
{
- // there is one case in which we can implement it for all ports easily:
- // do it as some classes used by both wxUniv and native ports (e.g.
- // wxGenericStaticText) do override DoGetBestClientSize() and so this
- // method must work for them and that ensures that it does, at least in
- // the default case)
+ // there is one case in which we can implement it for all ports easily
if ( GetBorder() == wxBORDER_NONE )
return wxSize(0, 0);
- wxFAIL_MSG( "must be overridden if called" );
-
- return wxDefaultSize;
+ // otherwise use the difference between the real size and the client size
+ // as a fallback: notice that this is incorrect in general as client size
+ // also doesn't take the scrollbars into account
+ return GetSize() - GetClientSize();
}
wxSize wxWindowBase::GetBestSize() const
break;
case wxWINDOW_VARIANT_SMALL:
- size *= 3;
- size /= 4;
+ size = wxRound(size * 3.0 / 4.0);
break;
case wxWINDOW_VARIANT_MINI:
- size *= 2;
- size /= 3;
+ size = wxRound(size * 2.0 / 3.0);
break;
case wxWINDOW_VARIANT_LARGE:
- size *= 5;
- size /= 4;
+ size = wxRound(size * 5.0 / 4.0);
break;
default:
if ( (constr->width.GetRelationship() != wxAsIs ) ||
(constr->height.GetRelationship() != wxAsIs) )
{
- SetSize(x, y, w, h);
+ // We really shouldn't set negative sizes for the windows so make
+ // them at least of 1*1 size
+ SetSize(x, y, w > 0 ? w : 1, h > 0 ? h : 1);
}
else
{