]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/panelg.cpp
OnExit() is called for modules which were initialized even if the init of
[wxWidgets.git] / src / generic / panelg.cpp
index e43bb932f1d3f20fd2bfc0d35151975e3cc52709..244cb0aedbcff746c6be416020de83c745285fcb 100644 (file)
@@ -21,6 +21,9 @@
 #endif
 
 #ifndef WX_PRECOMP
+#include "wx/object.h"
+#include "wx/font.h"
+#include "wx/colour.h"
 #include "wx/settings.h"
 #endif
 
@@ -31,52 +34,113 @@ IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow)
 
 BEGIN_EVENT_TABLE(wxPanel, wxWindow)
   EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged)
+  EVT_NAVIGATION_KEY(wxPanel::OnNavigationKey)
 END_EVENT_TABLE()
 
 #endif
 
-wxPanel::wxPanel(void)
+wxPanel::wxPanel()
 {
-  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
-  SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
 }
 
 bool wxPanel::Create(wxWindow *parent, wxWindowID id,
-           const wxPoint& pos,
-           const wxSize& size,
-           long style,
-           const wxString& name)
+                     const wxPoint& pos,
+                     const wxSize& size,
+                     long style,
+                     const wxString& name)
 {
-  bool ret = wxWindow::Create(parent, id, pos, size, style, name);
+    bool ret = wxWindow::Create(parent, id, pos, size, style, name);
 
-  SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
-  SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
-  SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
-  return ret;
-}
+    if ( ret ) 
+    {
+#ifndef __WXGTK__
+        SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+        SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+#endif
+    }
 
-void wxPanel::OnPaint(wxPaintEvent& WXUNUSED(event))
-{
-       // No: if you call the default procedure, it makes
-       // the following painting code not work.
-//     wxWindow::OnPaint(event);
+    return ret;
 }
 
 void wxPanel::InitDialog(void)
 {
-       wxInitDialogEvent event(GetId());
-       event.SetEventObject(this);
-       GetEventHandler()->ProcessEvent(event);
+    wxInitDialogEvent event(GetId());
+    event.SetEventObject(this);
+    GetEventHandler()->ProcessEvent(event);
 }
 
 // Responds to colour changes, and passes event on to children.
 void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
     SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
-    SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
     Refresh();
 
     // Propagate the event to the non-top-level children
     wxWindow::OnSysColourChanged(event);
 }
 
+void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
+{
+    if (GetChildren().GetCount() < 2)
+    {
+        event.Skip();
+        return;
+    }
+
+    // don't process these ones here
+    if (event.IsWindowChange()) 
+    {
+        event.Skip();
+        return;
+    }
+
+    wxWindow *winFocus = event.GetCurrentFocus();
+    if (!winFocus) winFocus = wxWindow::FindFocus();
+    
+    if (!winFocus)
+    {
+        event.Skip();
+        return;
+    }
+    
+    wxNode *start_node = GetChildren().Find( winFocus );
+    if (!start_node) start_node = GetChildren().First();
+    
+    wxNode *node = event.GetDirection() ? start_node->Next() : start_node->Previous();
+           
+    while (node != start_node)
+    {
+       if (!node)
+       {
+/*
+            if (GetParent() != NULL) 
+           {
+                wxNavigationKeyEvent new_event;
+                new_event.SetDirection( event.GetDirection() );
+                new_event.SetWindowChange(FALSE);
+                new_event.SetCurrentFocus( this );
+
+                if (GetParent()->GetEventHandler()->ProcessEvent(new_event))
+               {  
+                   return;
+               }
+            }
+*/
+           
+           node = event.GetDirection() ? GetChildren().First() : GetChildren().Last();
+       }
+               
+       wxWindow *child = (wxWindow*) node->Data();
+               
+       if (child->AcceptsFocus())
+       {
+           child->SetFocus();
+           return;
+       }
+               
+       node = node->Next();
+    }
+    
+    event.Skip();
+}
+