]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/panelg.cpp
wxIsAbsolutePath was correct.
[wxWidgets.git] / src / generic / panelg.cpp
index 9e8363baa9cc2779427e261c995ec0d709ae544f..73a7a04cf34a79c4b9ec8df2f74c3427790455ea 100644 (file)
@@ -62,7 +62,9 @@ END_EVENT_TABLE()
 void wxPanel::Init()
 {
     m_winLastFocused = (wxWindow *)NULL;
 void wxPanel::Init()
 {
     m_winLastFocused = (wxWindow *)NULL;
+#if wxUSE_BUTTON
     m_btnDefault = (wxButton *)NULL;
     m_btnDefault = (wxButton *)NULL;
+#endif // wxUSE_BUTTON
 }
 
 bool wxPanel::Create(wxWindow *parent, wxWindowID id,
 }
 
 bool wxPanel::Create(wxWindow *parent, wxWindowID id,
@@ -71,15 +73,7 @@ bool wxPanel::Create(wxWindow *parent, wxWindowID id,
                      long style,
                      const wxString& name)
 {
                      long style,
                      const wxString& name)
 {
-    bool ret = wxWindow::Create(parent, id, pos, size, style, name);
-
-    if ( ret )
-    {
-        SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
-        SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
-    }
-
-    return ret;
+    return wxWindow::Create(parent, id, pos, size, style, name);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -248,7 +242,7 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
 
         wxWindow *child = node->GetData();
 
 
         wxWindow *child = node->GetData();
 
-        if ( child->AcceptsFocus() )
+        if ( child->AcceptsFocusFromKeyboard() )
         {
             m_winLastFocused = child;  // should be redundant, but it is not
 
         {
             m_winLastFocused = child;  // should be redundant, but it is not
 
@@ -289,6 +283,13 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
     event.Skip();
 }
 
     event.Skip();
 }
 
+void wxPanel::RemoveChild(wxWindowBase *child)
+{
+    if ( child == m_winLastFocused )
+        m_winLastFocused = NULL;
+    wxWindow::RemoveChild(child);
+}
+
 void wxPanel::SetFocus()
 {
     wxLogTrace(_T("focus"), _T("SetFocus on wxPanel 0x%08x."), GetHandle());
 void wxPanel::SetFocus()
 {
     wxLogTrace(_T("focus"), _T("SetFocus on wxPanel 0x%08x."), GetHandle());
@@ -340,39 +341,52 @@ void wxPanel::OnFocus(wxFocusEvent& event)
 
 bool wxPanel::SetFocusToChild()
 {
 
 bool wxPanel::SetFocusToChild()
 {
-    if ( m_winLastFocused )
+    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.
     {
         // It might happen that the window got reparented or no longer accepts
         // the focus.
-        if ( (m_winLastFocused->GetParent() == this) &&
-             m_winLastFocused->AcceptsFocus() )
+        if ( (*childLastFocused)->GetParent() == win &&
+             (*childLastFocused)->AcceptsFocusFromKeyboard() )
         {
             wxLogTrace(_T("focus"),
                        _T("SetFocusToChild() => last child (0x%08x)."),
         {
             wxLogTrace(_T("focus"),
                        _T("SetFocusToChild() => last child (0x%08x)."),
-                       m_winLastFocused->GetHandle());
+                       (*childLastFocused)->GetHandle());
 
 
-            m_winLastFocused->SetFocus();
+            (*childLastFocused)->SetFocus();
             return TRUE;
         }
         else
         {
             // it doesn't count as such any more
             return TRUE;
         }
         else
         {
             // it doesn't count as such any more
-            m_winLastFocused = (wxWindow *)NULL;
+            *childLastFocused = (wxWindow *)NULL;
         }
     }
 
     // set the focus to the first child who wants it
         }
     }
 
     // set the focus to the first child who wants it
-    wxWindowList::Node *node = GetChildren().GetFirst();
+    wxWindowList::Node *node = win->GetChildren().GetFirst();
     while ( node )
     {
         wxWindow *child = node->GetData();
     while ( node )
     {
         wxWindow *child = node->GetData();
-        if ( child->AcceptsFocus() )
+
+        if ( child->AcceptsFocusFromKeyboard() && !child->IsTopLevel() )
         {
             wxLogTrace(_T("focus"),
                        _T("SetFocusToChild() => first child (0x%08x)."),
                        child->GetHandle());
 
         {
             wxLogTrace(_T("focus"),
                        _T("SetFocusToChild() => first child (0x%08x)."),
                        child->GetHandle());
 
-            m_winLastFocused = child;  // should be redundant, but it is not
+            *childLastFocused = child;  // should be redundant, but it is not
             child->SetFocus();
             return TRUE;
         }
             child->SetFocus();
             return TRUE;
         }