-bool wxPanel::SetFocusToChild()
-{
- return wxSetFocusToChild(this, &m_winLastFocused);
-}
-
-// ----------------------------------------------------------------------------
-// SetFocusToChild(): this function is used by wxPanel but also by wxFrame in
-// wxMSW, this is why it is outside of wxPanel class
-// ----------------------------------------------------------------------------
-
-bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
-{
- wxCHECK_MSG( win, FALSE, _T("wxSetFocusToChild(): invalid window") );
-
- if ( *childLastFocused )
- {
- // It might happen that the window got reparented or no longer accepts
- // the focus.
- if ( (*childLastFocused)->GetParent() == win &&
- (*childLastFocused)->AcceptsFocus() )
- {
- wxLogTrace(_T("focus"),
- _T("SetFocusToChild() => last child (0x%08x)."),
- (*childLastFocused)->GetHandle());
-
- (*childLastFocused)->SetFocus();
- return TRUE;
- }
- else
- {
- // it doesn't count as such any more
- *childLastFocused = (wxWindow *)NULL;
- }
- }
-
- // set the focus to the first child who wants it
- wxWindowList::Node *node = win->GetChildren().GetFirst();
- while ( node )
- {
- wxWindow *child = node->GetData();
-
- if ( child->AcceptsFocus()
- && !child->IsTopLevel()
-#if wxUSE_TOOLBAR
- && !wxDynamicCast(child, wxToolBar)
-#endif // wxUSE_TOOLBAR
-#if wxUSE_STATUSBAR
- && !wxDynamicCast(child, wxStatusBar)
-#endif // wxUSE_STATUSBAR
- )
- {
- wxLogTrace(_T("focus"),
- _T("SetFocusToChild() => first child (0x%08x)."),
- child->GetHandle());
-
- *childLastFocused = child; // should be redundant, but it is not
- child->SetFocus();
- return TRUE;
- }
-
- node = node->GetNext();
- }
-
- return FALSE;
-}