1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "panelg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
24 #include "wx/object.h"
26 #include "wx/colour.h"
27 #include "wx/settings.h"
30 #include "wx/generic/panelg.h"
32 #if !USE_SHARED_LIBRARY
33 IMPLEMENT_DYNAMIC_CLASS(wxPanel
, wxWindow
)
35 BEGIN_EVENT_TABLE(wxPanel
, wxWindow
)
36 EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged
)
37 EVT_SET_FOCUS(wxPanel::OnFocus
)
38 EVT_NAVIGATION_KEY(wxPanel::OnNavigationKey
)
48 bool wxPanel::Create(wxWindow
*parent
, wxWindowID id
,
56 bool ret
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
61 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
62 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
69 void wxPanel::InitDialog(void)
71 wxInitDialogEvent
event(GetId());
72 event
.SetEventObject(this);
73 GetEventHandler()->ProcessEvent(event
);
76 // Responds to colour changes, and passes event on to children.
77 void wxPanel::OnSysColourChanged(wxSysColourChangedEvent
& event
)
79 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE
));
82 // Propagate the event to the non-top-level children
83 wxWindow::OnSysColourChanged(event
);
86 void wxPanel::OnNavigationKey( wxNavigationKeyEvent
& event
)
88 // there is not much to do if we have only one child (or not at all)
89 if (GetChildren().GetCount() < 2)
95 // don't process these ones here
96 if (event
.IsWindowChange())
102 wxWindow
*winFocus
= event
.GetCurrentFocus();
104 winFocus
= wxWindow::FindFocus();
112 wxNode
*start_node
= GetChildren().Find( winFocus
);
114 start_node
= GetChildren().First();
116 wxNode
*node
= event
.GetDirection() ? start_node
->Next()
117 : start_node
->Previous();
119 while (node
!= start_node
)
124 // FIXME seems to enter in an infinite loop - how is this possible?
125 // we arrived at the last/first of our children - but may be this
126 // panel is inside another panel, so make focus go to the next/prev
127 // control in the parent (if we have one)
128 if (GetParent() != NULL
)
130 wxNavigationKeyEvent new_event
;
131 new_event
.SetDirection( event
.GetDirection() );
132 new_event
.SetWindowChange(FALSE
);
133 new_event
.SetCurrentFocus( this );
135 if (GetParent()->GetEventHandler()->ProcessEvent(new_event
))
142 node
= event
.GetDirection() ? GetChildren().First()
143 : GetChildren().Last();
148 wxWindow
*child
= (wxWindow
*)node
->Data();
150 if (child
->AcceptsFocus())
152 // ok, event processed
157 node
= event
.GetDirection() ? node
->Next() : node
->Previous();
160 // we cycled through all of our children and none of them wanted to accept
165 void wxPanel::OnFocus(wxFocusEvent
& event
)
168 m_lastFocus
->SetFocus();