X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/debe6624c1e9d4bf3243381153d1e173c849bcd8..793f619f7f0e5b1eaba6a9e3f731462c1893b7f7:/src/generic/panelg.cpp diff --git a/src/generic/panelg.cpp b/src/generic/panelg.cpp index e43bb932f1..2adf0c5360 100644 --- a/src/generic/panelg.cpp +++ b/src/generic/panelg.cpp @@ -31,52 +31,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(); +} +