]> git.saurik.com Git - wxWidgets.git/blame - src/generic/panelg.cpp
Added Property List classes to main library; added proplist sample; merged
[wxWidgets.git] / src / generic / panelg.cpp
CommitLineData
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
24#include "wx/settings.h"
25#endif
26
27#include "wx/generic/panelg.h"
28
29#if !USE_SHARED_LIBRARY
30IMPLEMENT_DYNAMIC_CLASS(wxPanel, wxWindow)
31
32BEGIN_EVENT_TABLE(wxPanel, wxWindow)
33 EVT_SYS_COLOUR_CHANGED(wxPanel::OnSysColourChanged)
90c3bdac 34 EVT_NAVIGATION_KEY(wxPanel::OnNavigationKey)
c801d85f
KB
35END_EVENT_TABLE()
36
37#endif
38
90c3bdac 39wxPanel::wxPanel()
c801d85f 40{
c801d85f
KB
41}
42
debe6624 43bool wxPanel::Create(wxWindow *parent, wxWindowID id,
90c3bdac
VZ
44 const wxPoint& pos,
45 const wxSize& size,
46 long style,
47 const wxString& name)
c801d85f 48{
b292e2f5 49 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
c801d85f 50
b292e2f5
RR
51 if ( ret )
52 {
f96aa4d9 53#ifndef __WXGTK__
b292e2f5
RR
54 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
55 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
f96aa4d9 56#endif
b292e2f5 57 }
c801d85f 58
b292e2f5 59 return ret;
c801d85f
KB
60}
61
62void wxPanel::InitDialog(void)
63{
b292e2f5
RR
64 wxInitDialogEvent event(GetId());
65 event.SetEventObject(this);
66 GetEventHandler()->ProcessEvent(event);
90c3bdac
VZ
67}
68
c801d85f
KB
69// Responds to colour changes, and passes event on to children.
70void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event)
71{
72 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
c801d85f
KB
73 Refresh();
74
75 // Propagate the event to the non-top-level children
76 wxWindow::OnSysColourChanged(event);
77}
78
b292e2f5 79void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
90c3bdac 80{
399aa5e3 81 if (GetChildren().GetCount() < 2)
b292e2f5
RR
82 {
83 event.Skip();
84 return;
90c3bdac
VZ
85 }
86
b292e2f5
RR
87 // don't process these ones here
88 if (event.IsWindowChange())
89 {
90 event.Skip();
91 return;
90c3bdac
VZ
92 }
93
b292e2f5
RR
94 wxWindow *winFocus = event.GetCurrentFocus();
95 if (!winFocus) winFocus = wxWindow::FindFocus();
96
97 if (!winFocus)
98 {
99 event.Skip();
100 return;
101 }
102
399aa5e3
JS
103 wxNode *start_node = GetChildren().Find( winFocus );
104 if (!start_node) start_node = GetChildren().First();
b292e2f5
RR
105
106 wxNode *node = event.GetDirection() ? start_node->Next() : start_node->Previous();
107
108 while (node != start_node)
109 {
110 if (!node)
111 {
112/*
113 if (GetParent() != NULL)
114 {
115 wxNavigationKeyEvent new_event;
116 new_event.SetDirection( event.GetDirection() );
117 new_event.SetWindowChange(FALSE);
118 new_event.SetCurrentFocus( this );
119
120 if (GetParent()->GetEventHandler()->ProcessEvent(new_event))
121 {
122 return;
123 }
124 }
125*/
126
399aa5e3 127 node = event.GetDirection() ? GetChildren().First() : GetChildren().Last();
b292e2f5
RR
128 }
129
130 wxWindow *child = (wxWindow*) node->Data();
131
132 if (child->AcceptsFocus())
133 {
134 child->SetFocus();
135 return;
136 }
137
138 node = node->Next();
139 }
140
141 event.Skip();
6e4739a0 142}
58614078 143