wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
- // reset the top-level parent's default item if it is this widget
+ // notify the parent about this window destruction
if ( m_parent )
- {
- wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent((wxWindow*)this),
- wxTopLevelWindow);
-
- if ( tlw && tlw->GetDefaultItem() == this )
- tlw->SetDefaultItem(NULL);
- if ( tlw && tlw->GetTmpDefaultItem() == this )
- tlw->SetTmpDefaultItem(NULL);
- }
-
- // reset the dangling pointer our parent window may keep to us
- if ( m_parent )
- {
m_parent->RemoveChild(this);
- }
#if wxUSE_CARET
delete m_caret;
if ( m_windowSizer )
{
- best = GetWindowSizeForVirtualSize(m_windowSizer->GetMinSize());
+ best = m_windowSizer->GetMinSize();
}
#if wxUSE_CONSTRAINTS
else if ( m_constraints )
}
}
-bool wxWindowBase::Enable(bool enable)
+bool wxWindowBase::IsEnabled() const
{
- if ( enable != m_isEnabled )
- {
- m_isEnabled = enable;
+ return IsThisEnabled() && (IsTopLevel() || !GetParent() || GetParent()->IsEnabled());
+}
- return true;
- }
- else
+void wxWindowBase::NotifyWindowOnEnableChange(bool enabled)
+{
+#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() )
+ return;
+
+ for ( wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
+ node;
+ node = node->GetNext() )
{
+ wxWindowBase * const child = node->GetData();
+ if ( !child->IsTopLevel() && child->IsThisEnabled() )
+ child->NotifyWindowOnEnableChange(enabled);
+ }
+}
+
+bool wxWindowBase::Enable(bool enable)
+{
+ if ( enable == IsThisEnabled() )
return false;
+
+ m_isEnabled = enable;
+
+#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);
+
+ return true;
}
bool wxWindowBase::IsShownOnScreen() const
return false;
}
+ const bool oldEnabledState = IsEnabled();
+
// unlink this window from the existing parent.
if ( oldParent )
{
wxTopLevelWindows.Append((wxWindow *)this);
}
+ // We need to notify window (and its subwindows) if by changing the parent
+ // we also change our enabled/disabled status.
+ const bool newEnabledState = IsEnabled();
+ if ( newEnabledState != oldEnabledState )
+ {
+ NotifyWindowOnEnableChange(newEnabledState);
+ }
+
return true;
}
msg.Printf(_T("wxWidgets Library (%s port)\n")
_T("Version %d.%d.%d%s%s, compiled at %s %s\n")
_T("Runtime version of toolkit used is %d.%d.%s\n")
- _T("Copyright (c) 1995-2006 wxWidgets team"),
+ _T("Copyright (c) 1995-2007 wxWidgets team"),
wxPlatformInfo::Get().GetPortIdName().c_str(),
wxMAJOR_VERSION,
wxMINOR_VERSION,
wxMessageBox(msg, _T("wxWidgets information"),
wxICON_INFORMATION | wxOK,
(wxWindow *)this);
+#endif // wxUSE_MSGDLG
}
else
-#endif // wxUSE_MSGDLG
{
event.Skip();
}
event.SetEventObject(win);
if ( !win->GetEventHandler()->ProcessEvent(event) )
{
+ // windows must handle this event, otherwise the app wouldn't behave
+ // correctly if it loses capture unexpectedly; see the discussion here:
+ // http://sourceforge.net/tracker/index.php?func=detail&aid=1153662&group_id=9863&atid=109863
+ // http://article.gmane.org/gmane.comp.lib.wxwidgets.devel/82376
wxFAIL_MSG( _T("window that captured the mouse didn't process wxEVT_MOUSE_CAPTURE_LOST") );
}
}
// keyboard navigation
// ----------------------------------------------------------------------------
-// Navigates in the specified direction.
-bool wxWindowBase::Navigate(int flags)
+// Navigates in the specified direction inside this window
+bool wxWindowBase::DoNavigateIn(int flags)
{
+#ifdef wxHAS_NATIVE_TAB_TRAVERSAL
+ // native code doesn't process our wxNavigationKeyEvents anyhow
+ return false;
+#else // !wxHAS_NATIVE_TAB_TRAVERSAL
wxNavigationKeyEvent eventNav;
eventNav.SetFlags(flags);
- eventNav.SetEventObject(this);
- if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
- {
- return true;
- }
- return false;
+ eventNav.SetEventObject(FindFocus());
+ return GetEventHandler()->ProcessEvent(eventNav);
+#endif // wxHAS_NATIVE_TAB_TRAVERSAL/!wxHAS_NATIVE_TAB_TRAVERSAL
}
void wxWindowBase::DoMoveInTabOrder(wxWindow *win, MoveKind move)