]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: panelg.cpp | |
3 | // Purpose: wxPanel | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "panelg.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
2432b92d JS |
24 | #include "wx/object.h" |
25 | #include "wx/font.h" | |
26 | #include "wx/colour.h" | |
c801d85f KB |
27 | #include "wx/settings.h" |
28 | #endif | |
29 | ||
30 | #include "wx/generic/panelg.h" | |
31 | ||
32 | #if !USE_SHARED_LIBRARY | |
33 | IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow) | |
34 | ||
35 | BEGIN_EVENT_TABLE(wxPanel, wxWindow) | |
36 | EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged) | |
90c3bdac | 37 | EVT_NAVIGATION_KEY(wxPanel::OnNavigationKey) |
c801d85f KB |
38 | END_EVENT_TABLE() |
39 | ||
40 | #endif | |
41 | ||
90c3bdac | 42 | wxPanel::wxPanel() |
c801d85f | 43 | { |
c801d85f KB |
44 | } |
45 | ||
debe6624 | 46 | bool wxPanel::Create(wxWindow *parent, wxWindowID id, |
90c3bdac VZ |
47 | const wxPoint& pos, |
48 | const wxSize& size, | |
49 | long style, | |
50 | const wxString& name) | |
c801d85f | 51 | { |
b292e2f5 | 52 | bool ret = wxWindow::Create(parent, id, pos, size, style, name); |
c801d85f | 53 | |
b292e2f5 RR |
54 | if ( ret ) |
55 | { | |
f96aa4d9 | 56 | #ifndef __WXGTK__ |
b292e2f5 RR |
57 | SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); |
58 | SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); | |
f96aa4d9 | 59 | #endif |
b292e2f5 | 60 | } |
c801d85f | 61 | |
b292e2f5 | 62 | return ret; |
c801d85f KB |
63 | } |
64 | ||
65 | void wxPanel::InitDialog(void) | |
66 | { | |
b292e2f5 RR |
67 | wxInitDialogEvent event(GetId()); |
68 | event.SetEventObject(this); | |
69 | GetEventHandler()->ProcessEvent(event); | |
90c3bdac VZ |
70 | } |
71 | ||
c801d85f KB |
72 | // Responds to colour changes, and passes event on to children. |
73 | void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event) | |
74 | { | |
75 | SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); | |
c801d85f KB |
76 | Refresh(); |
77 | ||
78 | // Propagate the event to the non-top-level children | |
79 | wxWindow::OnSysColourChanged(event); | |
80 | } | |
81 | ||
b292e2f5 | 82 | void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event ) |
90c3bdac | 83 | { |
399aa5e3 | 84 | if (GetChildren().GetCount() < 2) |
b292e2f5 RR |
85 | { |
86 | event.Skip(); | |
87 | return; | |
90c3bdac VZ |
88 | } |
89 | ||
b292e2f5 RR |
90 | // don't process these ones here |
91 | if (event.IsWindowChange()) | |
92 | { | |
93 | event.Skip(); | |
94 | return; | |
90c3bdac VZ |
95 | } |
96 | ||
b292e2f5 RR |
97 | wxWindow *winFocus = event.GetCurrentFocus(); |
98 | if (!winFocus) winFocus = wxWindow::FindFocus(); | |
99 | ||
100 | if (!winFocus) | |
101 | { | |
102 | event.Skip(); | |
103 | return; | |
104 | } | |
105 | ||
399aa5e3 JS |
106 | wxNode *start_node = GetChildren().Find( winFocus ); |
107 | if (!start_node) start_node = GetChildren().First(); | |
b292e2f5 RR |
108 | |
109 | wxNode *node = event.GetDirection() ? start_node->Next() : start_node->Previous(); | |
110 | ||
111 | while (node != start_node) | |
112 | { | |
113 | if (!node) | |
114 | { | |
115 | /* | |
116 | if (GetParent() != NULL) | |
117 | { | |
118 | wxNavigationKeyEvent new_event; | |
119 | new_event.SetDirection( event.GetDirection() ); | |
120 | new_event.SetWindowChange(FALSE); | |
121 | new_event.SetCurrentFocus( this ); | |
122 | ||
123 | if (GetParent()->GetEventHandler()->ProcessEvent(new_event)) | |
124 | { | |
125 | return; | |
126 | } | |
127 | } | |
128 | */ | |
129 | ||
399aa5e3 | 130 | node = event.GetDirection() ? GetChildren().First() : GetChildren().Last(); |
b292e2f5 RR |
131 | } |
132 | ||
133 | wxWindow *child = (wxWindow*) node->Data(); | |
134 | ||
135 | if (child->AcceptsFocus()) | |
136 | { | |
137 | child->SetFocus(); | |
138 | return; | |
139 | } | |
140 | ||
141 | node = node->Next(); | |
142 | } | |
143 | ||
144 | event.Skip(); | |
6e4739a0 | 145 | } |
58614078 | 146 |