#include "wx/font.h"
#include "wx/colour.h"
#include "wx/settings.h"
+#include "wx/log.h"
#endif
#include "wx/generic/panelg.h"
if ( ret )
{
-#ifndef __WXGTK__
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
-#endif
}
return ret;
void wxPanel::OnSize(wxSizeEvent& WXUNUSED(event))
{
#if wxUSE_CONSTRAINTS
- if (GetAutoLayout()) Layout();
+ if (GetAutoLayout())
+ Layout();
#endif
}
void wxPanel::SetFocus()
{
+ wxLogTrace(_T("focus"), _T("SetFocus on wxPanel 0x%08x."), GetHandle());
+
// If the panel gets the focus *by way of getting it set directly*
// we move the focus to the first window that can get it.
- wxNode *node = GetChildren().First();
- while (node)
+ // VZ: no, we set the focus to the last window too. I don't understand why
+ // should we make this distinction: if an app wants to set focus to
+ // some precise control, it may always do it directly, but if we don't
+ // use m_winLastFocused here, the focus won't be set correctly after a
+ // notebook page change nor after frame activation under MSW (it calls
+ // SetFocus too)
+ //
+ // If you still want to have old behaviour for wxGTK, edit the
+ // following line
+#if 0 // def __WXGTK__
+ m_winLastFocused = (wxWindow *)NULL;
+#endif // 0
+
+ if ( !SetFocusToChild() )
{
- wxWindow *child = (wxWindow*) node->Data();
- if (child->AcceptsFocus())
- {
- m_winLastFocused = child; // should be redundant, but it is not
- child->SetFocus();
- return;
- }
- node = node->Next();
+ wxWindow::SetFocus();
}
-
- m_winLastFocused = (wxWindow*) NULL;
-
- wxWindow::SetFocus();
}
void wxPanel::OnFocus(wxFocusEvent& event)
{
+ wxLogTrace(_T("focus"), _T("OnFocus on wxPanel 0x%08x."), GetHandle());
+
// If the panel gets the focus *by way of getting clicked on*
// we move the focus to either the last window that had the
// focus or the first one that can get it.
+ (void)SetFocusToChild();
+
+ event.Skip();
+}
- if (m_winLastFocused)
+bool wxPanel::SetFocusToChild()
+{
+ if ( m_winLastFocused )
{
- // It might happen that the window got reparented or no longer
- // accepts the focus.
- if ((m_winLastFocused->GetParent() == this) &&
- (m_winLastFocused->AcceptsFocus()))
+ // It might happen that the window got reparented or no longer accepts
+ // the focus.
+ if ( (m_winLastFocused->GetParent() == this) &&
+ m_winLastFocused->AcceptsFocus() )
{
+ wxLogTrace(_T("focus"),
+ _T("SetFocusToChild() => last child (0x%08x)."),
+ m_winLastFocused->GetHandle());
+
m_winLastFocused->SetFocus();
- return;
+ return TRUE;
+ }
+ else
+ {
+ // it doesn't count as such any more
+ m_winLastFocused = (wxWindow *)NULL;
}
}
- wxNode *node = GetChildren().First();
- while (node)
+ // set the focus to the first child who wants it
+ wxWindowList::Node *node = GetChildren().GetFirst();
+ while ( node )
{
- wxWindow *child = (wxWindow*) node->Data();
- if (child->AcceptsFocus())
+ wxWindow *child = node->GetData();
+ if ( child->AcceptsFocus() )
{
+ wxLogTrace(_T("focus"),
+ _T("SetFocusToChild() => first child (0x%08x)."),
+ child->GetHandle());
+
m_winLastFocused = child; // should be redundant, but it is not
child->SetFocus();
- return;
+ return TRUE;
}
- node = node->Next();
- }
- m_winLastFocused = (wxWindow*) NULL;
+ node = node->GetNext();
+ }
- event.Skip();
+ return FALSE;
}