// This removes any dangling pointers to this window in other windows'
// constraintsInvolvedIn lists.
UnsetConstraints(m_constraints);
- delete m_constraints;
- m_constraints = NULL;
+ wxDELETE(m_constraints);
}
#endif // wxUSE_CONSTRAINTS
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:
void wxWindowBase::NotifyWindowOnEnableChange(bool enabled)
{
+ // Under some platforms there is no need to update the window state
+ // explicitly, it will become disabled when its parent is. On other ones we
+ // do need to disable all windows recursively though.
#ifndef wxHAS_NATIVE_ENABLED_MANAGEMENT
DoEnable(enabled);
#endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
OnEnabled(enabled);
- // If we are top-level then the logic doesn't apply - otherwise
- // showing a modal dialog would result in total greying out (and ungreying
- // out later) of everything which would be really ugly
- if ( IsTopLevel() )
+ // Disabling a top level window is typically done when showing a modal
+ // dialog and we don't need to disable its children in this case, they will
+ // be logically disabled anyhow (i.e. their IsEnabled() will return false)
+ // and the TLW won't accept any input for them. Moreover, explicitly
+ // disabling them would look ugly as the entire TLW would be greyed out
+ // whenever a modal dialog is shown and no native applications under any
+ // platform behave like this.
+ if ( IsTopLevel() && !enabled )
return;
+ // When disabling (or enabling back) a non-TLW window we need to
+ // recursively propagate the change of the state to its children, otherwise
+ // they would still show as enabled even though they wouldn't actually
+ // accept any input (at least under MSW where children don't accept input
+ // if any of the windows in their parent chain is enabled).
+ //
+ // Notice that we must do this even for wxHAS_NATIVE_ENABLED_MANAGEMENT
+ // platforms as we still need to call the children OnEnabled() recursively.
for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
node;
node = node->GetNext() )
m_isEnabled = enable;
+ // If we call DoEnable() from NotifyWindowOnEnableChange(), we don't need
+ // to do it from here.
#ifdef wxHAS_NATIVE_ENABLED_MANAGEMENT
DoEnable(enable);
-#else // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
- wxWindowBase * const parent = GetParent();
- if( !IsTopLevel() && parent && !parent->IsEnabled() )
- {
- return true;
- }
#endif // !defined(wxHAS_NATIVE_ENABLED_MANAGEMENT)
NotifyWindowOnEnableChange(enable);
if ( deleteHandler )
{
- delete firstHandler;
- firstHandler = NULL;
+ wxDELETE(firstHandler);
}
return firstHandler;
node = next;
}
- delete m_constraintsInvolvedIn;
- m_constraintsInvolvedIn = NULL;
+ wxDELETE(m_constraintsInvolvedIn);
}
}
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
{